Example #1
0
        public static bool SaveSettingsFile(PluginSettingsBase settings, Type type, string filename)
        {
            MemoryStream ms = null;
            FileStream fs = null;
            XmlSerializer xs = null;
            try
            {
                ms = new MemoryStream();
                fs = new FileStream(filename, FileMode.Create, FileAccess.Write);

                xs = new XmlSerializer(type);
                xs.Serialize(ms, settings);
                ms.Seek(0, SeekOrigin.Begin);
                fs.Write(ms.ToArray(), 0, (int)ms.Length);
                ms.Close();
                fs.Close();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                if (ms != null) ms.Close();
                if (fs != null) fs.Close();
            }
        }
Example #2
0
        public SettingsWindow(PluginSettingsBase settings)
        {
            try
            {
                InitializeComponent();
                this.settings = new AutoRefSettings(settings);

                checkBoxActivated.IsChecked = this.settings.activated;
            }
            catch (Exception)
            {
            }            
        }
Example #3
0
 public static bool LoadSettingsFile(ref PluginSettingsBase settings, Type type, string filename)
 {
     MemoryStream ms = null;
     try
     {
         if (!File.Exists(filename)) return false;
         byte[] data = File.ReadAllBytes(filename);
         XmlSerializer xs = new XmlSerializer(type);
         ms = new MemoryStream(data);
         ms.Seek(0, SeekOrigin.Begin);
         settings = (PluginSettingsBase)xs.Deserialize(ms);
         ms.Close();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
     finally
     {
         if (ms != null) ms.Close();
     }
 }
Example #4
0
 public PluginSettingsBase(PluginSettingsBase orig)
 {
     try
     {
         this.activated = orig.activated;
     }
     catch (Exception)
     {
     }
 }
Example #5
0
 public virtual void LoadSettings()
 {
     try
     {
         if (File.Exists(SettingsFile))
         {
             if (!PluginSettingsBase.LoadSettingsFile(ref settings, GetSettingsType(), SettingsFile))
             {
                 settings = GetNewSettings();
                 PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile);
             }
         }
         else
         {
             settings = GetNewSettings();
             PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile);
         }
     }
     catch (Exception)
     {
     }
 }
Example #6
0
        public AutoRefSettings(PluginSettingsBase orig)
            : base(orig)
        {
            try
            {

            }
            catch (Exception)
            {
            }
        }