Пример #1
0
        private bool CancelDebugging(bool doClose = true)
        {
            //the UIMessages handler will return true for 'Yes' and false for 'No'
            var msg = UIMessages.Question(
                "Are you sure? If you cancel debugging, " +
                "you will need to restart PlexDL with the appropriate flags in order to resume.");

            //the user must have clicked 'No'; cancel operation
            if (!msg)
            {
                return(false);
            }

            //the user must have clicked 'Yes'; disable debugging,
            Flags.IsDebug = false;

            //and close the form.
            if (doClose)
            {
                Close();
            }

            //default
            return(true);
        }
Пример #2
0
        private void Startup()
        {
            try
            {
                //reset counter
                RefreshCount = 0;

                //poll rate GUI setup
                UpdatePollRate();

                //initial value refresh
                DoRefresh();

                //start the automatic refresh timer
                tmrAutoRefresh.Start();
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"DebugStartupError");

                //inform the user
                UIMessages.Error($@"Debug monitor startup error: {ex.Message}");
            }
        }
Пример #3
0
        public static DataTable AttributesFromObject(object content, bool silent = false)
        {
            var table = new DataTable();

            try
            {
                var contentType = content.GetType();
                var moviesType  = typeof(PlexMovie);
                var musicType   = typeof(PlexMusic);
                var tvShowType  = typeof(PlexTvShow);

                if (contentType == moviesType)
                {
                    table = MovieAttributesFromObject((PlexMovie)content, silent);
                }
                else if (contentType == musicType)
                {
                    table = MusicAttributesFromObject((PlexMusic)content, silent);
                }
                else if (contentType == tvShowType)
                {
                    table = TvAttributesFromObject((PlexTvShow)content, silent);
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "AttributeTableError");
                if (!silent)
                {
                    UIMessages.Error("Error occurred whilst building content attribute table:\n\n" + ex, @"Data Error");
                }
            }

            return(table);
        }
Пример #4
0
        private void PlayWorker(object sender, WaitWindowEventArgs e)
        {
            if (_mPlayer.Playing)
            {
                return;
            }

            if (Methods.RemoteFileExists(StreamingContent.StreamInformation.Links.View))
            {
                //file/URI to play
                var fileName = (string)e.Arguments[0];

                //GUI and worker methods
                StartPlayer(fileName);
                SetIconPause();

                //tooltip set
                tipMain.SetToolTip(btnPlayPause, @"Pause Playback");

                //stop button enable
                btnStop.Enabled = true;
            }
            else
            {
                UIMessages.Error(
                    @"Couldn't load the stream because the remote file doesn't exist or returned an error",
                    @"Network Error");
            }
        }
Пример #5
0
        public static DataTable GetFilteredTable(SearchData data, bool silent = true)
        {
            //UIMessages.Info(data.SearchTable.Rows.Count.ToString());
            //UIMessages.Info(data.SearchTable.Rows[0].ItemArray.Length.ToString());
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            DataTable tblFiltered = null;

            var rowCollection =
                (DataRow[])WaitWindow.WaitWindow.Show(GetSearchEnum, "Filtering Records", data.SearchTerm,
                                                      data.SearchRule, data.SearchColumn, data.SearchTable);

            if (rowCollection.Any())
            {
                tblFiltered = GetSearchTable(rowCollection);
            }
            else
            {
                if (!silent)
                {
                    UIMessages.Info(@"No Results Found for '" + data.SearchTerm + @"'");
                }
            }

            //UIMessages.Info("Filtered Table:" + filteredTable.Rows.Count + "\nTitles Table:" + titlesTable.Rows.Count);
            return(tblFiltered);
        }
Пример #6
0
        private void DoLoad()
        {
            try
            {
                //validate queue
                if (QueueProvider != null)
                {
                    //go through each QueueElement
                }
                else
                {
                    //log the error
                    LoggingHelpers.RecordException(@"Null HTTP Queue provider", @"DownloadManagerLoadError");

                    //alert user
                    UIMessages.Warning(@"Null HTTP Queue provider was specified to the Download Manager; couldn't load the form correctly.");

                    //close the form
                    Close();
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"DownloadManagerLoadError");

                //alert the user
                UIMessages.Error($"Error in download manager load:\n\n{ex}");

                //close the form
                Close();
            }
        }
