Ejemplo n.º 1
0
        private async Task <bool> TryShowStartUpDialogAsync()
        {
            string dialogKey   = nameof(StartUpDialog);
            bool   recordExist = CurrentApp.PActionManager.TryGetRecord(dialogKey,
                                                                        out PersistentActions.ActivationRecord record);

            if (recordExist)
            {
                if (record.LastActivationVersion.CompareTo(
                        Package.Current.Id.Version) < 0)
                {
                    CurrentApp.PActionManager.Activate(dialogKey);
                    StartUpDialog.IsLogUploadingPermissionPivotShown = false;
                    StartUpDialog.IsNetworkPermissionsPivotShown     = false;
                    await StartUpDialog.ShowAsync();

                    return(true);
                }
            }
            else
            {
                CurrentApp.PActionManager.Activate(dialogKey);
                await StartUpDialog.ShowAsync();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            /*var enc = CryptoHelper.EncryptStringAes("Hello, World!...", "qwerty7");
             * var ret = CryptoHelper.DecryptStringAes(enc, "qwerty7");*/

            // We can run single instance only here based on Visual Studio
            // Project Settings. So initialize instance to null here.
            Process instance = null;

            // If we are supposed to, check to see if we are the only instance of this
            // program running.
            if (Settings.Default.StartSingleInstanceOnly)
            {
                instance = RunningInstance();
            }

            // If we are the only running instance of this program then continue.
            if (instance == null)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var startUpArgs = parseArgs(args);

                var startUpDlg = new StartUpDialog();
                if (startUpDlg.DialogRequired && startUpDlg.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                // Apply config
                var cfg = new Config
                {
                    RestartEnabled                   = Settings.Default.Config_RestartEnabled,
                    MaxAttemptsCount                 = Settings.Default.Config_MaxAttemptsCount,
                    RestartDelay                     = Settings.Default.Config_RestartDelay,
                    DelayInsteadStop                 = Settings.Default.Config_AfterMaxAttemptsMakeDelay,
                    RestartHostsWithWarnings         = Settings.Default.Config_RestartHostsWithWarnings,
                    RestartHostsWithWarningsInterval = Settings.Default.Config_RestartHostsWithWarningsInterval
                };
                Logger.SetThresholdForAppender(HostLogDelegateAppender, Settings.Default.Config_TraceDebug ? Level.Debug : Level.Info);

                var hm = new HostsManager <HostViewModel>(cfg, startUpDlg.Storage, startUpDlg.Filename, startUpDlg.Password);

                bool firstStart = true;

                // changeSource request handling
                while (true)
                {
                    var mainForm = new MainForm(hm, firstStart && startUpArgs.Minimized);
                    firstStart = false;

                    Application.Run(mainForm);

                    if (mainForm.ChangeSourceRequested)
                    {
                        startUpDlg = new StartUpDialog();
                        if (startUpDlg.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }

                        hm = new HostsManager <HostViewModel>(
                            cfg,
                            startUpDlg.Storage,
                            startUpDlg.Filename,
                            startUpDlg.Password);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else
            {
                // We are not the only running instance of this program. So do this.
                HandleRunningInstance(instance);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This LoadProjectWithStartUpScreen method shows a <see cref="StartUpDialog"/>
        /// dialog for experiment selection or creation.
        /// </summary>
        private void LoadProjectWithStartUpScreen()
        {
            try
            {
                StartUpDialog newStartUpDlg = new StartUpDialog();

                // Dictionary to remember full path from recent files list
                // but show onlay file names
                Dictionary <string, string> recentFilesWithPath = new Dictionary <string, string>();

ShowStartDialog:
                recentFilesWithPath.Clear();
                newStartUpDlg.ListBoxItems.Clear();

                // Add recent files to dialogs recent experiments list box
                foreach (string entry in RecentFilesList.List)
                {
                    if (entry != string.Empty)
                    {
                        string fileName = Path.GetFileName(entry);
                        if (recentFilesWithPath.ContainsKey(fileName))
                        {
                            fileName += "(other path)";
                        }

                        recentFilesWithPath.Add(fileName, entry);
                        if (!newStartUpDlg.ListBoxItems.Contains(fileName))
                        {
                            newStartUpDlg.ListBoxItems.Add(fileName);
                        }
                    }
                }

                newStartUpDlg.ListBoxItems.Add("search for other ...");

                if (newStartUpDlg.ShowDialog() == DialogResult.OK)
                {
                    // Hide Dialog
                    newStartUpDlg.Hide();
                    this.Refresh();

                    // Is new project or recent project ?
                    bool isNewProject = newStartUpDlg.NewProject;
                    if (isNewProject)
                    {
                        this.mnuFileNewExperiment_Click(null, EventArgs.Empty);
                    }
                    else
                    {
                        string selectedItem = string.Empty;

                        // When user deselected any entry, use the project search mask.
                        if (newStartUpDlg.SelectedItem == string.Empty)
                        {
                            selectedItem = "search for other ...";
                        }
                        else
                        {
                            selectedItem = newStartUpDlg.SelectedItem;
                        }

                        // searched experiment is not in recent files list,
                        // so start with standard open file dialog
                        if (selectedItem == "search for other ...")
                        {
                            if (!this.OpenExperiment())
                            {
                                goto ShowStartDialog;
                            }
                        }
                        else
                        {
                            // after successful loading enable main menu items
                            if (this.OpenDocument(recentFilesWithPath[selectedItem]))
                            {
                                this.ChangeMenuItems(true);
                            }
                            else
                            {
                                goto ShowStartDialog;
                            }
                        }
                    }
                }
                else if (Document.ActiveDocument != null)
                {
                    this.CleanUpDocument();
                }
            }
            catch (Exception ex)
            {
                if (Document.ActiveDocument != null)
                {
                    this.CleanUpDocument();
                }

                ExceptionMethods.HandleException(ex);
            }
        }