/// <summary> /// Called by double clicking on a plugin symbol of CrypTool /// Adds a new PluginModel wrapping an instance of the selected plugin /// </summary> /// <param name="type"></param> public void Add(Type type) { if (!executing) { PluginModel pluginModel = (PluginModel)WorkspaceSpaceEditorView.Model.ModifyModel(new NewPluginModelOperation(new Point(0, 0), 0, 0, type)); WorkspaceSpaceEditorView.AddComponentVisual(pluginModel, 1); } }
void UsageStatisticPopup_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (TopUsages.SelectedItem != null) { try { var x = (SuggestionContainer)TopUsages.SelectedItem; PluginModel pluginModel = (PluginModel)_editor.Model.ModifyModel(new NewPluginModelOperation(position, 0, 0, x.ComponentType)); _editor.AddComponentVisual(pluginModel); ConnectorVisual connector = null; foreach (var con in pluginModel.GetInputConnectors()) { if (con.GetName() == x.ConnectorName) { connector = (ConnectorVisual)con.UpdateableView; } } foreach (var con in pluginModel.GetOutputConnectors()) { if (con.GetName() == x.ConnectorName) { connector = (ConnectorVisual)con.UpdateableView; } } if (connector == null) { throw new Exception(); } var input = SelectedConnector.Model.Outgoing == true ? connector : SelectedConnector; var output = SelectedConnector.Model.Outgoing == false ? connector : SelectedConnector; ConnectionModel connectionModel = (ConnectionModel)_editor.Model.ModifyModel(new NewConnectionModelOperation( output.Model, input.Model, output.Model.ConnectorType)); _editor.AddConnectionVisual(output, input, connectionModel); position.X += 50; position.Y += 50; } catch (Exception) { return; } Close(); } //e.Handled = true; }