Пример #7
0
        /// <summary>
        /// Attempts to run PlexDL in 'Open With' mode
        /// </summary>
        /// <param name="file"></param>
        /// <param name="appRun"></param>
        public static void OpenWith(string file, bool appRun = true)
        {
            //Windows has passed a file; we need to check what type it is
            var ext = Path.GetExtension(file);

            //check if it's a supported file-type
            if (CheckAgainstSupportedFiles(file))
            {
                //try the metadata import and then show it if successful
                try
                {
                    var metadata = MetadataIO.MetadataFromFile(file);
                    if (metadata != null)
                    {
                        UIUtils.RunMetadataWindow(metadata, appRun);
                    }
                    else
                    {
                        UIMessages.Error(@"Metadata parse failed; null result.");
                    }
                }
                catch (Exception ex)
                {
                    LoggingHelpers.RecordException(ex.Message, @"StartupLoadPxz");
                    UIMessages.Error($"Error occurred whilst loading PXZ file:\n\n{ex}");
                }
            }
            else
            {
                UIMessages.Error(@"PlexDL doesn't recognise this file-type: '" + ext + @"'",
                                 @"Validation Error");
            }
        }
Пример #8
0
        private void DoReset()
        {
            try
            {
                //query user
                if (UIMessages.Question(@"Are you sure? This will clear all settings in the current session."))
                {
                    //do the reset
                    ObjectProvider.Settings = new ApplicationOptions();

                    //refresh PropertyGrid on this form
                    settingsGrid.SelectedObject = ObjectProvider.Settings;
                    settingsGrid.Refresh();

                    //show alert
                    UIMessages.Info(@"Settings reset");
                }
            }
            catch (Exception ex)
            {
                //record error
                LoggingHelpers.RecordException(ex.Message, @"ResetSettingsError");

                //alert user
                UIMessages.Error($"Error while resetting\n\n{ex}");
            }
        }
Пример #9
0
        public DataTable Attributes()
        {
            var table = new DataTable();

            table.Columns.Add(@"Attribute", typeof(string));
            table.Columns.Add(@"Value", typeof(string));

            try
            {
                object[] authorName    = { @"User", Pxz.FileIndex.Author.UserAccount };
                object[] authorDisplay = { @"Display Name", Pxz.FileIndex.Author.DisplayName };
                object[] authorMachine = { @"PC Name", Pxz.FileIndex.Author.MachineName };
                object[] formatVersion = { @"Version", Pxz.FileIndex.FormatVersion.ToString() };
                object[] buildState    = { @"Release State", Pxz.FileIndex.BuildState.ToString() };
                object[] recordCount   = { @"# Records", Pxz.FileIndex.RecordReference.Count.ToString() };

                table.Rows.Add(authorName);
                table.Rows.Add(authorDisplay);
                table.Rows.Add(authorMachine);
                table.Rows.Add(formatVersion);
                table.Rows.Add(buildState);
                table.Rows.Add(recordCount);
            }
            catch (Exception ex)
            {
                UIMessages.Error(ex.ToString());
            }

            return(table);
        }
Пример #10
0
        private static void DoCommitDefault()
        {
            try
            {
                //null validation
                if (ObjectProvider.Settings != null)
                {
                    //returns true if the commit operation succeeded
                    if (ObjectProvider.Settings.CommitDefaultSettings())
                    {
                        //alert user
                        UIMessages.Info(@"Successfully saved settings");
                    }
                    else
                    {
                        //alert user
                        UIMessages.Error(@"An unknown error occurred whilst saving settings");
                    }
                }
                else
                {
                    //alert user
                    UIMessages.Error(@"Couldn't export settings because they were null");
                }
            }
            catch (Exception ex)
            {
                //record error
                LoggingHelpers.RecordException(ex.Message, @"SaveDefaultError");

                //alert user
                UIMessages.Error($"Error exporting to default\n\n{ex}");
            }
        }
Пример #11
0
        private void DoPxzLoad(string fileName)
        {
            try
            {
                //ensure the file exists
                if (File.Exists(fileName))
                {
                    //attempt PXZ load
                    var pxz = LoadPxz(fileName);

                    //set the global
                    Pxz = pxz;

                    //perform UI load
                    DoPxzLoad();
                }
                else
                {
                    //alert the user
                    UIMessages.Error(@"Couldn't find the specified PXZ file", @"Validation Error");
                }
            }
            catch (Exception ex)
            {
                UIMessages.Error(ex.ToString(), @"Load PXZ File Error");
            }
        }
