示例#1
0
 public static void Sync()
 {
     if (settings != null)
     {
         settings.Save();
     }
 }
        private async void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            SaveButton.Focus();
            string Errors = settings.Validate();

            ErrorText.Text = Errors;
            if (Errors == null)
            {
                bool IsFirstRun = (Settings.SavedFile == null);
                Settings.SavedFile = settings;
                settings.Save();
                SessionCore.Instance.Business.DownloadManager.Options = settings.Download;
                this.Close();

                if (settings.MediaPlayerApp == MediaPlayerApplication.Mpc)
                {
                    MpcConfigBusiness.ConfigureSettings();
                    SessionCore.Instance.Business.ConfigurePlayer();
                }

                if (IsFirstRun || settings.MediaPlayerApp != currentPlayer)
                {
                    SessionCore.Instance.Business.SetPlayer(SessionCore.Instance.GetNewPlayer());
                }

                await EditPlaylistBusiness.AutoBindFilesAsync();
            }
        }
示例#3
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         settingsfile.Save();
     }
     catch { };
 }
 public void Save()
 {
     Task.Factory.StartNew(() =>
     {
         lock (SyncRoot)
         {
             SettingsFile.Save();
         }
     });
 }
示例#5
0
 public void Save()
 {
     SettingsFile sf = new SettingsFile();
     sf.Set( "SignInUsername", SignInUsername );
     sf.Set( "PlayerName", PlayerName );
     sf.Set( "Password", PasswordSecurity.EncryptPassword( Password ) );
     sf.Set( "LastUrl", LastUrl );
     sf.Set( "SignInDate", SignInDate.Ticks );
     sf.Save( FileName );
 }
示例#6
0
        private void WindowViewBase_Closed(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Name))
            {
                return;
            }

            const string fileName = "windows.json";
            Dictionary <string, WindowSettings> windows;

            if (!SettingsFile.TryLoad(fileName, out windows))
            {
                windows = new Dictionary <string, WindowSettings>();
            }

            WindowSettings windowSettings;

            if (windows.TryGetValue(Name, out windowSettings))
            {
                // Preserve old values if WindowState != Normal
                if (WindowState == WindowState.Normal)
                {
                    windowSettings.Height = Height;
                    windowSettings.Width  = Width;
                    windowSettings.Top    = Top;
                    windowSettings.Left   = Left;
                }
                windowSettings.WindowState = WindowState;
            }
            else
            {
                windowSettings             = new WindowSettings();
                windowSettings.Height      = (WindowState == WindowState.Normal ? Height : (double?)null);
                windowSettings.Width       = (WindowState == WindowState.Normal ? Width : (double?)null);
                windowSettings.Top         = (WindowState == WindowState.Normal ? Top : (double?)null);
                windowSettings.Left        = (WindowState == WindowState.Normal ? Left : (double?)null);
                windowSettings.WindowState = WindowState;

                windows.Add(Name, windowSettings);
            }

            SettingsFile.Save(fileName, windows);
        }
示例#7
0
        private void OnUserKeyboardRelease(object sender, KeyEventArgs e)
        {
            idletime = 0;
            if (MacroActivateChanging)
            {
                ActivateKey = (int)e.KeyCode;
                MessageBox.Show(Translations.Get("activate_key_changed"));
                SettingsFile.Save(ActivateKey);
                MacroActivateChanging = false;
            }

            switch (e.KeyCode)
            {
            case System.Windows.Forms.Keys.F5:
                if (ShowInTaskbar)
                {
                    previousindex = List_Macros.SelectedIndex;
                    RefreshFiles();
                    List_Macros.SelectedIndex = previousindex;
                }
                break;

            case System.Windows.Forms.Keys.LShiftKey:
            case System.Windows.Forms.Keys.RShiftKey:
            case System.Windows.Forms.Keys.Shift:
            case System.Windows.Forms.Keys.ShiftKey:
                shift = false;
                break;
            }

            if ((int)e.KeyCode == ActivateKey)
            {
                MacroActivate = false;
            }

            while (PressedKeys.Contains(e.KeyCode))
            {
                PressedKeys.Remove(e.KeyCode);
            }

            ProceedOtherMacros(e.KeyCode, MacroType.Keyboard);
        }
