private void ShowEditorMenu(object sender, MouseButtonEventArgs e) { //Scan for menu from its siblings first. _editorMenu = RetrieveSiblingsEditorMenu(Target); #region If we seriously don't have a menu yet, then create one if (_editorMenu == null) { //if target is forloop && source is forloop //else if source is forloop //else if target is forloop //else standard... switch ((Target.DataContext as ActivityModel).ActivityClassification) { //nested switch make it a method to loop thru... case ActivityModel.ActivityType.ForLoop : { ForLoopComponent forLoop = Target as ForLoopComponent; IActivityComponent[] components = forLoop.GetNestedActivity.ToArray(); _editorMenu = new ActivityEditor(Target.GetInputs, forLoop, components); break; } case ActivityModel.ActivityType.Standard: { if (Source is ForLoopComponent) { _editorMenu = new ActivityEditor (Target.GetInputs, (Source as ForLoopComponent).GetNestedActivity.ToArray(), Target); break; } //Else Move to the standard if (Target.InputConn.Count > 1) { _editorMenu = new ActivityEditor (Target.GetInputs, Target); } else _editorMenu = new ActivityEditor(Source, Target); _editorMenu.ValidationFail += new ActivityEditor.ValidationFailEventHandler(_editorMenu_ValidationFail); break; } } } #endregion If we do not have a menu yet, create one #region Else just add the new item into the retrieved menu _editorMenu.UpdateSources(Target.GetInputs); #endregion this.UpdateSiblingsEditorMenu(_editorMenu); _editorMenu.Show(); }
private void UpdateSiblingsEditorMenu(ActivityEditor menu) { foreach (ActivityConnection conn in Target.InputConn) conn.SetEditorMenu = menu; }