public void WorkspaceLoad(string workspaceToLoad) {
			try {
				if (Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName != workspaceToLoad) {
					Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName = workspaceToLoad;
					Assembler.InstanceInitialized.AssemblerDataSnapshotSerializer.Serialize();
				}
				bool createdNewFile = this.GuiDataSnapshotSerializer.Initialize(Assembler.InstanceInitialized.AppDataPath,
					"Sq1.Gui.GuiDataSnapshot.json", "Workspaces",
					Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName);

				this.GuiDataSnapshot = this.GuiDataSnapshotSerializer.Deserialize();
				if (createdNewFile) {
					this.mainForm_LocationChanged(this, null);
					this.mainForm_ResizeEnd(this, null);
					this.GuiDataSnapshotSerializer.Serialize();
					
					// re-reading Workspaces\ since I just created one, and before it was empty; copy-paste from initializeWorkspacesManagerTrampoline()
					Assembler.InstanceInitialized.WorkspacesRepository.ScanFolders();
					this.WorkspacesManager = new MainFormWorkspacesManager(this);
					this.CtxWorkspaces.Items.AddRange(this.WorkspacesManager.WorkspaceMenuItemsWithHandlers);
				}
				//this.DataSnapshot.RebuildDeserializedChartFormsManagers(this);
				
				//foreach (Form each in this.OwnedForms) each.Close();
				foreach (IDockContent each in this.DockPanel.Documents) {
					var form = each as DockContent;
					form.Close();
				}
				foreach (FloatWindow each in this.DockPanel.FloatWindows) each.Close(); 
				foreach (DockWindow each in this.DockPanel.DockWindows) {
					//each.Close();
				}
	
				string file = this.LayoutXml;
				if (File.Exists(file) == false) file = this.LayoutXmlInitial;
				if (File.Exists(file)) {
					DeserializeDockContent deserializeDockContent = new DeserializeDockContent(this.PersistStringInstantiator);
					this.DockPanel.LoadFromXml(LayoutXml, deserializeDockContent);
				}
				Assembler.InstanceInitialized.MainFormDockFormsFullyDeserializedLayoutComplete = true;
	
//				this.mniExceptions.Checked = !ExceptionsForm.Instance.IsHidden;
//				this.mniSymbols.Checked = !DataSourcesForm.Instance.IsHidden;
//				this.mniSliders.Checked = !SlidersForm.Instance.IsHidden;
//				this.mniStrategies.Checked = !StrategiesForm.Instance.IsHidden;
//				this.mniSymbolManager.Checked = !SymbolManagerForm.Instance.IsHidden;
//				this.mniExecution.Checked = !ExecutionForm.Instance.IsHidden;
//				this.mniCsvImporter.Checked = !CsvImporterForm.Instance.IsHidden;
	
				this.initializeMainFromDeserializedDataSnapshot();
				this.mainFormEventManagerInitializeAfterDockingDeserialized();
	
				//this.PropagateSelectorsForCurrentChart();
				//WHY???this.MainFormEventManager.DockPanel_ActiveDocumentChanged(this, EventArgs.Empty);
	
				this.WorkspacesManager.SelectWorkspaceLoaded(workspaceToLoad);

				if (ExceptionsForm.Instance.ExceptionControl.Exceptions.Count > 0) {
					ExceptionsForm.Instance.Show(this.DockPanel);
					ExceptionsForm.Instance.ExceptionControl.PopulateDataSnapshotInitializeSplittersAfterDockContentDeserialized();
				}
			} catch (Exception ex) {
				#if DEBUG
				Debugger.Break();
				#endif
				this.PopupException(ex);
			}
		}
示例#2
0
        public void WorkspaceLoad(string workspaceToLoad)
        {
            try {
                if (Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName != workspaceToLoad)
                {
                    Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName = workspaceToLoad;
                    Assembler.InstanceInitialized.AssemblerDataSnapshotSerializer.Serialize();
                }
                bool createdNewFile = this.GuiDataSnapshotSerializer.Initialize(Assembler.InstanceInitialized.AppDataPath,
                                                                                "Sq1.Gui.GuiDataSnapshot.json", "Workspaces",
                                                                                Assembler.InstanceInitialized.AssemblerDataSnapshot.CurrentWorkspaceName);

                this.GuiDataSnapshot = this.GuiDataSnapshotSerializer.Deserialize();
                if (createdNewFile)
                {
                    this.mainForm_LocationChanged(this, null);
                    this.mainForm_ResizeEnd(this, null);
                    this.GuiDataSnapshotSerializer.Serialize();

                    // re-reading Workspaces\ since I just created one, and before it was empty; copy-paste from initializeWorkspacesManagerTrampoline()
                    Assembler.InstanceInitialized.WorkspacesRepository.ScanFolders();
                    this.WorkspacesManager = new MainFormWorkspacesManager(this);
                    this.CtxWorkspaces.Items.AddRange(this.WorkspacesManager.WorkspaceMenuItemsWithHandlers);
                }
                //this.DataSnapshot.RebuildDeserializedChartFormsManagers(this);

                //foreach (Form each in this.OwnedForms) each.Close();
                foreach (IDockContent each in this.DockPanel.Documents)
                {
                    var form = each as DockContent;
                    form.Close();
                }
                foreach (FloatWindow each in this.DockPanel.FloatWindows)
                {
                    each.Close();
                }
                foreach (DockWindow each in this.DockPanel.DockWindows)
                {
                    //each.Close();
                }

                string file = this.LayoutXml;
                if (File.Exists(file) == false)
                {
                    file = this.LayoutXmlInitial;
                }
                if (File.Exists(file))
                {
                    DeserializeDockContent deserializeDockContent = new DeserializeDockContent(this.PersistStringInstantiator);
                    this.DockPanel.LoadFromXml(LayoutXml, deserializeDockContent);
                }
                Assembler.InstanceInitialized.MainFormDockFormsFullyDeserializedLayoutComplete = true;

//				this.mniExceptions.Checked = !ExceptionsForm.Instance.IsHidden;
//				this.mniSymbols.Checked = !DataSourcesForm.Instance.IsHidden;
//				this.mniSliders.Checked = !SlidersForm.Instance.IsHidden;
//				this.mniStrategies.Checked = !StrategiesForm.Instance.IsHidden;
//				this.mniSymbolManager.Checked = !SymbolManagerForm.Instance.IsHidden;
//				this.mniExecution.Checked = !ExecutionForm.Instance.IsHidden;
//				this.mniCsvImporter.Checked = !CsvImporterForm.Instance.IsHidden;

                this.initializeMainFromDeserializedDataSnapshot();
                this.mainFormEventManagerInitializeAfterDockingDeserialized();

                //this.PropagateSelectorsForCurrentChart();
                //WHY???this.MainFormEventManager.DockPanel_ActiveDocumentChanged(this, EventArgs.Empty);

                this.WorkspacesManager.SelectWorkspaceLoaded(workspaceToLoad);

                if (ExceptionsForm.Instance.ExceptionControl.Exceptions.Count > 0)
                {
                    ExceptionsForm.Instance.Show(this.DockPanel);
                    ExceptionsForm.Instance.ExceptionControl.PopulateDataSnapshotInitializeSplittersAfterDockContentDeserialized();
                }
            } catch (Exception ex) {
                                #if DEBUG
                Debugger.Break();
                                #endif
                this.PopupException(ex);
            }
        }