private void ButtonLookupOnClick(object sender, EventArgs e) { var ownerform = GetParentForm(Parent); if (FormLookup == null) { MessageBox.Show(ownerform, @"Form Lookup is undefined", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if ((ownerform != null || ParentForm != null) && FormLookup != null) { //FormLookup.ShowDialog((ownerform == null ? ParentForm : ownerform)); // TODO GOOD LOGIC FormLookup.ShowDialog((ownerform ?? ParentForm)); if (FormLookup.DialogResult == DialogResult.OK) { if (FormLookup.SelectedItem == null) { return; } LTextBox.Text = FormLookup.SelectedItem.Text; OnListViewItemSelectedItemHandler(new OnListViewItemSelectedItemArgs(FormLookup.SelectedItem)); } } else { FormLookup.Show(); } } }
public void CreateFormsGrid() { // Remove excessive underlines from Form and Test links. ((DataGridViewLinkColumn) MainWindow.FormsGrid.Columns[0]).LinkBehavior = LinkBehavior.NeverUnderline; ((DataGridViewLinkColumn) MainWindow.FormsGrid.Columns[1]).LinkBehavior = LinkBehavior.NeverUnderline; var skylinePath = Path.Combine(MainWindow.ExeDir, "Skyline.exe"); var skylineDailyPath = Path.Combine(MainWindow.ExeDir, "Skyline-daily.exe"); skylinePath = File.Exists(skylinePath) ? skylinePath : skylineDailyPath; var assembly = Assembly.LoadFrom(skylinePath); var types = assembly.GetTypes(); var formLookup = new FormLookup(); foreach (var type in types) { if (IsForm(type) && !HasSubclasses(types, type)) { var typeName = SkylineTesterWindow.Implements(type, "IFormView") && type.DeclaringType != null ? type.DeclaringType.Name + "." + type.Name : type.Name; var test = formLookup.GetTest(typeName); if (test == "*") continue; MainWindow.FormsGrid.Rows.Add(typeName, test, 0); } } MainWindow.FormsGrid.Sort(MainWindow.FormsGrid.Columns[0], ListSortDirection.Ascending); MainWindow.FormsGrid.ClearSelection(); MainWindow.FormsGrid.Rows[0].Selected = true; UpdateForms(); }
// Load list of tests to be run into TestList. private static List <TestInfo> LoadTestList(CommandLineArgs commandLineArgs) { List <string> testNames; var testList = new List <TestInfo>(); // Clear forms/tests cache if desired. var formArg = commandLineArgs.ArgAsString("form"); // Load lists of tests to run. if (string.IsNullOrEmpty(formArg)) { testNames = LoadList(commandLineArgs.ArgAsString("test")); } // Find which tests best cover the desired forms. else { var formLookup = new FormLookup(); List <string> uncoveredForms; testNames = formLookup.FindTests(LoadList(formArg), out uncoveredForms); if (uncoveredForms.Count > 0) { MessageBox.Show("No tests found to show these Forms: " + string.Join(", ", uncoveredForms), "Warning"); return(testList); } } // Maintain order in list of explicitly specified tests var testDict = new Dictionary <string, int>(); for (int i = 0; i < testNames.Count; i++) { if (testDict.ContainsKey(testNames[i])) { MessageBox.Show("Duplicate test name: " + testNames[i]); throw new ArgumentException("Duplicate test name: " + testNames[i]); } testDict.Add(testNames[i], i); } var testArray = new TestInfo[testNames.Count]; var skipList = LoadList(commandLineArgs.ArgAsString("skip")); // Find tests in the test dlls. foreach (var testDll in TEST_DLLS) { foreach (var testInfo in RunTests.GetTestInfos(testDll)) { var testName = testInfo.TestClassType.Name + "." + testInfo.TestMethod.Name; if (testNames.Count == 0 || testNames.Contains(testName) || testNames.Contains(testInfo.TestMethod.Name)) { if (!skipList.Contains(testName) && !skipList.Contains(testInfo.TestMethod.Name)) { if (testNames.Count == 0) { testList.Add(testInfo); } else { string lookup = testNames.Contains(testName) ? testName : testInfo.TestMethod.Name; testArray[testDict[lookup]] = testInfo; } } } } } if (testNames.Count > 0) { testList.AddRange(testArray.Where(testInfo => testInfo != null)); } // Sort tests alphabetically, but run perf tests last for best coverage in a fixed amount of time. return(testList.OrderBy(e => e.IsPerfTest).ThenBy(e => e.TestMethod.Name).ToList()); }
private void toolStripMenuItemTreeViewEdit_Click(object sender, EventArgs e) { Refresh(); Node treeListNode = treeList.SelectedNode; Type type = treeListNode.Tag.GetType(); if (type == typeof(Lookup)) { try { Interfaces.Events.SetCursor(Cursors.WaitCursor); this.Refresh(); FormLookup form = new FormLookup((Lookup)treeListNode.Tag); if (form.ShowDialog(ParentForm) == DialogResult.OK) { treeList.BeginUpdate(); treeListNode.Text = form.Lookup.Alias; treeListNode.Tag = form.Lookup; treeList.EndUpdate(); return; } } finally { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.Default); this.Refresh(); } } else if (type == typeof (Option)) { IOption option = (IOption) treeListNode.Tag; IUserOption userOption; object parentObject = treeListNode.Parent.Parent.Tag; Type parentType = parentObject.GetType(); Type scriptBaseInterface = typeof (IScriptBaseObject); if (scriptBaseInterface.IsInstanceOfType(parentObject)) { IScriptBaseObject parentScriptObject = (IScriptBaseObject) parentObject; for (int i = 0; i < parentScriptObject.Ex.Count; i++) { if (parentScriptObject.Ex[i].Name == option.VariableName) { userOption = parentScriptObject.Ex[i]; FormVirtualPropertyEdit form = new FormVirtualPropertyEdit(userOption, parentScriptObject); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); } break; } } return; } if (parentType == typeof (Column)) { Column parentColumn = (Column) parentObject; for (int i = 0; i < parentColumn.Ex.Count; i++) { if (parentColumn.Ex[i].Name == option.VariableName) { userOption = parentColumn.Ex[i]; FormVirtualPropertyEdit form = new FormVirtualPropertyEdit(userOption, parentColumn); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); parentColumn.Ex[i].Value = form.VirtualProperty.Value; treeList.SelectedNode.Cells[1].Text = form.VirtualProperty.Value.ToString(); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); } break; } } return; } } if (type == typeof (Association)) { frmAssociationWizard.Association = (Association) treeListNode.Tag; frmAssociationWizard form = new frmAssociationWizard(); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); treeListNode.Cells[1].Text = frmAssociationWizard.Association.Name; treeListNode.Tag = frmAssociationWizard.Association; SetNodeImage(treeListNode, Images.GreenBullet); foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases) { database.SnapshotMode = true; } ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases) { database.SnapshotMode = false; } Interfaces.Events.RaiseIsDirtyEvent(); Interfaces.Events.SetCursor(Cursors.Default); return; } return; } ScriptBase scriptBase = (ScriptBase) treeListNode.Tag; if (type == typeof (Table) || type == typeof (View) || type == typeof (StoredProcedure)) { FormScriptObject form = new FormScriptObject((ScriptObject) scriptBase, (ScriptObject[]) treeListNode.Parent.Tag); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.ScriptObject); foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases) { database.SnapshotMode = true; } ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); foreach (Model.Database database in ProviderInfo.TheBllDatabase.Databases) { database.SnapshotMode = false; } Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (type == typeof (Column)) { FormColumn form = new FormColumn((Column) scriptBase); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.Column); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (ModelTypes.MapColumn == type) { FormMapColumn form = new FormMapColumn((ScriptObject) treeListNode.Parent.Parent.Tag, (MapColumn) scriptBase); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.MapColumn); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (type.BaseType == typeof (Relationship)) { FormRelationship form = new FormRelationship((Relationship) scriptBase, ProviderInfo.TheBllDatabase.AllScriptObjects); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.PrimaryRelationship); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (type == typeof (Filter)) { Model.Database database = (Model.Database) treeListNode.Parent.Parent.Parent.Parent.Tag; Filter filter = (Filter) scriptBase; FormFilter2 form; // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled) if (filter.Parent.GetType() == typeof (StoredProcedure)) { form = new FormFilter2(ParentForm, filter); } else { form = new FormFilter2(ParentForm, filter); } if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.TheFilter); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (type == typeof (Index)) { FormIndex form = new FormIndex((Index) scriptBase); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.Index); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } else if (type == typeof (Key)) { FormKey form = new FormKey((Key) scriptBase); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.UnShadeMainForm(); Interfaces.Events.RaiseRefreshApplicationEvent(); Interfaces.Events.SetCursor(Cursors.WaitCursor); treeList.BeginUpdate(); UpdateTreeListNodeText(treeListNode, form.Key); ProcessTreeValidity(treeList.Nodes); treeList.EndUpdate(); Interfaces.Events.SetCursor(Cursors.Default); return; } } }
private void toolStripMenuItemTreeViewAdd_Click(object sender, EventArgs e) { Refresh(); treeList.BeginUpdate(); Node treeListNode = treeList.SelectedNode; Type type = treeListNode.Tag.GetType(); if (type == typeof (Table[]) || type == typeof (View[]) || type == typeof (StoredProcedure[])) { Model.Database parent = (Model.Database) treeListNode.Parent.Tag; FormScriptObject form = new FormScriptObject((ScriptObject[]) treeListNode.Tag, parent); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddScriptObject(form.ScriptObject); Node newTreeListNode = AddNode(treeListNode, "", form.ScriptObject, Images.GreenBullet, true, form.ScriptObject.Enabled); GetTreeListNodeText(form.ScriptObject, newTreeListNode); SetupNewTreeListNode(newTreeListNode, form.ScriptObject); if (type == typeof (Table[])) { treeListNode.Tag = parent.Tables; } if (type == typeof (View[])) { treeListNode.Tag = parent.Views; } if (type == typeof (StoredProcedure[])) { treeListNode.Tag = parent.StoredProcedures; } ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } } else if (type == typeof (Column[])) { ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag; FormColumn form = new FormColumn(parent); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddColumn(form.Column); Node newTreeListNode = AddNode(treeListNode, "", form.Column, Images.GreenBullet, true, form.Column.Enabled); GetTreeListNodeText(form.Column, newTreeListNode); treeListNode.Tag = parent.Columns; ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } } else if (type == typeof(Lookup[])) { Model.Database database = (Model.Database)treeListNode.Parent.Tag; FormLookup form = new FormLookup(database); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); Node newTreeListNode = AddLookupNode(treeListNode, form.Lookup, Images.GreenBullet); treeListNode.Tag = database.Lookups; Interfaces.Events.SetCursor(Cursors.Default); treeList.SelectNode(newTreeListNode, eTreeAction.Code); } } else if (type == typeof (OneToOneRelationship[]) || type == typeof (OneToManyRelationship[]) || type == typeof (ManyToOneRelationship[]) || type == typeof (ManyToManyRelationship[])) { ScriptObject parent = (ScriptObject) treeListNode.Parent.Parent.Tag; Type relationshipType = null; if (type == typeof (OneToOneRelationship[])) { relationshipType = typeof (OneToOneRelationship); } if (type == typeof (ManyToOneRelationship[])) { relationshipType = typeof (ManyToOneRelationship); } if (type == typeof (OneToManyRelationship[])) { relationshipType = typeof (OneToManyRelationship); } if (type == typeof (ManyToManyRelationship[])) { relationshipType = typeof (ManyToManyRelationship); } FormRelationship form = new FormRelationship(relationshipType, (ScriptObject) treeListNode.Parent.Parent.Tag, ProviderInfo.TheBllDatabase.EnabledScriptObjects); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); ScriptObject primaryScriptObject = form.PrimaryRelationship.Parent; primaryScriptObject.AddRelationship(form.PrimaryRelationship); ScriptObject foreignScriptObject = form.ForeignRelationship.Parent; foreignScriptObject.AddRelationship(form.ForeignRelationship); Node newTreeListNode = AddNode(treeListNode, "", form.PrimaryRelationship, Images.GreenBullet, true, form.PrimaryRelationship.Enabled); GetTreeListNodeText(form.PrimaryRelationship, newTreeListNode); if (type == typeof (OneToOneRelationship[])) { treeListNode.Tag = parent.OneToOneRelationships; } if (type == typeof (ManyToOneRelationship[])) { treeListNode.Tag = parent.ManyToOneRelationships; } if (type == typeof (OneToManyRelationship[])) { treeListNode.Tag = parent.OneToManyRelationships; } if (type == typeof (ManyToManyRelationship[])) { treeListNode.Tag = parent.ManyToManyRelationships; } LoadTreeListNode(foreignScriptObject); ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } if (form.FilterWasCreated) { LoadTreeView(); } } else if (type == typeof (Filter[])) { Model.Database database = (Model.Database) treeListNode.Parent.Parent.Parent.Tag; ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag; FormFilter2 form; // Stored Procedure Filters can only be created from other Stored Procedures (Enabled or Disabled) if (parent.GetType() == typeof (StoredProcedure)) { form = new FormFilter2(ParentForm, parent); } else { form = new FormFilter2(ParentForm, parent); } if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddFilter(form.TheFilter); Node newTreeListNode = AddNode(treeListNode, "", form.TheFilter, Images.GreenBullet, true, form.TheFilter.Enabled); GetTreeListNodeText(form.TheFilter, newTreeListNode); treeListNode.Tag = parent.Filters; ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } } else if (type == typeof (Index[])) { Table parent = (Table) treeListNode.Parent.Tag; FormIndex form = new FormIndex((Table) treeListNode.Parent.Tag); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddIndex(form.Index); Node newTreeListNode = AddNode(treeListNode, "", form.Index, Images.GreenBullet, true, form.Index.Enabled); GetTreeListNodeText(form.Index, newTreeListNode); treeListNode.Tag = parent.Indexes; ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } } else if (type == typeof (Key[])) { Table parent = (Table) treeListNode.Parent.Tag; FormKey form = new FormKey((Table) treeListNode.Parent.Tag); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddKey(form.Key); Node newTreeListNode = AddNode(treeListNode, "", form.Key, Images.GreenBullet, true, form.Key.Enabled); GetTreeListNodeText(form.Key, newTreeListNode); treeListNode.Tag = parent.Keys; ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); } } else if (type == typeof (List<Association>)) { ScriptObject parent = (ScriptObject) treeListNode.Parent.Tag; frmAssociationWizard.Association = new Association((ScriptObject) treeListNode.Parent.Tag); frmAssociationWizard.Association.Enabled = true; frmAssociationWizard form = new frmAssociationWizard(); if (form.ShowDialog(ParentForm) == DialogResult.OK) { Interfaces.Events.SetCursor(Cursors.WaitCursor); parent.AddAssociation(frmAssociationWizard.Association); Node newTreeListNode = AddNode(treeListNode, frmAssociationWizard.Association.Name, frmAssociationWizard.Association, Images.GreenBullet, true, frmAssociationWizard.Association.Enabled); treeListNode.Tag = parent.Associations; ProcessTreeValidity(treeList.Nodes); Interfaces.Events.SetCursor(Cursors.Default); treeListNode.Expanded = true; treeList.SelectedNode = newTreeListNode; } } treeList.EndUpdate(); }