Esempio n. 1
0
 public static void Settings2XML()
 {
     try {
         string        favName = StaticFormsCalls.StartupPath + Path.DirectorySeparatorChar + "Settings.xml";
         XmlSerializer xmlSettingsSerializer = new XmlSerializer(typeof(XMLSettings));
         TextWriter    writer      = new StreamWriter(favName);
         XMLSettings   xmlSettings = new XMLSettings();
         xmlSettingsSerializer.Serialize(writer, xmlSettings);
         writer.Close();
     }
     catch { };
 }
Esempio n. 2
0
        public static void SettingsFromXML()
        {
            XmlSerializer xmlSettingsSerializer = new XmlSerializer(typeof(XMLSettings));
            FileStream    ReadFileStream        = null;

            try {
                string favName = StaticFormsCalls.StartupPath + Path.DirectorySeparatorChar + "Settings.xml";
                if (!File.Exists(favName))
                {
                    Settings2XML();
                }
                ReadFileStream = new FileStream(favName, FileMode.Open, FileAccess.Read, FileShare.Read);
                XMLSettings xmlSettings = (XMLSettings)xmlSettingsSerializer.Deserialize(ReadFileStream);
                ReadFileStream.Close();
                if (xmlSettings != null)
                {
                    pens[0] = Color.FromArgb(xmlSettings.backColor0);
                    pens[1] = Color.FromArgb(xmlSettings.backColor1);
                    pens[2] = Color.FromArgb(xmlSettings.backColor2);
                    pens[3] = Color.FromArgb(xmlSettings.backColor3);
                    pens[4] = Color.FromArgb(xmlSettings.backColor4);
                    pens[5] = Color.FromArgb(xmlSettings.backColor5);
                    pens[6] = Color.FromArgb(xmlSettings.backColor6);
                    pens[7] = Color.FromArgb(xmlSettings.backColor7);
                    pens[8] = Color.FromArgb(xmlSettings.backColor8);
                    pens[9] = Color.FromArgb(xmlSettings.backColor9);

                    if (!Initialized)
                    {
                        Initialize();
                    }

                    if (xmlSettings.sortedColors != null)//first time to use it will be null;
                    {
                        Constants.smoozedColors.Clear();
                        for (int c = 0; c < SmoozedColorTags.Length; c++)
                        {
                            SmoozedColorTags[c].index = -1;
                            if (xmlSettings.sortedColors[c] >= 0)
                            {
                                SmoozedColorTags[c].index = xmlSettings.sortedColors[c];
                                SmoozedColorTags[c].TrackerPositionPercentage = xmlSettings.TrackerPositionPercentages[c];
                            }
                            else
                            {
                                SmoozedColorTags[c].index = -1;
                                SmoozedColorTags[c].TrackerPositionPercentage = 0;
                            }
                        }
                        AddSmoozedColorList(false);
                    }

                    Constants.SortSmoozedColors();
                    FurcationColor = Color.FromArgb(xmlSettings.FurcationColor);
                    OneColor       = Color.FromArgb(xmlSettings.OneColor);
                    DiagramColor   = Color.FromArgb(xmlSettings.DiagramColor);

                    FunctionsLineWidth  = xmlSettings.FunctionsLineWidth;
                    FurcationsLineWidth = xmlSettings.FurcationsLineWidth;
                    DiagramLineWidth    = xmlSettings.DiagramLineWidth;

                    // UsedFontSize = xmlSettings.UsedFontSize;
                    currentFunctionType = xmlSettings.functionType;
                    Type3Color          = xmlSettings.Type3Color;
                }
            }
            catch { }
            finally {
                if (ReadFileStream != null)
                {
                    try {
                        ReadFileStream.Close();
                        ReadFileStream.Dispose();
                    }
                    catch { }
                }
            }
        }