protected override void SaveInternal()
        {
            if (!Modified)
            {
                return;
            }

            if (cbShellIntegration.Checked != SuiteRegistrationSupport.IsContextMenuHandlerRegistered())
            {
                if (cbShellIntegration.Checked)
                {
                    SuiteRegistrationSupport.RegisterContextMenuHandler();
                }
                else
                {
                    SuiteRegistrationSupport.UnregisterContextMenuHandler();
                }
            }

            SaveFileTypes(pnlAudioFiles);
            SaveFileTypes(pnlVideoFiles);
            SaveFileTypes(pnlPlaylists);

            ProTONEConfig.ExplorerLaunchType =
                (cmbExplorerLaunchType.SelectedItem as ExplorerLaunchType).CommandType.ToString();


            SuiteRegistrationSupport.ReloadFileAssociations();
        }
        public FileTypesPanel() : base()
        {
            this.Title = "TXT_S_FILETYPES";

            InitializeComponent();

            hdrAudio.Image     = ImageProcessing.AudioFile16;
            hdrVideo.Image     = ImageProcessing.VideoFile16;
            hdrPlaylists.Image = ImageProcessing.Playlist16;

            Translator.TranslateControl(this, DesignMode);
            ThemeManager.SetFont(btnSelAllAudio, FontSizes.Small);
            ThemeManager.SetFont(btnSelAllPlaylists, FontSizes.Small);
            ThemeManager.SetFont(btnSelAllVideo, FontSizes.Small);
            ThemeManager.SetFont(btnUnselAllAudio, FontSizes.Small);
            ThemeManager.SetFont(btnUnselAllPlaylists, FontSizes.Small);
            ThemeManager.SetFont(btnUnselAllVideo, FontSizes.Small);

            cbShellIntegration.Checked = SuiteRegistrationSupport.IsContextMenuHandlerRegistered();

            ActivateShellIntegration();
            FillExplorerLaunchTypes();

            this.Enabled = AppConfig.CurrentUserIsAdministrator;

            this.HandleCreated += new EventHandler(FileTypesPanel_HandleCreated);
        }
        public static bool ProcessCommandLine(bool testForShellExec)
        {
            string[] cmdLineArgs = Environment.GetCommandLineArgs();

            if (testForShellExec && cmdLineArgs.Length > 1 && cmdLineArgs[1].ToLowerInvariant() == "launch")
            {
                List <string> files = new List <string>();
                for (int i = 2; i < cmdLineArgs.Length; i++)
                {
                    files.Add(cmdLineArgs[i]);
                }

                try
                {
                    CommandType cmdType = (CommandType)Enum.Parse(typeof(CommandType),
                                                                  ProTONEConfig.ExplorerLaunchType);

                    if (SuiteRegistrationSupport.IsContextMenuHandlerRegistered() &&
                        (cmdType == CommandType.PlayFiles || cmdType == CommandType.EnqueueFiles))
                    {
                        if (RemoteControlHelper.IsPlayerRunning())
                        {
                            // There is another player instance that is running.
                            // Just pass the command to that instance and exit.
                            RemoteControlHelper.SendPlayerCommand(cmdType, files.ToArray());
                        }
                        else
                        {
                            // There is no other player instance.
                            // This instance needs to process the command itself.

                            // Note: when player is launched like this - clear previous playlist first.
                            _commandQueue.Add(BasicCommand.Create(CommandType.ClearPlaylist));

                            _commandQueue.Add(BasicCommand.Create(cmdType, files.ToArray()));

                            return(false); // Don't exit
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorDispatcher.DispatchError(ex, false);
                }

                return(true);
            }

            return(false);
        }
        public static void UnregisterServer(string s)
        {
            try
            {
                Logger.LogInfo("Attempt to unregister OPMedia.ShellSupport ...");

                SuiteRegistrationSupport.Init(MediaRenderer.GetSupportedFileProvider());
                SuiteRegistrationSupport.UnregisterKnownFileTypes();
                SuiteRegistrationSupport.UnregisterContextMenuHandler();
                SuiteRegistrationSupport.ReloadFileAssociations();

                Logger.LogInfo("OPMedia.ShellSupport was succesfully unregistered !");
            }
            catch (Exception exception)
            {
                ErrorDispatcher.DispatchFatalError("Fatal unregistration error: " + exception.Message);
            }
        }
        private MediaRenderer(bool isDefaultInstance)
        {
            streamRenderer = null;

            SuiteRegistrationSupport.Init(GetSupportedFileProvider());

            timerCheckState          = new Timer();
            timerCheckState.Enabled  = true;
            timerCheckState.Interval = 500;
            timerCheckState.Start();
            timerCheckState.Tick += new EventHandler(timerCheckState_Tick);

            if (isDefaultInstance &&
                ProTONEConfig.IsPlayer &&
                ProTONEConfig.SignalAnalisysFunctionActive(SignalAnalisysFunction.WCFInterface))
            {
                InternalInitSignalAnalisysWCF();
            }
        }
        private void SaveFileTypes(OPMFlowLayoutPanel pnl)
        {
            foreach (Control ctl in pnl.Controls)
            {
                OPMCheckBox cb = ctl as OPMCheckBox;
                if (cb != null)
                {
                    string fileType     = cb.Text;
                    bool   isRegistered = SuiteRegistrationSupport.IsFileTypeRegistered(fileType);

                    if (cb.Checked != isRegistered)
                    {
                        if (cb.Checked)
                        {
                            SuiteRegistrationSupport.RegisterFileType(fileType, false);
                        }
                        else
                        {
                            SuiteRegistrationSupport.UnregisterFileType(fileType, false);
                        }
                    }
                }
            }
        }
        private void FillFileTypeAssociations()
        {
            pnlAudioFiles.Padding = new Padding(0);
            pnlVideoFiles.Padding = new Padding(0);
            pnlPlaylists.Padding  = new Padding(0);
            pnlAudioFiles.Margin  = new Padding(0);
            pnlVideoFiles.Margin  = new Padding(0);
            pnlPlaylists.Margin   = new Padding(0);

            foreach (string str in MediaRenderer.SupportedAudioTypes)
            {
                bool   isRegistered = SuiteRegistrationSupport.IsFileTypeRegistered(str);
                string type         = str.ToUpperInvariant();

                OPMCheckBox cb = CreateCheckBox(type, isRegistered);
                pnlAudioFiles.Controls.Add(cb);
            }

            foreach (string str in MediaRenderer.SupportedVideoTypes)
            {
                bool   isRegistered = SuiteRegistrationSupport.IsFileTypeRegistered(str);
                string type         = str.ToUpperInvariant();

                OPMCheckBox cb = CreateCheckBox(type, isRegistered);
                pnlVideoFiles.Controls.Add(cb);
            }

            foreach (string str in MediaRenderer.SupportedPlaylists)
            {
                bool   isRegistered = SuiteRegistrationSupport.IsFileTypeRegistered(str);
                string type         = str.ToUpperInvariant();

                OPMCheckBox cb = CreateCheckBox(type, isRegistered);
                pnlPlaylists.Controls.Add(cb);
            }
        }