Exemplo n.º 1
0
        /// <summary>
        /// Deleting a component, will be called from all delete component points
        /// </summary>
        /// <param name="deleteComponent">The component to be deleted</param>
        //private void DeleteComponentFromMenu(modelComponent deleteComponent) {
        //    CommandObject co;
        //    // delete the eventChannels and therefore the events
        //    eventChannelLine eCL;
        //    for (int index = eventChannelLinesList.Count - 1; index >= 0; index--) {
        //        eCL = (eventChannelLine)eventChannelLinesList[index];
        //        if ((eCL.TriggerComponentId == deleteComponent.id) || (eCL.ListernerComponentId == deleteComponent.id)) {
        //            focusedEventChannel = eCL;
        //            // Ask a question, if component and therefore all events should be deleted. Causes some problems, if no is selected
        //            // if (MessageBox.Show(Properties.Resources.DeleteEventChannelConfirmTextFormat(focusedEventChannel.TriggerComponentId, focusedEventChannel.ListernerComponentId),
        //            //    Properties.Resources.DeleteEventChannelConfirmHeader, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) {
        //                co = new CommandObject("Add", focusedEventChannel);
        //                foreach (eventChannel eventCh in eventChannelList) {
        //                    foreach (object o in co.InvolvedObjects) {
        //                        if (!(o is eventChannelLine))
        //                            continue;
        //                        if ((eventCh.sources.source.component.id == ((eventChannelLine)o).TriggerComponentId) &&
        //                            (eventCh.targets.target.component.id == ((eventChannelLine)o).ListernerComponentId)) {
        //                            co.Parameter.Add(eventCh);
        //                        }
        //                    }
        //                }
        //                undoStack.Push(co);
        //                DeleteEventChannelCommand(focusedEventChannel);
        //                focusedEventChannel = null;
        //            //}
        //        }
        //    }
        //    focusedEventChannel = null;
        //    foreach (Object o in deleteComponent.ports.PortsList.Values) {
        //        if (o is inputPortType) {
        //            inputPortType pIn = (inputPortType)o;
        //            if (pIn.ChannelId != "") {
        //                channel tempChannel = deploymentChannelList[pIn.ChannelId];
        //                DeleteChannel(tempChannel);
        //                co = new CommandObject("Add", tempChannel);
        //                undoStack.Push(co);
        //            }
        //        } else if (o is outputPortType) {
        //            outputPortType pOut = (outputPortType)o;
        //            while (pOut.ChannelIds.Count > 0) {
        //                channel tempChannel = deploymentChannelList[pOut.ChannelIds[0].ToString()];
        //                DeleteChannel(tempChannel);
        //                co = new CommandObject("Add", tempChannel);
        //                undoStack.Push(co);
        //            }
        //        }
        //    }
        //    if (canvas.Children.Count > 0) {
        //        Keyboard.Focus(canvas.Children[0]);
        //    } else {
        //        Keyboard.Focus(canvas);
        //    }
        //    DeleteComponent(deleteComponent);
        //    co = new CommandObject("Add", deleteComponent);
        //    undoStack.Push(co);
        //    ResetPropertyDock();
        //}
        /// <summary>
        /// Opens a dialog box asking for a new component id. Returning the new id
        /// </summary>
        /// <param name="suggestID">Id, suggested by the system</param>
        /// <returns>Id, returned from user input</returns>
        private String SetNameForComponentOnCanvas(String suggestID)
        {
            // opening dialog box for the name of the component
            string nameErrorStr = "";
            NameDialog nameDiag;
            // the dialog appears as long as
            // 1. the name is empty
            // 2. the name is already been used
            do {
                nameDiag = new NameDialog();
                nameDiag.Owner = this;
                nameDiag.componentNameBox.Text = suggestID;
                if (nameErrorStr != "") {
                    nameDiag.errorField.Text = nameErrorStr;
                }
                nameDiag.ShowDialog();
                if (nameDiag.componentNameBox.Text.Length == 0) {
                    nameErrorStr = Properties.Resources.NameDialogTextEmpty;
                }
                else if (deploymentComponentList.ContainsKey(nameDiag.componentNameBox.Text)) {
                    nameErrorStr = Properties.Resources.NameDialogTextUsed;
                }
                else {
                    nameErrorStr = "";
                }
                if (nameDiag.DialogResult == false) {
                    nameErrorStr = "";
                }
            } while (nameErrorStr != "");

            if (nameDiag.DialogResult == true) {
                showNamingDialogOnComponentInsert = (bool)nameDiag.showCheckbox.IsChecked;
                if (showNamingDialogOnComponentInsert) {
                    ini.IniWriteValue("Options", "showNamingDialogOnComponentInsert", "true");
                }
                else {
                    ini.IniWriteValue("Options", "showNamingDialogOnComponentInsert", "false");
                }
                return nameDiag.componentNameBox.Text;
            }
            else {
                return "";
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Name dialog to edit the name of the model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditModelNameRibbonButton_Click(object sender, RoutedEventArgs e)
        {
            NameDialog nd = new NameDialog();
            nd.showCheckbox.Visibility = Visibility.Collapsed;
            nd.Title = Properties.Resources.EditModelNameWindow;
            nd.nameFieldLabel.Content = Properties.Resources.EditModelNameLabel;
            nd.Owner = this;
            nd.componentNameBox.Text = deploymentModel.modelName;
            nd.ShowDialog();

            if (nd.DialogResult == true) {
                deploymentModel.modelName = nd.componentNameBox.Text;
                modelHasBeenEdited = true;
            }
        }