private List <ComboBoxData> GetRemoteCommandsData()
        {
            List <ComboBoxData> retVal = new List <ComboBoxData>();

            foreach (OPMRemoteControl.CommandType type in Enum.GetValues(typeof(OPMRemoteControl.CommandType)))
            {
                switch (type)
                {
                case OPMRemoteControl.CommandType.Activate:
                case OPMRemoteControl.CommandType.Terminate:
                case OPMRemoteControl.CommandType.KeyPress:
                    retVal.Add(new ComboBoxData(type.ToString(), type.ToString(), type));
                    break;

                case OPMRemoteControl.CommandType.Playback:
                {
                    for (OPMShortcut cmd = OPMShortcut.CmdPlayPause; cmd < OPMShortcut.CmdGenericOpen; cmd++)
                    {
                        string cmdString = string.Format("{0}?{1}", type, cmd);
                        string desc      = Translator.Translate("TXT_" + cmd.ToString().ToUpperInvariant());

                        retVal.Add(new ComboBoxData(desc, cmdString, type));
                    }
                }
                break;

                default:
                    continue;
                }
            }

            return(retVal);
        }
        public static bool IsConfigurableShortcut(OPMShortcut cmd)
        {
            switch (cmd)
            {
                case OPMShortcut.CmdGenericApply:
                case OPMShortcut.CmdGenericNew:
                case OPMShortcut.CmdGenericOpen:
                case OPMShortcut.CmdGenericSave:
                case OPMShortcut.CmdGenericUndo:
                case OPMShortcut.CmdOpenHelp:
                case OPMShortcut.CmdShowLogConsole:
                case OPMShortcut.CmdDumpDebugStats:

                case OPMShortcut.CmdSwitchWindows:

                case OPMShortcut.CmdGenericCopy:
                case OPMShortcut.CmdGenericCut:
                case OPMShortcut.CmdGenericPaste:

                case OPMShortcut.CmdGenericRefresh:
                case OPMShortcut.CmdGenericDelete:
                case OPMShortcut.CmdGenericRename:
                case OPMShortcut.CmdGenericSearch:
                    return false;

                default:
                    return true;
            }
        }
Beispiel #3
0
        public int BuildCommandsMenu(int index, MenuWrapper <T> menu, EventHandler clickHandler)
        {
            for (OPMShortcut cmd = OPMShortcut.CmdPlayPause; cmd <= OPMShortcut.CmdFullScreen; cmd++)
            {
                BuildMenuEntry(cmd, menu, clickHandler, index);
                index++;
            }

            menu.InsertSingleEntry(index, new OPMMenuStripSeparator());
            index++;

            for (OPMShortcut cmd = OPMShortcut.CmdFwd; cmd <= OPMShortcut.CmdVolDn; cmd++)
            {
                BuildMenuEntry(cmd, menu, clickHandler, index);
                index++;
            }

            menu.InsertSingleEntry(index, new OPMMenuStripSeparator());
            index++;

            for (OPMShortcut cmd = OPMShortcut.CmdLoopPlay; cmd <= OPMShortcut.CmdToggleShuffle; cmd++)
            {
                BuildMenuEntry(cmd, menu, clickHandler, index);
                index++;
            }

            return(index);
        }
Beispiel #4
0
        public static string GetCommandDescription(string commandString)
        {
            string[] fields = commandString.Split("?".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (fields.Length != 2)
            {
                return(commandString);
            }

            switch (fields[0].ToLowerInvariant())
            {
            case "playback":
                for (OPMShortcut cmd = OPMShortcut.CmdPlayPause; cmd < OPMShortcut.CmdGenericOpen; cmd++)
                {
                    if (fields[1].ToLowerInvariant() == cmd.ToString().ToLowerInvariant())
                    {
                        return(Translator.Translate("TXT_" + cmd.ToString().ToUpperInvariant()));
                    }
                }
                break;

            case "keypress":
                return(string.Format("KeyPress : {0}", fields[1]));
            }

            return(commandString);
        }
        public static OPMShortcut MapCommand(Keys key)
        {
            if (key == Keys.Space)
            {
                return(OPMShortcut.CmdPlayPause);
            }

            KeysConverter kc          = new KeysConverter();
            string        pressedKeys = kc.ConvertToInvariantString(key);

            for (OPMShortcut cmd = CmdFirst; cmd < CmdLast; cmd++)
            {
                string actionKeys =
                    kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData);
                string altActionKeys =
                    kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData);

                if (pressedKeys == actionKeys || pressedKeys == altActionKeys)
                {
                    return(cmd);
                }
            }

            return(OPMShortcut.CmdOutOfRange);
        }