Пример #12
0
        private static PxzFile LoadPxz(string fileName, bool waitWindow = true)
        {
            //multi-threaded handler
            if (waitWindow)
            {
                return((PxzFile)WaitWindow.WaitWindow.Show(LoadPxz, @"Loading PXZ file", fileName));
            }

            try
            {
                //ensure the file exists
                if (File.Exists(fileName))
                {
                    //attempt PXZ load
                    var pxz = new PxzFile();
                    pxz.Load(fileName);

                    //return the loaded PXZ file
                    return(pxz);
                }
            }
            catch (Exception ex)
            {
                UIMessages.Error(ex.ToString(), @"Load PXZ File Error");
            }

            //default
            return(null);
        }
Пример #13
0
        private async void LoginAction()
        {
            try
            {
                //immediately stop the auto-checker to avoid double checks
                tmrLoginDetection.Stop();

                //change UI accordingly
                lblInstructions.Text = TalkingToPlex;
                btnOK.Enabled        = false; //so the user can't click it twice

                //try and grab the new token
                var newPin = await Task.Run(() => PlexAuthHandler.FromPinEndpoint(PlexRequestPin));

                //it's only successful if a token was actually provided
                if (newPin != null)
                {
                    Success = !string.IsNullOrEmpty(newPin.AuthToken);
                }

                //apply the result
                Result = newPin;

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                UIMessages.Error($"An error occurred whilst logging into Plex.tv:\n\n{ex}");
            }
        }
Пример #14
0
        private void FrmPlayer_Load(object sender, EventArgs e)
        {
            var formTitle = StreamingContent.StreamInformation.ContentTitle;

            Text = formTitle ?? "Player";
            //player.URL = StreamingContent.StreamUrl;

            if (!PlexDL.Player.Player.MFPresent)
            {
                UIMessages.Error(
                    @"MediaFoundation is not installed. The player will not be able to stream the selected content; reverting to WMP mode.",
                    @"Playback Error");
                _isWmp = true;
            }

            if (StreamingContent.StreamInformation.Container == "mkv")
            {
                var msg =
                    UIMessages.Question(
                        @"PlexDL Matroska (mkv) playback is not supported, however some codecs may still work unofficially. Would you like to continue playback via PVS?");

                if (!msg)
                {
                    Close();
                }
            }

            //decide appropriate player
            SwitchWmp();

            //UIMessages.Info(TitlesTable.Rows.Count + "\n" +StreamingContent.StreamIndex);
            //UIMessages.Info("Duration: "+StreamingContent.ContentDuration+"\nSize: "+StreamingContent.ByteLength);
        }
Пример #15
0
        public static void TokenClearProcedure()
        {
            if (IsTokenStored)
            {
                const string q = @"Are you sure you want to clear your token?";

                //if the user clicks 'No' (false for 'No', true for 'Yes'), simply exit the function.
                if (!UIMessages.Question(q))
                {
                    return;
                }

                if (ClearStored())
                {
                    UIMessages.Info(
                        @"Successfully cleared your Plex.tv token. It will be reinstated once you login via the Server Manager.");
                }
                else
                {
                    UIMessages.Error(
                        @"Couldn't clear your token, because an unknown error occurred. Please delete it manually, and report this issue via GitHub.");
                }
            }
            else
            {
                UIMessages.Error(
                    @"Couldn't clear your token, because PlexDL has not saved it yet.");
            }
        }
Пример #16
0
 private void ItmCommitToDefault_Click(object sender, EventArgs e)
 {
     try
     {
         if (ObjectProvider.Settings != null)
         {
             if (ObjectProvider.Settings.CommitDefaultSettings())
             {
                 UIMessages.Info(@"Successfully saved settings");
             }
             else
             {
                 UIMessages.Error(@"An unknown error occurred whilst saving settings");
             }
         }
         else
         {
             UIMessages.Error(@"Couldn't export settings because they were null");
         }
     }
     catch (Exception ex)
     {
         LoggingHelpers.RecordException(ex.Message, @"SaveDefaultError");
         UIMessages.Error($"Error exporting to default\n\n{ex}");
     }
 }
