Esempio n. 1
0
        private void languageBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            bool  showUpdate = false;
            AddOn selected   = (AddOn)languageBox.SelectedItem;

            if (selected == english)
            {
                translatorLabel.Text = "";
            }
            else
            {
                translatorLabel.Text = "Translated by " + selected.Creator;
                if (selected.Installed)
                {
                    AddOn update = installer.AvailableAddOns.Find(selected);
                    if (update != null && update.Version > selected.Version)
                    {
                        languageUpdateBox.Text = string.Format("Update {0} to {1}",
                                                               AddOn.VersionToString(selected.Version), AddOn.VersionToString(update.Version));
                        showUpdate = true;
                    }
                }
            }
            languageUpdateBox.Visible = showUpdate;
            selector_Changed(sender);
        }
Esempio n. 2
0
        internal void ShowReadme(AddOn addOn)
        {
            string readmePath = Installer.GetReadmePath(addOn);

            Text         = addOn.Name + " - Notes of the author";
            textBox.Text = File.ReadAllText(readmePath, Encoding.GetEncoding(1252));
            textBox.Select(0, 0);
            ShowDialog();
        }
Esempio n. 3
0
 public static string GetReadmePath(AddOn addOn)
 {
     if (addOn.Readme == "")
     {
         return("");
     }
     else
     {
         return(GetAddOnFolder(addOn) + "\\" + addOn.Readme);
     }
 }
Esempio n. 4
0
 private void readmeButton_Click(object sender, EventArgs e)
 {
     if (list.SelectedItems.Count > 0)
     {
         AddOn addOn = (AddOn)list.SelectedItems[0].Tag;
         if (addOn.Readme != "" && File.Exists(Installer.GetReadmePath(addOn)))
         {
             TextViewer textViewer = new TextViewer();
             textViewer.ShowReadme(addOn);
         }
     }
 }
Esempio n. 5
0
        void DownloadComplete(object sender, AsyncCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {             // unzip downloaded file
                AddOn currentDownload = installSet[currentDownloadIndex];
                try
                {
                    currentDownload.Files.Clear();
                    string zipFilePath  = downloadFolder + "\\" + Path.GetFileName(currentDownload.URL);
                    string targetFolder = GetAddOnFolder(currentDownload);
                    if (targetFolder != "")
                    {
                        if (targetFolder != programFolder && !Directory.Exists(targetFolder))
                        {
                            Directory.CreateDirectory(targetFolder);
                        }
                        using (ZipStorerLight package = ZipStorerLight.Open(zipFilePath))
                        {
                            List <ZipStorerLight.ZipFileEntry> content = package.ReadCentralDir();
                            foreach (ZipStorerLight.ZipFileEntry item in content)
                            {
                                if (item.FileSize > 0)                                 // skip folders
                                {
                                    package.ExtractFile(item, targetFolder + "\\" + item.FilenameInZip);
                                    currentDownload.Files.Add(targetFolder + "\\" + item.FilenameInZip);
                                }
                            }
                        }
                        File.Delete(zipFilePath);
                        installedAddOns.Add(currentDownload);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Exception while trying to install '{1}':\n{0}", ex, currentDownload.Name), "Error");
                }
            }

            if (e.Cancelled || currentDownloadIndex + 1 >= installSet.Count)
            {
                downloader.DownloadProgressChanged -= DownloadProgressChanged;
                downloader.DownloadFileCompleted   -= DownloadComplete;
                SaveAndQuit();
            }
            else
            {             // start next
                completedDownloadSize += installSet[currentDownloadIndex].Size;
                currentDownloadIndex++;
                StartCurrentDownload();
            }
        }
Esempio n. 6
0
        private void AddListItem(AddOn addOn)
        {
            ListViewItem item = new ListViewItem();

            item.Text = addOn.Name;
            item.SubItems.Add(AddOn.VersionToString(addOn.Version));
            if (!addOn.Installed && addOn.Size > 0)
            {
                item.SubItems.Add(MainForm.SizeString(addOn.Size));
            }
            item.Checked = addOn.Installed;
            item.Tag     = addOn;
            list.Items.Add(item);
        }
Esempio n. 7
0
 private void list_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (list.SelectedItems.Count == 0)
     {
         creatorLabel.Text    = "";
         infoLabel.Text       = "";
         readmeButton.Visible = false;
     }
     else
     {
         AddOn addOn = (AddOn)list.SelectedItems[0].Tag;
         creatorLabel.Text    = "Created by " + addOn.Creator;
         infoLabel.Text       = addOn.Info;
         readmeButton.Visible = addOn.Installed && addOn.Readme != "" && File.Exists(Installer.GetReadmePath(addOn));
     }
 }
