public static void Serialize(object Object, IniCollectionSettings CollectionSettings, string Filename)
 {
     IniFile.Save(Serialize(Object, CollectionSettings), Filename);
 }
Beispiel #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            TransparencyKey = Color.FromArgb(255, 255, 255, 255);
            BackColor = Color.FromArgb(255, 255, 255, 255);
            button1.Hide();
            timer_trackvisible.Interval = 100;
            timer_trackmovement.Interval = 1;

            #region read ini settings

            var MyIni = new IniFile.IniFile("TopMostApplication.exe.config");

            if (MyIni.KeyExists("ButtonText", "ini"))
            {
                string buttontext = MyIni.Read("ButtonText", "ini");
                button1.Text = buttontext;
            }

            if (MyIni.KeyExists("ImageFormat", "ini"))
            {
                string imageformatstr = MyIni.Read("ImageFormat", "ini").ToUpper();
                switch (imageformatstr)
                {
                    case "JPEG": imageformat = System.Drawing.Imaging.ImageFormat.Jpeg; imageext = "jpg";  break;
                    case "JPG": imageformat = System.Drawing.Imaging.ImageFormat.Jpeg; imageext = "jpg"; break;
                    case "PNG": imageformat = System.Drawing.Imaging.ImageFormat.Png; imageext = "png"; break;
                    case "BMP": imageformat = System.Drawing.Imaging.ImageFormat.Bmp; imageext = "bmp"; break;
                    case "TIFF": imageformat = System.Drawing.Imaging.ImageFormat.Tiff; imageext = "tif"; break;
                    case "TIF": imageformat = System.Drawing.Imaging.ImageFormat.Tiff; imageext = "tif"; break;
                    default:
                        break;
                }
            }

            if (MyIni.KeyExists("HotKey", "ini"))
            {
                string hotkeystr = MyIni.Read("HotKey", "ini").ToUpper();
                switch (hotkeystr)
                {
                    case "F1": hotkey = Keys.F1; break;
                    case "F2": hotkey = Keys.F2; break;
                    case "F3": hotkey = Keys.F3; break;
                    case "F4": hotkey = Keys.F4; break;
                    case "F5": hotkey = Keys.F5; break;
                    case "F6": hotkey = Keys.F6; break;
                    case "F7": hotkey = Keys.F7; break;
                    case "F8": hotkey = Keys.F8; break;
                    case "F9": hotkey = Keys.F9; break;
                    case "F10": hotkey = Keys.F10; break;
                    case "F11": hotkey = Keys.F11; break;
                    case "F12": hotkey = Keys.F12; break;
                    default:
                        break;
                }
            }

            if (MyIni.KeyExists("ProgramTitle", "ini"))
            {
                ProgramTitle = MyIni.Read("ProgramTitle", "ini").ToUpper();
            }

            if (MyIni.KeyExists("JPEGQuality", "ini"))
            {
                bool result = long.TryParse(MyIni.Read("JPEGQuality", "ini"), out JPEGQuality);
                if (!result) { JPEGQuality = 100; }
            }

            if (MyIni.KeyExists("FileNameTemplate", "ini"))
            {
                FileNameTemplate = MyIni.Read("FileNameTemplate", "ini");
                if (FileNameTemplate == null) { FileNameTemplate = "yyyyMMdd-HHmmss-ff"; }
            }

            #endregion

            hotkey.Hotkey h = new hotkey.Hotkey(hotkey, true, false, false, false);
            h.Pressed += H_Pressed;
            h.Register(this);

            // and finally, enable the timers
            // do this last so all configuration is complete before they can possibly run
            timer_trackvisible.Enabled = true;
            timer_trackmovement.Enabled = true;
        }
 public static object Deserialize(Type Type, string Filename, IniCollectionSettings CollectionSettings)
 {
     return(Deserialize(Type, IniFile.Load(Filename), CollectionSettings));
 }
 public static T Deserialize <T>(string filename, IniCollectionSettings CollectionSettings)
 {
     return(Deserialize <T>(IniFile.Load(filename), CollectionSettings));
 }
 public static object Deserialize(Type Type, string Filename)
 {
     return(Deserialize(Type, IniFile.Load(Filename)));
 }
 public static T Deserialize <T>(string filename)
 {
     return(Deserialize <T>(IniFile.Load(filename)));
 }
 public static void Serialize(object Object, string Filename)
 {
     IniFile.Save(Serialize(Object), Filename);
 }