示例#1
0
 public HotkeyLogic(Control mainFrm)
 {
     this.mainFrm   = mainFrm.ThrowIfNull(nameof(mainFrm), "A form is required to attach the hotkeys to.");
     hotkeysList    = new List <IHotkey>();
     keysTranslater = new KeysTranslater();
     MasterHotkey   = new ControlHotkey {
         Role = ControlRoles.MasterHotkey
     };
     MasterHotkey.Pressed += delegate { DisableEnableHotkeys(); };
     HotkeysEnabled        = true;
 }
示例#2
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(); };
        }
示例#3
0
 public XmlLogic(MainForm mainFrm, HotkeyLogic hkLogic)
 {
     this.mainFrm   = mainFrm.ThrowIfNull(nameof(mainFrm), "A form is required to attach the hotkeys to.");
     this.hkLogic   = hkLogic.ThrowIfNull(nameof(hkLogic), "HotkeyLogic required to work.");
     keysTranslater = new KeysTranslater();
 }