public void ConfigureUI()
        {
            // There is probably a better WPF way of binding all this, but for now, I am just going to set it.
            mainCanvas.Background = BrushCache.GetBrush(SystemColors.ControlColor);

            windowWidth.Minimum  = (int)Settings.MinimumSize.Width;
            windowHeight.Minimum = (int)Settings.MinimumSize.Height;

            // Grid
            gridVisible.IsChecked       = Settings.Grid.Visible;
            gridLineColor.SelectedColor = Settings.Grid.LineColor;
            gridTransparency.Value      = (int)(Settings.Grid.Opacity * 100);

            gridCellWidth.Value  = Settings.Grid.Width;
            gridCellHeight.Value = Settings.Grid.Height;

            // Snap
            snapEnabled.IsChecked = Settings.Snap.Enabled;
            snapHorizontal.Value  = Settings.Snap.X;
            snapVertical.Value    = Settings.Snap.Y;

            // Window
            windowBackgroundColor.SelectedColor = Settings.BackgroundColor;
            windowBackgroundImage.Text          = Settings.BackgroundImagePath;
            windowBackgroundVisible.IsChecked   = Settings.ShowBackgroundImage;

            windowWidth.Value  = (int)Settings.Layout.Width;
            windowHeight.Value = (int)Settings.Layout.Height;
        }
        private void ApplySettings()
        {
            #region Fix Background Brush (Grid)

            DrawingBrush drawingBrush = Resources["GridBrush"] as DrawingBrush;
            drawingBrush.Opacity = Settings.Grid.Opacity;

            // Probably some better WPF way of doing this...oh well
            if (Settings.Grid.Width > 0 && Settings.Grid.Height > 0)
            {
                double widthOffset  = 1.0 / Settings.Grid.Width;
                double heightOffset = 1.0 / Settings.Grid.Height;

                Brush lineBrush = BrushCache.GetBrush(Settings.Grid.LineColor);
                drawingBrush.Viewport = new Rect(new Size(Settings.Grid.Width, Settings.Grid.Height));

                DrawingGroup drawingGroup = drawingBrush.Drawing as DrawingGroup;
                drawingGroup.Children.Clear();

                drawingGroup.Children.Add(new GeometryDrawing
                {
                    Geometry = Geometry.Parse(String.Format("M0,0 L1,0 1,{0}, 0,{0}Z", heightOffset)),
                    Brush    = lineBrush
                });

                drawingGroup.Children.Add(new GeometryDrawing
                {
                    Geometry = Geometry.Parse(String.Format("M0,0 L0,1 {0},1, {0},0Z", widthOffset)),
                    Brush    = lineBrush
                });
            }

            #endregion

            _backgroundColorBrush = BrushCache.GetBrush(Settings.BackgroundColor);
            _backgroundImageBrush = null;

            if (Settings.BackgroundImagePath != null)
            {
                var image = Helper.GetImage(Settings.BackgroundImagePath);
                if (image != null)
                {
                    _backgroundImageBrush = new ImageBrush(image);
                }
            }

            backgroundButton.Visibility = _backgroundImageBrush != null ? Visibility.Visible : Visibility.Collapsed;

            Height = Settings.Layout.Height + _windowHeightOffset;
            Width  = Settings.Layout.Width + _windowWidthOffset;

            ShowGrid(Settings.Grid.Visible);
            ShowBackground(Settings.ShowBackgroundImage);

            UpdateTitle();
        }
        // Helper method to instantiate the corner Thumbs, set the Cursor property,
        // set some appearance properties, and add the elements to the visual tree.
        void BuildAdornerCorner(ref Thumb cornerThumb, Cursor customizedCursor)
        {
            if (cornerThumb != null)
            {
                return;
            }

            cornerThumb            = new Thumb();
            cornerThumb.Height     = cornerThumb.Width = 10;
            cornerThumb.Opacity    = 0.40;
            cornerThumb.Background = BrushCache.GetBrush(Colors.MediumBlue);

            if (allowResize)
            {
                cornerThumb.Cursor = customizedCursor;

                cornerThumb.PreviewMouseLeftButtonDown += cornerThumb_MouseButtonEvent;
                cornerThumb.PreviewMouseLeftButtonUp   += cornerThumb_MouseButtonEvent;
            }

            visualChildren.Add(cornerThumb);
        }
Пример #4
0
 public void ConfigureUI()
 {
     // There is probably a better WPF way of binding all this, but for now, I am just going to set it.
     MainList.Background = BrushCache.GetBrush(SystemColors.ControlColor);
 }