private void SetCurrentCanvasSession(CanvasSession pCanvasSession) { m_currentCanvasSession = pCanvasSession; if (m_currentCanvasSession == null) { toolPanelTop.Visible = false; panel1.Visible = false; panel1.Enabled = false; saveAsToolStripMenuItem.Enabled = false; saveToolStripMenuItem.Enabled = false; editToolStripMenuItem.Enabled = false; viewToolStripMenuItem.Enabled = false; windowToolStripMenuItem.Enabled = false; } else { // 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; panel1.Visible = true; panel1.Enabled = true; saveAsToolStripMenuItem.Enabled = true; saveToolStripMenuItem.Enabled = true; editToolStripMenuItem.Enabled = true; viewToolStripMenuItem.Enabled = true; windowToolStripMenuItem.Enabled = true; // Set the picture as the focus of the side bar layerControlForm.SetCanvasSession(m_currentCanvasSession); } }
//--------------------------------------------------------------------- // 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); } }
public void SetCanvasSession(CanvasSession pSession) { m_canvasSession = pSession; RebuildLayerControls(); }
private void SetCurrentCanvasSession(CanvasSession pCanvasSession) { m_currentCanvasSession = pCanvasSession; m_currentCanvasSession.OnFocus(); }
//--------------------------------------------------------------------- // 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); } }