mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
Run C# import cleanup based on the Solution files (#1838)
This is to make the style consistent with the rest of the project as well as removing unused imports.
This commit is contained in:
parent
6430551167
commit
91adfd8e9e
86 changed files with 682 additions and 1087 deletions
|
@ -3,9 +3,11 @@ using CalculatorApp.Converters;
|
|||
using CalculatorApp.ViewModel;
|
||||
using CalculatorApp.ViewModel.Common;
|
||||
using CalculatorApp.ViewModel.Common.Automation;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Windows.Foundation;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.Storage;
|
||||
|
@ -17,6 +19,7 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
using MUXC = Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace CalculatorApp
|
||||
|
@ -31,27 +34,27 @@ namespace CalculatorApp
|
|||
|
||||
public List<object> NavViewCategoriesSource
|
||||
{
|
||||
get { return (List<object>)GetValue(NavViewCategoriesSourceProperty); }
|
||||
set { SetValue(NavViewCategoriesSourceProperty, value); }
|
||||
get => (List<object>)GetValue(NavViewCategoriesSourceProperty);
|
||||
set => SetValue(NavViewCategoriesSourceProperty, value);
|
||||
}
|
||||
|
||||
public ApplicationViewModel Model => m_model;
|
||||
public ApplicationViewModel Model { get; }
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
m_model = new ApplicationViewModel();
|
||||
Model = new ApplicationViewModel();
|
||||
InitializeNavViewCategoriesSource();
|
||||
InitializeComponent();
|
||||
|
||||
KeyboardShortcutManager.Initialize();
|
||||
|
||||
Application.Current.Suspending += App_Suspending;
|
||||
m_model.PropertyChanged += OnAppPropertyChanged;
|
||||
Model.PropertyChanged += OnAppPropertyChanged;
|
||||
m_accessibilitySettings = new AccessibilitySettings();
|
||||
|
||||
if(Utilities.GetIntegratedDisplaySize(out var sizeInInches))
|
||||
if (Utilities.GetIntegratedDisplaySize(out var sizeInInches))
|
||||
{
|
||||
if(sizeInInches < 7.0) // If device's display size (diagonal length) is less than 7 inches then keep the calc always in Portrait mode only
|
||||
if (sizeInInches < 7.0) // If device's display size (diagonal length) is less than 7 inches then keep the calc always in Portrait mode only
|
||||
{
|
||||
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait | DisplayOrientations.PortraitFlipped;
|
||||
}
|
||||
|
@ -91,7 +94,7 @@ namespace CalculatorApp
|
|||
|
||||
public void SetHeaderAutomationName()
|
||||
{
|
||||
ViewMode mode = m_model.Mode;
|
||||
ViewMode mode = Model.Mode;
|
||||
var resProvider = AppResourceProvider.GetInstance();
|
||||
|
||||
string name;
|
||||
|
@ -110,7 +113,7 @@ namespace CalculatorApp
|
|||
{
|
||||
full = resProvider.GetResourceString("HeaderAutomationName_Converter");
|
||||
}
|
||||
name = LocalizationStringUtil.GetLocalizedString(full, m_model.CategoryName);
|
||||
name = LocalizationStringUtil.GetLocalizedString(full, Model.CategoryName);
|
||||
}
|
||||
|
||||
AutomationProperties.SetName(Header, name);
|
||||
|
@ -134,7 +137,7 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
m_model.Initialize(initialMode);
|
||||
Model.Initialize(initialMode);
|
||||
}
|
||||
|
||||
private void InitializeNavViewCategoriesSource()
|
||||
|
@ -150,7 +153,7 @@ namespace CalculatorApp
|
|||
{
|
||||
var graphCategory = (NavCategory)NavViewCategoriesSource.Find(x =>
|
||||
{
|
||||
if(x is NavCategory category)
|
||||
if (x is NavCategory category)
|
||||
{
|
||||
return category.ViewMode == ViewMode.Graphing;
|
||||
}
|
||||
|
@ -166,10 +169,10 @@ namespace CalculatorApp
|
|||
private List<object> ExpandNavViewCategoryGroups(IEnumerable<NavCategoryGroup> groups)
|
||||
{
|
||||
var result = new List<object>();
|
||||
foreach(var group in groups)
|
||||
foreach (var group in groups)
|
||||
{
|
||||
result.Add(group);
|
||||
foreach(var category in group.Categories)
|
||||
foreach (var category in group.Categories)
|
||||
{
|
||||
result.Add(category);
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ namespace CalculatorApp
|
|||
|
||||
private void UpdatePopupSize(Windows.UI.Core.WindowSizeChangedEventArgs e)
|
||||
{
|
||||
if(PopupContent != null)
|
||||
if (PopupContent != null)
|
||||
{
|
||||
PopupContent.Width = e.Size.Width;
|
||||
PopupContent.Height = e.Size.Height;
|
||||
|
@ -198,43 +201,43 @@ namespace CalculatorApp
|
|||
string propertyName = e.PropertyName;
|
||||
if (propertyName == ApplicationViewModel.ModePropertyName)
|
||||
{
|
||||
ViewMode newValue = m_model.Mode;
|
||||
ViewMode previousMode = m_model.PreviousMode;
|
||||
ViewMode newValue = Model.Mode;
|
||||
ViewMode previousMode = Model.PreviousMode;
|
||||
|
||||
KeyboardShortcutManager.DisableShortcuts(false);
|
||||
|
||||
if (newValue == ViewMode.Standard)
|
||||
{
|
||||
EnsureCalculator();
|
||||
m_model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
|
||||
m_model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
}
|
||||
else if (newValue == ViewMode.Scientific)
|
||||
{
|
||||
EnsureCalculator();
|
||||
m_model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
if (m_model.PreviousMode != ViewMode.Scientific)
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = true;
|
||||
if (Model.PreviousMode != ViewMode.Scientific)
|
||||
{
|
||||
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
|
||||
}
|
||||
|
||||
m_model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
Model.CalculatorViewModel.HistoryVM.ReloadHistory(newValue);
|
||||
}
|
||||
else if (newValue == ViewMode.Programmer)
|
||||
{
|
||||
m_model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
EnsureCalculator();
|
||||
if (m_model.PreviousMode != ViewMode.Programmer)
|
||||
if (Model.PreviousMode != ViewMode.Programmer)
|
||||
{
|
||||
m_calculator.AnimateCalculator(NavCategory.IsConverterViewMode(previousMode));
|
||||
}
|
||||
}
|
||||
else if (NavCategory.IsDateCalculatorViewMode(newValue))
|
||||
{
|
||||
if (m_model.CalculatorViewModel != null)
|
||||
if (Model.CalculatorViewModel != null)
|
||||
{
|
||||
m_model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
}
|
||||
EnsureDateCalculator();
|
||||
}
|
||||
|
@ -245,9 +248,9 @@ namespace CalculatorApp
|
|||
}
|
||||
else if (NavCategory.IsConverterViewMode(newValue))
|
||||
{
|
||||
if (m_model.CalculatorViewModel != null)
|
||||
if (Model.CalculatorViewModel != null)
|
||||
{
|
||||
m_model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
Model.CalculatorViewModel.HistoryVM.AreHistoryShortcutsEnabled = false;
|
||||
}
|
||||
|
||||
EnsureConverter();
|
||||
|
@ -359,7 +362,7 @@ namespace CalculatorApp
|
|||
|
||||
private void OnNavSelectionChanged(object sender, MUXC.NavigationViewSelectionChangedEventArgs e)
|
||||
{
|
||||
if(e.IsSettingsSelected)
|
||||
if (e.IsSettingsSelected)
|
||||
{
|
||||
ShowSettingsPopup();
|
||||
return;
|
||||
|
@ -423,10 +426,10 @@ namespace CalculatorApp
|
|||
private void UpdateViewState()
|
||||
{
|
||||
// All layout related view states are now handled only inside individual controls (standard, scientific, programmer, date, converter)
|
||||
if (NavCategory.IsConverterViewMode(m_model.Mode))
|
||||
if (NavCategory.IsConverterViewMode(Model.Mode))
|
||||
{
|
||||
int modeIndex = NavCategoryStates.GetIndexInGroup(m_model.Mode, CategoryGroupType.Converter);
|
||||
m_model.ConverterViewModel.CurrentCategory = m_model.ConverterViewModel.Categories[modeIndex];
|
||||
int modeIndex = NavCategoryStates.GetIndexInGroup(Model.Mode, CategoryGroupType.Converter);
|
||||
Model.ConverterViewModel.CurrentCategory = Model.ConverterViewModel.Categories[modeIndex];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +456,7 @@ namespace CalculatorApp
|
|||
{
|
||||
// We have just launched into our default mode (standard calc) so ensure calc is loaded
|
||||
EnsureCalculator();
|
||||
m_model.CalculatorViewModel.IsStandard = true;
|
||||
Model.CalculatorViewModel.IsStandard = true;
|
||||
}
|
||||
|
||||
Window.Current.SizeChanged += WindowSizeChanged;
|
||||
|
@ -477,7 +480,7 @@ namespace CalculatorApp
|
|||
|
||||
private void App_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
|
||||
{
|
||||
if (m_model.IsAlwaysOnTop)
|
||||
if (Model.IsAlwaysOnTop)
|
||||
{
|
||||
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
|
||||
localSettings.Values[ApplicationViewModel.WidthLocalSettings] = ActualWidth;
|
||||
|
@ -490,20 +493,30 @@ namespace CalculatorApp
|
|||
if (m_calculator == null)
|
||||
{
|
||||
// delay load calculator.
|
||||
m_calculator = new Calculator();
|
||||
m_calculator.Name = "Calculator";
|
||||
m_calculator.DataContext = m_model.CalculatorViewModel;
|
||||
Binding isStandardBinding = new Binding();
|
||||
isStandardBinding.Path = new PropertyPath("IsStandard");
|
||||
m_calculator = new Calculator
|
||||
{
|
||||
Name = "Calculator",
|
||||
DataContext = Model.CalculatorViewModel
|
||||
};
|
||||
Binding isStandardBinding = new Binding
|
||||
{
|
||||
Path = new PropertyPath("IsStandard")
|
||||
};
|
||||
m_calculator.SetBinding(Calculator.IsStandardProperty, isStandardBinding);
|
||||
Binding isScientificBinding = new Binding();
|
||||
isScientificBinding.Path = new PropertyPath("IsScientific");
|
||||
Binding isScientificBinding = new Binding
|
||||
{
|
||||
Path = new PropertyPath("IsScientific")
|
||||
};
|
||||
m_calculator.SetBinding(Calculator.IsScientificProperty, isScientificBinding);
|
||||
Binding isProgramerBinding = new Binding();
|
||||
isProgramerBinding.Path = new PropertyPath("IsProgrammer");
|
||||
Binding isProgramerBinding = new Binding
|
||||
{
|
||||
Path = new PropertyPath("IsProgrammer")
|
||||
};
|
||||
m_calculator.SetBinding(Calculator.IsProgrammerProperty, isProgramerBinding);
|
||||
Binding isAlwaysOnTopBinding = new Binding();
|
||||
isAlwaysOnTopBinding.Path = new PropertyPath("IsAlwaysOnTop");
|
||||
Binding isAlwaysOnTopBinding = new Binding
|
||||
{
|
||||
Path = new PropertyPath("IsAlwaysOnTop")
|
||||
};
|
||||
m_calculator.SetBinding(Calculator.IsAlwaysOnTopProperty, isAlwaysOnTopBinding);
|
||||
m_calculator.Style = CalculatorBaseStyle;
|
||||
|
||||
|
@ -526,9 +539,11 @@ namespace CalculatorApp
|
|||
if (m_dateCalculator == null)
|
||||
{
|
||||
// delay loading converter
|
||||
m_dateCalculator = new DateCalculator();
|
||||
m_dateCalculator.Name = "dateCalculator";
|
||||
m_dateCalculator.DataContext = m_model.DateCalcViewModel;
|
||||
m_dateCalculator = new DateCalculator
|
||||
{
|
||||
Name = "dateCalculator",
|
||||
DataContext = Model.DateCalcViewModel
|
||||
};
|
||||
|
||||
DateCalcHolder.Child = m_dateCalculator;
|
||||
}
|
||||
|
@ -544,9 +559,11 @@ namespace CalculatorApp
|
|||
{
|
||||
if (m_graphingCalculator == null)
|
||||
{
|
||||
m_graphingCalculator = new GraphingCalculator();
|
||||
m_graphingCalculator.Name = "GraphingCalculator";
|
||||
m_graphingCalculator.DataContext = m_model.GraphingCalcViewModel;
|
||||
m_graphingCalculator = new GraphingCalculator
|
||||
{
|
||||
Name = "GraphingCalculator",
|
||||
DataContext = Model.GraphingCalcViewModel
|
||||
};
|
||||
|
||||
GraphingCalcHolder.Child = m_graphingCalculator;
|
||||
}
|
||||
|
@ -557,10 +574,12 @@ namespace CalculatorApp
|
|||
if (m_converter == null)
|
||||
{
|
||||
// delay loading converter
|
||||
m_converter = new CalculatorApp.UnitConverter();
|
||||
m_converter.Name = "unitConverter";
|
||||
m_converter.DataContext = m_model.ConverterViewModel;
|
||||
m_converter.Style = UnitConverterBaseStyle;
|
||||
m_converter = new CalculatorApp.UnitConverter
|
||||
{
|
||||
Name = "unitConverter",
|
||||
DataContext = Model.ConverterViewModel,
|
||||
Style = UnitConverterBaseStyle
|
||||
};
|
||||
ConverterHolder.Child = m_converter;
|
||||
}
|
||||
}
|
||||
|
@ -596,7 +615,6 @@ namespace CalculatorApp
|
|||
private GraphingCalculator m_graphingCalculator;
|
||||
private UnitConverter m_converter;
|
||||
private DateCalculator m_dateCalculator;
|
||||
private ApplicationViewModel m_model;
|
||||
private AccessibilitySettings m_accessibilitySettings;
|
||||
private readonly AccessibilitySettings m_accessibilitySettings;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue