private void ProjectData_OnRestServerRemoved(object sender, OnRestServerRemovedEventArgs e) { MockServiceTabPage thisTabPage = tabControlMain.TabPages.Cast <MockServiceTabPage>().Where(c => c.MockRestServerUserControl.RestServerData == e.RestServer).FirstOrDefault(); if (thisTabPage != null) { tabControlMain.TabPages.Remove(thisTabPage); } }
private void RestServerManager_OnRestServerStarted(object sender, OnRestServerStartedEventArgs e) { if (treeViewServices.SelectedNode != null && treeViewServices.SelectedNode.Tag is MockServiceTabPage) { MockServiceTabPage thisTabPage = treeViewServices.SelectedNode.Tag as MockServiceTabPage; if (thisTabPage.MockRestServerUserControl.RestServerData == e.RestServer) { toolStripButtonRemoveServer.Enabled = false; } } }
private void ProjectData_OnRestServerAdded(object sender, OnRestServerAddedEventArgs e) { TreeNode newMockServiceTreeNode = new TreeNode(e.RestServer.Name); MockServiceTabPage newMockServiceTabPage = new MockServiceTabPage(e.RestServer); newMockServiceTreeNode.Tag = newMockServiceTabPage; m_RootProjectNode.Nodes.Add(newMockServiceTreeNode); newMockServiceTabPage.Tag = newMockServiceTreeNode; tabControlMain.TabPages.Add(newMockServiceTabPage); }
private void treeViewServices_MouseDoubleClick(object sender, MouseEventArgs e) { TreeViewHitTestInfo hitTest = treeViewServices.HitTest(e.Location); if (hitTest.Node != null && hitTest.Node.Tag is MockServiceTabPage) { MockServiceTabPage tabPage = hitTest.Node.Tag as MockServiceTabPage; if (!tabControlMain.TabPages.Contains(tabPage)) { tabControlMain.TabPages.Add(tabPage); } } }
private void toolStripButtonRemoveServer_Click(object sender, EventArgs e) { if (treeViewServices.SelectedNode != null) { if (treeViewServices.SelectedNode.Tag is MockServiceTabPage) { MockServiceTabPage thisTabPage = treeViewServices.SelectedNode.Tag as MockServiceTabPage; if (thisTabPage != null && MessageBox.Show($"Do you want to remove rest server {thisTabPage.MockRestServerUserControl.RestServerData.Name}?", "Remove Rest Server", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ProjectData.RemoveRestServer(thisTabPage.MockRestServerUserControl.RestServerData); treeViewServices.SelectedNode.Remove(); } } } }
private void treeViewServices_AfterSelect(object sender, TreeViewEventArgs e) { if (treeViewServices.SelectedNode != null) { if (treeViewServices.SelectedNode.Tag is MockServiceTabPage) { MockServiceTabPage thisTabPage = treeViewServices.SelectedNode.Tag as MockServiceTabPage; if (!thisTabPage.MockRestServerUserControl.RestServerRunning) { toolStripButtonRemoveServer.Enabled = true; } } else { toolStripButtonRemoveServer.Enabled = false; } } else { toolStripButtonRemoveServer.Enabled = false; } }