示例#1
0
        private void NewDrawingBoard(string fileName)
        {
            Engine.Workflow w = Engine.WorkflowCollection.NewWorkflow();

            if (string.IsNullOrEmpty(fileName))
            {
                w.SetCanvas(new Engine.Surface.Canvas(1200, 1200, Engine.Colors.White));
            }
            else
            {
                try
                {
                    w.SetCanvas(new Engine.Surface.Canvas(fileName));
                }
                catch (Exception e)
                {
                    MessageBox.Show(String.Format("Error reading file : ", e.Message));
                }
            }

            var db = new PaintualUI.Controls.DrawingBoard(w);

            NewDockPane(db, String.Format(t_defaultDocTabTitle + "{0}", w.Key));

            _app.ActiveContentHelper.SetCurrentDrawingBoard(db);

            // a suggested default tool to work with the new DrawingBoard
            SetActivity(new Engine.Tools.GrainyPen());
        }
示例#2
0
        private void E_windowsManager_ActiveDocumentChanged(object sender, Cuisine.Windows.ActiveDocumentChangedEventArgs e)
        {
            System.Windows.Controls.TabControl tabControl = e.TabControl;

            // SelectedContent is what is to become the previously selected item
            //System.Windows.Controls.Grid g = tabControl.SelectedContent as System.Windows.Controls.Grid;

            if (tabControl.SelectedItem == null)
            {
                return;
            }

            // SelectedItem is the one becoming active which gives the right DrawingBoard for our code
            Cuisine.Windows.DocumentContent dc = (Cuisine.Windows.DocumentContent)tabControl.SelectedItem;

            System.Windows.Controls.Grid g = (System.Windows.Controls.Grid)dc.Content;

            // can occur when new drawingBoard is created and is not set as a document in the DocumentContainer (one with tabs)
            if (g == null)
            {
                return;
            }

            if (g.Children[0] is PaintualUI.Controls.DrawingBoard == false)
            {
                return;
            }

            PaintualUI.Controls.DrawingBoard db = (PaintualUI.Controls.DrawingBoard)g.Children[0];

            SetCurrentDrawingBoard(db);
        }
示例#3
0
        public void SetCurrentDrawingBoard(PaintualUI.Controls.DrawingBoard db)
        {
            if (db != t_currentDrawingBoard)
            {
                t_currentDrawingBoard = db;

                Engine.Workflow w = t_currentDrawingBoard.Workflow;
                Engine.WorkflowCollection.SetAsActiveWorkflow(w.Key);

                // VisualPropertyPage has registered to this event
                OnCurrentDrawingBoardChanged();
            }
        }
示例#4
0
        private Engine.Workflow GetWorkflowForCurrentDrawingBoard()
        {
            PaintualUI.Controls.DrawingBoard db = _app.ActiveContentHelper.GetCurrentDrawingBoard();

            if (db == null)
            {
                MessageBox.Show("Select a drawing board first");
                return(null);
            }

            Engine.Workflow w = db.Workflow;

            return(w);
        }
示例#5
0
        private void NewDockPane(PaintualUI.Controls.DrawingBoard db, string title)
        {
            DockPane pane = new DockPane();

            pane.MinHeight = 100;
            pane.MinWidth  = 100;
            pane.Header    = title;
            Grid g = new Grid();

            g.Background = Brushes.White;
            g.Children.Add(db);
            pane.Content = g;

            WindowsManager.AddDocument(pane);
        }
示例#6
0
        private void E_WindowsManager_DocumentClosing(Cuisine.Windows.DocumentContent documentContent)
        {
            System.Windows.Controls.Grid g = (System.Windows.Controls.Grid)documentContent.Content;

            // can occur when new drawingBoard is created and is not set as a document in the DocumentContainer (one with tabs)
            if (g == null)
            {
                return;
            }

            if (g.Children[0] is PaintualUI.Controls.DrawingBoard == false)
            {
                // TODO : may need to handle closing of VisualPropertyPage (docPane)
                return;
            }

            PaintualUI.Controls.DrawingBoard db = (PaintualUI.Controls.DrawingBoard)g.Children[0];

            _app.ActiveContentHelper.DeleteDrawingBoard(db);
        }
示例#7
0
        private void Extraction_QuickExtractAndSave_Click(object sender, RoutedEventArgs e)
        {
            PaintualUI.Controls.DrawingBoard db = _app.ActiveContentHelper.GetCurrentDrawingBoard();

            if (db == null)
            {
                MessageBox.Show("Select a drawing board first");
                return;
            }

            Engine.Workflow w = db.Workflow;

            Engine.Tools.QuickExtractAndSave qeas = new Engine.Tools.QuickExtractAndSave();

            w.SetActivity(qeas);

            _app.VisualPropertyPageManager.Show(w);

            // TODO : determine when double click should not be handled anymore and release handler
            db.SelectionDoubleClick += qeas.HandleDoubleClick;
        }
示例#8
0
        private void Save_MenuItem_Click(object sender, RoutedEventArgs e)
        {
            PaintualUI.Controls.DrawingBoard db = _app.ActiveContentHelper.GetCurrentDrawingBoard();

            if (db == null)
            {
                MessageBox.Show("Select a drawing board first");
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog()
            {
                Filter = "PNG files(*.png)|*.png"
            };

            if (dialog.ShowDialog() == true)
            {
                Engine.Workflow w = db.Workflow;
                w.LastSavedFolder = dialog.FileName;
                w.SaveImage(dialog.FileName, Engine.Surface.ImageFileFormats.PNG);
            }
        }
示例#9
0
 public CurrentDrawingBoardChangedEventArgs(PaintualUI.Controls.DrawingBoard drawingBoard)
 {
     DrawingBoard = drawingBoard;
 }
示例#10
0
 public void DeleteDrawingBoard(PaintualUI.Controls.DrawingBoard db)
 {
     Engine.Workflow w = db.Workflow;
     Engine.WorkflowCollection.EndWorkflow(w.Key);
 }