Beispiel #6
0
        private void BuildThumbnailButtons(bool add)
        {
            if (_commandTarget != null)
            {
                for (OPMShortcut cmd = OPMShortcut.CmdPlayPause; cmd <= OPMShortcut.CmdLoad; cmd++)
                {
                    string name = cmd.ToString().Replace("Cmd", "btn");
                    if (cmd == OPMShortcut.CmdPlayPause)
                    {
                        if (MediaRenderer.DefaultInstance.FilterState == FilterState.Running)
                        {
                            name = "btnPause";
                        }
                        else
                        {
                            name = "btnPlay";
                        }
                    }


                    Bitmap img = OPMedia.UI.ProTONE.Properties.Resources.ResourceManager.GetImage(name);
                    if (img != null)
                    {
                        string btnTitle = Translator.Translate("TXT_" + cmd.ToString().ToUpperInvariant());
                        TaskbarThumbnailManager.Instance.AddThumbnailButton(btnTitle, img, (int)cmd);
                    }
                }

                TaskbarThumbnailManager.Instance.SubmitThumbnailButtons(add);
            }
        }
        public static bool IsConfigurableShortcut(OPMShortcut cmd)
        {
            switch (cmd)
            {
            case OPMShortcut.CmdGenericApply:
            case OPMShortcut.CmdGenericNew:
            case OPMShortcut.CmdGenericOpen:
            case OPMShortcut.CmdGenericSave:
            case OPMShortcut.CmdGenericUndo:
            case OPMShortcut.CmdOpenHelp:
            case OPMShortcut.CmdDumpDebugStats:

            case OPMShortcut.CmdSwitchWindows:

            case OPMShortcut.CmdGenericCopy:
            case OPMShortcut.CmdGenericCut:
            case OPMShortcut.CmdGenericPaste:

            case OPMShortcut.CmdGenericRefresh:
            case OPMShortcut.CmdGenericDelete:
            case OPMShortcut.CmdGenericRename:
            case OPMShortcut.CmdGenericSearch:
                return(false);

            default:
                return(true);
            }
        }
Beispiel #8
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ?
                Translator.Translate(tag) + ": " + param :
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                tsm.Text = tsm.ToolTipText;
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                        ShortcutMapper.GetShortcutString(command);
                }
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText +=
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }

                // TODO FIX
                //if (command == OPMShortcut.CmdGenericOpen && _recentFiles.Count > 0 && AppSettings.MCRememberRecentFiles)
                //{
//                    tsm.ToolTipText += "\r\n" + Translator.Translate("TXT_OPENRECENTFILEDROPDOWN");
//              }
            }
        }
Beispiel #9
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ? Translator.Translate(tag) + ": " + param :
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                string text = tsm.ToolTipText;
                if (text.Length > 45)
                {
                    tsm.Text = text.Substring(0, 45) + "...";
                }
                else
                {
                    tsm.ToolTipText = string.Empty;
                    tsm.Text        = text;
                }

                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                        ShortcutMapper.GetShortcutString(command);
                }
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText +=
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }
            }
        }
 public static void DispatchCommand(OPMShortcut cmd)
 {
     if (enableShortcutDispatch)
     {
         EventDispatch.DispatchEvent(EventNames.ExecuteShortcut,
                                     new OPMShortcutEventArgs(cmd));
     }
 }
        public static void DispatchKey(Keys key)
        {
            OPMShortcut cmd = MapCommand(key);

            if (cmd >= CmdFirst && cmd < CmdLast)
            {
                DispatchCommand(cmd);
            }
        }