Пример #17
0
        private void InitialSetup()
        {
            try
            {
                //metrics information must be valid to proceed
                if (Metrics != null)
                {
                    //caching data location
                    UpdateCachingDirectory();

                    //apply data
                    dgvMain.DataSource = GetMetrics();
                }
                else
                {
                    UIMessages.Warning(@"Metrics information was not configured on launch; data failed to load.");
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, "CacheMetricsLoadError");

                //inform the user
                UIMessages.Error("There was an error whilst loading caching metrics:\n\n" + ex,
                                 @"Load Error");

                //exit the form
                Close();
            }
        }
Пример #18
0
        private void Cast_Load(object sender, EventArgs e)
        {
            try
            {
                //setup service events
                if (Service != null)
                {
                    Service.ChromeCastClient.ConnectedChanged += Client_Connected;
                }

                //setup form title
                lblTitle.Text = StreamingContent.StreamInformation.ContentTitle;

                //setup the poster
                picPoster.BackgroundImage = ImageHandler.GetPoster(StreamingContent);
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"CastUILoadError");

                //alert the user
                UIMessages.Error($"Error occurred during cast load:\n\n{ex}");
            }
        }
Пример #19
0
        /*! \endcond */
        #endregion

        #region ### IOnRequestModule ###

        public CGData[] OnSlotDataRequest(CGModuleInputSlot requestedBy, CGModuleOutputSlot requestedSlot, params CGDataRequestParameter[] requests)
        {
            var raster  = GetRequestParameter <CGDataRequestRasterization>(ref requests);
            var options = GetRequestParameter <CGDataRequestMetaCGOptions>(ref requests);

            if (options)
            {
                if (options.CheckMaterialID)
                {
                    options.CheckMaterialID = false;
                    UIMessages.Add("MaterialID option not supported!");
                }
                if (options.IncludeControlPoints)
                {
                    options.IncludeControlPoints = false;
                    UIMessages.Add("IncludeCP option not supported!");
                }
            }
            if (!raster || raster.Length == 0)
            {
                return(null);
            }

            var data = GetSplineData(Spline, true, raster, options);

            return(new CGData[1] {
                data
            });
        }
Пример #20
0
        private void DRval_OnDataRestoreComplete(object sender, StringEventArgs e)
        {
            UIMessages msg = new UIMessages();

            InitializeUISuccess(e.Message, msg.Show(7));
            HideProgressbar();
        }
Пример #21
0
        private async void BtnPlayPause_Click(object sender, EventArgs e)
        {
            try
            {
                if (PlayState)
                {
                    //send pause command
                    await Controller.Pause();

                    //set UI
                    btnPlayPause.Text = @"Play";

                    //set flag
                    PlayState = false;
                }
                else
                {
                    //send play command
                    await Controller.Play();

                    //set UI
                    btnPlayPause.Text = @"Pause";

                    //set flag
                    PlayState = true;
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, @"CastPlayStateError");
                UIMessages.Error($"An error occurred whilst trying to play/pause your media:\n\n{ex}");
            }
        }
Пример #22
0
        private void BtnStartSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtSearchTerm.Text) &&
                    cbxSearchColumn.SelectedItem != null &&
                    cbxSearchRule.SelectedIndex >= 0)
                {
                    //the result is OK, close the form
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    //alert the user to the validation error
                    UIMessages.Error(@"Please enter all required values or exit the search",
                                     @"Validation Error");
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"SearchFormStartSearchError");

                //alert the user
                UIMessages.Error(ex.ToString());
            }
        }
Пример #23
0
        private void BtnTranslate_Click(object sender, EventArgs e)
        {
            try
            {
                //are both LogDel file name storage locations valid?
                if (!string.IsNullOrWhiteSpace(txtLogdel.Text) && !string.IsNullOrWhiteSpace(ofdLogdel.FileName))
                {
                    //reset progress bar
                    pbMain.Maximum = TotalCount;
                    pbMain.Value   = 0;

                    //setup background worker event handlers
                    bwTranslate.RunWorkerCompleted += BwTranslate_RunWorkerCompleted;
                    bwTranslate.ProgressChanged    += BwTranslate_ProgressChanged;

                    //start processing in the background
                    bwTranslate.RunWorkerAsync();
                }
                else
                {
                    //alert the user
                    UIMessages.Error(@"Incorrect value(s)");
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"TokenTranslatorProcessingError");

                //alert the user
                UIMessages.Error(ex.ToString());
            }
        }
