Example #1
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");
//              }
            }
        }
Example #2
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));
                }
            }
        }
        protected AddonHostForm()
            : base("TXT_APP_NAME")
        {
            InitializeComponent();
            SetNavPanelOrientation(Orientation.Vertical);

            this.Shown += new EventHandler(MainForm_Load);
            //this.Load += new EventHandler(MainForm_Load);

            this.HandleDestroyed += new EventHandler(MainForm_HandleDestroyed);

            this.ShowInTaskbar   = true;
            lblNoItems.Text      = Translator.Translate("TXT_THEREARENOITEMS");
            lblNoProperties.Text = Translator.Translate("TXT_THEREARENOITEMS");
            lblNoPreview.Text    = Translator.Translate("TXT_THEREARENOITEMS");

            this.Location    = AppConfig.WindowLocation;
            this.Size        = AppConfig.WindowSize;
            this.WindowState = AppConfig.WindowState;

            tsmiSettings.ShortcutKeyDisplayString =
                ShortcutMapper.GetShortcutString(OPMShortcut.CmdOpenSettings);

            tsmiSettings.Image = Resources.Settings.Transparent();

            SetColors();

            ExitEditPathMode(false);
        }
Example #4
0
 private void OnRestoreDefaults(object sender, EventArgs e)
 {
     if (MessageDisplay.Query("TXT_CONFIRM_RESTORE", "TXT_RESTOREDEFAULTS",
                              MessageBoxIcon.Question) == DialogResult.Yes)
     {
         ShortcutMapper.RestoreDefaults(true);
         DisplayKeys();
     }
 }
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                if (!ProcessCommandLine(true))
                {
                    try
                    {
                        RemoteControllableApplication.Start(ProTONEConstants.PlayerName);

                        ProcessCommandLine(false);

                        Translator.SetInterfaceLanguage(AppConfig.LanguageID);
                        Translator.RegisterTranslationAssembly(typeof(MediaPlayer).Assembly);
                        Translator.RegisterTranslationAssembly(typeof(MainForm).Assembly);

                        ShortcutMapper.IsPlayer = true;

                        mainFrm = new MainForm();

                        foreach (BasicCommand cmd in _commandQueue)
                        {
                            mainFrm.EnqueueCommand(cmd);
                        }

                        Application.Run(mainFrm);
                        mainFrm.Dispose();


                        ShortcutMapper.Save();
                    }
                    catch (MultipleInstancesException ex)
                    {
                        Logger.LogWarning(ex.Message);

                        // Send an activate command to the main instance
                        RemoteControlHelper.SendPlayerCommand(CommandType.Activate, null);
                    }
                    catch (Exception ex)
                    {
                        ErrorDispatcher.DispatchFatalError(ex);
                    }
                    finally
                    {
                        RemoteControllableApplication.Stop();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorDispatcher.DispatchFatalError(ex);
            }
        }
        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);
        }
Example #7
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);
     }
 }
Example #8
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);
            }
        }
Example #10
0
        private void AttachFileMenuItems(PlaylistItem playlistItem, MenuWrapper <T> menu, EventHandler clickHandler)
        {
            if (EnableSubtitleEntry(playlistItem))
            {
                if (menu.MenuItemsCount > 0)
                {
                    menu.AddSingleEntry(new OPMMenuStripSeparator());
                }

                string str = Translator.Translate("TXT_SEARCH_SUBTITLES");
                OPMToolStripMenuItem tsmi = new OPMToolStripMenuItem(str);
                tsmi.Click += clickHandler;
                tsmi.Tag    = OPMShortcut.CmdSearchSubtitles;
                tsmi.ShortcutKeyDisplayString = ShortcutMapper.GetShortcutString(OPMShortcut.CmdSearchSubtitles);

                menu.AddSingleEntry(tsmi);
            }
        }
Example #11
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);
             }
         }
     }
 }
Example #12
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);
        }
