public void ShowFoldChangeForm <T>() where T : FoldChangeForm, new() { IEnumerable <FoldChangeForm> forms; if (null != DockPanel) { forms = DockPanel.Contents.OfType <FoldChangeForm>(); } else { forms = FormUtil.OpenForms.OfType <FoldChangeForm>(); } FoldChangeForm otherOpenForm = null; foreach (var form in forms) { if (form is T) { if (SameBindingSource(form)) { form.Activate(); return; } } else if (otherOpenForm == null && !(form is FoldChangeGrid) && SameBindingSource(form)) { otherOpenForm = form; } } var graph = new T(); graph.SetBindingSource(FoldChangeBindingSource); var otherDockPane = FindPane(otherOpenForm); if (otherOpenForm != null && otherDockPane != null) { graph.Show(otherDockPane, null); } else if (Pane != null && this is FoldChangeGrid) { graph.Show(Pane, DockPaneAlignment.Right, 0.5); } else { graph.Show(Owner); } }
public bool SameBindingSource(FoldChangeForm foldChangeForm) { if (null != FoldChangeBindingSource && null != foldChangeForm.FoldChangeBindingSource) { return(ReferenceEquals(FoldChangeBindingSource, foldChangeForm.FoldChangeBindingSource)); } if (!ReferenceEquals(_documentContainer, foldChangeForm._documentContainer)) { return(false); } if (string.IsNullOrEmpty(_groupComparisonName)) { return(false); } return(_groupComparisonName == foldChangeForm._groupComparisonName); }