Пример #1
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.");
            }
        }
Пример #2
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}");
     }
 }
Пример #3
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}");
            }
        }
Пример #4
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}");
            }
        }
Пример #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 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();
        }
Пример #7
0
        private void ItmViaToken_Click(object sender, EventArgs e)
        {
            try
            {
                //check if there's a connection before trying to update the authentication token
                if (Internet.IsConnected)
                {
                    using (var frm = new Authenticate())
                    {
                        var existingInfo = new ConnectionInfo
                        {
                            PlexAccountToken = ObjectProvider.Settings.ConnectionInfo.PlexAccountToken
                        };

                        frm.ConnectionInfo = existingInfo;

                        if (frm.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        if (!frm.Success)
                        {
                            return;
                        }

                        if (ApplyToken(frm.ConnectionInfo.PlexAccountToken))
                        {
                            UIMessages.Info(
                                @"Token applied successfully. You can now load servers and relays from Plex.tv");
                            LoadServers(true);

                            //status update
                            SetInterfaceAuthenticationStatus(true);
                        }
                        else
                        {
                            UIMessages.Error(@"An unknown error occurred");
                        }
                    }
                }
                else
                {
                    // trying to connect on no connection will not end well; alert the user.
                    UIMessages.Warning(
                        @"No internet connection. Please connect to a network before attempting to authenticate.",
                        @"Network Error");
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "ConnectionError");
                UIMessages.Error("Connection Error:\n\n" + ex, @"Connection Error");
            }
        }
Пример #8
0
        /// <summary>
        /// Handles exporting to an eXtensible markup language file; will prompt the user with a 'Save As' dialog.
        /// </summary>
        /// <param name="table">The data to export; null checks are enforced.</param>
        private void ExportTableXml(DataTable table)
        {
            try
            {
                //the table mustn't be null; we cannot work on data that doesn't exist
                if (table != null)
                {
                    //the table must have data inside it; we cannot work on data that doesn't exist
                    if (table.Rows.Count > 0)
                    {
                        //dialog values
                        sfdExport.Filter     = @"XML File|*.xml";
                        sfdExport.DefaultExt = "xml";

                        //show the dialog and ensure the user pressed 'OK'
                        if (sfdExport.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        //the path of the file to write to/create
                        var file = sfdExport.FileName;

                        //use the export extensions provider to save the data to an XML file
                        table.ToXml(file);

                        //inform the user
                        UIMessages.Info("Success!");
                    }
                    else
                    {
                        //inform the user of the problem (no data; but not null)
                        UIMessages.Error("Couldn't export; table has no rows.");
                    }
                }
                else
                {
                    //inform the user of the problem (table isn't set)
                    UIMessages.Error("Couldn't export; table is null.");
                }
            }
            catch (Exception ex)
            {
                //log the problem
                LoggingHelpers.RecordException(ex.Message, @"DebugExportXMLError");

                //inform the user of the problem (unhandled exception)
                UIMessages.Error("Error occurred whilst exporting table:\n\n" + ex);
            }
        }
Пример #9
0
        private void DgvMain_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            //ensure the row count is above 0 before continuing
            if (dgvMain.Rows.Count <= 0)
            {
                return;
            }

            //it's above zero, so grab the value of the current cell that was double-clicked
            var value =
                dgvMain.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            //alert the user to the value they double-clicked
            UIMessages.Info(value, @"Cell Content");
        }
Пример #10
0
        private void ItmViewAccountToken_Click(object sender, EventArgs e)
        {
            var token = ObjectProvider.User.authenticationToken;

            if (string.IsNullOrEmpty(token))
            {
                return;
            }

            UIMessages.Info($@"Your account token is: {token}

We've also copied it to the clipboard for you :)");

            Clipboard.SetText(token);
        }
Пример #11
0
 private void ItmCreateAssociations_Click(object sender, EventArgs e)
 {
     try
     {
         if (UIMessages.Question(
                 "You are about to create PlexDL file associations for:\n\n*.pxz\n*.pmxml\n*.prof\n\nProceed?"))
         {
             FileAssociationsManager.EnsureAssociationsSet();
             UIMessages.Info(@"Done!");
         }
     }
     catch (Exception ex)
     {
         LoggingHelpers.RecordException(ex.Message, @"FileAssociationError");
         UIMessages.Error($"Error whilst trying to set PlexDL file associations:\n\n{ex}");
     }
 }
Пример #12
0
        private void ProfileDefinedServer()
        {
            //check to see if a loaded profile instated some valid server details
            if (CheckProfileDefinedServer())
            {
                //refresh from app.config file(s)
                Properties.Settings.Default.Reload();

                //parse the values
                var shown   = Properties.Settings.Default.PLSShown;
                var disable = Properties.Settings.Default.DisablePLSOnShown;

                //don't show the message if these are both true (cancel execution)
                if (shown && disable)
                {
                    return;
                }

                //the message to display to the user
                const string msg =
                    "It appears your loaded profile contains a previously loaded server. " +
                    "Would you like to prefill those details and connect?";

                //prompt the user (true for 'Yes', false for 'No')
                if (UIMessages.Question(msg))
                {
                    LoadProfileDefinedServer();
                    PlsShown(true, false);

                    return;
                }

                if (!disable)
                {
                    return;
                }

                UIMessages.Info(
                    @"We won't ask again. You can reenable this dialog via the global application config file (not your profile).");
                PlsShown(true);
            }
        }
Пример #13
0
        private void ItmExtractRecord_Click(object sender, EventArgs e)
        {
            if (dgvRecords.SelectedRows.Count == 1)
            {
                var recordName = dgvRecords.SelectedRows[0].Cells[0].Value.ToString();
                var record     = Pxz.LoadRecord(recordName);

                if (sfdExtract.ShowDialog() == DialogResult.OK)
                {
                    if (record.ExtractRecord(sfdExtract.FileName))
                    {
                        UIMessages.Info($"Successfully extracted '{recordName}'");
                    }
                    else
                    {
                        UIMessages.Error(@"Extraction failed; an unknown error occurred.");
                    }
                }
            }
        }
Пример #14
0
        private void ItmCSV_Click(object sender, EventArgs e)
        {
            try
            {
                //ensure a log file is selected in the list
                if (lstLogFiles.SelectedIndex > -1)
                {
                    var sel = LogDir + @"\" + lstLogFiles.SelectedItem;

                    if (File.Exists(sel))
                    {
                        if (sfdExportCsv.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }

                        var f = sfdExportCsv.FileName;
                        var t = LogReader.TableFromFile(sel, false, false);
                        t.ToCsv(f);
                        UIMessages.Info("Successfully exported log file to CSV",
                                        "Success");
                    }
                    else
                    {
                        UIMessages.Error("Selected file does not exist",
                                         "Validation Error");
                    }
                }
                else
                {
                    UIMessages.Error("Nothing is selected",
                                     "Validation Error");
                }
            }
            catch (Exception ex)
            {
                //inform the user of the error
                UIMessages.Error("Error occurred whilst exporting your log file. Details:\n\n" + ex,
                                 "IO Error");
            }
        }
Пример #15
0
        private bool ApplyToken(string token, bool silent = true)
        {
            try
            {
                //check if there's a connection before trying to update the authentication token
                if (Internet.IsConnected)
                {
                    ObjectProvider.User.authenticationToken = token;
                    ObjectProvider.Settings.ConnectionInfo.PlexAccountToken = token;
                    itmLoad.Enabled       = true;
                    itmDisplay.Enabled    = true;
                    dgvServers.DataSource = null;
                    if (!silent)
                    {
                        UIMessages.Info(
                            @"Token applied successfully. You can now load servers and relays from Plex.tv");
                    }

                    return(true);
                }

                // trying to connect on no connection will not end well; alert the user.
                if (!silent)
                {
                    UIMessages.Warning(
                        @"No internet connection. Please connect to a network before attempting to authenticate.",
                        @"Network Error");
                }
                return(false);
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "ConnectionError");
                if (!silent)
                {
                    UIMessages.Error("Connection Error:\n\n" + ex, @"Connection Error");
                }
                return(false);
            }
        }
Пример #16
0
        private void ItmBackup_Click(object sender, EventArgs e)
        {
            try
            {
                //ensure the logging directory exists
                if (Directory.Exists(LogDir))
                {
                    //the OK button must be pressed in the dialog
                    if (sfdBackup.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    //if the file already exists, delete it
                    if (File.Exists(sfdBackup.FileName))
                    {
                        File.Delete(sfdBackup.FileName);
                    }

                    //create a new ZIP file of all the logs in the logging directory
                    ZipFile.CreateFromDirectory(LogDir, sfdBackup.FileName, CompressionLevel.Optimal, false);

                    //inform the user of the successful operation
                    UIMessages.Info(@"Successfully backed up logs to " + sfdBackup.FileName);
                }
                else
                {
                    //alert the user
                    UIMessages.Error(
                        @"Could not backup logs due to no folder existing. This is a clear sign that no logs have been created, however you can check by clicking the Refresh button on the bottom left of this form.",
                        @"Validation Error");
                }
            }
            catch (Exception ex)
            {
                //report the error to the user
                UIMessages.Error("An error occurred whilst backing up log files. Details:\n\n" + ex,
                                 "IO Error");
            }
        }
Пример #17
0
        private static void DoCreateAssociations()
        {
            try
            {
                //query user
                if (UIMessages.Question(
                        "You are about to create PlexDL file associations for:\n\n*.pxz\n*.pmxml\n*.prof\n\nProceed?"))
                {
                    //create the file associations
                    FileAssociationsManager.EnsureAssociationsSet();

                    //alert user to success
                    UIMessages.Info(@"Done!");
                }
            }
            catch (Exception ex)
            {
                //record error
                LoggingHelpers.RecordException(ex.Message, @"FileAssociationError");

                //alert user
                UIMessages.Error($"Error whilst trying to set PlexDL file associations:\n\n{ex}");
            }
        }
Пример #18
0
        public static void MetadataToFile(string fileName, PlexObject contentToExport, Bitmap poster = null, bool silent = false)
        {
            try
            {
                //try and obtain a poster if one wasn't provided
                var p = poster ?? ImageHandler.GetPoster(contentToExport);

                //create each new PXZ record in memory
                var rawMetadata = new PxzRecord(contentToExport.RawMetadata, @"raw");
                var objMetadata = new PxzRecord(contentToExport.ToXml(), @"obj");
                var ptrMetadata = new PxzRecord(p, @"poster");

                //the records to save to the PXZ file are contained in a list
                var data = new List <PxzRecord>
                {
                    rawMetadata,
                    objMetadata,
                    ptrMetadata
                };

                //export the actor images (if any)
                if (contentToExport.Actors != null)
                {
                    if (contentToExport.Actors.Count > 0)
                    {
                        //loop through each actor and attempt an image download
                        foreach (var a in contentToExport.Actors)
                        {
                            //download
                            var image = ImageHandler.GetImageFromUrl(a.ThumbnailUri);

                            //verify
                            if (image != Resources.unavailable)
                            {
                                //create a new record for the image
                                var record = new PxzRecord(image, $"actor_{MD5Helper.CalculateMd5Hash(a.ThumbnailUri)}");

                                //add it to the collection
                                data.Add(record);
                            }
                        }
                    }
                }

                //embedded in PXZ indexing information
                var plexdlVersion = Assembly.GetEntryAssembly()?.GetName().Version;

                //initialise the PXZ file and flush it to disk
                var pxz = new PxzFile(data, plexdlVersion, BuildState.State);
                pxz.Save(fileName);

                //show a message indicating success if allowed
                if (!silent)
                {
                    UIMessages.Info(@"Successfully exported metadata!");
                }
            }
            catch (Exception ex)
            {
                if (!silent)
                {
                    UIMessages.Error("An error occurred\n\n" + ex, @"Metadata Export Error");
                }
                LoggingHelpers.RecordException(ex.Message, "XmlMetadataSaveError");
            }
        }
Пример #19
0
        private void ItmViaPlexTv_Click(object sender, EventArgs e)
        {
            try
            {
                //check if there's a connection before trying to update the authentication token
                if (Internet.IsConnected)
                {
                    var auth = AuthRoutine.GetAuthToken();

                    var r = auth.Result;

                    switch (r)
                    {
                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.Success:
                        if (ApplyToken(auth.Token))
                        {
                            UIMessages.Info(
                                @"Successfully connected to Plex.tv. You can now load and connect to your servers/relays.",
                                @"Success");
                            LoadServers(true);

                            //status update
                            SetInterfaceAuthenticationStatus(true);
                        }
                        else
                        {
                            UIMessages.Error(@"An unknown error occurred; we couldn't apply your account token.");
                        }

                        break;

                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.Cancelled:     //nothing
                        break;

                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.Failed:     //alert the user to the failure
                        UIMessages.Error(
                            @"Failed to apply your account token; the ticket authority didn't authorise the transaction or values were not valid.");
                        break;

                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.Error:     //alert the user to the error
                        UIMessages.Error(@"An unknown error occurred; we couldn't apply your account token.");
                        break;

                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.Invalid:     //alert the user
                        UIMessages.Error(@"Failed to apply your account token; details were invalid.");
                        break;

                    case PlexAPI.LoginHandler.Auth.Enums.AuthStatus.IncorrectResponse:
                        UIMessages.Error(
                            @"Failed to get an authentication ticket from Plex.tv; an incorrectly formatted response was received.");
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                else
                // trying to connect on no connection will not end well; alert the user.
                {
                    UIMessages.Warning(
                        @"No internet connection. Please connect to a network before attempting to authenticate.",
                        @"Network Error");
                }
            }
            catch (Exception ex)
            {
                LoggingHelpers.RecordException(ex.Message, "ConnectionError");
                UIMessages.Error("Connection Error:\n\n" + ex, @"Connection Error");
            }
        }
Пример #20
0
 private void BwTranslate_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     UIMessages.Info(@"Completed", @"Success");
     Close();
 }
Пример #21
0
        private void LoadStats(string fileName)
        {
            try
            {
                //ensure logdel file exists
                if (File.Exists(fileName))
                {
                    //load it to a DataTable
                    var logLoad = LogReader.TableFromFile(fileName, false);

                    //null validation
                    if (logLoad != null)
                    {
                        //ensure it contains a token column
                        if (logLoad.Columns.Contains("Token"))
                        {
                            //reset token lists
                            AllTokens   = new List <string>();
                            ValidTokens = new List <string>();

                            //reset token counters
                            TotalCount     = logLoad.Rows.Count;
                            InvalidCount   = 0;
                            ValidCount     = 0;
                            DuplicateCount = 0;

                            //each row in the log file
                            foreach (DataRow r in logLoad.Rows)
                            {
                                //skip over a blank token
                                if (r["Token"] == null)
                                {
                                    continue;
                                }

                                //the token is converted to a string
                                var t = r["Token"].ToString();

                                //if we haven't already processed this token
                                if (!AllTokens.Contains(t))
                                {
                                    //add it to the global list of current tokens
                                    AllTokens.Add(t);

                                    //is the token of the correct Plex length and is it a valid string?
                                    if (t.Length == 20 && !string.IsNullOrWhiteSpace(t))
                                    {
                                        //increment valid tokens
                                        ValidCount++;

                                        //add it to the list of valid tokens
                                        ValidTokens.Add(t);
                                    }
                                    else
                                    {
                                        //token was invalid, increment invalid tokens
                                        InvalidCount++;
                                    }
                                }
                                else
                                {
                                    //token was already processed, increment duplicate tokens
                                    DuplicateCount++;
                                }
                            }

                            //setup GUI
                            lblDuplicatesValue.Text = DuplicateCount.ToString();
                            lblInvalidValue.Text    = InvalidCount.ToString();
                            lblTotalValue.Text      = TotalCount.ToString();
                            lblValidValue.Text      = ValidCount.ToString();

                            //inform user
                            UIMessages.Info(@"Load succeeded");

                            //enable the translator button
                            btnTranslate.Enabled = true;
                        }
                        else
                        {
                            //alert the user of the error
                            UIMessages.Error(@"Invalid table layout");
                        }
                    }
                    else
                    {
                        //alert the user of the error
                        UIMessages.Error(@"Null table data");
                    }
                }
                else
                {
                    //alert the user of the error
                    UIMessages.Error(@"File doesn't exist");
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"TokenTranslatorError");

                //alert the user
                UIMessages.Error(ex.ToString());
            }
        }
Пример #22
0
        private void DataExport(ExportFormat format)
        {
            try
            {
                //validation
                if (dgvMain.Rows.Count > 0)
                {
                    //flag for success message
                    var exportSuccess = false;

                    //the data to export
                    var data = (DataTable)dgvMain.DataSource;

                    //use export framework
                    switch (format)
                    {
                    //XML exporter
                    case ExportFormat.Xml:

                        //setup the dialog
                        sfdExport.Filter     = @"XML File|*.xml";
                        sfdExport.DefaultExt = @"xml";

                        //show the dialog
                        if (sfdExport.ShowDialog() == DialogResult.OK)
                        {
                            //do the export
                            data.ToXml(sfdExport.FileName);

                            //set success
                            exportSuccess = true;
                        }

                        break;

                    //CSV exporter
                    case ExportFormat.Csv:

                        //setup the dialog
                        sfdExport.Filter     = @"CSV File|*.csv";
                        sfdExport.DefaultExt = @"csv";

                        //show the dialog
                        if (sfdExport.ShowDialog() == DialogResult.OK)
                        {
                            //do the export
                            data.ToCsv(sfdExport.FileName);

                            //set success
                            exportSuccess = true;
                        }

                        break;

                    //JSON exporter
                    case ExportFormat.Json:

                        //setup the dialog
                        sfdExport.Filter     = @"JSON File|*.json";
                        sfdExport.DefaultExt = @"json";

                        //show the dialog
                        if (sfdExport.ShowDialog() == DialogResult.OK)
                        {
                            //do the export
                            data.ToJson(sfdExport.FileName);

                            //set success
                            exportSuccess = true;
                        }

                        break;

                    //LOGDEL exporter
                    case ExportFormat.Logdel:

                        //setup the dialog
                        sfdExport.Filter     = @"LOGDEL File|*.logdel";
                        sfdExport.DefaultExt = @"logdel";

                        //show the dialog
                        if (sfdExport.ShowDialog() == DialogResult.OK)
                        {
                            //do the export
                            data.ToLogdel(sfdExport.FileName);

                            //set success
                            exportSuccess = true;
                        }

                        break;
                    }

                    //show only on success
                    if (exportSuccess)
                    {
                        UIMessages.Info(@"Export was successful");
                    }
                }
                else
                {
                    UIMessages.Error(@"Export failed; no data available.");
                }
            }
            catch (Exception ex)
            {
                //log the error
                LoggingHelpers.RecordException(ex.Message, @"ApiExplorerExportError");

                //alert the user
                UIMessages.Error($"Export error:\n\n{ex}");
            }
        }
Пример #23
0
        private void LoadStats(string fileName)
        {
            try
            {
                if (File.Exists(fileName))
                {
                    var logLoad = LogReader.TableFromFile(fileName, false);
                    if (logLoad != null)
                    {
                        if (logLoad.Columns.Contains("Token"))
                        {
                            AllTokens      = new List <string>();
                            ValidTokens    = new List <string>();
                            TotalCount     = logLoad.Rows.Count;
                            InvalidCount   = 0;
                            ValidCount     = 0;
                            DuplicateCount = 0;
                            foreach (DataRow r in logLoad.Rows)
                            {
                                if (r["Token"] == null)
                                {
                                    continue;
                                }

                                var t = r["Token"].ToString();

                                if (!AllTokens.Contains(t))
                                {
                                    AllTokens.Add(t);
                                    if (t.Length == 20 && !string.IsNullOrWhiteSpace(t))
                                    {
                                        ValidCount++;
                                        ValidTokens.Add(t);
                                    }
                                    else
                                    {
                                        InvalidCount++;
                                    }
                                }
                                else
                                {
                                    DuplicateCount++;
                                }
                            }

                            //gui settings
                            lblDuplicatesValue.Text = DuplicateCount.ToString();
                            lblInvalidValue.Text    = InvalidCount.ToString();
                            lblTotalValue.Text      = TotalCount.ToString();
                            lblValidValue.Text      = ValidCount.ToString();

                            UIMessages.Info(@"Load succeeded");
                            btnTranslate.Enabled = true;
                        }
                        else
                        {
                            UIMessages.Error(@"Invalid table layout");
                        }
                    }
                    else
                    {
                        UIMessages.Error(@"Null table data");
                    }
                }
                else
                {
                    UIMessages.Error(@"File doesn't exist");
                }
            }
            catch (Exception ex)
            {
                UIMessages.Error(ex.ToString());
            }
        }