Beispiel #12
0
        void MainForm_Load(object sender, EventArgs e)
        {
            #region API tester tab

            cmbCommandType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(RC.CommandType)))
            {
                cmbCommandType.Items.Add(item);
            }

            OPMShortcut[] cmds = new OPMShortcut[]
            {
                OPMShortcut.CmdPlayPause,
                OPMShortcut.CmdStop,
                OPMShortcut.CmdPrev,
                OPMShortcut.CmdNext,
        
                // Full Screen
                OPMShortcut.CmdFullScreen,
        
                // Media seek control
                OPMShortcut.CmdFwd,
                OPMShortcut.CmdRew,
        
                // Volume control
                OPMShortcut.CmdVolUp,
                OPMShortcut.CmdVolDn,
            };

            cmbPlaybackCmd.Items.Clear();
            foreach (var item in cmds)
            {
                cmbPlaybackCmd.Items.Add(item);
            }

            cmbCommandType.SelectedIndex = 0;
            cmbDestination.SelectedIndex = 1;

            txtDestinationName.Text = Environment.MachineName;

            #endregion API tester tab

            #region Simulator tab
            int i = 1000;
            foreach (Control ctl in pnlSimulator.Controls)
            {
                OPMButton btn = (ctl as OPMButton);
                if (btn != null)
                {
                    btn.Click += new EventHandler(OnSimulatorClick);
                    btn.Tag = (i++).ToString();
                }

            }
            #endregion
        }
        private bool VerifyShortcut(KeyEventArgs args)
        {
            OPMShortcut cmd = ShortcutMapper.MapCommand(args.KeyData);

            if (cmd == OPMShortcut.CmdOutOfRange)
            {
                // Key combination currently not assigned so it's OK to use it.
                return(true);
            }

            if (cmd == _cmd)
            {
                // Same command => ok to reassign.
                return(true);
            }

            string cmdOld = cmd.ToString().Replace("Cmd", string.Empty);
            string cmdNew = _cmd.ToString().Replace("Cmd", string.Empty);

            KeysConverter kc  = new KeysConverter();
            string        key = kc.ConvertToInvariantString(args.KeyData);

            if ((args.KeyData == Keys.Space && ShortcutMapper.IsPlayer) ||
                !ShortcutMapper.IsConfigurableShortcut(cmd))
            {
                // Key combination currently assigned
                // to a non-configurable command (e.g. F1 = help)
                MessageDisplay.Show(Translator.Translate("TXT_DUP_SHORTCUT_FIXED", key, cmdOld),
                                    Translator.Translate("TXT_DUPPLICATE_SHORTCUT"),
                                    MessageBoxIcon.Warning);
                return(false);
            }

            if (MessageDisplay.Query(Translator.Translate("TXT_DUP_SHORTCUT_CONFIRM", key, cmdOld, cmdNew),
                                     Translator.Translate("TXT_DUPPLICATE_SHORTCUT"),
                                     MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
            {
                // Key combination already assigned and the user did not want to change it use it.
                return(false);
            }

            // Unassign old shortcut
            if (ShortcutMapper.KeyCommands[(int)cmd].KeyData == args.KeyData)
            {
                // Was used for primary shortcut
                ShortcutMapper.KeyCommands[(int)cmd] = new KeyEventArgs(Keys.None);
            }
            else if (ShortcutMapper.AltKeyCommands[(int)cmd].KeyData == args.KeyData)
            {
                // Was used for alternate shortcut
                ShortcutMapper.AltKeyCommands[(int)cmd] = new KeyEventArgs(Keys.None);
            }

            return(true);
        }
        public static bool IsHiddenShortcut(OPMShortcut cmd)
        {
            switch (cmd)
            {
            case OPMShortcut.CmdDumpDebugStats:
                return(true);

            default:
                return(false);
            }
        }
Beispiel #15
0
 private void ProcessPlaybackCommand(string[] args)
 {
     try
     {
         OPMShortcut cmd = (OPMShortcut)Enum.Parse(typeof(OPMShortcut), args[0]);
         ShortcutMapper.DispatchCommand(cmd);
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
Beispiel #16
0
        private int ShortcutsSorter(OPMShortcut cmd1, OPMShortcut cmd2)
        {
            bool cfg1 = ShortcutMapper.IsConfigurableShortcut(cmd1);
            bool cfg2 = ShortcutMapper.IsConfigurableShortcut(cmd2);

            if (cfg1 != cfg2)
            {
                return(cfg1.CompareTo(cfg2));
            }
            else
            {
                return(cmd1.CompareTo(cmd2));
            }
        }
        private void OnMouseHover(object sender, EventArgs e)
        {
            ToolStripButton btn = sender as ToolStripButton;

            if (btn != null)
            {
                _hoveredItem = btn;

                OPMShortcut cmd         = (OPMShortcut)btn.Tag;
                string      resourceTag = string.Format("TXT_{0}", cmd.ToString().ToUpperInvariant()).Replace("CMD", "BTN");
                string      tipText     = Translator.Translate(resourceTag, ShortcutMapper.GetShortcutString(cmd));
                _tip.ShowSimpleToolTip(tipText, btn.Image);
            }
        }
Beispiel #18
0
        protected virtual bool IsShortcutAllowed(OPMShortcut cmd)
        {
            // By default we don't allow any command but Help and Show Log

            switch (cmd)
            {
            case OPMShortcut.CmdOpenHelp:
            case OPMShortcut.CmdDumpDebugStats:
                return(true);

            default:
                return(false);
            }
        }
Beispiel #19
0
        private void UpdateKey(OPMShortcut cmd)
        {
            KeysConverter kc     = new KeysConverter();
            string        key    = kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)cmd].KeyData);
            string        altKey = kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)cmd].KeyData);

            for (int i = 0; i < lvShortcuts.Items.Count; i++)
            {
                ListViewItem row = lvShortcuts.Items[i];
                if ((OPMShortcut)(row.Tag) == cmd)
                {
                    row.SubItems[hdrKey.Index].Text    = key;
                    row.SubItems[hdrAltkey.Index].Text = altKey;
                }
            }
        }
