Пример #1
0
        public override void Execute(object parameter = null)
        {
            if (parameter is Fluent.ToggleButton)
            {
                ToggleButton = (ToggleButton)parameter;
            }
            if (CommandLogger.LoggingStarted)
            {
                MessageBoxResult result = ExolutioYesNoBox.ShowYesNoCancel("Save log", "Do you wish to save recorded log file?");
                if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (result == MessageBoxResult.Yes)
                {
                    SaveFileDialog dlg = new SaveFileDialog
                    {
                        DefaultExt = ".eXoL",
                        Filter     = "eXolutio log files (*.eXoL)|*.eXoL|XML files (*.xml)|*.xml|All files (*.*)|*.*||"
                    };

                    bool?sresult = dlg.ShowDialog();
                    if (sresult == true)
                    {
                        XDocument doc = CommandLogger.SerializationDocument;
                        doc.Save(dlg.FileName);
                        CommandLogger.StopLogging();
                    }
                }
                else
                {
                    CommandLogger.StopLogging();
                }
            }
        }
Пример #2
0
 void Current_SelectionChanged()
 {
     if (bApply.IsEnabled && !applyButtonPressed)
     {
         if (ExolutioYesNoBox.Show("Changes not applied", "Apply performed changes?") == MessageBoxResult.Yes)
         {
             bApply_Click(null, null);
         }
         bApply.IsEnabled = false;
     }
     if (Current.ActiveDiagramView is PIMDiagramView)
     {
         PIMClass newSelection = Current.ActiveDiagramView.GetSingleSelectedComponentOrNull() as PIMClass;
         if (newSelection != null)
         {
             Initialize(controller, newSelection);
         }
         else
         {
             PIMAttribute a = Current.ActiveDiagramView.GetSingleSelectedComponentOrNull() as PIMAttribute;
             if (a != null)
             {
                 Initialize(controller, a.PIMClass, a);
             }
         }
     }
     else
     {
         this.Close();
     }
 }
Пример #3
0
 private void cbPSMSchema_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (bApply.IsEnabled)
     {
         if (ExolutioYesNoBox.Show("Changes not applied", "Apply performed changes?") == MessageBoxResult.Yes)
         {
             bApply_Click(null, null);
         }
     }
     bApply.IsEnabled = false;
     Initialize(controller, projectVersion, SelectedPSMSchema);
 }
Пример #4
0
        void schemaSettings_ValidationEventHandler(object sender, ValidationEventArgs e)
        {
            string location = string.Empty;

            if (e.Exception != null)
            {
                location = string.Format("\r\n\rLine number: {0} position {1}", e.Exception.LineNumber, e.Exception.LinePosition);
            }

            MessageBoxResult result = ExolutioYesNoBox.Show("Invalid document", string.Format("{0}{1}\r\n\rContinue validation?", e.Message, location));

            if (result == MessageBoxResult.No)
            {
                abortValidationAgainstSchema = true;
            }
            isValidAgainstSchema = false;
        }
Пример #5
0
        void recentFile_Click(object sender, RoutedEventArgs e)
        {
            string file = ((Control)sender).Tag.ToString();

            if (File.Exists(file))
            {
                GuiCommands.OpenProjectCommand.Execute(file, false, true);
            }
            else
            {
                if (ExolutioYesNoBox.Show("File no longer exists.", "Do you wish to remove the file from recent files list?") == MessageBoxResult.Yes)
                {
                    ConfigurationManager.Configuration.RecentFiles.RemoveAll(f => f.FullName == file);
                    FillRecent(ConfigurationManager.Configuration.RecentFiles,
                               ConfigurationManager.Configuration.RecentDirectories);
                }
            }
        }
Пример #6
0
        public override void Execute(object parameter = null)
        {
            // Save existing project before closing (if there are some unsaved changes)
            if (Current.Project != null && Current.Project.HasUnsavedChanges)
            {
                #if SILVERLIGHT
                MessageBoxResult r =
                    ExolutioYesNoBox.Show(CommandsResources.guiCloseProjectCommand_Execute_Current_project_is_not_saved, CommandsResources.guiCloseProjectCommand_Execute_Do_you_want_to_save_it_);
                #else
                MessageBoxResult r =
                    ExolutioYesNoBox.Show(CommandsResources.guiCloseProjectCommand_Execute_Current_project_is_not_saved, CommandsResources.guiCloseProjectCommand_Execute_Do_you_want_to_save_it_);
                #endif

                if (r == MessageBoxResult.Yes)
                {
                    GuiCommands.SaveProjectCommand.Execute();
                }
                else
                if (r == MessageBoxResult.Cancel)
                {
                    if (parameter is System.ComponentModel.CancelEventArgs)
                    {
                        ((System.ComponentModel.CancelEventArgs)parameter).Cancel = true;
                    }
                    return;
                }
            }
            else
            {
                if (Current.Project != null && Current.Project.ProjectFile != null && Current.Project.ProjectFile.Exists)
                {
                    #if SILVERLIGHT
                    #else
                    // save layout of project
                    Current.MainWindow.SaveProjectLayout(Current.MainWindow.UserFileForProjectFile(Current.Project.ProjectFile.FullName));
                    #endif
                }
            }

            Current.Project = null;
            Current.MainWindow.CloseProject();
            Current.MainWindow.CloseRibbonBackstage();
        }