示例#8
0
            public static SettingsFile Load()
            {
                SettingsFile retValue = new SettingsFile();

                if (File.Exists(StateFile))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(SettingsFile));

                    using (var reader = new StreamReader(StateFile))
                    {
                        retValue = (SettingsFile)serializer.Deserialize(reader);
                    }
                }
                else
                {
                    retValue.Save();
                }

                return(retValue);
            }
示例#9
0
        private void MainWindow_Closed(object sender, EventArgs e)
        {
            // Splitter/InitialDirectory settings
            MainWindowSettings settings = new MainWindowSettings();

            settings.GridSplitterPosition = tagView.FileExplorer.GridSplitterPosition.Value;
            settings.Directory            = tagView.FileExplorer.DirectoryController.CurrentDirectory;

            // Column settings
            settings.ColumnSettings = new Dictionary <string, DataGridColumnSettings>();
            foreach (var item in tagView.FileExplorer.GetFileViewColumns())
            {
                string name = item.GetValue(DataGridUtil.NameProperty).ToString();
                // TODO: Need to account for IsStar, etc in item.Width
                settings.ColumnSettings.Add(name, new DataGridColumnSettings {
                    Width        = item.Width.IsAbsolute ? item.ActualWidth : item.Width.Value,
                    DisplayIndex = item.DisplayIndex,
                    IsStar       = item.Width.IsAbsolute ? false : true,
                });
            }

            SettingsFile.Save("mainWindow.json", settings);
        }
示例#10
0
        private void btnCreateGrp_Click(object sender, EventArgs e)
        {
            if (tvAppSettings.SelectedNode == null)
            {
                return;
            }

            if (!String.IsNullOrEmpty(txtValue.Text))
            {
                //We're in group create mode
                if (this.tvAppSettings.SelectedNode.Parent == null)
                {
                    if (!settingsFile.Groups.Contains(txtValue.Text))
                    {
                        settingsFile.Groups.Add(txtValue.Text);
                        settingsFile.Save();

                        //Now read properties of Group
                        try
                        {
                            SettingGroup loadedGroup = settingsFile.Groups[txtValue.Text];

                            if (loadedGroup != null)
                            {
                                status.Text = String.Format("Got group {0} w/ {1} settings", loadedGroup.Name, loadedGroup.Settings.Count);
                                RefreshTree();
                            }
                        }
                        catch
                        {
                            //Did not load group!
                            status.Text = "Problem creating group" + txtValue.Text;
                        }
                    }
                    else
                    {
                        status.Text = "Group already exists";
                    }
                }
                //Otherwise, we're in setting create/edit mode
                else
                {
                    #region Goes Into other Form
                    if (tvAppSettings.SelectedNode.Tag != null)
                    {
                        //We're going to create a new setting as we're sitting on a group
                        if (tvAppSettings.SelectedNode.Tag.GetType() == typeof(SettingGroup))
                        {
                            //Redirect to create value
                            SettingForm sf = new SettingForm();
                            sf.CreateSetting();

                            string newSettingName  = sf.settingName;
                            object newSettingValue = sf.settingValue;

                            if (String.IsNullOrEmpty(sf.message))
                            {
                                Setting      newSetting    = new Setting(newSettingName, newSettingValue);
                                SettingGroup groupSelected = (SettingGroup)tvAppSettings.SelectedNode.Tag;
                                groupSelected.Settings.Add(newSetting);
                                status.Text = "Created new setting";

                                settingsFile.Save();
                                RefreshTree();
                            }
                            else
                            {
                                status.Text = sf.message;
                            }
                        }
                        else if (tvAppSettings.SelectedNode.Tag.GetType() == typeof(Setting))
                        {
                            //Redirect to edit value
                            SettingForm sf = new SettingForm();
                            sf.EditSetting(((Setting)tvAppSettings.SelectedNode.Tag).Name, ((Setting)tvAppSettings.SelectedNode.Tag).Value);
                            object newSettingValue = sf.settingValue;

                            if (newSettingValue != null && String.IsNullOrEmpty(sf.message))
                            {
                                //We're on an existing setting
                                Setting selectedSetting = (Setting)tvAppSettings.SelectedNode.Tag;
                                selectedSetting.Value = newSettingValue;
                                status.Text           = "Updated existing setting";

                                settingsFile.Save();
                                RefreshTree();
                            }
                            else
                            {
                                status.Text = sf.message;
                            }
                        }
                    }
                    #endregion
                }
            }
        }
