diff --git a/src/MahApps.Metro.Demo_v2/App.xaml b/src/MahApps.Metro.Demo_v2/App.xaml index cf2ca5d08c..e33cbaf11b 100644 --- a/src/MahApps.Metro.Demo_v2/App.xaml +++ b/src/MahApps.Metro.Demo_v2/App.xaml @@ -1,8 +1,8 @@  @@ -16,19 +16,19 @@ - + diff --git a/src/MahApps.Metro.Demo_v2/App.xaml.cs b/src/MahApps.Metro.Demo_v2/App.xaml.cs index 03b9b7ff63..8dd65ea95a 100644 --- a/src/MahApps.Metro.Demo_v2/App.xaml.cs +++ b/src/MahApps.Metro.Demo_v2/App.xaml.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; +// 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.Windows; namespace MahApps.Metro.Demo_v2 @@ -14,4 +12,4 @@ namespace MahApps.Metro.Demo_v2 public partial class App : Application { } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/AssemblyInfo.cs b/src/MahApps.Metro.Demo_v2/AssemblyInfo.cs index 8b5504ecfb..815c616377 100644 --- a/src/MahApps.Metro.Demo_v2/AssemblyInfo.cs +++ b/src/MahApps.Metro.Demo_v2/AssemblyInfo.cs @@ -1,10 +1,14 @@ +// 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.Windows; [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Controls/DemoView.cs b/src/MahApps.Metro.Demo_v2/Controls/DemoView.cs index cadf980dab..51ac20e56a 100644 --- a/src/MahApps.Metro.Demo_v2/Controls/DemoView.cs +++ b/src/MahApps.Metro.Demo_v2/Controls/DemoView.cs @@ -1,12 +1,11 @@ -using ICSharpCode.AvalonEdit; +// 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 ICSharpCode.AvalonEdit; using MahApps.Demo.Core; -using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -22,12 +21,10 @@ public class DemoView : HeaderedContentControl /// Identifies the dependency property. public static readonly DependencyProperty HyperlinkOnlineDocsProperty = DependencyProperty.Register(nameof(HyperlinkOnlineDocs), typeof(string), typeof(DemoView), new PropertyMetadata(null)); - - public DemoView() { - DemoProperties.CollectionChanged += DemoProperties_CollectionChanged; + this.DemoProperties.CollectionChanged += this.DemoProperties_CollectionChanged; } public ObservableCollection DemoProperties { get; } = new ObservableCollection(); @@ -38,43 +35,42 @@ private void DemoProperties_CollectionChanged(object sender, System.Collections. { foreach (DemoViewProperty item in e.NewItems) { - item.PropertyChanged += DemoProperties_ItemPropertyChanged; + item.PropertyChanged += this.DemoProperties_ItemPropertyChanged; } } + if (e.OldItems != null) { foreach (DemoViewProperty item in e.OldItems) { - item.PropertyChanged -= DemoProperties_ItemPropertyChanged; + item.PropertyChanged -= this.DemoProperties_ItemPropertyChanged; } } } private void DemoProperties_ItemPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { - SetExampleXaml(); + this.SetExampleXaml(); } - - public string ExampleXaml { - get { return (string)GetValue(ExampleXamlProperty); } - set { SetValue(ExampleXamlProperty, value); } + get => (string)this.GetValue(ExampleXamlProperty); + set => this.SetValue(ExampleXamlProperty, value); } private void SetExampleXaml() { - if (PART_AvalonEdit != null) + if (this.PART_AvalonEdit != null) { - var exampleText = ExampleXaml; + var exampleText = this.ExampleXaml; - foreach (var item in DemoProperties) + foreach (var item in this.DemoProperties) { exampleText = exampleText.Replace($"[{item.PropertyName}]", item.GetExampleXamlContent()); } - PART_AvalonEdit.Text = exampleText; + this.PART_AvalonEdit.Text = exampleText; } } @@ -88,8 +84,8 @@ private static void OnExampleXamlChanged(DependencyObject d, DependencyPropertyC public string HyperlinkOnlineDocs { - get { return (string)GetValue(HyperlinkOnlineDocsProperty); } - set { SetValue(HyperlinkOnlineDocsProperty, value); } + get => (string)this.GetValue(HyperlinkOnlineDocsProperty); + set => this.SetValue(HyperlinkOnlineDocsProperty, value); } public SimpleCommand NavigateToOnlineDocs { get; } = new SimpleCommand( @@ -100,9 +96,8 @@ public override void OnApplyTemplate() { base.OnApplyTemplate(); - PART_AvalonEdit = GetTemplateChild(nameof(PART_AvalonEdit)) as TextEditor; - SetExampleXaml(); + this.PART_AvalonEdit = this.GetTemplateChild(nameof(this.PART_AvalonEdit)) as TextEditor; + this.SetExampleXaml(); } - } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Controls/DemoViewProperty.cs b/src/MahApps.Metro.Demo_v2/Controls/DemoViewProperty.cs index 3aa3b0a424..9c3865562f 100644 --- a/src/MahApps.Metro.Demo_v2/Controls/DemoViewProperty.cs +++ b/src/MahApps.Metro.Demo_v2/Controls/DemoViewProperty.cs @@ -1,11 +1,11 @@ -using MahApps.Metro.Demo_v2; +// 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 MahApps.Metro.Demo_v2; using System; using System.Collections; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Data; @@ -14,11 +14,12 @@ namespace MahApps.Demo.Controls public class DemoViewProperty : DependencyObject, INotifyPropertyChanged { #region PropertyChanged + public event PropertyChangedEventHandler PropertyChanged; public void RaisePropertyChanged(string PropertyName) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); } private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) @@ -31,34 +32,33 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged #endregion - #region Constructors public DemoViewProperty() { - GetExampleXamlContent = GetExampleXamlContent_Default; + this.GetExampleXamlContent = this.GetExampleXamlContent_Default; } - public DemoViewProperty(DependencyProperty dependencyProperty, DependencyObject bindingTarget, string groupName = null, DataTemplate dataTemplate = null) : this() + public DemoViewProperty(DependencyProperty dependencyProperty, DependencyObject bindingTarget, string groupName = null, DataTemplate dataTemplate = null) + : this() { - SetCurrentValue(PropertyNameProperty, GetDefaultPropertyName(dependencyProperty)); + this.SetCurrentValue(PropertyNameProperty, this.GetDefaultPropertyName(dependencyProperty)); - SetCurrentValue(GroupNameProperty, groupName ?? GetDefaultGroupName()); + this.SetCurrentValue(GroupNameProperty, groupName ?? this.GetDefaultGroupName()); - SetCurrentValue(DataTemplateProperty, dataTemplate ?? GetDefaultDataTemplate(dependencyProperty)); + this.SetCurrentValue(DataTemplateProperty, dataTemplate ?? this.GetDefaultDataTemplate(dependencyProperty)); // Create Binding to the Control var binding = new Binding() - { - Path = new PropertyPath(dependencyProperty), - Source = bindingTarget, - Mode = BindingMode.TwoWay - }; - BindingOperations.SetBinding(this, DemoViewProperty.ValueProperty, binding); - + { + Path = new PropertyPath(dependencyProperty), + Source = bindingTarget, + Mode = BindingMode.TwoWay + }; + BindingOperations.SetBinding(this, ValueProperty, binding); } - #endregion + #endregion /// Identifies the dependency property. public static readonly DependencyProperty PropertyNameProperty = DependencyProperty.Register(nameof(PropertyName), typeof(string), typeof(DemoViewProperty), new PropertyMetadata(null)); @@ -75,15 +75,13 @@ public DemoViewProperty(DependencyProperty dependencyProperty, DependencyObject /// Identifies the dependency property. public static readonly DependencyProperty GroupNameProperty = DependencyProperty.Register(nameof(GroupName), typeof(string), typeof(DemoViewProperty), new PropertyMetadata(null)); - - /// /// Gets or Sets the PropertyName /// public string PropertyName { - get { return (string)GetValue(PropertyNameProperty); } - set { SetValue(PropertyNameProperty, value); } + get => (string)this.GetValue(PropertyNameProperty); + set => this.SetValue(PropertyNameProperty, value); } private string GetDefaultPropertyName(DependencyProperty dependencyProperty) @@ -96,38 +94,36 @@ private string GetDefaultPropertyName(DependencyProperty dependencyProperty) { return $"{dependencyProperty.OwnerType.Name}.{dependencyProperty.Name}"; } - } - + /// /// Gets or Sets the Value /// public object Value { - get { return (object)GetValue(ValueProperty); } - set { SetValue(ValueProperty, value); } + get => (object)this.GetValue(ValueProperty); + set => this.SetValue(ValueProperty, value); } - /// /// Gets or Sets the GroupName /// public string GroupName { - get { return (string)GetValue(GroupNameProperty); } - set { SetValue(GroupNameProperty, value); } + get => (string)this.GetValue(GroupNameProperty); + set => this.SetValue(GroupNameProperty, value); } private string GetDefaultGroupName() { - if (string.IsNullOrWhiteSpace(PropertyName)) + if (string.IsNullOrWhiteSpace(this.PropertyName)) return null; switch (this.PropertyName) { - case string _ when PropertyName.EndsWith("Alignment"): - case string _ when PropertyName.EndsWith("Height"): - case string _ when PropertyName.EndsWith("Width"): + case string _ when this.PropertyName.EndsWith("Alignment"): + case string _ when this.PropertyName.EndsWith("Height"): + case string _ when this.PropertyName.EndsWith("Width"): return "Layout"; default: @@ -140,8 +136,8 @@ private string GetDefaultGroupName() /// public DataTemplate DataTemplate { - get { return (DataTemplate)GetValue(DataTemplateProperty); } - set { SetValue(DataTemplateProperty, value); } + get => (DataTemplate)this.GetValue(DataTemplateProperty); + set => this.SetValue(DataTemplateProperty, value); } private DataTemplate GetDefaultDataTemplate(DependencyProperty dependencyProperty) @@ -162,27 +158,27 @@ private DataTemplate GetDefaultDataTemplate(DependencyProperty dependencyPropert dependencyProperty.PropertyType.IsAssignableFrom(typeof(double)) || dependencyProperty.PropertyType.IsAssignableFrom(typeof(decimal))) { - return App.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Numeric"] as DataTemplate; + return Application.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Numeric"] as DataTemplate; } if (dependencyProperty.PropertyType.IsAssignableFrom(typeof(string))) { - return App.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.String"] as DataTemplate; + return Application.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.String"] as DataTemplate; } if (dependencyProperty.PropertyType == typeof(bool)) { - return App.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Boolean"] as DataTemplate; + return Application.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Boolean"] as DataTemplate; } if (dependencyProperty.PropertyType.IsEnum) { - return App.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Enum"] as DataTemplate; + return Application.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Enum"] as DataTemplate; } if (dependencyProperty.PropertyType.IsAssignableFrom(typeof(Style))) { - return App.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Styles"] as DataTemplate; + return Application.Current.Resources["MahDemo.DataTemplates.PropertyPresenter.Styles"] as DataTemplate; } return null; @@ -193,19 +189,19 @@ private DataTemplate GetDefaultDataTemplate(DependencyProperty dependencyPropert /// public IEnumerable ItemSource { - get { return (IEnumerable)GetValue(ItemSourceProperty); } - set { SetValue(ItemSourceProperty, value); } + get => (IEnumerable)this.GetValue(ItemSourceProperty); + set => this.SetValue(ItemSourceProperty, value); } - #region XAML Replace Value + public Func GetExampleXamlContent { get; set; } private string GetExampleXamlContent_Default() { - return Value?.ToString(); + return this.Value?.ToString(); } - #endregion + #endregion } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Controls/DemoViewPropertyTemplateSelector.cs b/src/MahApps.Metro.Demo_v2/Controls/DemoViewPropertyTemplateSelector.cs index df6a562126..f218bb31ce 100644 --- a/src/MahApps.Metro.Demo_v2/Controls/DemoViewPropertyTemplateSelector.cs +++ b/src/MahApps.Metro.Demo_v2/Controls/DemoViewPropertyTemplateSelector.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// 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.Windows; using System.Windows.Controls; @@ -16,12 +15,12 @@ public override DataTemplate SelectTemplate(object item, DependencyObject contai { if (item is DemoViewProperty demoProperty) { - return demoProperty.DataTemplate ?? FallbackTemplate; + return demoProperty.DataTemplate ?? this.FallbackTemplate; } else { - return FallbackTemplate; + return this.FallbackTemplate; } } } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Converter/EnumToItemSourceConverter.cs b/src/MahApps.Metro.Demo_v2/Converter/EnumToItemSourceConverter.cs index 45d6706150..b5cc414428 100644 --- a/src/MahApps.Metro.Demo_v2/Converter/EnumToItemSourceConverter.cs +++ b/src/MahApps.Metro.Demo_v2/Converter/EnumToItemSourceConverter.cs @@ -1,10 +1,10 @@ -using MahApps.Metro.Converters; +// 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 MahApps.Metro.Converters; using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MahApps.Demo.Converter { @@ -16,6 +16,7 @@ protected override object Convert(object value, Type targetType, object paramete { return Enum.GetValues(value.GetType()); } + throw new ArgumentException("the provided value is not a valid Enum"); } @@ -24,4 +25,4 @@ protected override object ConvertBack(object value, Type targetType, object para throw new NotSupportedException(); } } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Core/BaseClass.cs b/src/MahApps.Metro.Demo_v2/Core/BaseClass.cs index e9e12cc77b..d102c2e533 100644 --- a/src/MahApps.Metro.Demo_v2/Core/BaseClass.cs +++ b/src/MahApps.Metro.Demo_v2/Core/BaseClass.cs @@ -1,10 +1,11 @@ -using System; +// 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.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MahApps.Demo.Core { @@ -17,7 +18,7 @@ public class BaseClass : INotifyPropertyChanged, INotifyDataErrorInfo public void RaisePropertyChanged(string PropertyName) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName)); } #endregion INotifyPropertyChanged @@ -26,7 +27,7 @@ public void RaisePropertyChanged(string PropertyName) public event EventHandler ErrorsChanged; - public bool HasErrors => _errorsByPropertyName.Count > 0; + public bool HasErrors => this._errorsByPropertyName.Count > 0; private readonly Dictionary> _errorsByPropertyName = new Dictionary>(); @@ -38,43 +39,42 @@ public IEnumerable GetErrors(string propertyName) } else { - return _errorsByPropertyName.ContainsKey(propertyName) - ? _errorsByPropertyName[propertyName] - : null; + return this._errorsByPropertyName.ContainsKey(propertyName) + ? this._errorsByPropertyName[propertyName] + : null; } } public bool GetHasError(string PropertyName) { - return _errorsByPropertyName.ContainsKey(PropertyName); + return this._errorsByPropertyName.ContainsKey(PropertyName); } public void AddError(string propertyName, string error) { - if (!_errorsByPropertyName.ContainsKey(propertyName)) - _errorsByPropertyName[propertyName] = new List(); + if (!this._errorsByPropertyName.ContainsKey(propertyName)) this._errorsByPropertyName[propertyName] = new List(); - if (!_errorsByPropertyName[propertyName].Contains(error)) + if (!this._errorsByPropertyName[propertyName].Contains(error)) { - _errorsByPropertyName[propertyName].Add(error); - OnErrorsChanged(propertyName); + this._errorsByPropertyName[propertyName].Add(error); + this.OnErrorsChanged(propertyName); } } public void ClearErrors(string propertyName) { - if (_errorsByPropertyName.ContainsKey(propertyName)) + if (this._errorsByPropertyName.ContainsKey(propertyName)) { - _errorsByPropertyName.Remove(propertyName); - OnErrorsChanged(propertyName); + this._errorsByPropertyName.Remove(propertyName); + this.OnErrorsChanged(propertyName); } } public void OnErrorsChanged(string propertyName) { - ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName)); + this.ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(propertyName)); } #endregion INotifyDataErrorInfo } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/Core/SimpleCommand.cs b/src/MahApps.Metro.Demo_v2/Core/SimpleCommand.cs index bc7d052014..9a91c48f8d 100644 --- a/src/MahApps.Metro.Demo_v2/Core/SimpleCommand.cs +++ b/src/MahApps.Metro.Demo_v2/Core/SimpleCommand.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// 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.Windows.Input; namespace MahApps.Demo.Core @@ -36,4 +36,4 @@ public void Execute(object parameter) this.ExecuteDelegate?.Invoke(parameter); } } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml b/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml index 7f1040dd05..af417a7472 100644 --- a/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml +++ b/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml @@ -21,16 +21,18 @@ IsEnabled="True" /> ]]> - - diff --git a/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml.cs b/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml.cs index 6de35109de..d781836e95 100644 --- a/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml.cs +++ b/src/MahApps.Metro.Demo_v2/ExampleViews/BadgedExample.xaml.cs @@ -1,20 +1,13 @@ -using MahApps.Demo.Controls; +// 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 MahApps.Demo.Controls; using MahApps.Metro.Controls; -using MahApps.Metro.Demo_v2; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using ControlzEx; namespace MahApps.Demo.ExampleViews { @@ -25,19 +18,19 @@ public partial class BadgedExample : UserControl { public BadgedExample() { - InitializeComponent(); + this.InitializeComponent(); - demoView.DemoProperties.Add(new DemoViewProperty(Badged.BadgeProperty, badge, "Badged")); + this.demoView.DemoProperties.Add(new DemoViewProperty(BadgedEx.BadgeProperty, this.badge, "Badged")); } private void Button_Click(object sender, RoutedEventArgs e) { - badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, (badge.Badge as int? ?? 0) + 1); + this.badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, (this.badge.Badge as int? ?? 0) + 1); } private void Button_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { - badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, null); + this.badge.SetCurrentValue(ControlzEx.BadgedEx.BadgeProperty, null); } } -} +} \ No newline at end of file diff --git a/src/MahApps.Metro.Demo_v2/ExampleViews/ButtonExample.xaml b/src/MahApps.Metro.Demo_v2/ExampleViews/ButtonExample.xaml index c556d048be..08292b9036 100644 --- a/src/MahApps.Metro.Demo_v2/ExampleViews/ButtonExample.xaml +++ b/src/MahApps.Metro.Demo_v2/ExampleViews/ButtonExample.xaml @@ -20,10 +20,10 @@ IsEnabled="True" /> ]]>