Exemple #1
0
        private bool OptionDifficultySettingChanged(OptionDifficultySetting value)
        {
            //save the change in the config file
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (IsolatedStorageFileStream isfs = new IsolatedStorageFileStream(c_configFile, FileMode.Create, isf))
                {
                    using (StreamWriter sr = new StreamWriter(isfs))
                    {
                        sr.WriteLine(value.ToString());
                    }
                }
            }

            // Show or hide UI elements appropriately
            if (m_workspace.Difficulty == OptionDifficultySetting.MaterialBalance)
            {
                Compounds_DF_TabControl.SelectedItem = DFAnalysisTab;
                CompoundTableTab.Visibility          = Visibility.Collapsed;
            }
            else
            {
                CompoundTableTab.Visibility = Visibility.Visible;
            }

            // Tell the control palette that the difficulty changed
            PrimaryPalette.RefreshPalette(value);

            return(true);
        }
Exemple #2
0
        public void Save(System.IO.Stream outputStream, string versionNumber)
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = "   ";

            //create our XML writer
            using (XmlWriter writer = XmlWriter.Create(outputStream, settings))
            {
                // Create the root node
                writer.WriteStartElement("ProcessFlowDiagram");

                //version number
                writer.WriteAttributeString("ChemProV.version", versionNumber);

                // Write the difficulty setting as an attribute
                writer.WriteAttributeString("DifficultySetting", m_difficulty.ToString());

                // DrawingCanvas and all its elements first
                writer.WriteStartElement("DrawingCanvas");
                {
                    // Process units
                    writer.WriteStartElement("ProcessUnits");
                    foreach (AbstractProcessUnit apu in m_procUnits)
                    {
                        writer.WriteStartElement("GenericProcessUnit");
                        apu.WriteXml(writer);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    // Then streams
                    writer.WriteStartElement("Streams");
                    foreach (AbstractStream stream in m_streams)
                    {
                        writer.WriteStartElement("AbstractStream");
                        stream.WriteXml(writer);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    // Now write the stream property tables. Data-structures-wise these are properties
                    // of the streams, but the file format was designed (before I came along) such that
                    // the property tables are under their own element and we have to maintain this
                    // file format.
                    writer.WriteStartElement("PropertiesWindows");
                    foreach (AbstractStream stream in m_streams)
                    {
                        stream.PropertiesTable.WriteXml(writer, stream.UIDString);
                    }
                    writer.WriteEndElement();

                    // Write "free-floating" sticky notes
                    writer.WriteStartElement("StickyNotes");
                    foreach (Logic.StickyNote sn in m_stickyNotes)
                    {
                        writer.WriteStartElement("StickyNote");
                        sn.WriteXml(writer);
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // Write equations
                writer.WriteStartElement("EquationEditor");
                writer.WriteStartElement("Equations");
                foreach (EquationModel model in m_equations)
                {
                    writer.WriteStartElement("EquationModel");
                    model.WriteXml(writer);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.WriteEndElement();

                // At one time there was a feedback window, but it's not in use anymore. To maintain
                // file format compatibility though, we still write the element.
                writer.WriteStartElement("FeedbackWindow");
                writer.WriteEndElement();

                // Write degrees of freedom analysis
                writer.WriteStartElement("DegreesOfFreedomAnalysis");
                writer.WriteElementString("Text", m_dfAnalysis.Text);
                foreach (BasicComment bc in m_dfAnalysis.Comments)
                {
                    writer.WriteStartElement("Comment");
                    if (!string.IsNullOrEmpty(bc.CommentUserName))
                    {
                        writer.WriteAttributeString("UserName", bc.CommentUserName);
                    }
                    writer.WriteValue(bc.CommentText);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                // End the root node
                writer.WriteEndElement();
            }
        }