コード例 #1
0
        public Workspace(MainWindow window)
        {
            _window = window;

            //set window colors
            _window.WindowGrid.Background             = CustomBrushes.WindowBackground;
            _window.BackgroundLayerOption.Background  = CustomBrushes.VeryDarkGray;
            _window.LayerSettingsSection.Background   = CustomBrushes.VeryDarkGray;
            _window.WorkspaceButtonsBorder.Background = CustomBrushes.VeryDarkGray;

            ImageGrid = new Grid()
            {
                Background = CustomBrushes.CheckerBoardDark, Width = ImageGridSize, Height = ImageGridSize
            };
            BackgroundLayer = new Grid();
            ImageGrid.Children.Add(BackgroundLayer);
            _workspaceZoomBorder       = new ZoomBorder(_window, _window.WorkspaceHolder);
            _workspaceZoomBorder.Child = ImageGrid;
            _window.WorkspaceHolder.Children.Add(_workspaceZoomBorder);
            ImageGrid.ClipToBounds = true;

            _window.MouseDown                    += (s, e) => OnWindowMouseDown();
            _window.KeyDown                      += OnWindowKeyDown;
            _window.AddLayerButton.Click         += (s, e) => StartImageImport();
            _window.SaveImageButton.Click        += (s, e) => SaveImage();
            _window.WorkspaceZoomInButton.Click  += (s, e) => WorkspaceZoom(true);
            _window.WorkspaceZoomOutButton.Click += (s, e) => WorkspaceZoom(false);
            _window.LayerSizeDownButton.Click    += (s, e) => LayerSizeDown();
            _window.LayerSizeUpButton.Click      += (s, e) => LayerSizeUp();

            Layers = new List <LayerPanel>();
            _window.LayersListView.Background        = CustomBrushes.VeryDarkGray;
            _window.LayersListView.ItemsSource       = Layers;
            _window.LayersListView.SelectionChanged += OnLayerSelected;
            _window.LayersListView.MouseDoubleClick += OnLayerDoubleClick;

            _window.BackgroundColorBackground.Background = CustomBrushes.CheckerBoardDarkSmall;

            _patternController = new PatternMenuController(window, this);
        }