Example #13
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();
                }
            }
        }
        private void OnSettingsChanged(object sender, EventArgs e)
        {
            try
            {
                Modified = true;

                if (sender == chkEnablePlaylistEvt)
                {
                    ShortcutMapper.DispatchCommand(OPMShortcut.CmdPlaylistEnd);
                }

                UnsubscribeAll();

                SystemScheduler.PlaylistEventEnabled = chkEnablePlaylistEvt.Checked;
                ManageVisibility();
            }
            finally
            {
                SubscribeAll();
            }
        }
Example #16
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                if (m.Msg == (int)Messages.WM_COMMAND)
                {
                    if (ThumbButton.Clicked == User32.HIWORD((long)m.WParam))
                    {
                        int id = User32.LOWORD((long)m.WParam);

                        if (!MainThread.AreModalFormsOpen)
                        {
                            ShortcutMapper.DispatchCommand((OPMShortcut)id);

                            // If an application processes this message, it should return zero.
                            m.Result = IntPtr.Zero;
                        }
                    }
                }
            }
            catch { }

            base.WndProc(ref m);
        }
Example #17
0
        public void DisplayKeys()
        {
            try
            {
                User32.LockWindowUpdate(this.Handle);

                this.SuspendLayout();

                lvShortcuts.Items.Clear();

                List <OPMShortcut> shortcuts = new List <OPMShortcut>();
                for (OPMShortcut cmd = ShortcutMapper.CmdFirst; cmd < ShortcutMapper.CmdLast; cmd++)
                {
                    shortcuts.Add(cmd);
                }

                shortcuts.Sort(ShortcutsSorter);

                StringBuilder sb = new StringBuilder();

                foreach (OPMShortcut cmd in shortcuts)
                {
                    if (ShortcutMapper.IsHiddenShortcut(cmd))
                    {
                        continue;
                    }

                    string        cmdName = cmd.ToString();
                    string        desc    = Translator.Translate("TXT_" + cmdName.ToUpperInvariant());
                    KeysConverter kc      = new KeysConverter();
                    string        key     = kc.ConvertToInvariantString(ShortcutMapper.KeyCommands[(int)cmd].KeyData);
                    string        altKey  = kc.ConvertToInvariantString(ShortcutMapper.AltKeyCommands[(int)cmd].KeyData);

                    ListViewItem item = new ListViewItem(cmdName.Replace("Cmd", string.Empty));

                    OPMListViewSubItem subItemDesc   = new OPMListViewSubItem(item, desc);
                    OPMListViewSubItem subItemKey    = null;
                    OPMListViewSubItem subItemAltKey = null;

                    if (ShortcutMapper.IsConfigurableShortcut(cmd))
                    {
                        subItemKey    = new OPMListViewSubItem(_llEditKeys, item, key);
                        subItemAltKey = new OPMListViewSubItem(_llEditKeys, item, altKey);
                    }
                    else
                    {
                        subItemKey    = new OPMListViewSubItem(item, key);
                        subItemAltKey = new OPMListViewSubItem(item, altKey);
                    }

                    item.SubItems.Add(subItemDesc);
                    item.SubItems.Add(subItemKey);
                    item.SubItems.Add(subItemAltKey);


                    item.Tag = cmd;
                    lvShortcuts.Items.Add(item);

                    sb.AppendLine("<tr>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(item.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemDesc.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemKey.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine(subItemAltKey.Text);
                    sb.AppendLine("</td>");

                    sb.AppendLine("<td>");
                    sb.AppendLine("Yes");
                    sb.AppendLine("</td>");

                    sb.AppendLine("</tr>");
                }

                this.ResumeLayout();
            }
            finally
            {
                User32.LockWindowUpdate(IntPtr.Zero);
            }
        }
 private void tXTAPPHELPToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ShortcutMapper.DispatchCommand(OPMShortcut.CmdOpenHelp);
 }
 private void btnSettings_Click(object sender, EventArgs e)
 {
     ShortcutMapper.DispatchCommand(OPMShortcut.CmdOpenSettings);
 }
 public void OnKeymapChanged()
 {
     tsmiSettings.ShortcutKeyDisplayString =
         ShortcutMapper.GetShortcutString(OPMShortcut.CmdOpenSettings);
 }
