예제 #1
0
 private void ListBoxProjectData_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.RemovedItems.Count == 1 && _gridChanged)
     {
         CommitCurrentCharacterPixels(e.RemovedItems[0] as ProjectCharacter);
     }
     if (e.AddedItems.Count == 1)
     {
         var projectCharacter = e.AddedItems[0] as ProjectCharacter;
         if (projectCharacter != null)
         {
             _isSwitchingDisplayedCharacter = true;
             MainPixelGrid.SetGridData(projectCharacter.Pixels);
             _isSwitchingDisplayedCharacter = false;
         }
     }
     UpdateProjectButtonStatus();
     e.Handled = true;
 }
예제 #2
0
 private void ButtonMoveRight_Click(object sender, RoutedEventArgs e)
 {
     MainPixelGrid.Transform(0, 0, 0, 1);
 }
예제 #3
0
 private void ButtonMoveUp_Click(object sender, RoutedEventArgs e)
 {
     MainPixelGrid.Transform(-1, 0, 0, 0);
 }
예제 #4
0
        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;
        }
예제 #5
0
        private void SyncProjectSettings()
        {
            UpdateProjectCharacterCount();
            _gridChanged    = false;
            _projectChanged = false;

            // Configure bindings
            var binding = new Binding("CharacterWidth")
            {
                Source = Project
            };

            MainPixelGrid.SetBinding(PixelGrid.PixelGridWidthProperty, binding);
            binding = new Binding("CharacterHeight")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(PixelGrid.PixelGridHeightProperty, binding);
            binding = new Binding("AscentHeight")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.AscentHeightProperty, binding);
            binding = new Binding("DescentHeight")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.DescentHeightProperty, binding);
            binding = new Binding("UppercaseHeight")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.UppercaseHeightProperty, binding);
            binding = new Binding("LowercaseHeight")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.LowercaseHeightProperty, binding);
            binding = new Binding("LeftBearingWidth")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.LeftBearingWidthProperty, binding);
            binding = new Binding("RightBearingWidth")
            {
                Source = Project
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.RightBearingWidthProperty, binding);
            binding = new Binding("IsAscentOverlay")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsAscentOverlayVisibleProperty, binding);
            binding = new Binding("IsDescentOverlay")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsDescentOverlayVisibleProperty, binding);
            binding = new Binding("IsBearingOverlay")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsBearingOverlayVisibleProperty, binding);
            binding = new Binding("IsBaselineGuide")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsBaselineGuideVisibleProperty, binding);
            binding = new Binding("IsUppercaseGuide")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsUppercaseGuideVisibleProperty, binding);
            binding = new Binding("IsLowercaseGuide")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsLowercaseGuideVisibleProperty, binding);
            binding = new Binding("IsBearingGuides")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.IsBearingGuideVisibleProperty, binding);
            binding = new Binding("IsExtendGuides")
            {
                Source = Project, Mode = BindingMode.TwoWay
            };
            MainPixelGrid.SetBinding(GlyphPixelGrid.ExtendGuideLinesProperty, binding);
            MainPixelGrid.ChangeAllPixels(false);
        }