Exemplo n.º 1
0
        /// <summary>
        /// Creates a new schema: Clean the canvas (with CleanACS()) and reset the deployment
        /// model in the background. Open save dialog, if requested
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewSchema_Click(object sender, RoutedEventArgs e)
        {
            if (modelHasBeenEdited) {
                SaveQuestionDialog saveQuestion = new SaveQuestionDialog();
                saveQuestion.Owner = this;
                saveQuestion.ShowDialog();

                // Process message box results
                switch (saveQuestion.Result) {
                    case SaveQuestionDialog.save:
                        if (SaveLocalCommand(false) == true) {
                            CleanACS();
                            modelHasBeenEdited = false;
                        }
                        break;
                    case SaveQuestionDialog.dontSave:
                        CleanACS();
                        modelHasBeenEdited = false;
                        break;
                    case SaveQuestionDialog.cancel:
                        break;
                }
            }
            else {
                CleanACS();
            }
            SetSaveFile(null);
            deploymentModel.modelName = GenerateModelName();

            if (areStatus.Status == AREStatus.ConnectionStatus.Synchronised) {
                areStatus.Status = AREStatus.ConnectionStatus.Connected;
            }
            else if ((areStatus.Status == AREStatus.ConnectionStatus.Running) || (areStatus.Status == AREStatus.ConnectionStatus.Pause)) {
                areStatus.Status = AREStatus.ConnectionStatus.Synchronised;
                areStatus.Status = AREStatus.ConnectionStatus.Connected;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Close Application. Before layout settings will be saved and the user
        /// will be asked to save the data model
        /// </summary>
        /// <param name="eventObject">Object of type CancelEventArgs or RoutedEventArgs</param>
        private void CloseCommand(object eventObject)
        {
            if (dockableComponentProperties.ContainerPane.Items.Count > 0) {
                dockableComponentProperties.ContainerPane.SelectedItem = dockableComponentProperties.ContainerPane.Items[0];
            }
            if (ini.IniReadValue("Options", "useAppDataFolder").Equals("true")) {
                dockManager.SaveLayout(Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\AsTeRICS\\ACS\\" + ini.IniReadValue("Layout", "layout_file"));
            } else {
                if (File.Exists(ini.IniReadValue("Layout", "layout_file"))) {
                    dockManager.SaveLayout(ini.IniReadValue("Layout", "layout_file"));
                } else {
                    dockManager.SaveLayout(AppDomain.CurrentDomain.BaseDirectory + ini.IniReadValue("Layout", "layout_file"));
                }
            }

            if (modelHasBeenEdited) {
                SaveQuestionDialog saveQuestion = new SaveQuestionDialog();
                saveQuestion.Owner = this;
                saveQuestion.ShowDialog();

                // Process message box results
                switch (saveQuestion.Result) {
                    case SaveQuestionDialog.save:
                        bool shouldSaveAs = false;
                        if (saveFile == null) shouldSaveAs = true;
                        if (SaveLocalCommand(shouldSaveAs) == true) {
                            StopStatusPolling();
                            if (!(eventObject is CancelEventArgs)) {
                                Application.Current.Shutdown();
                            }
                        }
                        else {
                            if (eventObject is CancelEventArgs) {
                                ((CancelEventArgs)eventObject).Cancel = true;
                            }
                        }
                        break;
                    case SaveQuestionDialog.dontSave:
                        StopStatusPolling();
                        if (!(eventObject is CancelEventArgs)) {
                            Application.Current.Shutdown();
                        }
                        break;
                    case SaveQuestionDialog.cancel:
                        if (eventObject is CancelEventArgs) {
                            ((CancelEventArgs)eventObject).Cancel = true;
                        }
                        break;
                }
            }
            else {
                StopStatusPolling();
                if (!(eventObject is CancelEventArgs)) {
                    Application.Current.Shutdown();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Download and install the bundle from the ARE
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DownloadBundles_Click(object sender, RoutedEventArgs e)
        {
            Boolean doOverride = true;
            if (showOverrideComponentCollectionQuestion) {
                CustomMessageBox messageBox = new CustomMessageBox(Properties.Resources.BundleDownloadFromAREQuestion, Properties.Resources.BundleDownloadFromAREQuestionHeader, CustomMessageBox.messageType.Question, CustomMessageBox.resultType.YesNo);
                messageBox.Owner = this;
                messageBox.showCheckbox.IsChecked = showOverrideComponentCollectionQuestion;
                messageBox.ShowDialog();

                showOverrideComponentCollectionQuestion = (bool)messageBox.showCheckbox.IsChecked;
                if (showOverrideComponentCollectionQuestion) {
                    ini.IniWriteValue("Options", "showOverrideComponentCollectionQuestion", "true");
                } else {
                    ini.IniWriteValue("Options", "showOverrideComponentCollectionQuestion", "false");
                }
                doOverride = (bool)messageBox.DialogResult;
            }

            if (doOverride) {

                bool cont = true;
                if (modelHasBeenEdited) {
                    SaveQuestionDialog saveQuestion = new SaveQuestionDialog();
                    saveQuestion.Owner = this;
                    saveQuestion.ShowDialog();

                    // Process message box results
                    switch (saveQuestion.Result) {
                        case SaveQuestionDialog.save:
                            if (SaveLocalCommand(false) == true) {
                                CleanACS();
                                modelHasBeenEdited = false;
                            }
                            break;
                        case SaveQuestionDialog.dontSave:
                            CleanACS();
                            modelHasBeenEdited = false;
                            break;
                        case SaveQuestionDialog.cancel:
                            cont = false;
                            break;
                    }
                } else {
                    CleanACS();
                }
                if (cont) {

                    SetSaveFile(null);
                    deploymentModel.modelName = GenerateModelName();

                    try {
                        List<String> allBundles = asapiClient.getBundleDescriptors();
                        StreamWriter tempfile = new StreamWriter(System.IO.Path.GetTempPath() + "tempBundle.xml", false, System.Text.Encoding.ASCII);
                        tempfile.Write("<?xml version=\"1.0\"?>");
                        tempfile.Write("<componentTypes xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                        String tempStr;
                        foreach (string str in allBundles) {
                            tempStr = str.Remove(0, str.IndexOf("<componentType ") - 1);
                            tempStr = tempStr.Remove(tempStr.IndexOf("</componentTypes>"), 17);
                            tempfile.WriteLine(tempStr);
                            //Console.WriteLine(str);
                        }

                        tempfile.Write("</componentTypes>");

                        tempfile.Close();
                        componentList.Clear();
                        LoadBundle(System.IO.Path.GetTempPath() + "tempBundle.xml");  // ini.IniReadValue("model", "tempfile"));
                        activeBundle = AREHost;
                    } catch (Exception ex) {
                        MessageBox.Show(Properties.Resources.DownloadBundleError, Properties.Resources.DownloadBundleErrorHeader, MessageBoxButton.OK, MessageBoxImage.Error);
                        traceSource.TraceEvent(TraceEventType.Error, 3, ex.Message);
                        CheckASAPIConnection();
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Check if current model needs saving and then open model
        /// </summary>
        private void CheckIfSavedAndOpenCommand(String inputFile)
        {
            if (modelHasBeenEdited) {
                SaveQuestionDialog saveQuestion = new SaveQuestionDialog();
                saveQuestion.Owner = this;
                saveQuestion.ShowDialog();

                // Process message box results
                switch (saveQuestion.Result) {
                    case SaveQuestionDialog.save:
                        if (SaveLocalCommand(false) == true) {
                            OpenLocalCommand(inputFile);
                            modelHasBeenEdited = false;
                        }
                        break;
                    case SaveQuestionDialog.dontSave:
                        OpenLocalCommand(inputFile);
                        modelHasBeenEdited = false;
                        break;
                    case SaveQuestionDialog.cancel:
                        break;
                }
            }
            else {
                OpenLocalCommand(inputFile);
                modelHasBeenEdited = false;
            }
        }