internal void loadAddonProject() { if (openProjectDialog.ShowDialog() == DialogResult.OK) { if (openProjectDialog.FileName.EndsWith(".addonmanager.project")) { addonProject = File.ReadAllText(openProjectDialog.FileName, Encoding.UTF8).DeserializeObject<AddonProject>(); addonProject.projectLocation = openProjectDialog.FileName; #region Catalog and Basket clearCatalogListBoxes(); ActiveCheckedListBox.managingLists = true; // Products foreach (string product in addonProject.catalog.catalog_products) { if (product.Trim().IndexOf('(') != -1) { int targetIndex = productsListBox.Items.IndexOf(productsListBox.Items.Cast<string>() .Where(itemText => itemText.StartsWith(AddonProject.Catalog.getListBoxEntryText(product))) .First()); productsListBox.Items[targetIndex] = product; productsListBox.SetItemChecked(targetIndex, true); } } // Categories foreach (string category in addonProject.catalog.catalog_categories) { if (category.Trim().IndexOf('(') != -1) { int targetIndex = categoriesListBox.Items.IndexOf(categoriesListBox.Items.Cast<string>() .Where(itemText => itemText.StartsWith(AddonProject.Catalog.getListBoxEntryText(category))) .First()); categoriesListBox.Items[targetIndex] = category; categoriesListBox.SetItemChecked(targetIndex, true); } } ActiveCheckedListBox.managingLists = false; // Basket Files List<string> basketFiles = new List<string>(); foreach (string basket in addonProject.catalog.basket_definitions) basketFiles.Add(basket.Trim()); addItemsWithNaturalOrder(ref basketsListBox, basketFiles); // Others addonProject.catalog.addonCreator = addonProject.catalog.addonCreator .Substring(0, Math.Min(addonProject.catalog.addonCreator.Length, Addon.addonCreatorDef[2] - 1)); addonProject.catalog.addonDescription = addonProject.catalog.addonDescription .Substring(0, Math.Min(addonProject.catalog.addonDescription.Length, Addon.addonDescriptionDef[2] - 1)); addonProject.catalog.addonName = addonProject.catalog.addonName .Substring(0, Math.Min(addonProject.catalog.addonName.Length, Addon.addonNameDef[2] - 1)); addonProject.catalog.addonVersion = addonProject.catalog.addonVersion .Substring(0, Math.Min(addonProject.catalog.addonVersion.Length, Addon.addonVersionDef[2] - 1)); #endregion #region Accent if (addonProject.accent.accentXamlBytes != null) avalonEditProxyAccent.textEditor.Text = addonProject.accent.accentXaml; // Others addonProject.accent.addonCreator = addonProject.accent.addonCreator .Substring(0, Math.Min(addonProject.accent.addonCreator.Length, Addon.addonCreatorDef[2] - 1)); addonProject.accent.addonDescription = addonProject.accent.addonDescription .Substring(0, Math.Min(addonProject.accent.addonDescription.Length, Addon.addonDescriptionDef[2] - 1)); addonProject.accent.addonName = addonProject.accent.addonName .Substring(0, Math.Min(addonProject.accent.addonName.Length, Addon.addonNameDef[2] - 1)); addonProject.accent.addonVersion = addonProject.accent.addonVersion .Substring(0, Math.Min(addonProject.accent.addonVersion.Length, Addon.addonVersionDef[2] - 1)); #endregion #region Theme if (addonProject.theme.themeXamlBytes != null) avalonEditProxyTheme.textEditor.Text = addonProject.theme.themeXaml; // Others addonProject.theme.addonCreator = addonProject.theme.addonCreator .Substring(0, Math.Min(addonProject.theme.addonCreator.Length, Addon.addonCreatorDef[2] - 1)); addonProject.theme.addonDescription = addonProject.theme.addonDescription .Substring(0, Math.Min(addonProject.theme.addonDescription.Length, Addon.addonDescriptionDef[2] - 1)); addonProject.theme.addonName = addonProject.theme.addonName .Substring(0, Math.Min(addonProject.theme.addonName.Length, Addon.addonNameDef[2] - 1)); addonProject.theme.addonVersion = addonProject.theme.addonVersion .Substring(0, Math.Min(addonProject.theme.addonVersion.Length, Addon.addonVersionDef[2] - 1)); #endregion #region Language if (addonProject.language.languageFileBytes != null) avalonEditProxyLanguage.textEditor.Text = addonProject.language.languageFileText; // Others addonProject.language.addonCreator = addonProject.language.addonCreator .Substring(0, Math.Min(addonProject.language.addonCreator.Length, Addon.addonCreatorDef[2] - 1)); addonProject.language.addonDescription = addonProject.language.addonDescription .Substring(0, Math.Min(addonProject.language.addonDescription.Length, Addon.addonDescriptionDef[2] - 1)); addonProject.language.addonName = addonProject.language.addonName .Substring(0, Math.Min(addonProject.language.addonName.Length, Addon.addonNameDef[2] - 1)); addonProject.language.addonVersion = addonProject.language.addonVersion .Substring(0, Math.Min(addonProject.language.addonVersion.Length, Addon.addonVersionDef[2] - 1)); #endregion MessageBox.Show("The selected project was loaded successfully!", "Just to let you know...", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please select a file with the default extension '.addonmanager.project' and retry.", "Hold your horses there, big guy!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public MainForm(Boolean isFirstRun = false, String installAddonPath = null, Boolean setupIPCTalk = false, Int32 port = -1) { Logger.Setup(); #region Culture Independency Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); Properties.Resources.Culture = new CultureInfo("en-GB"); log.Info("Culture independency achieved."); #endregion Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont); InitializeComponent(); offlineServerTalk = new OfflineServerTalk(); addonProject = new AddonProject(); htmlPanel = new HtmlPanel(); htmlPanel.AutoSize = false; htmlPanel.BorderStyle = BorderStyle.Fixed3D; htmlPanel.Location = new Point(186, 38); htmlPanel.Size = new Size(210, 299); htmlPanel.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; installAddonGroupBox.Controls.Add(htmlPanel); avalonEditProxyAccent.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyTheme.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyLanguage.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyMemoryPatch.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#"); avalonEditProxyAccent.textEditor.Text = AddonProject.Accent.defaultAccentXaml; avalonEditProxyTheme.textEditor.Text = AddonProject.Theme.defaultThemeXaml; avalonEditProxyLanguage.textEditor.Text = AddonProject.Language.defaultLanguageFileText; if (!String.IsNullOrWhiteSpace(installAddonPath)) { log.Info("/installAddon was specified, executing run-once installation."); // handle auto install } else { if (isFirstRun) { if (setupIPCTalk && port != -1) offlineServerTalk.initialize(port); BeginInvoke(new MethodInvoker(delegate { Hide(); FirstRunForm frForm = new FirstRunForm(this); frForm.Show(); })); } } }