/// <summary>
        /// Swap Active Canvas Session
        /// </summary>
        private void OnCanvasWindowGotFocus(object sender, EventArgs e)
        {
            //          Console.WriteLine("Canvas Got Focus!");
            CanvasWindow cw = sender as CanvasWindow;

            SetCurrentCanvasSession(cw.m_session);
        }
Example #2
0
 //-------------------------------------------------------------------------
 // Constructor
 //-------------------------------------------------------------------------
 public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
 {
     m_controller = new Controller(pCanvasWindow.GetPicture(), pCanvasWindow);
     m_controller.NewUserConnected = OnNewUserConnected;
     m_mainForm = pMainForm;
     m_canvasWindow = pCanvasWindow;
     m_canvasWindow.m_session = this;
     m_layerControl = pLayerControlForm;
     m_layerControl.SetCanvasSession(this);
     //setup first layer
     m_controller.CreateLocalUser();
     ResetCanvas();
     m_controller.Connect(ResetCanvas);
 }
Example #3
0
 //-------------------------------------------------------------------------
 // Constructor
 //-------------------------------------------------------------------------
 public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
 {
     m_controller = new Controller(pCanvasWindow.GetPicture(), pCanvasWindow);
     m_controller.NewUserConnected = OnNewUserConnected;
     m_mainForm               = pMainForm;
     m_canvasWindow           = pCanvasWindow;
     m_canvasWindow.m_session = this;
     m_layerControl           = pLayerControlForm;
     m_layerControl.SetCanvasSession(this);
     //setup first layer
     m_controller.CreateLocalUser();
     ResetCanvas();
     m_controller.Connect(ResetCanvas);
 }
Example #4
0
        //---------------------------------------------------------------------
        // Create a new picture and window
        //---------------------------------------------------------------------
        public void CreateNewPicture()
        {
            // Launch a dialogue to ask the user for the properties of the new picture
            NewPictureForm newPictureForm = new NewPictureForm();

            newPictureForm.Owner = this;
            newPictureForm.ShowDialog();

            // Check if the user hit OK or Cancel
            if (newPictureForm.DialogResult == DialogResult.OK)
            {
                // Create a new form to hold the picture
                CanvasWindow newMDIChild = new CanvasWindow(newPictureForm.canvasWidth, newPictureForm.canvasHeight, newPictureForm.canvasName);

                // Set the parent form the main form
                newMDIChild.MdiParent = this;

                // Make the form visible
                newMDIChild.Show();

                // Put the form on top of the others
                newMDIChild.BringToFront();

                //when a canvas is selected we want to update the toolbars and such!
                newMDIChild.GotFocus += (object sender, EventArgs e) => {
                    CanvasWindow cw = sender as CanvasWindow;
                    SetCurrentCanvasSession(cw.m_session);
                };

                //when a canvas is shut down we need to disable the toolbar if there are no other canvases left
                newMDIChild.HandleDestroyed += (object sender, EventArgs args) => {
                    if (m_currentCanvasSession != null && sender == m_currentCanvasSession.canvasWindow)
                    {
                        SetCurrentCanvasSession(null);
                    }
                };

                //create a new canvas session to go with the canvasWindow
                CanvasSession newSession = new CanvasSession(this, newMDIChild, layerControlForm);
                m_canvasSessions.Add(newSession);
                SetCurrentCanvasSession(newSession);
            }
        }
