Exemple #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();
                }
            }
        }
Exemple #2
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();
                }
            }
        }
Exemple #3
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();
            }
        }
Exemple #4
0
 public virtual void SaveSettings()
 {
     try
     {
         PluginSettingsBase.SaveSettingsFile(settings, GetSettingsType(), SettingsFile);
     }
     catch (Exception)
     {
     }
 }
Exemple #5
0
 public PluginSettingsBase(PluginSettingsBase orig)
 {
     try
     {
         this.activated = orig.activated;
     }
     catch (Exception)
     {
     }
 }
Exemple #6
0
 public AutoRefSettings(PluginSettingsBase orig)
     : base(orig)
 {
     try
     {
     }
     catch (Exception)
     {
     }
 }
        public SettingsWindow(PluginSettingsBase settings)
        {
            try
            {
                InitializeComponent();
                this.settings = new AutoRefSettings(settings);

                checkBoxActivated.IsChecked = this.settings.activated;
            }
            catch (Exception)
            {
            }            
        }
        public SettingsWindow(PluginSettingsBase settings)
        {
            try
            {
                InitializeComponent();
                this.settings = new AutoRefSettings(settings);

                checkBoxActivated.IsChecked = this.settings.activated;
            }
            catch (Exception)
            {
            }
        }
Exemple #9
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)
     {
     }
 }
Exemple #10
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();
     }
 }
Exemple #11
0
 public PluginSettingsBase(PluginSettingsBase orig)
 {
     try
     {
         this.activated = orig.activated;
     }
     catch (Exception)
     {
     }
 }
Exemple #12
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)
     {
     }
 }
Exemple #13
0
        public AutoRefSettings(PluginSettingsBase orig)
            : base(orig)
        {
            try
            {

            }
            catch (Exception)
            {
            }
        }