Beispiel #20
0
 private DialogResult EditCommand(OPMShortcut cmd, bool primary)
 {
     try
     {
         ShortcutMapper.EnableShortcutDispatch = false;
         return(new KeyCommandEditor(cmd, primary).ShowDialog());
     }
     catch
     {
         return(DialogResult.Cancel);
     }
     finally
     {
         ShortcutMapper.EnableShortcutDispatch = true;
     }
 }
Beispiel #21
0
 void lvShortcuts_SubItemEditing(object sender, ListViewSubItemEventArgs args)
 {
     if (args != null && args.Item != null && !args.Handled)
     {
         OPMShortcut cmd = (OPMShortcut)args.Item.Tag;
         if (ShortcutMapper.IsConfigurableShortcut(cmd))
         {
             if (args.SubItemIndex == hdrKey.Index)
             {
                 EditCommand(cmd, true);
             }
             else if (args.SubItemIndex == hdrAltkey.Index)
             {
                 EditCommand(cmd, false);
             }
         }
     }
 }
        public KeyCommandEditor(OPMShortcut cmd, bool primary) :
            base("TXT_EDIT_KEY")
        {
            InitializeComponent();
            _cmd     = cmd;
            _primary = primary;

            this.TopMost      = true;
            this.ControlBox   = true;
            this.MaximizeBox  = false;
            this.MinimizeBox  = false;
            this.IsToolWindow = true;

            this.Load  += new EventHandler(OnLoad);
            this.Shown += new EventHandler(KeyCommandEditor_Shown);
            this.KeyUp += new KeyEventHandler(KeyCommandEditor_KeyUp);

            Application.DoEvents();
        }
        public KeyCommandEditor(OPMShortcut cmd, bool primary) :
            base("TXT_EDIT_KEY")
        {
            InitializeComponent();
            _cmd = cmd;
            _primary = primary;

            this.TopMost = true;
            this.ControlBox = true;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.IsToolWindow = true;

            this.Load += new EventHandler(OnLoad);
            this.Shown += new EventHandler(KeyCommandEditor_Shown);
            this.KeyUp += new KeyEventHandler(KeyCommandEditor_KeyUp);

            Application.DoEvents();
        }
        public static void Save()
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                KeysConverter kc = new KeysConverter();

                for (OPMShortcut cmd = CmdFirst; cmd < CmdLast; cmd++)
                {
                    sb.AppendLine(string.Format("{0};{1};{2}",
                                                cmd,
                                                kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData),
                                                kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData)));
                }

                PersistenceProxy.SaveObject(true, "Keymap", sb.ToString());
            }
            catch { }
        }