示例#11
0
 public void Save()
 {
     SettingsFile.Save(InstallerState, nameof(InstallerState));
 }
示例#12
0
        // ==== Options tab ====
        void SaveLauncherSettings( object sender, EventArgs e )
        {
            if( !settingsLoaded )
                return;
            Log( "SaveLauncherSettings" );

            // confirm erasing accounts
            if( sender == xRememberUsername && !xRememberUsername.Checked &&
                !ConfirmDialog.Show( "Forget all usernames?",
                                     "When you uncheck \"remember usernames\", all currently-stored account " +
                                     "information will be forgotten. Continue?" ) ) {
                xRememberUsername.Checked = true;
                lOptionsStatus.Text = "";
                return;
            }

            // confirm forgetting accounts
            if( sender == xMultiUser && !xMultiUser.Checked && accounts.Count > 1 &&
                !ConfirmDialog.Show( "Forget all other accounts?",
                                     "When you uncheck \"multiple accounts\", all account information other than " +
                                     "the currently-selected user will be forgotten. Continue?" ) ) {
                xMultiUser.Checked = true;
                lOptionsStatus.Text = "";
                return;
            }

            SettingsFile settings = new SettingsFile();
            settings.Set( "rememberUsername", xRememberUsername.Checked );
            settings.Set( "multiUser", xMultiUser.Checked );
            settings.Set( "rememberPassword", xRememberPassword.Checked );
            settings.Set( "rememberServer", xRememberServer.Checked );
            settings.Set( "gameUpdateMode", (GameUpdateMode)cGameUpdates.SelectedIndex );
            settings.Set( "startingTab", (StartingTab)cStartingTab.SelectedIndex );
            settings.Save( Paths.LauncherSettingsFile );

            if( sender == xRememberUsername ) {
                if( xRememberUsername.Checked ) {
                    xRememberPassword.Enabled = true;
                    lOptionsStatus.Text = "Usernames will now be remembered.";
                    xMultiUser.Enabled = true;
                } else {
                    xRememberPassword.Checked = false;
                    xRememberPassword.Enabled = false;
                    xMultiUser.Checked = false;
                    xMultiUser.Enabled = false;
                    accounts.RemoveAllAccounts();
                    LoadAccounts();
                    lOptionsStatus.Text = "Usernames will no longer be remembered.";
                }
                SignInFieldChanged( null, EventArgs.Empty );

            } else if( sender == xRememberPassword ) {
                if( xRememberPassword.Checked ) {
                    lOptionsStatus.Text = "Passwords will now be remembered.";
                } else {
                    lOptionsStatus.Text = "Passwords will no longer be remembered.";
                }
                SignInFieldChanged( null, EventArgs.Empty );

            } else if( sender == xRememberServer ) {
                if( xRememberServer.Checked ) {
                    lOptionsStatus.Text = "Last-joined server will now be remembered.";
                } else {
                    lOptionsStatus.Text = "Last-joined server will no longer be remembered.";
                }

            } else if( sender == xMultiUser ) {
                if( xMultiUser.Checked ) {
                    lOptionsStatus.Text = "All users will now be remembered.";
                } else {
                    lOptionsStatus.Text = "Only most-recent user will now be remembered.";
                }
                LoadAccounts();

            } else if( sender == cGameUpdates ) {
                lOptionsStatus.Text = "\"Game updates\" preference saved.";

            } else if( sender == cStartingTab ) {
                lOptionsStatus.Text = "\"Starting tab\" preference saved.";

            } else {
                lOptionsStatus.Text = "Preferences saved.";
            }
        }
