public override void Draw(DrawingContext ctx, Matrix matrix)
        {
            bool  flag = false;
            Point pointBegin;
            Point pointEnd;

            this.GetPoints(out pointBegin, out pointEnd);
            if (this.IsX)
            {
                GridColumnSelectionSet columnSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridColumnSelectionSet;
                if (columnSelectionSet != null)
                {
                    flag = !columnSelectionSet.GridLineMode && columnSelectionSet.IsSelected(this.Grid.ColumnDefinitions[this.Index]);
                }
            }
            else
            {
                GridRowSelectionSet gridRowSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridRowSelectionSet;
                if (gridRowSelectionSet != null)
                {
                    flag = !gridRowSelectionSet.GridLineMode && gridRowSelectionSet.IsSelected(this.Grid.RowDefinitions[this.Index]);
                }
            }
            MatrixTransform matrixTransform = new MatrixTransform(matrix);

            matrixTransform.Freeze();
            ctx.PushTransform((Transform)matrixTransform);
            ctx.DrawRectangle(flag ? (Brush)LayoutBackgroundAdorner.SelectedBrush : (Brush)LayoutBackgroundAdorner.UnselectedBrush, (Pen)null, new Rect(pointBegin, pointEnd));
            ctx.Pop();
        }
Esempio n. 2
0
        protected override bool OnButtonDown(Point pointerPosition)
        {
            this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            LayoutLineHeaderAdorner lineHeaderAdorner = this.ActiveAdorner as LayoutLineHeaderAdorner;
            LayoutBackgroundAdorner backgroundAdorner = this.ActiveAdorner as LayoutBackgroundAdorner;

            if (lineHeaderAdorner != null)
            {
                GridElement gridElement = (GridElement)lineHeaderAdorner.Element;
                if (lineHeaderAdorner.IsX)
                {
                    GridColumnSelectionSet columnSelectionSet = this.ActiveSceneViewModel.GridColumnSelectionSet;
                    ColumnDefinitionNode   selectionToSet     = gridElement.ColumnDefinitions[lineHeaderAdorner.Index];
                    columnSelectionSet.GridLineMode = true;
                    columnSelectionSet.SetSelection(selectionToSet);
                }
                else
                {
                    GridRowSelectionSet gridRowSelectionSet = this.ActiveSceneViewModel.GridRowSelectionSet;
                    RowDefinitionNode   selectionToSet      = gridElement.RowDefinitions[lineHeaderAdorner.Index];
                    gridRowSelectionSet.GridLineMode = true;
                    gridRowSelectionSet.SetSelection(selectionToSet);
                }
                this.firstLineHeaderDrag = true;
                ((GridRowColumnAdornerSet)lineHeaderAdorner.AdornerSet).DraggingGridline = true;
                return(true);
            }
            return(backgroundAdorner != null);
        }
Esempio n. 3
0
        public override void Draw(DrawingContext drawingContext, Matrix matrix)
        {
            bool flag;

            if (this.IsX)
            {
                GridColumnSelectionSet columnSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridColumnSelectionSet;
                flag = columnSelectionSet.GridLineMode && columnSelectionSet.IsSelected(this.Grid.ColumnDefinitions[this.Index]);
            }
            else
            {
                GridRowSelectionSet gridRowSelectionSet = ((GridRowColumnAdornerSet)this.AdornerSet).GridRowSelectionSet;
                flag = gridRowSelectionSet.GridLineMode && gridRowSelectionSet.IsSelected(this.Grid.RowDefinitions[this.Index]);
            }
            Brush  brush   = flag ? this.ActiveBrush : this.InactiveBrush;
            Matrix matrix1 = this.TruncateMatrix(matrix);
            Point  center  = this.GetCenter(matrix, matrix1);

            matrix1.Translate(center.X, center.Y);
            if (!this.IsX)
            {
                matrix1.RotatePrepend(-90.0);
            }
            MatrixTransform matrixTransform = new MatrixTransform(matrix1);

            matrixTransform.Freeze();
            drawingContext.PushTransform((Transform)matrixTransform);
            drawingContext.DrawGeometry(brush, this.ThinPen, LayoutAdorner.TriangleGeometry);
            drawingContext.Pop();
        }