Beispiel #25
0
        protected bool ProcessKeyDown(Control ctlSender, Keys key, Keys modifiers)
        {
            if (modifiers == Keys.None && AllowCloseOnKeyDown(key))
            {
                DialogResult = MapDialogResult(key);
                Close();
                return(false);
            }
            else
            {
                OPMShortcut cmd = ShortcutMapper.MapCommand(key);
                if (IsShortcutAllowed(cmd))
                {
                    ShortcutMapper.DispatchCommand(cmd);
                    return(false);
                }
            }

            return(true);
        }
Beispiel #26
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ?
                Translator.Translate(tag) + ": " + param :
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                string text = tsm.ToolTipText;
                if (text.Length > 45)
                {
                    tsm.Text = text.Substring(0, 45) + "...";
                }
                else
                {
                    tsm.ToolTipText = string.Empty;
                    tsm.Text        = text;
                }

                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                        ShortcutMapper.GetShortcutString(command);
                }
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText +=
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }

                if (command == OPMShortcut.CmdGenericOpen && _recentFiles.Count > 0 && BuiltinAddonConfig.MCRememberRecentFiles)
                {
                    tsm.ToolTipText += "\r\n" + Translator.Translate("TXT_OPENRECENTFILEDROPDOWN");
                }
            }
        }
        private void OnButtonPressed(object sender, EventArgs e)
        {
            ToolStripButton btn = sender as ToolStripButton;

            if (btn != null)
            {
                try
                {
                    OPMShortcut cmd = (OPMShortcut)btn.Tag;
                    ShortcutMapper.DispatchCommand(cmd);
                }
                catch (Exception ex)
                {
                    ErrorDispatcher.DispatchError(ex, false);
                }
                finally
                {
                    UpdateStateButtons();
                }
            }
        }
Beispiel #28
0
        public void AttachCommonPlaylistToolsMenu(MenuWrapper <T> menu, MenuType menuType, EventHandler clickHandler, PlaylistItem plItem)
        {
            //OPMShortcut cmdStart = (menuType == MenuType.SingleItem) ?
            //  OPMShortcut.CmdMoveUp : OPMShortcut.CmdClear;

            for (OPMShortcut cmd = OPMShortcut.CmdMoveUp; cmd <= OPMShortcut.CmdSavePlaylist; cmd++)
            {
                switch (cmd)
                {
                case OPMShortcut.CmdMoveUp:
                case OPMShortcut.CmdMoveDown:
                case OPMShortcut.CmdDelete:
                    BuildMenuEntry(cmd, menu, clickHandler, -1, plItem != null);
                    break;

                default:
                    BuildMenuEntry(cmd, menu, clickHandler);
                    break;
                }
            }
        }
        public static string GetShortcutString(OPMShortcut cmd)
        {
            if (cmd >= OPMShortcut.CmdPlayPause && cmd < OPMShortcut.CmdOutOfRange)
            {
                KeysConverter kc = new KeysConverter();

                string actionKeys =
                    kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData);
                string altActionKeys =
                    kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData);

                if (actionKeys == altActionKeys)
                {
                    return(actionKeys);
                }
                else
                {
                    return(actionKeys + " " + Translator.Translate("TXT_OR") + " " + altActionKeys);
                }
            }

            return(string.Empty);
        }
        public static void Load()
        {
            try
            {
                KeysConverter kc = new KeysConverter();

                string keymap = PersistenceProxy.ReadObject(true, "Keymap", string.Empty);
                if (string.IsNullOrEmpty(keymap) == false)
                {
                    string[] lines = keymap.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (lines != null)
                    {
                        foreach (string line in lines)
                        {
                            string[] fields = line.Split(";".ToCharArray());
                            if (fields.Length >= 2)
                            {
                                OPMShortcut cmd = (OPMShortcut)Enum.Parse(typeof(OPMShortcut), fields[0]);
                                keyCommands[(int)cmd] = new KeyEventArgs((Keys)kc.ConvertFromInvariantString(fields[1]));

                                if (fields.Length >= 3)
                                {
                                    altKeyCommands[(int)cmd] = new KeyEventArgs((Keys)kc.ConvertFromInvariantString(fields[2]));
                                }
                                else
                                {
                                    altKeyCommands[(int)cmd] = new KeyEventArgs(keyCommands[(int)cmd].KeyData);
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #31
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ?
                Translator.Translate(tag) + ": " + param :
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                tsm.Text = tsm.ToolTipText;
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                        ShortcutMapper.GetShortcutString(command);
                }
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText +=
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }

                // TODO FIX
                //if (command == OPMShortcut.CmdGenericOpen && _recentFiles.Count > 0 && AppSettings.MCRememberRecentFiles)
                //{
//                    tsm.ToolTipText += "\r\n" + Translator.Translate("TXT_OPENRECENTFILEDROPDOWN");
  //              }
            }
        }
Beispiel #32
0
 private void BuildMenuText(ToolStripItem tsm, string tag, CatalogItem targetItem, OPMShortcut command)
 {
     BuildMenuText(tsm, tag, (targetItem != null) ? targetItem.OrigItemPath : string.Empty, command);
 }
Beispiel #33
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ?
                Translator.Translate(tag) + ": " + param :
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                string text = tsm.ToolTipText;
                if (text.Length > 45)
                {
                    tsm.Text = text.Substring(0, 45) + "...";
                }
                else
                {
                    tsm.ToolTipText = string.Empty;
                    tsm.Text = text;
                }

                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                        ShortcutMapper.GetShortcutString(command);
                }
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText +=
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }

                if (command == OPMShortcut.CmdGenericOpen && _recentFiles.Count > 0 && SkinBuilderConfiguration.RememberRecentFiles)
                {
                    tsm.ToolTipText += "\r\n" + Translator.Translate("TXT_OPENRECENTFILEDROPDOWN");
                }
            }
        }