Example #5
0
        //---------------------------------------------------------------------
        // Create a new picture and window
        //---------------------------------------------------------------------
        public void CreateNewPicture()
        {
            // Launch a dialogue to ask the user for the properties of the new picture
            NewPictureForm newPictureForm = new NewPictureForm();
            newPictureForm.Owner = this;
            newPictureForm.ShowDialog();

            // Check if the user hit OK or Cancel
            if (newPictureForm.DialogResult == DialogResult.OK) {
                // Create a new form to hold the picture
                CanvasWindow newMDIChild = new CanvasWindow(newPictureForm.canvasWidth, newPictureForm.canvasHeight, newPictureForm.canvasName);

                // Set the parent form the main form
                newMDIChild.MdiParent = this;

                // Make the form visible
                newMDIChild.Show();

                // Put the form on top of the others
                newMDIChild.BringToFront();

                //when a canvas is selected we want to update the toolbars and such!
                newMDIChild.GotFocus += (object sender, EventArgs e) =>{
                    CanvasWindow cw = sender as CanvasWindow;
                    SetCurrentCanvasSession(cw.m_session);
                };

                //when a canvas is shut down we need to disable the toolbar if there are no other canvases left
                newMDIChild.HandleDestroyed += (object sender, EventArgs args) => {
                    if (m_currentCanvasSession != null && sender == m_currentCanvasSession.canvasWindow) {
                        SetCurrentCanvasSession(null);
                    }
                };

                //create a new canvas session to go with the canvasWindow
                CanvasSession newSession = new CanvasSession(this, newMDIChild, layerControlForm);
                m_canvasSessions.Add(newSession);
                SetCurrentCanvasSession(newSession);
            }
        }
        //---------------------------------------------------------------------
        // Create a new picture and window
        //---------------------------------------------------------------------
        public void CreateNewPicture()
        {
            // Launch a dialogue to ask the user for the properties of the new picture
            NewPictureForm newPictureForm = new NewPictureForm();

            newPictureForm.Owner = this;
            newPictureForm.ShowDialog();

            // Check if the user hit OK or Cancel
            if (newPictureForm.DialogResult == DialogResult.OK)
            {
                // Create a new form to hold the picture
                CanvasWindow newMDIChild = new CanvasWindow(newPictureForm.canvasWidth, newPictureForm.canvasHeight, newPictureForm.canvasName);

                // Set the parent form the main form
                newMDIChild.MdiParent = this;

                // Make the form visible
                newMDIChild.Show();

                // Put the form on top of the others
                newMDIChild.BringToFront();

                newMDIChild.GotFocus += OnCanvasWindowGotFocus;

                // Add new picture to the base application
                SetCurrentCanvasSession(new CanvasSession(this, newMDIChild));
                m_canvasSessions.Add(m_currentCanvasSession);

                // Set up the workspace - the side pannel mostly
                // TODO: this stuff could probably be done in a seperate function that is called eveytime the canvas count changes.
                toolPanelTop.Visible = true;
                rightPanel.Visible   = true;
                rightPanel.Enabled   = true;

                // Set the picture as the focus of the side bar
                layerControlForm.ChangePictureFocus(newMDIChild.GetPicture());
            }
        }
        //---------------------------------------------------------------------
        // Create a new picture and window
        //---------------------------------------------------------------------
        public void CreateNewPicture()
        {
            // Launch a dialogue to ask the user for the properties of the new picture
            NewPictureForm newPictureForm = new NewPictureForm();
            newPictureForm.Owner = this;
            newPictureForm.ShowDialog();

            // Check if the user hit OK or Cancel
            if (newPictureForm.DialogResult == DialogResult.OK) {
                // Create a new form to hold the picture
                CanvasWindow newMDIChild = new CanvasWindow(newPictureForm.canvasWidth, newPictureForm.canvasHeight, newPictureForm.canvasName);

                // Set the parent form the main form
                newMDIChild.MdiParent = this;

                // Make the form visible
                newMDIChild.Show();

                // Put the form on top of the others
                newMDIChild.BringToFront();

                newMDIChild.GotFocus += OnCanvasWindowGotFocus;

                // Add new picture to the base application
                SetCurrentCanvasSession(new CanvasSession(this, newMDIChild));
                m_canvasSessions.Add(m_currentCanvasSession);

                // Set up the workspace - the side pannel mostly
                // TODO: this stuff could probably be done in a seperate function that is called eveytime the canvas count changes.
                toolPanelTop.Visible = true;
                rightPanel.Visible = true;
                rightPanel.Enabled = true;

                // Set the picture as the focus of the side bar
                layerControlForm.ChangePictureFocus(newMDIChild.GetPicture());
            }
        }
        //-------------------------------------------------------------------------
        // Constructor
        //-------------------------------------------------------------------------
        public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
        {
            m_toolRunner = new ToolRunner("localUserInput", pCanvasWindow.GetPicture());
            m_mainForm = pMainForm;
            m_canvasWindow = pCanvasWindow;
            m_canvasWindow.m_session = this;
            m_layerControl = pLayerControlForm;

            //setup first layer
            selectedLayerID = Gui_CreateLayer();
            Gui_ClearSelectedLayer();

            //add listeners for all functions that should redraw the main canvas
            m_toolRunner.AddFunctionListener( (pA, pB, pC) => { m_canvasWindow.Redraw(pA); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer");

            //add listeners for all functions that should rebuild the layer list
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.RebuildLayerControls(); }, "reorder_layers", "rename_layer", "remove_layer", "create_layer");

            //add listeners for all functions that should update a layer thumbnail
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.UpdateThumbnail(pC["layer"] as string); }, "tool_up", "undo", "clear");

            //add listeners for updating the status bar (:
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_mainForm.SetStatus("last action: " + pB); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer", "create_layer");
        }
Example #9
0
        //-------------------------------------------------------------------------
        // Constructor
        //-------------------------------------------------------------------------
        public CanvasSession(MainForm pMainForm, CanvasWindow pCanvasWindow, LayerControlForm pLayerControlForm)
        {
            m_toolRunner             = new ToolRunner("localUserInput", pCanvasWindow.GetPicture());
            m_mainForm               = pMainForm;
            m_canvasWindow           = pCanvasWindow;
            m_canvasWindow.m_session = this;
            m_layerControl           = pLayerControlForm;

            //setup first layer
            selectedLayerID = Gui_CreateLayer();
            Gui_ClearSelectedLayer();

            //add listeners for all functions that should redraw the main canvas
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_canvasWindow.Redraw(pA); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer");

            //add listeners for all functions that should rebuild the layer list
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.RebuildLayerControls(); }, "reorder_layers", "rename_layer", "remove_layer", "create_layer");

            //add listeners for all functions that should update a layer thumbnail
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_layerControl.UpdateThumbnail(pC["layer"] as string); }, "tool_up", "undo", "clear");

            //add listeners for updating the status bar (:
            m_toolRunner.AddFunctionListener((pA, pB, pC) => { m_mainForm.SetStatus("last action: " + pB); }, "tool_down", "tool_up", "tool_move", "undo", "clear", "reorder_layers", "remove_layer", "create_layer");
        }
Example #10
0
 public PanTool(CanvasWindow pWindow)
 {
     m_window = pWindow;
 }
Example #11
0
 public ZoomTool(CanvasWindow pWindow)
 {
     m_window = pWindow;
 }
Example #12
0
 public Controller(Picture pPicture, CanvasWindow pWindow)
 {
     m_picture = pPicture;
     m_canvasWindow = pWindow;
     client = null;
 }
Example #13
0
 public ZoomTool(CanvasWindow pWindow)
 {
     m_window = pWindow;
 }
Example #14
0
 public PanTool(CanvasWindow pWindow)
 {
     m_window = pWindow;
 }
Example #15
0
 public Controller(Picture pPicture, CanvasWindow pWindow)
 {
     m_picture      = pPicture;
     m_canvasWindow = pWindow;
     client         = null;
 }