Example #21
0
        private void BuildMenuEntry(OPMShortcut cmd, MenuWrapper <T> menu, EventHandler clickHandler, int index = -1, bool enabled = true)
        {
            if (cmd == OPMShortcut.CmdOpenDisk)
            {
                if (VideoDVDHelpers.IsOSSupported == false)
                {
                    return;
                }
            }

            string shortcuts = ShortcutMapper.GetShortcutString(cmd);
            string menuName  = cmd.ToString().ToUpperInvariant().Replace("CMD", "MNU");
            string imageName = "btn" + cmd.ToString().Replace("Cmd", "");

            string desc = Translator.Translate("TXT_" + menuName);

            OPMToolStripMenuItem tsmi = new OPMToolStripMenuItem(desc);

            tsmi.Click += clickHandler;
            tsmi.Tag    = cmd;
            tsmi.ShortcutKeyDisplayString = shortcuts;

            switch (cmd)
            {
            case OPMShortcut.CmdMoveUp:
                tsmi.Image = OPMedia.UI.Properties.Resources.Up16;
                break;

            case OPMShortcut.CmdMoveDown:
                tsmi.Image = OPMedia.UI.Properties.Resources.Down16;
                break;

            case OPMShortcut.CmdDelete:
                tsmi.Image = OPMedia.UI.Properties.Resources.Delete16;
                break;

            case OPMShortcut.CmdLoadPlaylist:
                tsmi.Image = OPMedia.UI.Properties.Resources.Open16;
                break;

            case OPMShortcut.CmdSavePlaylist:
                tsmi.Image = OPMedia.UI.Properties.Resources.Save16;
                break;

            case OPMShortcut.CmdOpenDisk:
                tsmi.Image = ImageProcessing.DVD;
                break;

            case OPMShortcut.CmdOpenURL:
                tsmi.Image = OPMedia.Core.Properties.Resources.Internet;
                break;

            case OPMShortcut.CmdPlayPause:
            {
                Bitmap img = null;

                switch (MediaRenderer.DefaultInstance.FilterState)
                {
                case Runtime.ProTONE.Rendering.DS.BaseClasses.FilterState.Paused:
                    img = Resources.btnPlay;
                    break;

                case Runtime.ProTONE.Rendering.DS.BaseClasses.FilterState.Running:
                    img = Resources.btnPause;
                    break;

                default:
                    img = Resources.btnPlay;
                    break;
                }

                img.MakeTransparent(ThemeManager.TransparentColor);
                tsmi.Image = img;
            }
            break;

            case OPMShortcut.CmdCfgAudio:
                tsmi.Image = ImageProcessing.AudioFile16;
                break;

            case OPMShortcut.CmdCfgVideo:
                tsmi.Image = ImageProcessing.VideoFile16;
                break;

            case OPMShortcut.CmdCfgSubtitles:
                tsmi.Image = ImageProcessing.Subtitle16;
                break;

            case OPMShortcut.CmdOpenSettings:
                tsmi.Image = OPMedia.UI.Properties.Resources.Settings16;
                break;

            case OPMShortcut.CmdCfgTimer:
                tsmi.Image = Resources.IconTime;
                break;

            default:
                tsmi.Image = Resources.ResourceManager.GetImage(imageName);
                break;
            }

            tsmi.Enabled = enabled;

            if (index >= 0)
            {
                menu.InsertSingleEntry(index, tsmi);
            }
            else
            {
                menu.AddSingleEntry(tsmi);
            }
        }
