private void AddEndpoint(EndpointData data) { ListViewItem newMockEndpointItem = new ListViewItem(data.Name); MockEndpointTabPage newMockEndpointTabPage = new MockEndpointTabPage(data); newMockEndpointItem.Tag = data; lvEndpoints.Items.Add(newMockEndpointItem); newMockEndpointItem.Text = $"{data.Name}({data.HttpEndpointAddress} )"; newMockEndpointItem.Text = $"{data.Name}({data.HttpEndpointAddress})"; newMockEndpointTabPage.Tag = newMockEndpointItem; tabControlEndpoints.TabPages.Add(newMockEndpointTabPage); }
private void ShowEndpointTab(ListViewItem item, EndpointData data, bool openTab) { MockEndpointTabPage thisTagPage = tabControlEndpoints.TabPages.Cast <MockEndpointTabPage>().Where(c => c.EndpointData == data).FirstOrDefault(); if (!m_RestServerData.Endpoints.Contains(data)) { m_RestServerData.AddEndpoint(data); } else if (thisTagPage != null) { tabControlEndpoints.SelectedTab = thisTagPage; } else if (openTab) { MockEndpointTabPage newMockEndpointTabPage = new MockEndpointTabPage(data); item.Tag = data; newMockEndpointTabPage.Tag = item; tabControlEndpoints.TabPages.Add(newMockEndpointTabPage); tabControlEndpoints.SelectedTab = newMockEndpointTabPage; } }
private void SetRestServerEnables(bool enable) { rbHttp.Enabled = enable; rbHttps.Enabled = enable; txtPort.Enabled = enable; txtBaseAddress.Enabled = enable; checkBoxAuth.Enabled = enable; txtAuthUser.Enabled = enable; txtAuthPassword.Enabled = enable; toolStripButtonAddEndpoint.Enabled = enable; toolStripButtonRemoveEndpoint.Enabled = enable; toolStripButtonStart.Enabled = enable; toolStripButtonStop.Enabled = !enable; toolStripProgressBar.Visible = !enable; foreach (TabPage tabPage in tabControlEndpoints.TabPages) { if (tabPage is MockEndpointTabPage) { MockEndpointTabPage mockEndpointTabPage = tabPage as MockEndpointTabPage; mockEndpointTabPage.MockEndpointUserControl.SetRestServerEnables(enable); } } }
private void RestServerData_OnEndpointRemoved(object sender, OnEndpointRemovedEventArgs e) { MockEndpointTabPage thisTabPage = tabControlEndpoints.TabPages.Cast <MockEndpointTabPage>().Where(c => c.MockEndpointUserControl.EndpointData == e.Endpoint).FirstOrDefault(); tabControlEndpoints.TabPages.Remove(thisTabPage); }