private void ButtonCharacterSetAdd_Click(object sender, RoutedEventArgs e) { var newCharacterSet = new CharacterSet(); _csManager.Add(newCharacterSet); ListBoxCharacterSet.SelectedIndex = _csManager.IndexOf(newCharacterSet); ListBoxCharacterSet.ScrollIntoView(ListBoxCharacterSet.SelectedItem); e.Handled = true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { // Configure bindings var binding = new Binding("SelectedItems.Count") { Source = ListBoxProjectData, Converter = new IntegerToVisibilityConverter(), ConverterParameter = "=,1,Hidden" }; MainPixelGrid.SetBinding(VisibilityProperty, binding); GuidePanel.SetBinding(VisibilityProperty, binding); binding = new Binding("IsAscentOverlayVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonAscentOverlay.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsDescentOverlayVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonDescentOverlay.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsBearingOverlayVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonBearingOverlay.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsBaselineGuideVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonBaselineGuide.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsUppercaseGuideVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonUppercaseGuide.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsLowercaseGuideVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonLowercaseGuide.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("IsBearingGuideVisible") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonBearingGuide.SetBinding(ToggleButton.IsCheckedProperty, binding); binding = new Binding("ExtendGuideLines") { Source = MainPixelGrid, Mode = BindingMode.TwoWay }; ButtonExtendGuides.SetBinding(ToggleButton.IsCheckedProperty, binding); // Load the character set color scheme ColorScheme scheme; if (Settings.Default.Preferences_Appearance_CharacterSetColors == null || Settings.Default.Preferences_Appearance_CharacterSetColors.Count == 0) { scheme = ColorScheme.BlackOnlyScheme; } else { scheme = new ColorScheme(Settings.Default.Preferences_Appearance_CharacterSetColors); } // Load the character set database _csManager = new CharacterSetManager(scheme); if (!_csManager.Load(Settings.Default.Database_Filename)) { _csManager.Clear(); _csManager.Add(new CharacterSet()); _csManager.Save(Settings.Default.Database_Filename); MessageBox.Show( "The character set database is either missing or corrupted.\nA new empty database has been created.", "Database missing", MessageBoxButton.OK, MessageBoxImage.Exclamation); } // Subscribe to events MainPixelGrid.GridUpdated += MainPixelGrid_GridUpdated; }