Пример #24
0
        public void UIMessages_DefaultLanguage_ReturnsCorrectWelcomeMessage()
        {
            IUIMessages uIMessages = UIMessages.GetMessagesForLanguage();

            string expectedMessage = uIMessages.WelcomeToWebsiteMessage;

            Assert.AreEqual(expectedMessage, "Welcome to ABCD News");
        }
Пример #25
0
 private void UnregisterElementBindings(BindingConfig[] elements)
 {
     foreach (BindingConfig config in elements)
     {
         UIMessages.Unsubscribe(config.message, GetHandler(config.componentType));
         bindings.Remove(config.message);
     }
 }
Пример #26
0
        private void BwTranslate_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //alert the user to the success
            UIMessages.Info(@"Completed", @"Success");

            //close the form and hence exit the application
            Close();
        }
Пример #27
0
 private void RegisterElementBindings(BindingConfig[] elements)
 {
     foreach (BindingConfig config in elements)
     {
         Transform child = transform.Find(config.objectName);
         bindings[config.message] = new BindingInfo(child, config.converter);
         UIMessages.Subscribe(config.message, GetHandler(config.componentType));
     }
 }
Пример #28
0
        public static DataTable TvAttributesFromObject(PlexTvShow content, bool silent = false)
        {
            var table = new DataTable("TvAttributes");
            var columnAttributeName  = new DataColumn("Name", typeof(string));
            var columnAttributeValue = new DataColumn("Value");

            table.Columns.AddRange(
                new[]
            {
                columnAttributeName,
                columnAttributeValue
            });
            try
            {
                var season        = new[] { "Season Name", content.Season };
                var episodeCount  = new[] { "Episode Count", content.EpisodesInSeason.ToString() };
                var seasonNumber  = new[] { "Season #", content.SeasonNumber.ToString() };
                var episodeNumber = new[] { "Episode #", content.EpisodeNumber.ToString() };
                var genre         = new[] { "Genre", content.ContentGenre };
                var runtime       = new[]
                { "Runtime", Methods.CalculateTime(content.StreamInformation.ContentDuration) };
                var resolution = new[] { "Resolution", content.StreamResolution.ResolutionString() };
                var frameRate  = new[] { "Frame-rate", FormatFramerate(content) };
                var size       = new[] { "File size", Methods.FormatBytes(content.StreamInformation.ByteLength) };
                var container  = new[] { "Container", content.StreamInformation.Container };

                var newRows = new[]
                {
                    season,
                    episodeCount,
                    seasonNumber,
                    episodeNumber,
                    genre,
                    runtime,
                    resolution,
                    frameRate,
                    size,
                    container
                };

                foreach (object[] row in newRows)
                {
                    table.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "AttributeTableError");
                if (!silent)
                {
                    UIMessages.Error("Error occurred whilst building content attribute table:\n\n" + ex, @"Data Error");
                }
            }

            return(table);
        }
Пример #29
0
        public bool IsValid(out string message)
        {
            if (string.IsNullOrWhiteSpace(ExamType))
            {
                message = UIMessages.GetRequiredMessage("İmtahan Növü");
                return(false);
            }

            message = string.Empty;
            return(true);
        }
Пример #30
0
        private async Task StopApplication()
        {
            try
            {
                //multi-threaded
                if (InvokeRequired)
                {
                    BeginInvoke((MethodInvoker) delegate
                    {
                        StopApplication().GetAwaiter().GetResult();
                    });
                }
                else
                {
                    //set UI
                    btnCast.Enabled      = false;
                    btnDiscover.Enabled  = true;
                    btnPlayPause.Enabled = false;
                    btnCast.Text         = @"Stopping";
                    btnPlayPause.Text    = @"Play";

                    //kill the application
                    if (Controller != null)
                    {
                        await Controller.StopApplication();
                    }

                    //disconnect
                    if (Service?.ConnectedChromecast != null)
                    {
                        if (Service.ChromeCastClient != null)
                        {
                            await Service.ChromeCastClient.DisconnectChromecast();
                        }
                    }

                    //restore UI
                    btnCast.Enabled = true;
                    btnCast.Text    = @"Cast";

                    //set flags
                    ConnectState = false;
                    PlayState    = false;
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"CastStopError");

                //alert the user
                UIMessages.Error($"Error occurred whilst stopping the application:\n\n{ex}");
            }
        }