示例#13
0
 void xFailSafe_CheckedChanged( object sender, EventArgs e )
 {
     SettingsFile sf = new SettingsFile();
     if( File.Exists( Paths.GameSettingsFile ) ) {
         sf.Load( Paths.GameSettingsFile );
     }
     bool failSafeEnabled = sf.GetBool( "mc.failsafe", false );
     if( failSafeEnabled != xFailSafe.Checked ) {
         sf.Set( "mc.failsafe", xFailSafe.Checked );
         sf.Save( Paths.GameSettingsFile );
     }
     lOptionsStatus.Text = "Fail-safe mode " + (xFailSafe.Checked ? "enabled" : "disabled") + ".";
 }
示例#14
0
 public void SaveSettings()
 {
     settingsFile.Save();
 }
示例#15
0
        private static void SaveSettings()
        {
            var settings = Settings();

            SettingsFile.Save("appsettings.json", settings.ToJson());
        }
示例#16
0
 internal static void Save()
 {
     s_File.Save();
 }
示例#17
0
        /// <summary>
        /// Processes difficulty change when inside the Chief of Police's Office Room.
        /// </summary>
        private void ChiefOfPolice_DifficultySelection()
        {
            // If player enters any police station, enters the Chief of Police's office room, and enters a marker, set difficulty
            // Wait 10 seconds in script to prevent stuck at the restart point

            //Blip selectDifficultyBlip = Blip.AddBlip(ChiefOfPoliceRoom);
            bool isHardcoreModeActive = controller.HardcoreModeIsActive();
            int  waitTime             = 10000; // 10 seconds refresh

            if (isHardcoreModeActive == false)
            {
                if (LPlayer.LocalPlayer.IsInPoliceDepartment && LPlayer.LocalPlayer.Ped.Position.DistanceTo(ChiefOfPoliceRoom) < 1f &&
                    (LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_SWAT") | LPlayer.LocalPlayer.Skin.Model == new Model("M_Y_NHELIPILOT")))
                {
                    this.isSelectingDifficulty = true;
                    int[] tempDiff = { 1, 2, 3 };
                    int   keyPress = 0;
                    //AnimationSet difficultyPlayAnim = new AnimationSet("cellphone");
                    Functions.PrintHelp("Use left and right arrows to select a difficulty. When done, press ~KEY_ACCEPT_CALLOUT~ to confirm. Otherwise press ~KEY_ARREST_CALL_TRANSPORTER~ to quit.");
                    TaskSequence mytask = new TaskSequence();
                    mytask.AddTask.StandStill(-1);
                    mytask.AddTask.UseMobilePhone(-1);
                    mytask.Perform(LPlayer.LocalPlayer.Ped);
                    //LPlayer.LocalPlayer.CanControlCharacter = false;
                    while (this.isSelectingDifficulty)
                    {
                        if (Functions.IsKeyDown(Keys.Left))
                        {
                            keyPress--;
                            if (keyPress < 0)
                            {
                                keyPress = 2;
                            }
                        }
                        else if (Functions.IsKeyDown(Keys.Right))
                        {
                            keyPress++;
                            if (keyPress > 2)
                            {
                                keyPress = 0;
                            }
                        }
                        if (keyPress == 0)
                        {
                            Game.DisplayText("Difficulty: Easy", 1000);
                        }
                        else if (keyPress == 1)
                        {
                            Game.DisplayText("Difficulty: Medium", 1000);
                        }
                        else if (keyPress == 2)
                        {
                            Game.DisplayText("Difficulty: Hard", 1000);
                        }

                        if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("AcceptCallout", "Keybindings", Keys.Y)))
                        {
                            SettingsIni.SetValue("Difficulty", "GlobalSettings", tempDiff[keyPress]);
                            SettingsIni.Save();
                            Functions.PrintText("Difficulty has been set", 5000);
                            LPlayer.LocalPlayer.CanControlCharacter = true;
                            LPlayer.LocalPlayer.Ped.Task.ClearAll();
                            this.isSelectingDifficulty = false;
                            Function.Call("TRIGGER_MISSION_COMPLETE_AUDIO", new Parameter[] { 1 });
                            Game.WaitInCurrentScript(waitTime);
                        }
                        else if (Functions.IsKeyDown(SettingsFile.Open("LCPDFR\\LCPDFR.ini").GetValueKey("ArrestCallTransporter", "Keybindings", Keys.N)))
                        {
                            //LPlayer.LocalPlayer.CanControlCharacter = true;
                            LPlayer.LocalPlayer.Ped.Task.ClearAll();
                            this.isSelectingDifficulty = false;
                            Game.WaitInCurrentScript(waitTime);
                        }
                        Game.WaitInCurrentScript(0); // yield
                    }
                }
            }
        }
