/// <summary> /// Event to save new workspace /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveWorkspace_Click(object sender, EventArgs e) { var childCount = MdiChildren.Count(); if (childCount < 1) { MessageBox.Show(this, "Please add element to your workspace", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var frm = new frmPopup(); frm.ShowDialog(); if (frm.WorkspaceName != null && frm.WorkspaceName.Trim() != string.Empty) { if (SQLiteDBOperation.DuplicateWorkspace(frm.WorkspaceName.Trim().ToLower())) { //Add new workspace int workSpaceid = SQLiteDBOperation.AddWorkspace(frm.WorkspaceName); //Add forms for the respective workspace AddWorkspaceForm(workSpaceid); //uncheck all menu items //foreach (ToolStripMenuItem item in workspaceToolStripMenuItem.DropDownItems) //{ // item.Checked = false; //} foreach (var item in workspaceToolStripMenuItem.DropDownItems) { try { // Seperator is throwing exception ToolStripMenuItem stripmenu = item as ToolStripMenuItem; stripmenu.Checked = false; } catch { continue; } } //Add new menu strip and mark it as active/checked ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Name = workSpaceid.ToString(); menuItem.Text = frm.WorkspaceName; menuItem.Checked = true; menuItem.Click += MenuItem_Click; workspaceToolStripMenuItem.DropDownItems.Add(menuItem); currentWorkspaceId = workSpaceid; } else { MessageBox.Show(this, "Workspace already exist.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void workspaceToolStripMenuItem1_Click(object sender, EventArgs e) { var form = new frmPopup(); form.ShowDialog(); if (form.WorkspaceName != null && form.WorkspaceName.Trim() != string.Empty) { if (SQLiteDBOperation.DuplicateWorkspace(form.WorkspaceName.Trim().ToLower())) { currentWorkspaceId = 0; foreach (Form childForm in MdiChildren) { childForm.Close(); } int workSpaceid = SQLiteDBOperation.AddWorkspace(form.WorkspaceName); //uncheck all menu items foreach (var item in workspaceToolStripMenuItem.DropDownItems) { try { // Seperator is throwing exception ToolStripMenuItem stripmenu = item as ToolStripMenuItem; stripmenu.Checked = false; } catch { continue; } } //Add new menu strip and mark it as active/checked ToolStripMenuItem menuItem = new ToolStripMenuItem(); menuItem.Name = workSpaceid.ToString(); menuItem.Text = form.WorkspaceName; menuItem.Checked = true; menuItem.Click += MenuItem_Click; workspaceToolStripMenuItem.DropDownItems.Add(menuItem); currentWorkspaceId = workSpaceid; lblShowActiveWorkspace.Text = form.WorkspaceName; } else { MessageBox.Show(this, "Workspace already exist.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void marketWatchToolStripMenuItem_Click(object sender, EventArgs e) { var frm = new frmPopup(); frm.ShowDialog(); if (string.IsNullOrEmpty(frm.WorkspaceName)) { return; } else { this.Invoke((Action) delegate() { var name = Guid.NewGuid().ToString(); frmMarketWatchWin watch = new frmMarketWatchWin(); watch.MdiParent = this; watch.Name = name; watch.Text = frm.WorkspaceName; AddContextMenuTabControlItem(name, watch); watch.Show(); }); } }