private void EnableMainRepositorie(string Language) { if (!Enum.IsDefined(typeof(HardwareTypeEnum), Settings.Default.HardwareType)) { return; } HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType)); bool found = false; int i = 0; while ((i < _repositoryLocations.MainRepositories.Count) && (!found)) { if (_repositoryLocations.MainRepositories[i].Name.Equals("Main_Type" + det.RepositoryType + "_" + Language, StringComparison.CurrentCultureIgnoreCase)) { found = true; } else { i++; } } if (found) { foreach (RepositoryLocationInfo info in _repositoryLocations.MainRepositories) { if (info.Name.StartsWith("Main_Type" + det.RepositoryType + "_" + Language, StringComparison.CurrentCultureIgnoreCase)) { info.Enabled = true; } else if (info.Name.StartsWith("Main_", StringComparison.CurrentCultureIgnoreCase)) { info.Enabled = false; } } _repositoryLocations.SaveRepository(); } else { foreach (RepositoryLocationInfo info in _repositoryLocations.MainRepositories) { if (info.Name.StartsWith("Main_Type" + det.RepositoryType + "_English", StringComparison.CurrentCultureIgnoreCase)) { info.Enabled = true; } else if (info.Name.StartsWith("Main_", StringComparison.CurrentCultureIgnoreCase)) { info.Enabled = false; } } _repositoryLocations.SaveRepository(); } }
public override bool Execute() { if (cbxHardwareType.SelectedIndex == 0) { errorProvider.Clear(); errorProvider.SetError(cbxHardwareType, cbxHardwareType.Items[0].ToString()); return(false); } if (FtpCommands.TestFTPserver(txtServerName.Text, txtUserName.Text, txtPassword.Text)) { HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)cbxHardwareType.SelectedIndex); Settings.Default.Server = txtServerName.Text; Settings.Default.Username = txtUserName.Text; Settings.Default.Password = txtPassword.Text; Settings.Default.FTPSubFolder = det.DefaultFTPSubFolder; Settings.Default.WebserverSubFolder = det.DefaultWebserverSubFolder; string prevHardwareType = Settings.Default.HardwareType; Settings.Default.HardwareType = ((HardwareTypeEnum)cbxHardwareType.SelectedIndex).ToString(); Settings.Default.HardwareName = cbxHardwareType.Items[cbxHardwareType.SelectedIndex].ToString(); Settings.Default.FirstRun = false; Settings.Default.Save(); if (prevHardwareType != Settings.Default.HardwareType) { //reload the repository to fix the magic tokens Repository newRep = new Repository(UpdateRepositoryState); panelResults["Repository"] = newRep; Thread t = new Thread(new ThreadStart(newRep.UpdateRepository)); t.Start(); while (t.ThreadState != ThreadState.Stopped) { Application.DoEvents(); Thread.Sleep(50); } } else { ((Repository)panelResults["Repository"]).LoadRepositoryFiles(); } //this will trigger an appinfo update panelResults["SelectedItem"] = 1; return(true); } else { Logger.GetInstance().AddLogLine(LogLevel.Warning, "FTP test failed. Error while trying to connect to the FTP server."); MessageBox.Show(Resources.MessageBox_FtpConnectionTestFailed, Resources.MessageBox_FtpConnectionTestCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void cbxHardwareType_SelectedIndexChanged(object sender, EventArgs e) { if (cbxHardwareType.SelectedIndex > 0) { HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)cbxHardwareType.SelectedIndex); txtServerName.Text = det.DefaultServerName; txtUserName.Text = det.DefaultFtpUsername; txtPassword.Text = det.DefaultFtpPassword; } }
private void UpdateUI() { string PrevSelection = ""; if (lvSelectItem.SelectedItems.Count > 0) { PrevSelection = lvSelectItem.SelectedItems[0].Text; } lvSelectItem.Items.Clear(); lvSelectItem.Tag = 1; if (tabSelectCategory.SelectedTab == tabNew) { HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType)); foreach (RepositoryApplicationInfo app in repository.Applications) { if (app.IsNew) { //lbSelectedItem.Items.Add(app); AddSelectItemItem(app, 0); } } foreach (RepositoryCustomMenuInfo menu in repository.CustomMenus) { if ((menu.IsNew) && (det.RepositoryType == "AB" | det.RepositoryType == "A4")) { //lbSelectedItem.Items.Add(menu); AddSelectItemItem(menu, 0); } } foreach (RepositoryThemeInfo theme in repository.Themes) { if (theme.IsNew && det.RepositoryType == "AB") { //lbSelectedItem.Items.Add(theme); AddSelectItemItem(theme, 0); } } foreach (RepositoryWaitImagesInfo waitImages in repository.WaitImages) { if (waitImages.IsNew && det.RepositoryType == "AB") { //lbSelectedItem.Items.Add(waitImages); AddSelectItemItem(waitImages, 0); } } foreach (RepositoryWebserviceInfo web in repository.Webservices) { if (web.IsNew && det.RepositoryType == "AB") { //lbSelectedItem.Items.Add(web); AddSelectItemItem(web, 0); } } } if (tabSelectCategory.SelectedTab == tabApplications) { foreach (RepositoryApplicationInfo app in repository.Applications) { //lbSelectedItem.Items.Add(app); AddSelectItemItem(app); } } if (tabSelectCategory.SelectedTab == tabCustomMenus) { foreach (RepositoryCustomMenuInfo index in repository.CustomMenus) { //lbSelectedItem.Items.Add(index); AddSelectItemItem(index); } } if (tabSelectCategory.SelectedTab == tabThemes) { foreach (RepositoryThemeInfo them in repository.Themes) { if ((cbxThemeFormat.SelectedIndex == 0) && (them.ForHD)) { //lbSelectedItem.Items.Add(them); AddSelectItemItem(them); } if ((cbxThemeFormat.SelectedIndex == 1) && (them.ForSD)) { //lbSelectedItem.Items.Add(them); AddSelectItemItem(them); } } } if (tabSelectCategory.SelectedTab == tabWaitImages) { foreach (RepositoryWaitImagesInfo wi in repository.WaitImages) { //lbSelectedItem.Items.Add(wi); AddSelectItemItem(wi); } } if (tabSelectCategory.SelectedTab == tabWebservices) { foreach (RepositoryWebserviceInfo wsi in repository.Webservices) { //lbSelectedItem.Items.Add(wsi); AddSelectItemItem(wsi); } } if (tabSelectCategory.SelectedTab == tabUpdates) { List <RepositoryFileInfoBase> allItems = new List <RepositoryFileInfoBase>(); allItems.AddRange(repository.Applications.ToArray()); allItems.AddRange(repository.CustomMenus.ToArray()); allItems.AddRange(repository.Themes.ToArray()); allItems.AddRange(repository.WaitImages.ToArray()); allItems.AddRange(repository.Webservices.ToArray()); foreach (RepositoryFileInfoBase item in allItems) { if (item.UpdateAvailable) { //lbSelectedItem.Items.Add(item); AddSelectItemItem(item, 1); } } } if (tabSelectCategory.SelectedTab == tabInstalled) { foreach (InstalledAppInfo appinfo in installedAppsManager.InstalledApps) { List <RepositoryFileInfoBase> allItems = new List <RepositoryFileInfoBase>(); allItems.AddRange(repository.Applications.ToArray()); allItems.AddRange(repository.CustomMenus.ToArray()); allItems.AddRange(repository.Themes.ToArray()); allItems.AddRange(repository.WaitImages.ToArray()); allItems.AddRange(repository.Webservices.ToArray()); int i = 0; while ((i < allItems.Count) && (!allItems[i].Name.Equals(appinfo.Name, StringComparison.CurrentCultureIgnoreCase))) { i++; } if (i < allItems.Count) { AddSelectItemItem(new RepositoryApplicationInfo(appinfo.Name, allItems[i].Author, allItems[i].Maintainer, appinfo.Version, allItems[i].Homepage, allItems[i].Forum, allItems[i].Description, allItems[i].Changelog, allItems[i].UsageInstructions, allItems[i].DownloadURL, allItems[i].Screenshots, (allItems[i] is RepositoryApplicationInfo) ? ((RepositoryApplicationInfo)allItems[i]).InstallScript : string.Empty, (allItems[i] is RepositoryApplicationInfo) ? ((RepositoryApplicationInfo)allItems[i]).GayaInterfaceURL : string.Empty, (allItems[i] is RepositoryApplicationInfo) ? ((RepositoryApplicationInfo)allItems[i]).WebInterfaceURL : string.Empty), appinfo.Started ? 2 : 3); } else { //lbSelectedItem.Items.Add(new RepositoryApplicationInfo(appinfo.Name, string.Empty, string.Empty, appinfo.Version, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], string.Empty, string.Empty, string.Empty)); AddSelectItemItem(new RepositoryApplicationInfo(appinfo.Name, string.Empty, string.Empty, appinfo.Version, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], string.Empty, string.Empty, string.Empty), appinfo.Started?2:3); } } //retrigger the scrollbar, needed for some UI quirck //where the horizontal scrollbar appeared for no reason lvSelectItem.Scrollable = false; lvSelectItem.Scrollable = true; } lvSelectItem.Tag = null; lvSelectItem.SelectedItems.Clear(); int j = 0; while ((j < lvSelectItem.Items.Count) && (lvSelectItem.Items[j].Text != PrevSelection)) { j++; } if (j < lvSelectItem.Items.Count) { lvSelectItem.Items[j].Selected = true; lvSelectItem.Items[j].BackColor = SystemColors.Highlight; lvSelectItem.Items[j].ForeColor = SystemColors.HighlightText; lvSelectItem.TopItem = j >= 2 ? lvSelectItem.Items[j - 2] : lvSelectItem.Items[0]; } else { if (lvSelectItem.Items.Count > 0) { lvSelectItem.Items[0].Selected = true; lvSelectItem.Items[0].BackColor = SystemColors.Highlight; lvSelectItem.Items[0].ForeColor = SystemColors.HighlightText; } else { tbAuthor.Text = tbDescription.Text = tbHomepageURL.Text = tbInstalledVersion.Text = tbItemType.Text = tbMaintainer.Text = tbAdditionalUsageInstrictions.Text = tbChangelog.Text = tbWebserviceName.Text = string.Empty; llWebbrowserInterface.Text = string.Empty; } } }
private void ShowHideSupportedTabs() { HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType)); if (det.RepositoryType == "A4") { if (!tabSelectCategory.TabPages.Contains(tabCustomMenus)) { tabSelectCategory.TabPages.Add(tabCustomMenus); } if (tabSelectCategory.TabPages.Contains(tabThemes)) { tabSelectCategory.TabPages.Remove(tabThemes); } if (tabSelectCategory.TabPages.Contains(tabWaitImages)) { tabSelectCategory.TabPages.Remove(tabWaitImages); } if (tabSelectCategory.TabPages.Contains(tabWebservices)) { tabSelectCategory.TabPages.Remove(tabWebservices); } } if (det.RepositoryType == "C" | det.RepositoryType == "V") { if (tabSelectCategory.TabPages.Contains(tabThemes)) { tabSelectCategory.TabPages.Remove(tabThemes); } if (tabSelectCategory.TabPages.Contains(tabCustomMenus)) { tabSelectCategory.TabPages.Remove(tabCustomMenus); } if (tabSelectCategory.TabPages.Contains(tabWaitImages)) { tabSelectCategory.TabPages.Remove(tabWaitImages); } if (tabSelectCategory.TabPages.Contains(tabWebservices)) { tabSelectCategory.TabPages.Remove(tabWebservices); } } if (det.RepositoryType == "AB") { if (!tabSelectCategory.TabPages.Contains(tabThemes)) { tabSelectCategory.TabPages.Add(tabThemes); } if (!tabSelectCategory.TabPages.Contains(tabWaitImages)) { tabSelectCategory.TabPages.Add(tabWaitImages); } } }
private void pnlDone_VisibleChanged(object sender, EventArgs e) { if (this.Visible) { HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType)); gbxWebbrowserUI.Visible = gbxUsageInstructions.Visible = gbxGayaInterface.Visible = false; if (((RepositoryFileInfoBase)panelResults["SelectedItem"]).UsageInstructions.Length > 0) { tbUsageInstructions.Text = ((RepositoryFileInfoBase)panelResults["SelectedItem"]).UsageInstructions; gbxUsageInstructions.Visible = true; } if (panelResults["SelectedItem"] is RepositoryApplicationInfo) { RepositoryApplicationInfo app = panelResults["SelectedItem"] as RepositoryApplicationInfo; if (!string.IsNullOrEmpty(app.WebInterfaceURL)) { gbxWebbrowserUI.Visible = true; linkWebInterfaceURL.Text = app.WebInterfaceURL; linkWebInterfaceURL.Links.Clear(); linkWebInterfaceURL.Links.Add(0, linkWebInterfaceURL.Text.Length, app.WebInterfaceURL); } if (!string.IsNullOrEmpty(app.GayaInterfaceURL)) { gbxGayaInterface.Visible = true; lblNewWebserviceName.Text = app.Name; } } if (panelResults["SelectedItem"] is RepositoryApplicationInfo) { lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Application.Replace("\\n", "\n"); } if (panelResults["SelectedItem"] is RepositoryThemeInfo) { lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Theme.Replace("\\n", "\n"); } if (panelResults["SelectedItem"] is RepositoryCustomMenuInfo) { if (det.RepositoryType == "AB") { lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_CustomMenu.Replace("\\n", "\n"); } if (det.RepositoryType == "A4") { string Warning = ""; string Command = Settings.Default.CommandsScriptURL.Substring(Settings.Default.CommandsScriptURL.LastIndexOf('/') + 1); Command = Command.Substring(0, Command.Length - 3) + "cgi"; string WarningTitle = ""; Warning += Resources.MessageBox_RestartNMTConfirm; WarningTitle = Resources.MessageBox_RestartNMTCaption; Command += "?reboot"; lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_CustomMenuA4.Replace("\\n", "\n"); } } if (panelResults["SelectedItem"] is RepositoryWaitImagesInfo) { lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_WaitImageSet.Replace("\\n", "\n"); } if (panelResults["SelectedItem"] is RepositoryWebserviceInfo) { lblSelectionSpecificInstructions.Text = Resources.DoneInstalling_Webservice.Replace("\\n", "\n"); } } }