-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Graph Control Prep #3033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Graph Control Prep #3033
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
edd407d
Move needed graph Dependencies to Microsoft.Toolkit and Microsoft.Too…
michael-hawker e69a8ad
Mark older Graph Controls Deprecated being replaced by new Graph Cont…
michael-hawker a452da0
Clean-up warnings by modernizing syntax
michael-hawker 4bdd9dc
Merge branch 'master' into mhawker/graph-helpers
michael-hawker 4e1c0b0
Grab Exception Message if no InnerException
michael-hawker b8f50ca
Merge branch 'master' into mhawker/graph-helpers
azchohfi 027c565
Move ToFileSizeString to new Convert static class.
michael-hawker 723de7b
Merge branch 'master' into mhawker/graph-helpers
azchohfi 64e514e
Merge branch 'master' into mhawker/graph-helpers
azchohfi 09b1d8e
Merge branch 'master' into mhawker/graph-helpers
azchohfi 3ace37e
Add Missing Header
michael-hawker 245187e
Rename Convert to Converters to not clash with system one.
michael-hawker 2c9e028
Merge branch 'master' into mhawker/graph-helpers
michael-hawker d402103
Merge branch 'master' into mhawker/graph-helpers
azchohfi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
Microsoft.Toolkit.Uwp.UI.Controls.Graph/SharePointFileList/FileSizeConverter.cs
This file was deleted.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
Microsoft.Toolkit.Uwp.UI.Controls.Graph/SharePointFileList/SharePointFileList.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Microsoft.Toolkit.Uwp.UI/Converters/FileSizeToFriendlyStringConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using Windows.UI.Xaml.Data; | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Converters | ||
| { | ||
| /// <summary> | ||
| /// Converts a file size in bytes to a more human-readable friendly format using <see cref="Toolkit.Converters.ToFileSizeString(long)"/> | ||
| /// </summary> | ||
| public class FileSizeToFriendlyStringConverter : IValueConverter | ||
| { | ||
| /// <inheritdoc/> | ||
| public object Convert(object value, Type targetType, object parameter, string language) | ||
| { | ||
| if (value is long size) | ||
| { | ||
| return Toolkit.Converters.ToFileSizeString(size); | ||
| } | ||
|
|
||
| return string.Empty; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public object ConvertBack(object value, Type targetType, object parameter, string language) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System; | ||
| using System.ComponentModel; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.Toolkit.Helpers | ||
| { | ||
| /// <summary> | ||
| /// Helper class to wrap around a Task to provide more information usable for UI databinding scenarios. As discussed in MSDN Magazine: https://msdn.microsoft.com/magazine/dn605875. | ||
| /// </summary> | ||
| /// <typeparam name="TResult">Type of result returned by task.</typeparam> | ||
| public sealed class NotifyTaskCompletion<TResult> : INotifyPropertyChanged | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="NotifyTaskCompletion{TResult}"/> class. | ||
| /// </summary> | ||
| /// <param name="task">Task to wait on.</param> | ||
| public NotifyTaskCompletion(Task<TResult> task) | ||
| { | ||
| Task = task; | ||
| if (!task.IsCompleted) | ||
| { | ||
| TaskCompletion = WatchTaskAsync(task); | ||
| } | ||
| } | ||
|
|
||
| private async Task WatchTaskAsync(Task task) | ||
| { | ||
| try | ||
| { | ||
| await task; | ||
| } | ||
| catch | ||
| { | ||
| } | ||
|
|
||
| if (PropertyChanged == null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCompleted))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsNotCompleted))); | ||
|
|
||
| if (task.IsCanceled) | ||
| { | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsCanceled))); | ||
| } | ||
| else if (task.IsFaulted) | ||
| { | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsFaulted))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Exception))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(InnerException))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(ErrorMessage))); | ||
| } | ||
| else | ||
| { | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsSuccessfullyCompleted))); | ||
| PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Result))); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the task that is being waited on. | ||
| /// </summary> | ||
| public Task<TResult> Task { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the task wrapper task. | ||
| /// </summary> | ||
| public Task TaskCompletion { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the result of the given task. | ||
| /// </summary> | ||
| public TResult Result | ||
| { | ||
| get | ||
| { | ||
| return (Task.Status == TaskStatus.RanToCompletion) ? | ||
| Task.Result : | ||
| default(TResult); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the status of the task. | ||
| /// </summary> | ||
| public TaskStatus Status => Task.Status; | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the task is completed. | ||
| /// </summary> | ||
| public bool IsCompleted => Task.IsCompleted; | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the task is not completed. | ||
| /// </summary> | ||
| public bool IsNotCompleted => !Task.IsCompleted; | ||
michael-hawker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the task was successfully completed. | ||
| /// </summary> | ||
| public bool IsSuccessfullyCompleted => Task.Status == TaskStatus.RanToCompletion; | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the task was cancelled. | ||
| /// </summary> | ||
| public bool IsCanceled => Task.IsCanceled; | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether there was an error with the task. | ||
| /// </summary> | ||
| public bool IsFaulted => Task.IsFaulted; | ||
|
|
||
| /// <summary> | ||
| /// Gets the exception which occured on the task (if one occurred). | ||
| /// </summary> | ||
| public AggregateException Exception => Task.Exception; | ||
|
|
||
| /// <summary> | ||
| /// Gets the inner exception of the task. | ||
| /// </summary> | ||
| public Exception InnerException => Exception?.InnerException; | ||
|
|
||
| /// <summary> | ||
| /// Gets the error message of the task. | ||
| /// </summary> | ||
| public string ErrorMessage => InnerException?.Message ?? Exception.Message; | ||
|
|
||
| /// <summary> | ||
| /// PropertyChanged event. | ||
| /// </summary> | ||
| public event PropertyChangedEventHandler PropertyChanged; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.