示例#18
0
 private void OnClose(object sender, FormClosingEventArgs e)
 {
     SettingsFile.Save(ActivateKey);
 }
示例#19
0
        public FormMain()
        {
            if (!WindowManager.IsSingleInstance)
            {
                MessageBox.Show(Translations.Get("already_running"));
                Environment.Exit(0);
            }

            PressedKeys = new List <Keys>();
            InitializeComponent();
            HideMainForm();

            this.Text            = Translations.Get("about_text");
            this.Item_Title.Text = Translations.Get("about_title");

            Input              = new GlobalHooker();
            KInput             = new KeyboardHookListener(Input);
            MInput             = new MouseHookListener(Input);
            KInput.Enabled     = true; MInput.Enabled = true;
            MInput.MouseDown  += new MouseEventHandler(OnUserMouseInteraction);
            MInput.MouseUp    += new MouseEventHandler(OnUserMouseInteraction);
            MInput.MouseMove  += new MouseEventHandler(OnUserMouseInteraction);
            MInput.MouseClick += new MouseEventHandler(OnUserMouseClick);
            KInput.KeyDown    += new KeyEventHandler(OnUserKeyboardPress);
            KInput.KeyUp      += new KeyEventHandler(OnUserKeyboardRelease);
            KeySender.KeyStroke(KeySender.VkKeyScan('^'));

            if (File.Exists(SettingsFile.SaveFile))
            {
                SettingsFile.Load(ref ActivateKey);
            }
            else
            {
                SettingsFile.Save(ActivateKey);
                if (MessageBox.Show(
                        String.Format(
                            "{0}\n\n{1}\n{2}\n\n{3}",
                            Translations.Get("welcome_text_1"),
                            Translations.Get("welcome_text_2"),
                            Translations.Get("welcome_text_3"),
                            Translations.Get("welcome_text_4")
                            ),
                        Translations.Get("welcome_title"),
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question
                        ) == DialogResult.Yes)
                {
                    Button_Help_Click(new object(), EventArgs.Empty);
                }
            }

            RefreshFiles();

            WqlEventQuery query = new WqlEventQuery("Select * From __InstanceCreationEvent Within 2 Where TargetInstance Isa 'Win32_Process'");

            watcher = new ManagementEventWatcher(query);
            watcher.EventArrived += new EventArrivedEventHandler(OnWindowOpen);
            watcher.Start();

            ProceedOtherMacros(Keys.None, MacroType.Startup);

            timer          = new System.Windows.Forms.Timer();
            timer.Interval = 1000;
            timer.Tick    += new EventHandler(OnIDLETick);
            timer.Start();
        }
示例#20
0
 public static void Save()
 {
     s_File.Save();
 }