private void setSolution(NodeSolution value, bool isDirty, bool isCloseEnabled) { if (rootSolutionItem.Solution != value) { rootSolutionItem.Solution = value; dirty = isDirty || m_requireSaving.Count > 0; m_CloseEnabled.SetCondition(isCloseEnabled); } }
public static NodeSolution BuildWith(FieldSolutionName SolutionName, FieldLayout Layout) { //build fields Dictionary <FieldIdentifier, FieldBase> mutableFields = new Dictionary <FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_SolutionNameName), SolutionName); mutableFields.Add(new FieldIdentifier(m_LayoutName), Layout); //build children KeyedNodeCollection <NodeBase> mutableChildren = new KeyedNodeCollection <NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSolution Builder = new NodeSolution( new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection <NodeBase>(mutableChildren)); return(Builder); }
public void OpenExecute(string openFileName, bool readOnly) { if (dirty) { // give the user a chance to save DialogResult result = messagingService.Value.ShowDialog( Resources.Strings.Solution_Confirm_DoYouWantToSave, Resources.Strings.Solution_Confirm_DoYouWantToSave_Title, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Cancel) { return; } else if (result == DialogResult.Yes) { SaveExecute(); } } bool addExtension = true; bool checkFileExists = true; bool checkPathExists = true; string fileName; if (openFileName == null) { fileName = fileDialogService.Value.OpenFileDialog( SOLUTION_EXTENSION, @"c:\", m_filters, Resources.Strings.Solution_OpenFileDialog_Title, addExtension, checkFileExists, checkPathExists); } else { fileName = openFileName; } if (fileName != null) { try { using (Stream src = File.OpenRead(fileName)) { using (Stream dest = new MemoryStream()) { try { Decompress(src, dest); dest.Seek(0, SeekOrigin.Begin); // after Decompress, pointer is at the end using (StreamReader reader = new StreamReader(dest, Encoding.Unicode)) { string xml = reader.ReadToEnd(); NodeSolution readSolution = NodeBase.NodeFromXML(xml, null) as NodeSolution; setSolution(readSolution, false, true); if (!readOnly) { SolutionFileName = fileName; } else { SolutionFileName = null; } layoutManager.Value.ShowPad(this); SolutionLoaded(this, new EventArgs()); layoutManager.Value.RestoreLayout(readSolution.Layout.ToString()); } } catch (InvalidDataException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_InvalidDataException, Resources.Strings.Solution_Open_InvalidDataException_Title); } } } } catch (PathTooLongException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_PathTooLongException, Resources.Strings.Solution_Open_PathTooLongException_Title); } catch (DirectoryNotFoundException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_DirectoryNotFoundException, Resources.Strings.Solution_Open_DirectoryNotFoundException_Title); } catch (UnauthorizedAccessException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_UnauthorizedAccessException, Resources.Strings.Solution_Open_UnauthorizedAccessException_Title); } catch (FileNotFoundException) { messagingService.Value.ShowMessage( Resources.Strings.Solution_Open_FileNotFoundException, Resources.Strings.Solution_Open_FileNotFoundException_Title); } } }
public static NodeSolution BuildWith(FieldSolutionName SolutionName, FieldLayout Layout) { //build fields Dictionary<FieldIdentifier, FieldBase> mutableFields = new Dictionary<FieldIdentifier, FieldBase>(); mutableFields.Add(new FieldIdentifier(m_SolutionNameName), SolutionName); mutableFields.Add(new FieldIdentifier(m_LayoutName), Layout); //build children KeyedNodeCollection<NodeBase> mutableChildren = new KeyedNodeCollection<NodeBase>(); //Add Children here: mutableChildren.Add(SomeChild); //build node NodeSolution Builder = new NodeSolution( new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields), new ReadOnlyCollection<NodeBase>(mutableChildren)); return Builder; }