Example #1
0
 protected override void WndProc(ref Message m)
 {
     if (!MultiInstanceManager.ProcessMessage(ref m))
     {
         base.WndProc(ref m);
     }
 }
Example #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            MultiInstanceManager.Initialize(this);
            SettingsManager.Initialize();

            RestoreSavedPosition();
            InitializeProjectManager();
            menuStrip1.Enabled = false;
        }
Example #3
0
        private bool OpenPartProjectFile(string projectFilePath)
        {
            if (!CloseCurrentProject())
            {
                return(false);
            }

            if (MultiInstanceManager.InstanceCount > 1)
            {
                if (MultiInstanceManager.CheckFileIsOpen(projectFilePath))
                {
                    MessageBoxEX.ShowDetails(this,
                                             Messages.Error_OpeningProject,
                                             Messages.Caption_OpeningProject,
                                             "The file is already opened in another instance."); //TODO: translate
                    return(false);
                }
            }

            PartProject loadedProject = null;

            try
            {
                loadedProject = PartProject.Open(projectFilePath);
            }
            catch (Exception ex)
            {
                MessageBoxEX.ShowDetails(this,
                                         Messages.Error_OpeningProject,
                                         Messages.Caption_OpeningProject, ex.ToString());
            }

            if (loadedProject != null)
            {
                LoadPartProject(loadedProject);
            }

            return(loadedProject != null);
        }
Example #4
0
        private void CheckCanRecoverProject()
        {
            SettingsManager.CleanUpFilesHistory();

            if (SettingsManager.Current.OpenedProjects.Count > 0)
            {
                bool projectWasLoaded = false;

                foreach (var fileInfo in SettingsManager.Current.OpenedProjects.ToArray())
                {
                    //project was not correctly closed
                    if (File.Exists(fileInfo.TemporaryPath))
                    {
                        if (projectWasLoaded)
                        {
                            continue;
                        }

                        if (MultiInstanceManager.InstanceCount > 1)
                        {
                            bool isOpenInOtherInstance = MultiInstanceManager.CheckFileIsOpen(fileInfo.TemporaryPath);
                            if (isOpenInOtherInstance)
                            {
                                return;
                            }
                        }

                        bool projectRestored = false;

                        if (MessageBoxEX.Show(this,
                                              Messages.Message_RecoverProject,
                                              Messages.Caption_RecoverLastProject,
                                              MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            PartProject loadedProject = null;
                            try
                            {
                                loadedProject             = PartProject.Open(fileInfo.TemporaryPath);
                                loadedProject.ProjectPath = fileInfo.ProjectFile;

                                if (LoadPartProject(loadedProject, fileInfo.TemporaryPath))
                                {
                                    projectRestored  = true;
                                    projectWasLoaded = true;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBoxEX.ShowDetails(this,
                                                         Messages.Error_OpeningProject,
                                                         Messages.Caption_OpeningProject, ex.ToString());
                                //exceptionThrown = true;
                            }
                        }

                        if (!projectRestored)
                        {
                            ProjectManager.DeleteTemporaryProject(fileInfo.TemporaryPath);
                        }

                        break;
                    }
                }
            }
        }