Пример #7
0
        private void TabControl_CurrentChanging(object sender, CurrentChangingEventArgs e)
        {
            TabItem tab = (TabItem)((ICollectionView)sender).CurrentItem;

            if (e.IsCancelable && Current.Project.UsesVersioning)
            {
                if (ExolutioYesNoBox.Show("Apply changes", "Click 'Yes' to apply changes. \nClick 'No' to discard changes made in this page.") == MessageBoxResult.Yes)
                {
                    if (tab.IsAmong(tabAttributes, tabGeneral))
                    {
                        ApplyChanges();
                    }
                }
                else
                {
                    e.Cancel = true;
                    tabControl1.SelectedItem = tab;
                }
            }
        }
Пример #8
0
        void recentDirectory_Click(object sender, RoutedEventArgs e)
        {
            string directory = ((Control)sender).Tag.ToString();

            if (Directory.Exists(directory))
            {
                guiOpenProjectCommand c = new guiOpenProjectCommand();
                c.InitialDirectory = ((Control)sender).Tag.ToString();
                c.Execute(((Control)sender).Tag.ToString(), false, false);
            }
            else
            {
                if (ExolutioYesNoBox.Show("Directory no longer exists.", "Do you wish to remove the directory from recent directories list?") == MessageBoxResult.Yes)
                {
                    ConfigurationManager.Configuration.RecentDirectories.RemoveAll(d => d.FullName == directory);
                    FillRecent(ConfigurationManager.Configuration.RecentFiles,
                               ConfigurationManager.Configuration.RecentDirectories);
                }
            }
        }
