예제 #1
0
파일: Drawing.cs 프로젝트: ondrej11/o106
        public Drawing(Canvas canvas)
        {
            Check.NotNull(canvas, "canvas");

            ActionManager = new ActionManager();
            StyleManager = new StyleManager(this);

            Figures = new RootFigureList(this);

            OnAttachToCanvas += Drawing_OnAttachToCanvas;
            OnDetachFromCanvas += Drawing_OnDetachFromCanvas;

            Canvas = canvas;

            CoordinateSystem = new CoordinateSystem(this);
            CoordinateGrid = new CartesianGrid() { Drawing = this, Visible = Settings.Instance.ShowGrid };
            Figures.Add(CoordinateGrid);
            Version = Settings.CurrentDrawingVersion;
        }
예제 #2
0
        protected virtual void SetupLayout()
        {
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            this.RowDefinitions.Add(new RowDefinition());
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = GridLength.Auto
            });
            this.ColumnDefinitions.Add(new ColumnDefinition());
            this.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = GridLength.Auto
            });

            CreateRibbon();
            CreateCanvas();
            CreatePropertyGrid();
            CreateStatusBar();
            CreateFigureExplorer();
            CreateAIDebugWindow();

            this.Children.Add(Ribbon);
            this.Children.Add(DrawingControl);
            this.Children.Add(propertyGridScrollViewer);
            this.Children.Add(StatusBar);
            this.Children.Add(FigureExplorer);
            this.Children.Add(AIDebugWindow);

            FigureExplorer.Visible = Settings.Instance.ShowFigureExplorer;
            AIDebugWindow.Visible  = Settings.Instance.ShowAIDebugWindow;

            Grid.SetColumnSpan(Ribbon, 2);
            Grid.SetColumnSpan(AIDebugWindow, 2);
            Grid.SetColumn(FigureExplorer, 1);
            Grid.SetColumn(DrawingControl, 0);
            Grid.SetColumn(propertyGridScrollViewer, 0);
            Grid.SetColumn(StatusBar, 0);
            Grid.SetRow(FigureExplorer, 1);
            Grid.SetRow(DrawingControl, 1);
            Grid.SetRow(propertyGridScrollViewer, 1);
            Grid.SetRow(StatusBar, 1);
            Grid.SetRow(AIDebugWindow, 2);

            CommandToggleGrid           = new Command(ToggleGrid, CartesianGrid.GetIcon(), "Grid", BehaviorCategories.Coordinates);
            CommandToggleOrtho          = new Command(ToggleOrtho, new CheckBox(), "Ortho", BehaviorCategories.Selection);
            CommandToggleSnapToGrid     = new Command(ToggleSnapToGrid, new CheckBox(), "Snap to grid", BehaviorCategories.Selection);
            CommandToggleSnapToPoint    = new Command(ToggleSnapToPoint, new CheckBox(), "Snap to point", BehaviorCategories.Selection);
            CommandToggleLabelNewPoints = new Command(ToggleLabelNewPoints, new CheckBox(), "Label New Points", BehaviorCategories.Points);
            CommandTogglePolar          = new Command(TogglePolar, new CheckBox(), "Polar", BehaviorCategories.Selection);
            CommandToggleSnapToCenter   = new Command(ToggleSnapToCenter, new CheckBox(), "Snap to Center", BehaviorCategories.Selection);
            CommandShowFigureExplorer   = new Command(ToggleFigureExplorer, new CheckBox()
            {
                IsChecked = FigureExplorer.Visible
            }, "Figure List", BehaviorCategories.Drawing);
            CommandShowAIDebugWindow = new Command(ToggleAIDebugWindow, new CheckBox()
            {
                IsChecked = AIDebugWindow.Visible
            }, "AI Output", BehaviorCategories.Parsing);
        }