Exemplo n.º 1
0
        public void Write(OptionsObject opt)
        {
            FileStream fs = new FileStream(fname, FileMode.OpenOrCreate);
            //fs.Lock(0, fs.Length);
            StreamWriter fr = new StreamWriter(fs);

            fr.WriteLine("[options]");
            fr.WriteLine("RunOnStartup={0}", opt.RunOnStartup);
            fr.WriteLine("ShowHotkey={0}", (int)opt.ShowHotkey);
            fr.WriteLine("ExitHotkey={0}", (int)opt.ExitHotkey);
            fr.WriteLine("ScrollHotkey={0}", (int)opt.ScrollHotkey);

            fr.Close();
        }
Exemplo n.º 2
0
        public OptionsObject Read()
        {
            OptionsObject opt = new OptionsObject();
            FileStream fs = new FileStream(fname, FileMode.Open);
            //fs.Lock(0, fs.Length);
            StreamReader fr = new StreamReader(fs);

            if (fr.ReadLine() == "[options]")
            {
                opt.RunOnStartup = SetBool(fr.ReadLine());
                opt.ShowHotkey = SetKey(fr.ReadLine());
                opt.ExitHotkey = SetKey(fr.ReadLine());
                opt.ScrollHotkey = SetKey(fr.ReadLine());
            }
            fr.Close();
            return opt;
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            OptionsIO optio = new OptionsIO(MainWindow.SettingsFile);
            OptionsObject opt=new OptionsObject();
            opt.RunOnStartup = RunOnStartup;
            opt.ShowHotkey = ShowHotkey;
            opt.ExitHotkey = ExitHotkey;
            opt.ScrollHotkey = ScrollHotkey;
            optio.Write(opt);

            winmain.ShowHotkey = ShowHotkey;
            winmain.ExitHotkey = ExitHotkey;
            winmain.ScrollHotkey = ScrollHotkey;
            winmain.RunOnStartup = RunOnStartup;

            if (RunOnStartup) winmain.CreateShortcut();
            else winmain.DeleteShortcut();

            winmain.ShowHideOptions();
        }
Exemplo n.º 4
0
        private void InitOptions()
        {
            if (!File.Exists(SettingsFile))
            {
                OptionsObject opt = new OptionsObject();
                opt.RunOnStartup = RunOnStartup;
                opt.ShowHotkey = ShowHotkey;
                opt.ExitHotkey = ExitHotkey;
                opt.ScrollHotkey = ScrollHotkey;
                OptionsIO optio = new OptionsIO(SettingsFile);
                optio.Write(opt);
                InTutorialMode = true;
            }
            else
            {
                OptionsObject opt = new OptionsIO(SettingsFile).Read();
                ShowHotkey = opt.ShowHotkey;
                ExitHotkey = opt.ExitHotkey;
                ScrollHotkey = opt.ScrollHotkey;
                RunOnStartup = opt.RunOnStartup;
                InTutorialMode = false;
            }

            if (!RunOnStartup) DeleteShortcut();
            else CreateShortcut();

            OptionsWindow = new options(winmain);
            OptionsWindow.Show();
            MoveX(OptionsWindow, 0, -(int)OptionsWindow.Width, 0);

            //tutorialmode = true;
        }