Beispiel #34
0
        public static string GetShortcutString(OPMShortcut cmd)
        {
            if (cmd >= OPMShortcut.CmdPlayPause && cmd < OPMShortcut.CmdOutOfRange)
            {
                KeysConverter kc = new KeysConverter();
                
                string actionKeys =
                   kc.ConvertToInvariantString(keyCommands[(int)cmd].KeyData);
                string altActionKeys =
                    kc.ConvertToInvariantString(altKeyCommands[(int)cmd].KeyData);

                if (actionKeys == altActionKeys)
                    return actionKeys;
                else
                    return actionKeys + " " + Translator.Translate("TXT_OR") + " " + altActionKeys;

            }

            return string.Empty;
        }
 protected override bool IsShortcutAllowed(OPMShortcut cmd)
 {
     // Any command in range is valid.
     return(ShortcutMapper.CmdFirst <= cmd && cmd <= ShortcutMapper.CmdLast);
 }
Beispiel #36
0
 public static void DispatchCommand(OPMShortcut cmd)
 {
     if (enableShortcutDispatch)
     {
         EventDispatch.DispatchEvent(EventNames.ExecuteShortcut, 
             new OPMShortcutEventArgs(cmd));
     }
 }
Beispiel #37
0
 private void BuildMenuText(ToolStripItem tsm, string tag, CatalogItem targetItem, OPMShortcut command)
 {
     BuildMenuText(tsm, tag, (targetItem != null) ? targetItem.OrigItemPath : string.Empty, command);
 }
Beispiel #38
0
 private DialogResult EditCommand(OPMShortcut cmd, bool primary)
 {
     try
     {
         ShortcutMapper.EnableShortcutDispatch = false;
         return new KeyCommandEditor(cmd, primary).ShowDialog();
     }
     catch
     {
         return DialogResult.Cancel;
     }
     finally
     {
         ShortcutMapper.EnableShortcutDispatch = true;
     }
 }
Beispiel #39
0
        private int ShortcutsSorter(OPMShortcut cmd1, OPMShortcut cmd2)
        {
            bool cfg1 = ShortcutMapper.IsConfigurableShortcut(cmd1);
            bool cfg2 = ShortcutMapper.IsConfigurableShortcut(cmd2);

            if (cfg1 != cfg2)
            {
                return cfg1.CompareTo(cfg2);
            }
            else
            {
                return cmd1.CompareTo(cmd2);
            }
        }
Beispiel #40
0
        protected virtual bool IsShortcutAllowed(OPMShortcut cmd)
        {
            // By default we don't allow any command but Help and Show Log

            switch (cmd)
            {
                case OPMShortcut.CmdOpenHelp:
                case OPMShortcut.CmdShowLogConsole:
                case OPMShortcut.CmdDumpDebugStats:
                    return true;

                default:
                    return false;
            }
        }
