void ResetCanvas() { if (m_canvasWindow.InvokeRequired) { m_canvasWindow.Invoke(new Action(ResetCanvas)); } else { m_canvasWindow.GetPicture().ClearAll(); selectedLayerID = Gui_CreateLayer(); // Gui_ClearSelectedLayer(); } }
//------------------------------------------------------------------------- // 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); }
//--------------------------------------------------------------------- // 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"); }
//------------------------------------------------------------------------- // 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"); }
internal Picture GetPicture() { return(m_canvasWindow.GetPicture()); }