Example #1
0
        private void CreateNewSPESProject_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                //Zum Starten der Modellierung werden die folgenden Methoden aufgerufen.
                FolderBrowserDialog folder = new FolderBrowserDialog();
                folder.Description = "Please select an empty folder.";
                folder.ShowDialog();

                //check if folder is empty
                if (new System.IO.DirectoryInfo(folder.SelectedPath).GetFiles().Any())
                {
                    throw new Exception("Selected folder is not empty.");
                }

                //Ruft Dialogbox auf, in der der Benutzer den Namen das Systems angibt
                string systemname = Microsoft.VisualBasic.Interaction.InputBox("Type in the name of the system", "Get System name", "System_Name");

                //pressing abort returns empty string
                if (String.IsNullOrWhiteSpace(systemname))
                {
                    return;
                }

                documentReferencer = new SPES_DocumentReferencer();

                string path = folder.SelectedPath;
                //pressing abort returns empty string
                if (String.IsNullOrWhiteSpace(path))
                {
                    return;
                }

                this.application.ActiveDocument.SaveAs(System.IO.Path.Combine(path, systemname + "_Overview.vsdx"));
                this.spesapp.CreateRectangle(systemname);
                this.spesapp.CreateSystem(documentReferencer);
                this.spesapp.SetHyperlink();

                //create config file
                documentReferencer.SaveConfigToFile(documentReferencerFile);

                //this._spesapp.deleteModels();
            }
            //Fange mögliche Fehler ab und informiere Benutzer, dass die Generierung unvollständig ist
            catch (Exception exc)
            {
                if (exc.InnerException != null)
                {
                    System.Windows.Forms.MessageBox.Show("Not all elements could created through Modeling: " + exc.InnerException.Message);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Not all elements could created through Modeling: " + exc.Message);
                }
            }
        }
Example #2
0
        private async void Application_DocumentLoadedOrCreated(IVDocument pDoc)
        {
            await startupTask;

            if (!initialized)
            {
                //set ribbon behaviour
                if (IsSPESproject)
                {
                    //set document referencer
                    documentReferencer = new SPES_DocumentReferencer();
                    documentReferencer.LoadConfigFromFile(documentReferencerFile);

                    //set SPES specifics
                    this.ModelTargetDropDown.Enabled  = false;
                    this.CreateNewSPESProject.Visible = false;

                    //load module based on definition
                    var type = documentReferencer.GetTypeFromFile(application.ActiveDocument.Name);
                    if (type != null)
                    {
                        ModelTargetDropDown.SelectedItem = ModelTargetDropDown.Items.First(k => k.Label == modelverifiers.First(t => t.ToString() == type.ToString()).ModelName);
                    }
                    else
                    {
                        ModelTargetDropDown.SelectedItem = ModelTargetDropDown.Items.Where(t => t.Label == "none").First();
                    }
                }
                else
                {
                    //set normal behaviour
                    this.ModelTargetDropDown.Enabled  = true;
                    this.CreateNewSPESProject.Visible = true;
                }

                ModelTargetDropDown_SelectionChanged(null, null);
                initialized = true;
            }
        }