Example #1
0
        public FormProgressBar(Settings settings)
        {
            InitializeComponent();

            if (settings.GetBool("PortableProgressBar")) {
                this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            }

            Rectangle workingArea = Screen.PrimaryScreen.WorkingArea;

            if (this.DwmEnabled) {
                this.Left = workingArea.Width - this.Width - 4;
                this.Top = workingArea.Height - this.Height - 4;
            } else {
                this.Left = workingArea.Width - this.Width;
                this.Top = workingArea.Height - this.Height;
            }
        }
Example #2
0
 /// <summary>
 /// Deserialize settings from file to object
 /// </summary>
 /// <param name="obj">The object</param>
 /// <param name="filename">The filename (usually AddonPath + "/settings.txt")</param>
 public void DeserializeSettings(object obj, string filename)
 {
     Type type = obj.GetType();
       Settings settings = new Settings(filename);
       FieldInfo[] fields = type.GetFields();
       foreach (FieldInfo field in fields) {
     if (settings.Contains(field.Name)) {
       if (field.FieldType == typeof(string)) {
     field.SetValue(obj, settings.GetString(field.Name));
       } else if (field.FieldType == typeof(bool)) {
     field.SetValue(obj, settings.GetBool(field.Name));
       } else if (field.FieldType == typeof(int)) {
     field.SetValue(obj, settings.GetInt(field.Name));
       } else if (field.FieldType == typeof(long)) {
     field.SetValue(obj, settings.GetLong(field.Name));
       } else if (field.FieldType == typeof(float)) {
     field.SetValue(obj, settings.GetFloat(field.Name));
       }
     }
       }
 }