Пример #9
0
        private bool ApplyAssociationChanges()
        {
            #region check for deleted associations

            foreach (PSMAssociation psmAssociation in psmClass.ChildPSMAssociations)
            {
                bool found = false;
                foreach (FakePSMAssociation fakeAssociation in fakeAssociations)
                {
                    if (fakeAssociation.SourceAssociation == psmAssociation && fakeAssociation.Checked)
                    {
                        found = true;
                        break;
                    }
                    else if (fakeAssociation.SourceAssociation == psmAssociation && !fakeAssociation.Checked)
                    {
                        fakeAssociation.SourceAssociation = null;
                    }
                }
                if (!found)
                {
                    MessageBoxResult result = ExolutioYesNoBox.Show("Cut or delete", string.Format("Click 'Yes' if you want to delete the association '{0}' with the whole subtree.\nClick 'No' if you want to delete the association and make the subtree a new tree. ", psmAssociation));
                    if (result == MessageBoxResult.No)
                    {
                        Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation deleteCommand = new Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation(controller);
                        deleteCommand.Set(psmAssociation);
                        controller.CreatedMacro.Commands.Add(deleteCommand);
                    }
                    else if (result == MessageBoxResult.Yes)
                    {
                        cmdDeletePSMAssociationRecursive deleteCommand = new cmdDeletePSMAssociationRecursive(controller);
                        deleteCommand.Set(psmAssociation);
                        controller.CreatedMacro.Commands.Add(deleteCommand);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            #endregion

            // check for changes and new associations
            var modified = from FakePSMAssociation a in fakeAssociations
                           where a.SourceAssociation != null && a.SomethingChanged()
                           select a;
            var added = from FakePSMAssociation a in fakeAssociations where a.SourceAssociation == null && a.Checked select a;

            #region editing exisiting association
            foreach (FakePSMAssociation modifiedAssociation in modified)
            {
                PSMAssociation sourceAssociation = modifiedAssociation.SourceAssociation;
                uint           lower;
                UnlimitedInt   upper;
                if (
                    !IHasCardinalityExt.ParseMultiplicityString(modifiedAssociation.Multiplicity, out lower,
                                                                out upper))
                {
                    error = true;
                    return(!error);
                }

                cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                updateCommand.Set(sourceAssociation, modifiedAssociation.Name, lower, upper);
                updateCommand.InterpretedAssociation = modifiedAssociation.RepresentedPIMAssociation;
                controller.CreatedMacro.Commands.Add(updateCommand);
            }
            #endregion

            #region new association
            foreach (FakePSMAssociation addedAssociation in added)
            {
                uint         lower = 1;
                UnlimitedInt upper = 1;
                if (!String.IsNullOrEmpty(addedAssociation.Multiplicity))
                {
                    if (!IHasCardinalityExt.ParseMultiplicityString(addedAssociation.Multiplicity, out lower, out upper))
                    {
                        error = true;
                        return(!error);
                    }
                }

                if (addedAssociation.RepresentedPIMAssociation == null)
                {
                    cmdNewPSMClass createNewPSMClass = new cmdNewPSMClass(controller);
                    createNewPSMClass.SchemaGuid = psmClass.Schema;
                    createNewPSMClass.ClassGuid  = Guid.NewGuid();
                    controller.CreatedMacro.Commands.Add(createNewPSMClass);

                    cmdNewPSMAssociation createNewPSMAssociation = new cmdNewPSMAssociation(controller);
                    addedAssociation.AddedAssociationID     = Guid.NewGuid();
                    createNewPSMAssociation.AssociationGuid = addedAssociation.AddedAssociationID;
                    createNewPSMAssociation.Set(psmClass, createNewPSMClass.ClassGuid, psmClass.Schema);
                    controller.CreatedMacro.Commands.Add(createNewPSMAssociation);

                    cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                    updateCommand.Set(createNewPSMAssociation.AssociationGuid, addedAssociation.Name, lower, upper);
                    controller.CreatedMacro.Commands.Add(updateCommand);
                }
                else
                {
                    //ExolutioMessageBox.Show("Creating new association", addedAssociation.Name, "");
                    cmdCreateNewPSMClassAsIntChild createNewPSMAssociation = new cmdCreateNewPSMClassAsIntChild(controller);
                    addedAssociation.AddedAssociationID = Guid.NewGuid();

                    if (addedAssociation.SourcePIMAssociationEnd == null)
                    {
                        foreach (PIMAssociationEnd otherEnd in addedAssociation.RepresentedPIMAssociation.PIMAssociationEnds)
                        {
                            if (otherEnd.PIMClass == psmClass.Interpretation)
                            {
                                continue;
                            }
                            addedAssociation.SourcePIMAssociationEnd = otherEnd;
                        }
                    }

                    createNewPSMAssociation.Set(psmClass, addedAssociation.SourcePIMAssociationEnd, Guid.Empty, addedAssociation.AddedAssociationID);
                    controller.CreatedMacro.Commands.Add(createNewPSMAssociation);

                    cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                    updateCommand.Set(addedAssociation.AddedAssociationID, addedAssociation.Name, lower, upper);
                    controller.CreatedMacro.Commands.Add(updateCommand);
                }
            }
            #endregion

            #region ordering

            {
                List <Guid> ordering = new List <Guid>();
                foreach (FakePSMAssociation association in fakeAssociations)
                {
                    if (association.SourceAssociation != null)
                    {
                        ordering.Add(association.SourceAssociation.ID);
                    }
                    else if (association.AddedAssociationID != Guid.Empty)
                    {
                        ordering.Add(association.AddedAssociationID);
                    }
                }

                cmdReorderComponents <PSMAssociation> reorderCommand = new cmdReorderComponents <PSMAssociation>(controller)
                {
                    ComponentGuids = ordering, OwnerCollection = psmClass.ChildPSMAssociations
                };
                controller.CreatedMacro.Commands.Add(reorderCommand);
            }

            #endregion

            return(!error);
        }
Пример #10
0
        public override void Execute(object parameter)
        {
            Updater.Updater      updater = new Updater.Updater();
            IEnumerable <string> files   = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.dll").Concat(Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.exe"));

            Dictionary <string, Version> clientVersions = new Dictionary <string, Version>();

            foreach (string file in files)
            {
                Version clientVersion = AssemblyName.GetAssemblyName(file).Version;
                clientVersions[Path.GetFileName(file)] = clientVersion;
            }

            Dictionary <string, Version> newAvailableVersions;

            if (updater.AreNewVersionsAvailable(clientVersions, out newAvailableVersions) && ExolutioYesNoBox.ShowYesNoCancel("New version available", "New version is available. \r\nDo you wish to update?") == MessageBoxResult.Yes)
            {
                System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo("Exolutio.Updater.exe");
                info.UseShellExecute = true;
                (Current.MainWindow).Close();
                System.Diagnostics.Process.Start(info);
            }
            else
            {
                ExolutioMessageBox.Show("Exolutio Update", "Updates checked", "This is the latest version.");
            }
        }