Beispiel #41
0
 protected override bool IsShortcutAllowed(OPMShortcut cmd)
 {
     // Any command in range is valid.
     return (ShortcutMapper.CmdFirst <= cmd && cmd <= ShortcutMapper.CmdLast);
 }
Beispiel #42
0
 public OPMShortcutEventArgs(OPMShortcut cmd)
 {
     this.cmd = cmd;
 }
Beispiel #43
0
        private void UpdateKey(OPMShortcut cmd)
        {
            KeysConverter kc = new KeysConverter();
            string key = kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)cmd].KeyData);
            string altKey = kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)cmd].KeyData);

            for (int i = 0; i < lvShortcuts.Items.Count; i++)
            {
                ListViewItem row = lvShortcuts.Items[i];
                if ((OPMShortcut)(row.Tag) == cmd)
                {
                    row.SubItems[hdrKey.Index].Text = key;
                    row.SubItems[hdrAltkey.Index].Text = altKey;
                }
            }
        }
Beispiel #44
0
        private void BuildMenuText(ToolStripItem tsm, string tag, string param, OPMShortcut command)
        {
            tsm.ToolTipText =
                (tsm.Enabled && !string.IsNullOrEmpty(param)) ? Translator.Translate(tag) + ": " + param : 
                Translator.Translate(tag);
            tsm.Text = Translator.Translate(tag);

            if (tsm is OPMToolStripMenuItem)
            {
                string text = tsm.ToolTipText;
                if (text.Length > 45)
                {
                    tsm.Text = text.Substring(0, 45) + "...";
                }
                else
                {
                    tsm.ToolTipText = string.Empty;
                    tsm.Text = text;
                }
                
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    (tsm as OPMToolStripMenuItem).ShortcutKeyDisplayString = 
                        ShortcutMapper.GetShortcutString(command);
                }
                
            }
            else
            {
                if (command != OPMShortcut.CmdOutOfRange)
                {
                    tsm.ToolTipText += 
                        string.Format(" ({0})", ShortcutMapper.GetShortcutString(command));
                }
            }
        }
        void MainForm_Load(object sender, EventArgs e)
        {
            #region API tester tab

            cmbCommandType.Items.Clear();
            foreach (var item in Enum.GetValues(typeof(RC.CommandType)))
            {
                cmbCommandType.Items.Add(item);
            }

            OPMShortcut[] cmds = new OPMShortcut[]
            {
                OPMShortcut.CmdPlayPause,
                OPMShortcut.CmdStop,
                OPMShortcut.CmdPrev,
                OPMShortcut.CmdNext,

                // Full Screen
                OPMShortcut.CmdFullScreen,

                // Media seek control
                OPMShortcut.CmdFwd,
                OPMShortcut.CmdRew,

                // Volume control
                OPMShortcut.CmdVolUp,
                OPMShortcut.CmdVolDn,
            };

            cmbPlaybackCmd.Items.Clear();
            foreach (var item in cmds)
            {
                cmbPlaybackCmd.Items.Add(item);
            }

            cmbCommandType.SelectedIndex = 0;
            cmbDestination.SelectedIndex = 1;

            txtDestinationName.Text = Environment.MachineName;

            #endregion API tester tab

            #region Simulator tab
            int i = 1000;
            foreach (Control ctl in pnlSimulator.Controls)
            {
                OPMButton btn = (ctl as OPMButton);
                if (btn != null)
                {
                    btn.Click += new EventHandler(OnSimulatorClick);
                    btn.Tag    = (i++).ToString();
                }
            }
            #endregion

            #region WCF tab
            WCFOpen();
            _tmrWCFCheck          = new Timer();
            _tmrWCFCheck.Interval = 2000;
            _tmrWCFCheck.Tick    += new EventHandler(_tmrWCFCheck_Tick);
            _tmrWCFCheck.Start();
            #endregion
        }
Beispiel #46
0
        public static bool IsHiddenShortcut(OPMShortcut cmd)
        {
            switch (cmd)
            {
                case OPMShortcut.CmdDumpDebugStats:
                    return true;

                default:
                    return false;
            }
        }