Esempio n. 8
0
        static string GetAddOnFolder(AddOn addOn)
        {
            switch (addOn.Type)
            {
            case AddOnType.Language:
                return(appDataFolder + "\\Localization");

            case AddOnType.MapSet:
                return(appDataFolder + "\\Maps");

            case AddOnType.AI:
                return(programFolder);

            default:
                return("");
            }
        }
Esempio n. 9
0
 public void SetData(AddOnSet installed, AddOnSet available, AddOnType type)
 {
     this.type = type;
     foreach (AddOn addOn in installed)
     {
         if (addOn.Type == type)
         {
             AddListItem(addOn);
             AddOn current = available.Find(addOn);
             if (current != null && current.Version > addOn.Version)
             {
                 AddListItem(current);
             }
         }
     }
     foreach (AddOn addOn in available)
     {
         if (addOn.Type == type && installed.Find(addOn) == null)
         {
             AddListItem(addOn);
         }
     }
     enabled = Installer.CanInstall(type, out disabledMessage);
 }
Esempio n. 10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            changeLabel.Text = "Add: 0\r\nRemove: 0";

            int         ScreenMode     = 1;
            int         ResolutionX    = 0;
            int         ResolutionY    = 0;
            int         ResolutionFreq = 0;
            RegistryKey registry       = null;

            try
            {
                registry = Registry.CurrentUser.OpenSubKey(registryKeyPath, false);
                if (registry != null)
                {
                    object value = registry.GetValue("ScreenMode");
                    if (value != null)
                    {
                        ScreenMode = (int)value;
                    }
                    value = registry.GetValue("ResolutionX");
                    if (value != null)
                    {
                        ResolutionX = (int)value;
                    }
                    value = registry.GetValue("ResolutionY");
                    if (value != null)
                    {
                        ResolutionY = (int)value;
                    }
                    value = registry.GetValue("ResolutionFreq");
                    if (value != null)
                    {
                        ResolutionFreq = (int)value;
                    }
                }
            }
            finally
            {
                if (registry != null)
                {
                    registry.Close();
                }
            }

            DisplayModeList displayModeList = new DisplayModeList();

            foreach (DEVMODE mode in displayModeList)
            {
                if (mode.dmPelsWidth >= 800 && mode.dmPelsHeight >= 480 && mode.dmBitsPerPel >= 16)
                {
                    resolutionBox.Items.Add(new DisplayMode(mode));
                    if (mode.dmPelsWidth == ResolutionX && mode.dmPelsHeight == ResolutionY && mode.dmDisplayFrequency == ResolutionFreq)
                    {
                        resolutionBox.SelectedIndex = resolutionBox.Items.Count - 1;
                    }
                }
            }
            if (resolutionBox.SelectedIndex < 0)
            {
                resolutionBox.SelectedIndex = resolutionBox.Items.Count - 1;
            }
            switch (ScreenMode)
            {
            case 0: screenWindowRadio.Checked = true; break;

            case 1: screenNormalRadio.Checked = true; break;

            case 2: screenResolutionRadio.Checked = true; break;
            }

            installer    = new Installer();
            english      = new AddOn(AddOnType.Language, "english", false);
            english.Name = "English";

            Text += " " + AddOn.VersionToString(thisVersion);
        }