Esempio n. 4
0
        protected override bool OnClickEnd(Point pointerPosition, int clickCount)
        {
            GridLockAdorner                    gridLockAdorner         = this.ActiveAdorner as GridLockAdorner;
            LayoutBackgroundAdorner            backgroundAdorner       = this.ActiveAdorner as LayoutBackgroundAdorner;
            LayoutLineHeaderAdorner            lineHeaderAdorner       = this.ActiveAdorner as LayoutLineHeaderAdorner;
            GridDesignModeAdorner              designModeAdorner       = this.ActiveAdorner as GridDesignModeAdorner;
            NewGridlineAdorner                 newGridlineAdorner      = this.ActiveAdorner as NewGridlineAdorner;
            LayoutEmptyBackgroundHeaderAdorner backgroundHeaderAdorner = this.ActiveAdorner as LayoutEmptyBackgroundHeaderAdorner;
            GridElement        grid = (GridElement)((Adorner)this.ActiveAdorner).Element;
            GridLayoutDesigner gridLayoutDesigner = (GridLayoutDesigner)grid.LayoutDesigner;

            pointerPosition = this.ToolBehaviorContext.SnappingEngine.SnapPoint(pointerPosition);
            Matrix transformFromRoot = this.ActiveView.GetComputedTransformFromRoot((SceneElement)grid);

            pointerPosition *= transformFromRoot;
            if (backgroundHeaderAdorner == null)
            {
                if (lineHeaderAdorner != null)
                {
                    ((GridRowColumnAdornerSet)lineHeaderAdorner.AdornerSet).DraggingGridline = false;
                    if (clickCount > 1)
                    {
                        if (lineHeaderAdorner.IsX)
                        {
                            gridLayoutDesigner.RemoveColumn(grid, lineHeaderAdorner.Index);
                        }
                        else
                        {
                            gridLayoutDesigner.RemoveRow(grid, lineHeaderAdorner.Index);
                        }
                    }
                }
                else if (gridLockAdorner != null)
                {
                    using (SceneEditTransaction editTransaction = this.ActiveDocument.CreateEditTransaction(StringTable.UndoUnitToggleGridProperty))
                    {
                        if (gridLockAdorner.IsX)
                        {
                            ColumnDefinitionNode columnDefinitionNode = grid.ColumnDefinitions[gridLockAdorner.Index];
                            GridLength           width = columnDefinitionNode.Width;
                            if (width.IsAuto)
                            {
                                columnDefinitionNode.ClearValue(ColumnDefinitionNode.MinWidthProperty);
                                gridLayoutDesigner.SetColumnWidthToStar(grid, gridLockAdorner.Index);
                            }
                            else if (width.IsAbsolute)
                            {
                                gridLayoutDesigner.SetColumnWidth(grid, gridLockAdorner.Index, GridLength.Auto, columnDefinitionNode.ComputedWidth);
                            }
                            else
                            {
                                gridLayoutDesigner.SetColumnWidth(grid, gridLockAdorner.Index, new GridLength(columnDefinitionNode.ComputedWidth), double.NaN);
                            }
                        }
                        else
                        {
                            RowDefinitionNode rowDefinitionNode = grid.RowDefinitions[gridLockAdorner.Index];
                            GridLength        height            = rowDefinitionNode.Height;
                            if (height.IsAuto)
                            {
                                rowDefinitionNode.ClearValue(RowDefinitionNode.MinHeightProperty);
                                gridLayoutDesigner.SetRowHeightToStar(grid, gridLockAdorner.Index);
                            }
                            else if (height.IsAbsolute)
                            {
                                gridLayoutDesigner.SetRowHeight(grid, gridLockAdorner.Index, GridLength.Auto, rowDefinitionNode.ComputedHeight);
                            }
                            else
                            {
                                gridLayoutDesigner.SetRowHeight(grid, gridLockAdorner.Index, new GridLength(rowDefinitionNode.ComputedHeight), double.NaN);
                            }
                        }
                        editTransaction.Commit();
                    }
                }
                else if (backgroundAdorner != null)
                {
                    if (backgroundAdorner.IsX)
                    {
                        GridColumnSelectionSet columnSelectionSet   = this.ActiveSceneViewModel.GridColumnSelectionSet;
                        ColumnDefinitionNode   columnDefinitionNode = grid.ColumnDefinitions[backgroundAdorner.Index];
                        columnSelectionSet.GridLineMode = false;
                        if (this.IsShiftDown)
                        {
                            columnSelectionSet.ToggleSelection(columnDefinitionNode);
                        }
                        else
                        {
                            columnSelectionSet.SetSelection(columnDefinitionNode);
                        }
                    }
                    else
                    {
                        GridRowSelectionSet gridRowSelectionSet = this.ActiveSceneViewModel.GridRowSelectionSet;
                        RowDefinitionNode   rowDefinitionNode   = grid.RowDefinitions[backgroundAdorner.Index];
                        gridRowSelectionSet.GridLineMode = false;
                        if (this.IsShiftDown)
                        {
                            gridRowSelectionSet.ToggleSelection(rowDefinitionNode);
                        }
                        else
                        {
                            gridRowSelectionSet.SetSelection(rowDefinitionNode);
                        }
                    }
                }
                else if (newGridlineAdorner != null && this.IsNewGridlineEnabled)
                {
                    if (newGridlineAdorner.IsX)
                    {
                        gridLayoutDesigner.AddVerticalGridline(grid, pointerPosition.X);
                    }
                    else
                    {
                        gridLayoutDesigner.AddHorizontalGridline(grid, pointerPosition.Y);
                    }
                }
                else if (designModeAdorner != null)
                {
                    grid.ViewModel.IsInGridDesignMode = !designModeAdorner.Grid.ViewModel.IsInGridDesignMode;
                }
            }
            this.ToolBehaviorContext.SnappingEngine.Stop();
            this.ActiveView.UpdateLayout();
            this.ActiveSceneViewModel.RefreshSelection();
            return(base.OnClickEnd(pointerPosition, clickCount));
        }