Ejemplo n.º 1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (AppDataManager.getCfgParameter(AppDataNames.SaveOnClosing) == "1")
                {
                    SaveToXml();
                }
                else
                {
                    DialogResult answer = AskForSaving();
                    switch (answer)
                    {
                    case DialogResult.Cancel:
                        e.Cancel = true;
                        break;

                    case DialogResult.Yes:
                        SaveToXml();
                        break;
                    }
                }
                if (!e.Cancel)
                {
                    AppDataManager.setCfgParameter(AppDataNames.DefaultAudioOutputDevice, audioHkDevicesCmbBox.SelectedValue.ToString());
                    AppDataManager.saveCfg();
                    SoundPlayer.Instance.Notificator.Dispose();
                }
            }
            catch (Exception ex)
            {
                Logger.NewLog(ex, "Exception when closing the form");
                e.Cancel = false;
            }
        }
Ejemplo n.º 2
0
        private DialogResult AskForSaving()
        {
            DialogResult answer = DialogResult.None;

            if (AppDataManager.getCfgParameter(AppDataNames.DisableDirtyTracker) == "0" && dirtyTracker.IsFormDirty())
            {
                answer = MessageBox.Show("Save hotkeys?", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            }
            return(answer);
        }
Ejemplo n.º 3
0
 public OptionsForm(MainForm mainF)
 {
     this.mainF = mainF;
     InitializeComponent();
     this.FormBorderStyle                   = FormBorderStyle.FixedSingle;
     hotkeysStartTxtBox.Text                = AppDataManager.getCfgParameter(AppDataNames.DefaultXmlFilePath);
     hotkeysStartChkBox.Checked             = AppDataManager.getCfgParameter(AppDataNames.LoadXmlOnStartUp) == "1";
     disableDirtyTrackerChkBox.Checked      = AppDataManager.getCfgParameter(AppDataNames.DisableDirtyTracker) == "1";
     resetRatesOnNewPlayChkBox.Checked      = AppDataManager.getCfgParameter(AppDataNames.ResetRatesOnNewPlay) == "1";
     resetAutoRepeatOnNewPlayChkBox.Checked = AppDataManager.getCfgParameter(AppDataNames.ResetAutoRepeatOnNewPlay) == "1";
     displayFullFilepathsChkBox.Checked     = AppDataManager.getCfgParameter(AppDataNames.DisplayTracksFullFilepaths) == "1";
     enableNotifChkBox.Checked              = AppDataManager.getCfgParameter(AppDataNames.EnableNotifications) == "1";
     audioLatencyNumBox.Value               = int.TryParse(AppDataManager.getCfgParameter(AppDataNames.AudioLatency), out int latency) ? latency : 50;
     tracksPlayOrderCmbBox.Text             = AppDataManager.getCfgParameter(AppDataNames.TracksPlayOrder);
 }
Ejemplo n.º 4
0
        private void Init(bool isFirstInstance)
        {
            InitializeComponent();

            var devices = DirectSoundOut.Devices;

            hkLogic        = new HotkeyLogic(this);
            xmlLogic       = new XmlLogic(this, hkLogic);
            keysTranslater = new KeysTranslater();

            audioHkDevicesCmbBox.DataSource    = devices;
            audioHkDevicesCmbBox.DisplayMember = "Description";
            audioHkDevicesCmbBox.ValueMember   = "Guid";
            try
            {
                audioHkDevicesCmbBox.SelectedValue = new Guid(AppDataManager.getCfgParameter(AppDataNames.DefaultAudioOutputDevice));
            }
            catch (FormatException) { }
            if (audioHkDevicesCmbBox.SelectedValue == null)
            {
                audioHkDevicesCmbBox.SelectedValue = devices.FirstOrDefault().Guid;
            }
            DataGridViewComboBoxColumn audioDeviceCln = new DataGridViewComboBoxColumn
            {
                Name             = "audioDeviceCln",
                DataPropertyName = "Guid",
                HeaderText       = "Audio Output",
                Width            = 220,
                DataSource       = devices.ToList(),
                ValueMember      = "Guid",
                DisplayMember    = "Description"
            };

            audioHkDataGrid.Columns.Add(audioDeviceCln);
            audioHkStartAtTimePicker.Format       = DateTimePickerFormat.Custom;
            audioHkStartAtTimePicker.CustomFormat = "mm:ss";
            audioHkStartAtTimePicker.ShowUpDown   = true;

            friendlyActionsNames = new Dictionary <string, ControlRoles>()
            {
                { "Forward", ControlRoles.Forward },
                { "Backward", ControlRoles.Backward },
                { "Play/Pause", ControlRoles.PlayPause },
                { "Stop", ControlRoles.Stop },
                { "Increase Volume", ControlRoles.IncreaseVolume },
                { "Decrease Volume", ControlRoles.DecreaseVolume },
                { "Mute Sound", ControlRoles.Mute },
                { "Increase Speed", ControlRoles.IncreaseSpeed },
                { "Decrease Speed", ControlRoles.DecreaseSpeed },
                { "Increase Tempo", ControlRoles.IncreaseTempo },
                { "Decrease Tempo", ControlRoles.DecreaseTempo },
                { "Increase Pitch", ControlRoles.IncreasePitch },
                { "Decrease Pitch", ControlRoles.DecreasePitch },
                { "Reset Music Rates", ControlRoles.ResetRates },
                { "Hold Down Key", ControlRoles.HoldDownKey },
                { "Disable/Enable Hotkeys", ControlRoles.MasterHotkey },
                { "Auto Repeat Track", ControlRoles.AutoRepeat }
            };
            controlHkRoleCmbBox.DataSource    = new BindingSource(friendlyActionsNames, null);
            controlHkRoleCmbBox.DisplayMember = "Key";
            controlHkRoleCmbBox.ValueMember   = "Value";

            fadingDataGrid.Rows.Add("Stop", "Stop", "0 ms", "0 ms");
            fadingDataGrid.Rows.Add("Play/Pause", "PlayPause", "0 ms", "0 ms");
            fadingDataGrid.Rows.Add("Start New Sound", "StartSound", "0 ms", "0 ms");
            fadingDataGrid.Rows.Add("Forward/Backward", "ForwardBackward", "0 ms", "0 ms");

            alwaysSaveOnClosingFileSubMenuItem.Checked = AppDataManager.getCfgParameter(AppDataNames.SaveOnClosing) == "1";
            UpdateResetMusicRates(AppDataManager.getCfgParameter(AppDataNames.ResetRatesOnNewPlay) == "1");
            UpdateResetAutoRepeat(AppDataManager.getCfgParameter(AppDataNames.ResetAutoRepeatOnNewPlay) == "1");
            UpdateAudioLatency(AppDataManager.getCfgParameter(AppDataNames.AudioLatency));
            UpdateTracksOrder(AppDataManager.getCfgParameter(AppDataNames.TracksPlayOrder));
            UpdateNotifications(AppDataManager.getCfgParameter(AppDataNames.EnableNotifications) == "1");
            if (isFirstInstance == true && AppDataManager.getCfgParameter(AppDataNames.LoadXmlOnStartUp) == "1")
            {
                LoadXml(AppDataManager.getCfgParameter(AppDataNames.DefaultXmlFilePath));
                currentXmlFilePath = AppDataManager.getCfgParameter(AppDataNames.DefaultXmlFilePath);
            }
            else
            {
                // initialized otherwise in LoadXml
                InitDirtyTracker();
            }
            if (AppDataManager.getCfgParameter(AppDataNames.DisplayTracksFullFilepaths) == "1")
            {
                UpdateTracksFilepathsDisplay(true);
            }
            SoundPlayer.Instance.Notificator.Click += delegate { ShowMe(); };
        }