Esempio n. 1
0
        public AppContext(string filepath)
        {
            Context = this;
            if (Settings.Default.RecentFileList == null)
            {
                Settings.Default.RecentFileList = new StringCollection();
                Settings.Default.Save();
            }

            var diagramForm = new DiagramForm();

            MainForm = diagramForm;
            diagramForm.Show();
            if (string.IsNullOrEmpty(filepath))
            {
                LoadLastFile(diagramForm);
            }
            else
            {
                try
                {
                    diagramForm.OpenFileByPath(filepath);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Format("{0}:{1}{2}", DesignerResources.FileCouldntBeOpened, Environment.NewLine, exception.Message), DesignerResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            diagramForm.Focus();
        }
Esempio n. 2
0
        public void LoadLastFile(DiagramForm diagramForm)
        {
            if (!Settings.Default.AutoLoadLastFile || Settings.Default.RecentFileList.Count == 0)
            {
                return;
            }
            var recentFiles = new string[Settings.Default.RecentFileList.Count];

            Settings.Default.RecentFileList.CopyTo(recentFiles, 0);
            foreach (var file in recentFiles)
            {
                var filepath = file;
                if (!Path.IsPathRooted(filepath))
                {
                    filepath = Path.Combine(WaveletStudio.Utils.AssemblyDirectory, filepath);
                }
                if (!File.Exists(filepath))
                {
                    continue;
                }
                try
                {
                    diagramForm.OpenFileByPath(filepath);
                    break;
                }
                catch (Exception)
                {
                    continue;
                }
            }
        }
Esempio n. 3
0
        public AppContext()
        {
            Context = this;
            if (Settings.Default.RecentFileList == null)
            {
                Settings.Default.RecentFileList = new StringCollection();
                Settings.Default.Save();
            }

            var diagramForm = new DiagramForm();

            MainForm = diagramForm;
            diagramForm.Show();
            LoadLastFile(diagramForm);
            diagramForm.Focus();
        }