GetBestTranslation() public static method

public static GetBestTranslation ( string ID ) : string
ID string
return string
Ejemplo n.º 1
0
        public static void CheckPrerequisites()
        {
            DialogResult res;

            switch (OSInfo.OSInfo.GetOSSupported())
            {
            case OSInfo.OSInfo.OsSupport.Blocked:
                MessageBox.Show(Localizer.GetBestTranslation("OS_Support"), OSInfo.OSInfo.GetOSDisplayVersion(),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                break;

            case OSInfo.OSInfo.OsSupport.NotSupported:
                res = MessageBox.Show(Localizer.GetBestTranslation("OS_Warning"), OSInfo.OSInfo.GetOSDisplayVersion(),
                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (res == DialogResult.Cancel)
                {
                    Application.Exit();
                }
                break;
            }
            if (OSInfo.OSInfo.OSServicePackMinor != 0)
            {
                res = MessageBox.Show(Localizer.GetBestTranslation("OS_Beta"), OSInfo.OSInfo.GetOSDisplayVersion(),
                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (res == DialogResult.Cancel)
                {
                    Application.Exit();
                }
            }
        }
        public DeployTool()
        {
            //Create necessary directory tree
            if (!Directory.Exists(Application.StartupPath + "\\deploy"))
            {
                Directory.CreateDirectory(Application.StartupPath + "\\deploy");
            }

            //Set default folders
            InstallationProperties.Instance.Set("MPDir",
                                                Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                                "\\Team MediaPortal\\MediaPortal");
            InstallationProperties.Instance.Set("TVServerDir",
                                                Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                                "\\Team MediaPortal\\MediaPortal TV Server");

            string tmpPrg = Environment.GetEnvironmentVariable("ProgramW6432");

            if (!string.IsNullOrEmpty(tmpPrg))
            {
                InstallationProperties.Instance.Set("ProgramFiles", tmpPrg);
            }
            else
            {
                InstallationProperties.Instance.Set("ProgramFiles", Environment.GetEnvironmentVariable("ProgramFiles"));
            }

            // Paint first screen
            InitializeComponent();
            Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            Localizer.SwitchCulture("en-US");
            UpdateUI();

            // Delete Run registry key
            DialogType firstDlg;

            if (Utils.AutoRunApplication("delete"))
            {
                firstDlg = DialogType.Installation;
                InstallationProperties.Instance.Load();
                Localizer.SwitchCulture(InstallationProperties.Instance["language"]);
                _restart = true;
            }
            else
            {
                firstDlg = DialogType.Welcome;
                Localizer.SwitchCulture("en-US");
                _restart = false;
            }
            _currentDialog = DialogFlowHandler.Instance.GetDialogInstance(firstDlg);
            splitContainer2.Panel1.Controls.Add(_currentDialog);
            InstallationProperties.Instance.Set("InstallTypeHeader", "Choose installation type");
            backButton.Visible = false;
            UpdateUI();
            if (_restart)
            {
                nextButton.Text = Localizer.GetBestTranslation("Install_buttonInstall");
            }
            nextButton.Focus();
        }
Ejemplo n.º 3
0
 public void UpdateUI()
 {
     labelHeading.Text = "";
     Text            = Localizer.GetBestTranslation("MainWindow_AppName");
     backButton.Text = Localizer.GetBestTranslation("MainWindow_backButton");
     nextButton.Text = Localizer.GetBestTranslation("MainWindow_nextButton");
 }
Ejemplo n.º 4
0
        public static string GetDownloadString(string session_id, string node_id)
        {
            XmlDocument  doc     = new XmlDocument();
            HTTPDownload dlg     = new HTTPDownload();
            string       XmlFile = Application.StartupPath + "\\ApplicationLocations.xml";
            const string XmlUrl  = "http://install.team-mediaportal.com/DeployTool/ApplicationLocations.xml";

            //HTTP update of the xml file with the application download URLs
            if (!File.Exists(XmlFile))
            {
                dlg.ShowDialog(XmlUrl, XmlFile, GetUserAgentOsString());
            }
            try
            {
                doc.Load(XmlFile);
                XmlNode node = doc.SelectSingleNode("/Applications/" + session_id + "/" + node_id);
                return(node.InnerText);
            }
            catch
            {
                MessageBox.Show(Localizer.GetBestTranslation("DownloadSettings_failed"), XmlUrl, MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                File.Delete(XmlFile);
                Environment.Exit(-2);
            }
            return(String.Empty);
        }
Ejemplo n.º 5
0
 public DialogResult ShowDialog(string targetDir, string targetFile)
 {
     target_file       = targetFile;
     target_dir        = targetDir;
     labelHeading.Text = String.Format(Localizer.GetBestTranslation("ManualDownload_errFileNotFound"), target_file);
     ShowDialog();
     return(DialogResult.OK);
 }
Ejemplo n.º 6
0
 private void UpdateUI()
 {
     Text = Localizer.GetBestTranslation("ManualDownload_Title");
     labelHeading.Text   = Localizer.GetBestTranslation("ManualDownload_labelHeading");
     linkURL.Text        = labelTargetFile.Text = Localizer.GetBestTranslation("ManualDownload_linkURL");
     linkDir.Text        = Localizer.GetBestTranslation("ManualDownload_linkDir");
     labelDesc.Text      = Localizer.GetBestTranslation("ManualDownload_labelDesc");
     buttonContinue.Text = Localizer.GetBestTranslation("ManualDownload_buttonContinue");
 }
Ejemplo n.º 7
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     client.CancelAsync();
     Utils.ErrorDlg(Localizer.GetBestTranslation("HTTPDownload_msgCanceledByUser"));
     try
     {
         File.Delete(_target);
     }
     catch {}
     DialogResult = DialogResult.Cancel;
 }
        private void backButton_Click(object sender, EventArgs e)
        {
            bool isFirstDlg = false;

            _currentDialog = DialogFlowHandler.Instance.GetPreviousDlg(ref isFirstDlg);
            if (isFirstDlg)
            {
                backButton.Visible = false;
            }
            nextButton.Text = Localizer.GetBestTranslation("MainWindow_nextButton");
            SwitchDialog(_currentDialog);
        }
Ejemplo n.º 9
0
        public static void NotifyReboot(string DisplayName)
        {
            // Write Run registry key
            Utils.AutoRunApplication("set");

            // Notify about the needed reboot
            MessageBox.Show(Localizer.GetBestTranslation("Reboot_Required"), DisplayName, MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);

            //Close DeployTool
            Environment.Exit(-3);
        }
Ejemplo n.º 10
0
        private void bExit_Click(object sender, EventArgs e)
        {
            string                  message = Localizer.GetBestTranslation("Exit_Installation");
            const string            caption = "MediaPortal";
            const MessageBoxButtons buttons = MessageBoxButtons.YesNo;

            DialogResult result = MessageBox.Show(this, message, caption, buttons);

            if (result == DialogResult.Yes)
            {
                Application.Exit();
            }
        }
Ejemplo n.º 11
0
 private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error is WebException)
     {
         Utils.ErrorDlg(Localizer.GetBestTranslation("HTTPDownload_errDownloadFailed"));
         try
         {
             File.Delete(_target);
         }
         catch {}
         DialogResult = DialogResult.Abort;
     }
     else
     {
         DialogResult = DialogResult.OK;
     }
 }
Ejemplo n.º 12
0
        private void nextButton_Click(object sender, EventArgs e)
        {
            //
            // check Internet connection unless files have already been downloaded
            //
            if (_currentDialog.type == DialogType.DownloadOnly &&
                Directory.GetFiles(Application.StartupPath + "\\deploy").Length < 3)
            {
                if (!InstallationChecks.InternetChecker.CheckConnection())
                {
                    MessageBox.Show(Localizer.GetBestTranslation("DownloadOnly_NoConnectionWarning"), "MediaPortal",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            //
            // check if there's is sufficient hard disk space for installation
            //
            if (_currentDialog.type == DialogType.DBMSSettings || _currentDialog.type == DialogType.TvServerSettings ||
                _currentDialog.type == DialogType.MPSettings)
            {
                // at least 0.5 GB free disk space are required for installation
                const double requiredDiskSpace = 0.5;
                double       actualDiskSpace   =
                    InstallationChecks.DiskSpaceChecker.GetRemainingHardDiskCapacity(_currentDialog.installationPath);

                if (actualDiskSpace < requiredDiskSpace)
                {
                    MessageBox.Show(string.Format(Localizer.GetBestTranslation("DiskSpace_Error"), requiredDiskSpace * 1000),
                                    "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (nextButton.Text == Localizer.GetBestTranslation("MainWindow_buttonClose"))
            {
                //
                // If in download_only mode, start explorer to show downloaded stuff
                //
                if (InstallationProperties.Instance["InstallType"] == "download_only")
                {
                    try
                    {
                        Process process = new Process();
                        process.StartInfo.FileName        = "explorer.exe";
                        process.StartInfo.Arguments       = "/e, " + Application.StartupPath + "\\deploy";
                        process.StartInfo.UseShellExecute = true;
                        process.Start();
                    }
                    // Starting processes might fail - prefer a not opening Explorer instead of a big crash window...
                    catch (Exception)
                    {
                    }
                }
                Close();
                return;
            }
            if (nextButton.Text == Localizer.GetBestTranslation("Install_buttonDownload") ||
                nextButton.Text == Localizer.GetBestTranslation("Install_buttonInstall"))
            {
                nextButton.Enabled = false;
            }
            if (!_currentDialog.SettingsValid())
            {
                return;
            }
            _currentDialog.SetProperties();
            if (InstallationProperties.Instance["language"] != _currentCulture)
            {
                _currentCulture = InstallationProperties.Instance["language"];
                Localizer.SwitchCulture(_currentCulture);
                UpdateUI();
            }
            _currentDialog = _currentDialog.GetNextDialog();
            SwitchDialog(_currentDialog);
            if (!backButton.Visible)
            {
                backButton.Visible = true;
            }
            if (InstallationProperties.Instance["finished"] == "yes")
            {
                backButton.Visible = false;
                nextButton.Enabled = true;
                nextButton.Text    = Localizer.GetBestTranslation("MainWindow_buttonClose");
            }
            if (!_restart && InstallationProperties.Instance["Install_Dialog"] == "yes")
            {
                nextButton.Text = InstallationProperties.Instance["InstallType"] == "download_only"
                            ? Localizer.GetBestTranslation("Install_buttonDownload")
                            : Localizer.GetBestTranslation("Install_buttonInstall");
                InstallationProperties.Instance.Set("Install_Dialog", "no");
            }
        }
Ejemplo n.º 13
0
 private void UpdateUI()
 {
     Text = Localizer.GetBestTranslation("ManualDownload_Title");
     buttonBrowse.Text = Localizer.GetBestTranslation("MainWindow_browseButton");
 }