public override void Execute() { //var events = CurrentElement.Parent.Parent.Parent.Parent.Service.SelectMany(s => s.Contract.Events.Event); var usecases = this.CurrentElement.Root.As <IApplication>().Design.UseCases.UseCase; var picker = new ElementPicker() as IElementPicker; if (picker != null) { (picker as ElementPicker).SetDropdownEditable(false); (picker as ElementPicker).Owner = System.Windows.Application.Current.MainWindow; (picker as ElementPicker).WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; } picker.Elements = usecases .Where(uc => !uc.UseCaseLinks.Any(l => l.LinkedElementId == this.CurrentElement.Id)) .Select(uc => uc.InstanceName).ToList(); using (new MouseCursor(Cursors.Arrow)) { if (picker.ShowDialog().Value) { var selectedElement = picker.SelectedItem; usecases.FirstOrDefault(uc => uc.InstanceName == selectedElement).AddRelatedElement(this.CurrentElement); } } }
/// <inheritdoc /> public IActionContext InterceptAction(IActionContext ctxt) { if (ctxt.Action is ElementPicker.ElementPickerAction == false || ctxt.Model is IElementPickerCallback == false) { return(null); } var m = (IElementPickerCallback)ctxt.Model; var elemPicker = new ElementPicker(); if (elemPicker.ShowDialog() ?? false) { m.SetElement(elemPicker.SelectedElement); return(ctxt); } return(null); }