using System; using System.Collections.Generic; using System.Linq; using System.Text; 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.Shapes; namespace GraphingCalculator { /// /// Interaction logic for SettingsWindow.xaml /// public partial class SettingsWindow : Window { public SettingsWindow() { InitializeComponent(); this.Loaded += new RoutedEventHandler(SettingsWindow_Loaded); } void SettingsWindow_Loaded(object sender, RoutedEventArgs e) { Update(); } private void Update() { sliderGraphPrecision.Value = GraphingCalculator.Properties.Settings.Default.PlotPrecision; sliderGridDensity.Value = GraphingCalculator.Properties.Settings.Default.GridDensity; sliderDoublePrecision.Value = GraphingCalculator.Properties.Settings.Default.RoundDoublesGraph; sliderNavigationSensitivity.Value = GraphingCalculator.Properties.Settings.Default.NavigationSensitivity; sliderZoomSensitivity.Value = GraphingCalculator.Properties.Settings.Default.ZoomSensitivity; } private void Save() { GraphingCalculator.Properties.Settings.Default.PlotPrecision = sliderGraphPrecision.Value; GraphingCalculator.Properties.Settings.Default.GridDensity = sliderGridDensity.Value; GraphingCalculator.Properties.Settings.Default.RoundDoublesGraph = Convert.ToInt32(sliderDoublePrecision.Value); GraphingCalculator.Properties.Settings.Default.NavigationSensitivity = sliderNavigationSensitivity.Value; GraphingCalculator.Properties.Settings.Default.ZoomSensitivity = sliderZoomSensitivity.Value; } private void buttonDefaults_Click(object sender, RoutedEventArgs e) { sliderGraphPrecision.Value = 600; sliderGridDensity.Value = 41; sliderDoublePrecision.Value = 4; sliderNavigationSensitivity.Value = 0.1; sliderZoomSensitivity.Value = 1.075; } private void buttonCancel_Click(object sender, RoutedEventArgs e) { this.Close(); } private void buttonAccept_Click(object sender, RoutedEventArgs e) { Save(); this.Close(); } private void sliderDoublePrecision_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (outputDoublePrecision != null) outputDoublePrecision.Text = e.NewValue.ToString() + " decimals"; } private void sliderNavigationSensitivity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (outputNavigationSensitivity != null) outputNavigationSensitivity.Text = Math.Round(e.NewValue * 100, 0).ToString() + "% of screen"; } private void sliderZoomSensitivity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (outputZoomSensitivity != null) outputZoomSensitivity.Text = Math.Round((e.NewValue-1) * 100, 0).ToString() + "% of screen"; } } }