Exemplo n.º 1
0
 /// <summary>
 /// Localize WPF form
 /// </summary>
 public static void LocaliseForm(System.Windows.Window sourceWindow)
 {
     sourceWindow.Title = Localise.GetPhrase(sourceWindow.Title);
     if (sourceWindow.ToolTip != null)
     {
         sourceWindow.ToolTip = Localise.GetPhrase((string)sourceWindow.ToolTip);
     }
     LocaliseControl(sourceWindow);
 }
 public void SetWakeUpTime(DateTime time)
 {
     try
     {
         bgWorker.RunWorkerAsync(time.ToFileTime());
     }
     catch (Exception)
     {
         Log.AppLog.WriteEntry(this, Localise.GetPhrase("Background timer already running, cannot start another event"), Log.LogEntryType.Warning, true);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Localize Windows form with tooltip and context menu strip
 /// </summary>
 public static void LocaliseForm(System.Windows.Forms.Form sourceForm, System.Windows.Forms.ToolTip toolTip, System.Windows.Forms.ContextMenuStrip contextMenuStrip)
 {
     LocaliseForm(sourceForm, toolTip);
     foreach (System.Windows.Forms.ToolStripItem item in contextMenuStrip.Items)
     {
         item.Text = Localise.GetPhrase(item.Text);
         if (item.AutoToolTip)
         {
             item.ToolTipText = Localise.GetPhrase(item.ToolTipText);
         }
     }
 }
Exemplo n.º 4
0
        private static void LocaliseControl <T>(T control, System.Windows.Forms.ToolTip toolTip = null)
        {
            if (control is System.Windows.Forms.Control.ControlCollection) // Window forms controls
            {
                System.Windows.Forms.Control.ControlCollection ctl = control as System.Windows.Forms.Control.ControlCollection;

                foreach (System.Windows.Forms.Control childCtl in ctl) // look for all child controls
                {
                    if (toolTip != null)
                    {
                        toolTip.SetToolTip(childCtl, Localise.GetPhrase(toolTip.GetToolTip(childCtl)));
                    }

                    if ((childCtl.GetType() == typeof(System.Windows.Forms.Label)) || (childCtl.GetType() == typeof(System.Windows.Forms.GroupBox)) || (childCtl.GetType() == typeof(System.Windows.Forms.CheckBox)) || (childCtl.GetType() == typeof(System.Windows.Forms.Button)))
                    {
                        childCtl.Text = Localise.GetPhrase(childCtl.Text);
                    }

                    LocaliseControl(childCtl.Controls, toolTip); // Localize recursively for nested controls
                }
            }
            else // WPF controls
            {
                for (int i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(control as System.Windows.DependencyObject); i++) // look for all child controls
                {
                    dynamic childCtl = System.Windows.Media.VisualTreeHelper.GetChild(control as System.Windows.DependencyObject, i);
                    if (IsSettingsExist(childCtl, "ToolTip")) // Check and change tooltip
                    {
                        if (childCtl.ToolTip != null)
                        {
                            childCtl.ToolTip = Localise.GetPhrase((string)childCtl.ToolTip);
                        }
                    }

                    if (((childCtl.GetType() == typeof(System.Windows.Controls.Label))) || ((childCtl.GetType() == typeof(System.Windows.Controls.GroupBox))) || ((childCtl.GetType() == typeof(System.Windows.Controls.CheckBox))) || ((childCtl.GetType() == typeof(System.Windows.Controls.Button))))
                    {
                        if ((childCtl.Content != null) && (childCtl.Content.GetType() == typeof(System.Windows.Controls.TextBlock))) // Check for nested labels
                        {
                            childCtl.Content.Text = Localise.GetPhrase(childCtl.Content.Text);
                        }
                        else
                        {
                            childCtl.Content = Localise.GetPhrase(childCtl.Content);
                        }
                    }

                    LocaliseControl(childCtl, null); // Localize recursively for nested controls
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Used to check for updates to MCEBuddy
        /// </summary>
        /// <param name="nonGUI">True if called from a thread (not GUI)</param>
        public void Check(bool nonGUI)
        {
            try
            {
                LatestVersion latestVersion;
                string        announcement     = "";
                string        announcementLink = "";
                string        donationLink     = "";
                string        facebookLink     = "";
                Ini           configIni        = new Ini(GlobalDefs.TempSettingsFile);

                // Get all the version information
                string pageOutput = WebUtility.HtmlDecode(DownloadWebPage(Crypto.Decrypt(GlobalDefs.MCEBUDDY_CHECK_NEW_VERSION), nonGUI));
                if (String.IsNullOrWhiteSpace(pageOutput))
                {
                    return;
                }

                latestVersion    = ParseVersion(pageOutput);              // Get the latest version
                announcement     = ParseAnnouncement(pageOutput);         // Get any critical announcements
                announcementLink = ParseLink(pageOutput, "Link");         // Get the link for any critical announcements
                donationLink     = ParseLink(pageOutput, "DonationLink"); // Get the link for donations
                facebookLink     = ParseLink(pageOutput, "FacebookLink"); // Get the link for donations

                // Check and write any critical announcement (always overwrite to get latest annnoucement, even if blank)
                configIni.Write("Engine", "Announcement", announcement);
                configIni.Write("Engine", "AnnouncementLink", announcementLink);
                configIni.Write("Engine", "DonationLink", donationLink);
                configIni.Write("Engine", "FacebookLink", facebookLink);

                // Check and write the version information
                if ("" == latestVersion.latestVersionString)
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("Unable to get Latest Version information"), Log.LogEntryType.Warning);
                    return; //didn't get the data we were expecting
                }
                else
                {
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Latest Version") + " " + latestVersion.latestVersionString, Log.LogEntryType.Debug);
                    string currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    Log.AppLog.WriteEntry(this, Localise.GetPhrase("MCEBuddy Current Version") + " " + currentVersion, Log.LogEntryType.Debug);
                    configIni.Write("Engine", "LatestVersion", latestVersion.latestVersionString);
                }
            }
            catch
            { }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Call back handler for aSynchronous eMail, checks for success or failure of email sending
        /// </summary>
        private static void eMailClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            SendEmailOptions userState = (SendEmailOptions)e.UserState;

            if (userState == null)
            {
                return;
            }

            if (e.Error == null)
            {
                userState.jobLog.WriteEntry(Localise.GetPhrase("Successfully send eMail"), Log.LogEntryType.Information, true);
            }
            else
            {
                userState.jobLog.WriteEntry(Localise.GetPhrase("Error sending eMail") + " -> " + e.ToString(), Log.LogEntryType.Error, true);
            }

            return;
        }
            private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
            {
                long waketime = (long)e.Argument;

                using (SafeWaitHandle handle = CreateWaitableTimer(IntPtr.Zero, true, this.GetType().Assembly.GetName().Name.ToString() + ".Timer"))
                {
                    if (SetWaitableTimer(handle, ref waketime, 0, IntPtr.Zero, IntPtr.Zero, true)) //set the timer to fire at the desired time and wake up the system if suspended (not call backfunction as this is only to wake up the system), the jobs are handlded by the monitor thread
                    {
                        using (_wakeEventHandles[0] = new EventWaitHandle(false, EventResetMode.ManualReset))
                        {
                            _wakeEventHandles[0].SafeWaitHandle = handle;                                  // OS timer set to wake up the system
                            _wakeEventHandles[1] = new EventWaitHandle(false, EventResetMode.ManualReset); // Manually triggered abort function to signal shutdown of application
                            int index = WaitHandle.WaitAny(_wakeEventHandles);                             // Wait until either of the above 2 events are triggered to complete this function
                        }
                    }
                    else
                    {
                        Log.AppLog.WriteEntry(this, Localise.GetPhrase("Error setting up wake up timer"), Log.LogEntryType.Error, true);
                    }
                }
            }
Exemplo n.º 8
0
        /// <summary>
        /// Send email in the background and callback handler when completed (synchronous or asynchronous)
        /// Check the error in the callback handler for eMail status (success or error or cancelled)
        /// </summary>
        /// <param name="asyncCallback">User handler to call back and will send eMail asynchronously. The callback handler will receive an object of type EmailUserState</param>
        /// <param name="forceAsyncNoCallback">If set to true it will send eMail asynchronously without any user callback handler</param>
        /// <returns>False if an error is encountered crafting the eMail message</returns>
        public static bool SendEMail(EmailBasicSettings emailSettings, string subject, string message, Log jobLog, SendCompletedEventHandler asyncCallback, bool forceAsyncNoCallback = false)
        {
            string smtpServer   = emailSettings.smtpServer;
            int    portNo       = emailSettings.port; // default port is 25
            bool   ssl          = emailSettings.ssl;
            string fromAddress  = emailSettings.fromAddress;
            string toAddresses  = emailSettings.toAddresses;
            string bccAddresses = emailSettings.bccAddress;
            string username     = emailSettings.userName;
            string password     = emailSettings.password;

            jobLog.WriteEntry(Localise.GetPhrase("Request to send eMail"), Log.LogEntryType.Information, true);
            jobLog.WriteEntry("Server -> " + smtpServer, Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("Port -> " + portNo.ToString(System.Globalization.CultureInfo.InvariantCulture), Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("SSL -> " + ssl.ToString(System.Globalization.CultureInfo.InvariantCulture), Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("Username -> " + username, Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("From -> " + fromAddress, Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("To -> " + toAddresses, Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("Subject -> " + subject, Log.LogEntryType.Debug, true);
            jobLog.WriteEntry("Message -> " + message, Log.LogEntryType.Debug, true);

            try
            {
                // Create the eMail message
                MailMessage eMailMessage = new MailMessage();
                eMailMessage.Subject = subject;
                eMailMessage.Body    = message;
                eMailMessage.From    = new MailAddress(fromAddress);
                if (!String.IsNullOrWhiteSpace(toAddresses)) // Avoid an exception, since to is not mandatory
                {
                    string[] addresses = toAddresses.Split(';');
                    for (int i = 0; i < addresses.Length; i++)
                    {
                        eMailMessage.To.Add(addresses[i]); // Add the To recipients
                    }
                }
                if (!String.IsNullOrWhiteSpace(bccAddresses)) // Avoid an exception, since bcc is not mandatory
                {
                    string[] bccToAddresses = bccAddresses.Split(';');
                    for (int i = 0; i < bccToAddresses.Length; i++)
                    {
                        eMailMessage.Bcc.Add(bccToAddresses[i]); // Add the Bcc recipients
                    }
                }
                eMailMessage.BodyEncoding    = System.Text.Encoding.UTF8;
                eMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;

                // Create the client to send the message
                SmtpClient eMailClient = new SmtpClient(smtpServer, portNo);
                if (username != "")
                {
                    eMailClient.Credentials = new System.Net.NetworkCredential(username, password); // add the authentication details
                }
                if (ssl)
                {
                    eMailClient.EnableSsl = true;              // Set the SSL if required
                }
                eMailClient.Timeout = GlobalDefs.SMTP_TIMEOUT; // Set the timeout

                // Send the eMail - check for Async or Sync email sending
                if (asyncCallback == null && !forceAsyncNoCallback)
                {
                    eMailClient.Send(eMailMessage);
                    jobLog.WriteEntry(Localise.GetPhrase("Successfully send eMail"), Log.LogEntryType.Information, true);
                }
                else
                {
                    if (forceAsyncNoCallback)
                    {
                        eMailClient.SendCompleted += eMailClient_SendCompleted; // use default call back
                    }
                    else
                    {
                        eMailClient.SendCompleted += eMailClient_SendCompleted + asyncCallback; // Register call back
                    }
                    eMailClient.SendAsync(eMailMessage, new SendEmailOptions {
                        eMailSettings = emailSettings, message = message, subject = subject, jobLog = jobLog, asyncCallBackHandler = asyncCallback, forceAysncCallBack = forceAsyncNoCallback
                    });
                }

                return(true);
            }
            catch (Exception e)
            {
                jobLog.WriteEntry(Localise.GetPhrase("Error sending eMail") + " -> " + e.ToString(), Log.LogEntryType.Error, true);
                return(false);
            }
        }
        /// <summary>
        /// Replaces a string of user custom parameters from the metadata
        /// </summary>
        /// <param name="commandParameters">Original string of user custom Parameters</param>
        /// <param name="workingPath">Temp working path</param>
        /// <param name="destinationPath">Destination path for converted file</param>
        /// <param name="convertedFile">Full path to final converted file</param>
        /// <param name="sourceFile">Full path to original source file</param>
        /// <param name="remuxFile">Full path to intermediate remuxed file</param>
        /// <param name="edlFile">Full path to EDL file</param>
        /// <param name="srtFile">Full path to SRT file</param>
        /// <param name="profile">Profile name</param>
        /// <param name="taskName">Task Name</param>
        /// <param name="metaData">Video metadata structure for source file</param>
        /// <param name="jobLog">JobLog</param>
        /// <returns>Converted string of custom parameters, empty string if there is an error</returns>
        public static string CustomParamsReplace(
            string commandParameters,
            string workingPath,
            string destinationPath,
            string convertedFile,
            string sourceFile,
            string remuxFile,
            string edlFile,
            string srtFile,
            string profile,
            string taskName,
            VideoTags metaData,
            Log jobLog)
        {
            string translatedCommand = "";

            if (metaData == null)
            {
                metaData = new VideoTags(); // Incase Metadata does not exit, create an empty metadata so it doesn't crash the function
            }
            // SRT and EDl files are substitued if they exist otherwise they are ""
            if (!File.Exists(srtFile))
            {
                srtFile = "";
            }

            if (!File.Exists(edlFile))
            {
                edlFile = "";
            }

            try
            {
                char[] commandBytes = commandParameters.ToCharArray();
                for (int i = 0; i < commandBytes.Length; i++)
                {
                    switch (commandBytes[i])
                    {
                    case '%':
                        string command = "";
                        while (commandBytes[++i] != '%')
                        {
                            command += commandBytes[i].ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower();
                        }

                        string format = "";
                        switch (command)
                        {
                        case "taskname":
                            translatedCommand += (taskName);         // Preserve case for parameters
                            break;

                        case "profile":
                            translatedCommand += (profile);         // Preserve case for parameters
                            break;

                        case "convertedfile":
                            translatedCommand += (convertedFile);         // Preserve case for parameters
                            break;

                        case "sourcefile":
                            translatedCommand += (sourceFile);         // Preserve case for parameters
                            break;

                        case "remuxfile":
                            translatedCommand += (remuxFile);         // Preserve case for parameters
                            break;

                        case "workingpath":
                            translatedCommand += (workingPath);         // Preserve case for parameters
                            break;

                        case "destinationpath":
                            translatedCommand += (destinationPath);         // Preserve case for parameters
                            break;

                        case "srtfile":
                            translatedCommand += (srtFile);         // Preserve case for parameters
                            break;

                        case "edlfile":
                            translatedCommand += (edlFile);         // Preserve case for parameters
                            break;

                        case "originalfilepath":
                            translatedCommand += (Path.GetDirectoryName(sourceFile));         // Preserve case for parameters
                            break;

                        case "originalfilename":
                            translatedCommand += (Path.GetFileNameWithoutExtension(sourceFile));         // Preserve case for parameters
                            break;

                        case "originalext":         // Extension of the source file
                            translatedCommand += FilePaths.CleanExt(sourceFile).Replace(".", "");
                            break;

                        case "convertedext":         // Extension of the converted file
                            translatedCommand += FilePaths.CleanExt(convertedFile).Replace(".", "");
                            break;

                        case "showname":
                            translatedCommand += (metaData.Title);         // Preserve case for parameters
                            break;

                        case "genre":
                            translatedCommand += (metaData.Genres != null ? (metaData.Genres.Length > 0 ? metaData.Genres[0] : "") : "");         // Preserve case for parameters
                            break;

                        case "episodename":
                            translatedCommand += (metaData.SubTitle);         // Preserve case for parameters
                            break;

                        case "episodedescription":
                            translatedCommand += (metaData.Description);         // Preserve case for parameters
                            break;

                        case "network":
                            translatedCommand += (metaData.Network);         // Preserve case for parameters
                            break;

                        case "bannerfile":
                            translatedCommand += (metaData.BannerFile);         // Preserve case for parameters
                            break;

                        case "bannerurl":
                            translatedCommand += (metaData.BannerURL);         // Preserve case for parameters
                            break;

                        case "movieid":
                            translatedCommand += (metaData.tmdbId);         // Preserve case for parameters
                            break;

                        case "imdbmovieid":
                            translatedCommand += (metaData.imdbId);         // Preserve case for parameters
                            break;

                        case "seriesid":
                            translatedCommand += (metaData.tvdbId);         // Preserve case for parameters
                            break;

                        case "season":
                            format = "";
                            try
                            {
                                if (commandBytes[i + 1] == '#')
                                {
                                    while (commandBytes[++i] == '#')
                                    {
                                        format += "0";
                                    }

                                    --i;         // adjust for last increment
                                }
                            }
                            catch { }                                                                              // this is normal incase it doesn't exist

                            translatedCommand += ((metaData.Season == 0 ? "" : metaData.Season.ToString(format))); // Preserve case for parameters
                            break;

                        case "episode":
                            format = "";
                            try
                            {
                                if (commandBytes[i + 1] == '#')
                                {
                                    while (commandBytes[++i] == '#')
                                    {
                                        format += "0";
                                    }

                                    --i;         // adjust for last increment
                                }
                            }
                            catch { }                                                                                // this is normal incase it doesn't exist

                            translatedCommand += ((metaData.Episode == 0 ? "" : metaData.Episode.ToString(format))); // Preserve case for parameters
                            break;

                        case "issport":
                            translatedCommand += (metaData.IsSports.ToString(CultureInfo.InvariantCulture));         // Preserve case for parameters
                            break;

                        case "ismovie":
                            translatedCommand += (metaData.IsMovie.ToString(CultureInfo.InvariantCulture));         // Preserve case for parameters
                            break;

                        case "premiereyear":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("yyyy") : "");         // Preserve case for parameters
                            break;

                        case "premieremonth":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("%M") : "");         // Preserve case for parameters
                            break;

                        case "premieremonthshort":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("MMM") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "premieremonthlong":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("MMMM") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "premiereday":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("%d") : "");         // Preserve case for parameters
                            break;

                        case "premieredayshort":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("ddd") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "premieredaylong":
                            translatedCommand += ((metaData.SeriesPremiereDate > GlobalDefs.NO_BROADCAST_TIME) ? metaData.SeriesPremiereDate.ToLocalTime().ToString("dddd") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "airyear":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("yyyy") : "");         // Preserve case for parameters
                            break;

                        case "airmonth":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("%M") : "");         // Preserve case for parameters
                            break;

                        case "airmonthshort":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("MMM") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "airmonthlong":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("MMMM") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "airday":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("%d") : "");         // Preserve case for parameters
                            break;

                        case "airdayshort":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("ddd") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "airdaylong":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("dddd") : "");         // Preserve case for parameters, culture sensitive
                            break;

                        case "airhour":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("%h") : "");         // Preserve case for parameters
                            break;

                        case "airhourampm":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("tt") : "");         // Preserve case for parameters
                            break;

                        case "airminute":
                            translatedCommand += ((metaData.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.OriginalBroadcastDateTime.ToLocalTime().ToString("%m") : "");         // Preserve case for parameters
                            break;

                        case "recordyear":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("yyyy") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("yyyy"));         // Preserve case for parameters
                            break;

                        case "recordmonth":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("%M") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("%M"));         // Preserve case for parameters
                            break;

                        case "recordmonthshort":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("MMM") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("MMM"));         // Preserve case for parameters, culture sensitive
                            break;

                        case "recordmonthlong":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("MMMM") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("MMMM"));         // Preserve case for parameters, culture sensitive
                            break;

                        case "recordday":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("%d") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("%d"));         // Preserve case for parameters
                            break;

                        case "recorddayshort":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("ddd") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("ddd"));         // Preserve case for parameters, culture sensitive
                            break;

                        case "recorddaylong":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("dddd") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("dddd"));         // Preserve case for parameters, culture sensitive
                            break;

                        case "recordhour":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("%h") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("%h"));         // Preserve case for parameters
                            break;

                        case "recordhourampm":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("tt") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("tt"));         // Preserve case for parameters
                            break;

                        case "recordminute":
                            translatedCommand += ((metaData.RecordedDateTime > GlobalDefs.NO_BROADCAST_TIME) ? metaData.RecordedDateTime.ToLocalTime().ToString("%m") : Util.FileIO.GetFileCreationTime(sourceFile).ToString("%m"));         // Preserve case for parameters
                            break;

                        case "rating":         // Parental rating
                            translatedCommand += metaData.Rating;
                            break;

                        case "airingdbid":         // SageTV Airing DbId
                            translatedCommand += metaData.sageTV.airingDbId;
                            break;

                        case "mediafiledbid":         // SageTV MediaFile DbId
                            translatedCommand += metaData.sageTV.mediaFileDbId;
                            break;

                        default:
                            jobLog.WriteEntry(Localise.GetPhrase("Invalid custom command format detected, skipping") + " : " + command, Log.LogEntryType.Warning);         // We had an invalid format
                            break;
                        }
                        break;

                    default:
                        translatedCommand += commandBytes[i];
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                jobLog.WriteEntry("Invalid custom params replace. Error " + e.ToString(), Log.LogEntryType.Warning);
                return(""); // return nothing
            }

            return(translatedCommand);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Localize Windows form with tooltip
 /// </summary>
 public static void LocaliseForm(System.Windows.Forms.Form sourceForm, System.Windows.Forms.ToolTip toolTip)
 {
     sourceForm.Text = Localise.GetPhrase(sourceForm.Text);
     LocaliseControl(sourceForm.Controls, toolTip);
 }