Example #22
0
        void cmsMain_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = MainThread.AreModalFormsOpen;
            if (e.Cancel)
            {
                MainThread.ModalForm.Activate();
                return;
            }

            cmsMain.SuspendLayout();

            while (_cmdMenusCount > 0)
            {
                cmsMain.Items.RemoveAt(0);
                _cmdMenusCount--;
            }

            _cmdMenusCount = new MenuBuilder <ContextMenuStrip>(null).BuildCommandsMenu(0,
                                                                                        new MenuWrapper <ContextMenuStrip>(cmsMain), new EventHandler(NotifyMenuClick));

            foreach (ToolStripItem tsi in cmsMain.Items)
            {
                if (tsi == mnuMediaState)
                {
                    continue;
                }

                string text = tsi.Text;

                if (text.Length > 45)
                {
                    tsi.Text        = text.Substring(0, 45) + "...";
                    tsi.ToolTipText = text;
                }
                else
                {
                    tsi.ToolTipText = "";
                }

                if (tsi is OPMToolStripMenuItem && tsi.Tag != null)
                {
                    switch ((OPMShortcut)tsi.Tag)
                    {
                    case OPMShortcut.CmdToggleShuffle:
                        (tsi as OPMToolStripMenuItem).Checked = ProTONEConfig.ShufflePlaylist;
                        break;

                    case OPMShortcut.CmdPlaylistEnd:
                        (tsi as OPMToolStripMenuItem).Checked = SystemScheduler.PlaylistEventEnabled;
                        break;

                    case OPMShortcut.CmdLoopPlay:
                        (tsi as OPMToolStripMenuItem).Checked = ProTONEConfig.LoopPlay;
                        break;
                    }

                    if (tsi.Tag != null)
                    {
                        (tsi as OPMToolStripMenuItem).ShortcutKeyDisplayString =
                            ShortcutMapper.GetShortcutString((OPMShortcut)tsi.Tag);
                    }
                }
            }

            // Dummy playlist item  - required to prevent initial "delayed" opening
            mnuPlaylistPlaceholder.DropDownItems.Add(string.Empty);
            mnuPlaylistPlaceholder.DropDownOpening += new EventHandler(mnuPlaylist_DropDownOpening);

            mnuTools.DropDownItems.Add(string.Empty);
            mnuTools.DropDownOpening += new EventHandler(mnuTools_DropDownOpening);

            volumeScale.Width = timeScale.Width = 250;

            cmsMain.ResumeLayout();
        }
Example #23
0
        public void HandlePlaylistItemMenuClick(object sender, EventArgs e)
        {
            OPMToolStripMenuItem senderMenu = (sender as OPMToolStripMenuItem);

            if (senderMenu != null)
            {
                try
                {
                    senderMenu.Enabled = false;

                    if (senderMenu.Tag != null)
                    {
                        if (senderMenu.Tag is PlaylistSubItem)
                        {
                            if (senderMenu.Tag is DvdSubItem)
                            {
                                DvdSubItem            si   = senderMenu.Tag as DvdSubItem;
                                DvdRenderingStartHint hint =
                                    (si != null) ?
                                    si.StartHint as DvdRenderingStartHint : null;

                                if (hint != null && hint.IsSubtitleHint)
                                {
                                    MediaRenderer.DefaultInstance.SubtitleStream = hint.SID;
                                    return;
                                }
                            }

                            if (senderMenu.Tag is AudioCdSubItem)
                            {
                                CDAFileInfo cdfi = (senderMenu.Tag as AudioCdSubItem).Parent.MediaFileInfo as CDAFileInfo;
                                if (cdfi != null)
                                {
                                    cdfi.RefreshDisk();
                                    EventDispatch.DispatchEvent(LocalEventNames.UpdatePlaylistNames, true);
                                }
                            }
                            else
                            {
                                PlaylistSubItem psi = senderMenu.Tag as PlaylistSubItem;
                                if (psi != null && psi.StartHint != null)
                                {
                                    JumpToPlaylistSubItem(senderMenu.Tag as PlaylistSubItem);
                                }
                            }
                        }
                        else if (senderMenu.Tag is PlaylistItem)
                        {
                            JumpToPlaylistItem(senderMenu.Tag as PlaylistItem);
                        }
                        else
                        {
                            ShortcutMapper.DispatchCommand((OPMShortcut)senderMenu.Tag);
                        }
                    }
                }
                finally
                {
                    senderMenu.Enabled = true;
                }
            }
        }