public MDICanvas() { InitializeComponent(); var zBitmap = new Bitmap(32, 32); Graphics zGraphics = Graphics.FromImage(zBitmap); Brush zBlack = new SolidBrush(Color.LightGray); Brush zWhite = new SolidBrush(Color.White); zGraphics.FillRectangle(zBlack, 0, 0, 16, 16); zGraphics.FillRectangle(zWhite, 16, 0, 16, 16); zGraphics.FillRectangle(zBlack, 16, 16, 16, 16); zGraphics.FillRectangle(zWhite, 0, 16, 16, 16); panelCardCanvas.BackgroundImage = zBitmap; CardMakerInstance.CanvasUserAction = false; UpdateText(); // m_zCardCanvas is a panel within the panelCardCanvas m_zCardCanvas = new CardCanvas { Location = new Point(0, 0), }; m_zCardCanvas.MouseMove += cardCanvas_MouseMove; m_zCardCanvas.MouseDown += cardCanvas_MouseDown; m_zCardCanvas.MouseUp += cardCanvas_MouseUp; m_zCardCanvas.ContextMenuStrip = m_zContextMenu; m_zContextMenu.RenderMode = ToolStripRenderMode.System; m_zContextMenu.Opening += contextmenuOpening_Handler; panelCardCanvas.Controls.Add(m_zCardCanvas); LayoutManager.Instance.LayoutUpdated += Layout_Updated; LayoutManager.Instance.LayoutLoaded += Layout_Loaded; LayoutManager.Instance.LayoutRenderUpdated += LayoutRender_Updated; LayoutManager.Instance.DeckIndexChanged += DeckIndex_Changed; ElementManager.Instance.ElementSelected += Element_Selected; ProjectManager.Instance.ProjectOpened += Project_Opened; }
private void CardMakerMDI_Load(object sender, EventArgs e) { // always before any dialogs ShapeManager.Init(); // Setup all the child dialogs SetupMDIForm(MDICanvas.Instance, true); SetupMDIForm(MDIElementControl.Instance, true); SetupMDIForm(MDILayoutControl.Instance, true); SetupMDIForm(MDILogger.Instance, true); SetupMDIForm(MDIProject.Instance, true); SetupMDIForm(MDIIssues.Instance, false); SetupMDIForm(MDIDefines.Instance, false); // populate the windows menu foreach (var zChild in MdiChildren) { string sText = string.Empty; switch (zChild.Name) { case "MDICanvas": sText = "&Canvas"; break; case "MDIElementControl": sText = "&Element Control"; break; case "MDILayoutControl": sText = "&Layout Control"; break; case "MDILogger": sText = "L&ogger"; break; case "MDIProject": sText = "&Project"; break; case "MDIIssues": sText = "&Issues"; break; case "MDIDefines": sText = "&Defines"; break; } ToolStripItem zItem = new ToolStripMenuItem(sText); zItem.Tag = zChild; windowToolStripMenuItem.DropDownItems.Add(zItem); zItem.Click += (zSender, eArgs) => { var zForm = (Form)((ToolStripMenuItem)zSender).Tag; var pointLocation = zForm.Location; zForm.Show(); zForm.BringToFront(); zForm.Location = pointLocation; }; } // create the main drawing canvas m_zDrawCardCanvas = MDICanvas.Instance.CardCanvas; // make a new project by default newToolStripMenuItem_Click(sender, e); var sData = m_zIniManager.GetValue(Name); var bRestoredFormState = false; if (!string.IsNullOrEmpty(sData)) { IniManager.RestoreState(this, sData); bRestoredFormState = true; } foreach (var zForm in MdiChildren) { sData = m_zIniManager.GetValue(zForm.Name); if (!string.IsNullOrEmpty(sData)) { IniManager.RestoreState(zForm, sData); } } if (!bRestoredFormState) { Logger.AddLogLine("Restored default form layout."); #if MONO_BUILD MDICanvas.Instance.Size = new Size(457, 300); MDICanvas.Instance.Location = new Point(209, 5); MDIElementControl.Instance.Size = new Size(768, 379); MDIElementControl.Instance.Location = new Point(3, 310); MDILayoutControl.Instance.Size = new Size(300, 352); MDILayoutControl.Instance.Location = new Point(805, 4); MDIProject.Instance.Size = new Size(200, 266); MDIProject.Instance.Location = new Point(6, 10); MDILogger.Instance.Size = new Size(403, 117); MDILogger.Instance.Location = new Point(789, 571); #else MDICanvas.Instance.Size = new Size(457, 300); MDICanvas.Instance.Location = new Point(209, 5); MDIElementControl.Instance.Size = new Size(579, 290); MDIElementControl.Instance.Location = new Point(3, 310); MDILayoutControl.Instance.Size = new Size(300, 352); MDILayoutControl.Instance.Location = new Point(670, 4); MDIProject.Instance.Size = new Size(200, 266); MDIProject.Instance.Location = new Point(6, 10); MDILogger.Instance.Size = new Size(403, 117); MDILogger.Instance.Location = new Point(667, 531); #endif } var arrayFiles = m_zIniManager.GetValue(IniSettings.PreviousProjects).Split(new char[] { CHAR_FILE_SPLIT }, StringSplitOptions.RemoveEmptyEntries); if (0 < arrayFiles.Length) { foreach (var sFile in arrayFiles) { m_listRecentFiles.Add(sFile); } } LayoutTemplateManager.Instance.LoadLayoutTemplates(StartupPath); RestoreReplacementChars(); var zGraphics = CreateGraphics(); try { m_nApplicationDPI = zGraphics.DpiX; } finally { zGraphics.Dispose(); } // load the specified project from the command line if (!string.IsNullOrEmpty(Program.CommandLineProjectFile)) InitOpen(Program.CommandLineProjectFile); }