예제 #1
0
        public MainForm()
        {
            InitializeComponent();

              if (Properties.Settings.Default.NeedUpgrade)
              {
            Properties.Settings.Default.Upgrade();
            Properties.Settings.Default.NeedUpgrade = false;
            Properties.Settings.Default.AutoUpdateThisVersion = true;
            Properties.Settings.Default.Save();
              }

              if (Program.Mono)
              {
            comboBoxUserColor1.BackColor = Color.DarkGreen;
            comboBoxUserColor1.ForeColor = Color.White;
            comboBoxUserColor2.BackColor = Color.DarkBlue;
            comboBoxUserColor2.ForeColor = Color.White;
            comboBoxUserColor3.BackColor = Color.DarkRed;
            comboBoxUserColor3.ForeColor = Color.White;
            comboBoxUserColor4.BackColor = Color.DarkViolet;
            comboBoxUserColor4.ForeColor = Color.White;
            comboBoxUserColor5.BackColor = Color.DarkOrange;
            comboBoxUserColor5.ForeColor = Color.White;
            richTextBox1.Font = new Font(richTextBox1.Font, FontStyle.Bold);
              }

              createProjectMenu();

              #region loadSettings
              loadSelectedProject();
              #endregion

              #region initialization of background workers
              bwSuggestions.DoWork += new DoWorkEventHandler(bwSuggestions_DoWork);
              bwSuggestions.WorkerSupportsCancellation = true;

              bwLoadHistory.DoWork += new DoWorkEventHandler(bwLoadHistory_DoWork);
              bwLoadHistory.WorkerSupportsCancellation = true;

              bwFindRevision.DoWork += new DoWorkEventHandler(bwFindRevision_DoWork);
              bwFindRevision.WorkerSupportsCancellation = true;

              bwAuthors.DoWork += new DoWorkEventHandler(bwAuthors_DoWork);
              bwAuthors.WorkerSupportsCancellation = true;
              #endregion

              articleSuggestions.Left = textBoxArticleTitle.Left + groupBox1.Left;
              articleSuggestions.Width = textBoxArticleTitle.Width;
              articleSuggestions.Top = textBoxArticleTitle.Top + groupBox1.Top + textBoxArticleTitle.Height;

              listViewEdits.ListViewItemSorter = lvwColumnSorterEdits;
              listViewUsers.ListViewItemSorter = lvwColumnSorterUsers;

              suggestionFetcher = new SuggestionFetcher(Projects.currentProjectBaseUrl, 30);
              revisionsFetcher = new RevisionsFetcher(Projects.currentProjectBaseUrl);

              comboBox1.SelectedIndex = 0;

              prepareListViewStatistics();

              if ((Properties.Settings.Default.AutoUpdate) && (Properties.Settings.Default.AutoUpdateThisVersion))
            AutoUpdate.CheckForUpdate();
        }
예제 #2
0
        private void loadSelectedProject()
        {
            #region search Project/Language
              Projects.Project selectedProject = null; ;
              Projects.ProjectLanguage selectedLanguage = null;
              foreach (Projects.Project p in Projects.projects)
              {
            if (p.shortname == Properties.Settings.Default.Project)
            {
              selectedProject = p;
              if (p.languages.Count > 0)
              {
            foreach (Projects.ProjectLanguage lang in p.languages)
            {
              if (lang.shortname == Properties.Settings.Default.ProjectLanguage)
              {
                selectedLanguage = lang;
                break;
              }
            }
              }
              break;
            }
              }
              if ((selectedProject != null) && (selectedProject.languages.Count == 0)) selectedLanguage = null;
              if (selectedProject == null) selectedProject = Projects.projects[0]; // Wikipedia
              if ((selectedProject.languages.Count > 0) && (selectedLanguage == null))
              {
            selectedLanguage = selectedProject.languages[0]; // some (random) standard!
            // search for standard language
            foreach (Projects.ProjectLanguage lang in selectedProject.languages)
            {
              if (lang.shortname == selectedProject.standardLanguage)
              {
            selectedLanguage = lang;
            break;
              }
            }
            // maybe the system is in another language
            CultureInfo ci = Thread.CurrentThread.CurrentCulture;
            string localLanguage = ci.TwoLetterISOLanguageName;
            foreach (Projects.ProjectLanguage lang in selectedProject.languages)
            {
              if (lang.shortname == localLanguage)
              {
            selectedLanguage = lang;
            break;
              }
            }
              }
              // save
              Properties.Settings.Default.Project = selectedProject.shortname;
              if (selectedLanguage != null)
            Properties.Settings.Default.ProjectLanguage = selectedLanguage.shortname;
              else
            Properties.Settings.Default.ProjectLanguage = "";
              Properties.Settings.Default.Save();
              #endregion

              // baseUrl
              if (selectedProject.languages.Count == 0)
            Projects.currentProjectBaseUrl = selectedProject.baseUrl;
              else
            Projects.currentProjectBaseUrl = selectedLanguage.baseUrl;
              Projects.currentProjectBaseUrl += selectedProject.adding;//"/w/";

              suggestionFetcher = new SuggestionFetcher(Projects.currentProjectBaseUrl, 30);
              revisionsFetcher = new RevisionsFetcher(Projects.currentProjectBaseUrl);

              // show name
              Projects.currentProjectSaveName = "";
              if (selectedLanguage != null) Projects.currentProjectSaveName = selectedLanguage.shortname + ".";
              Projects.currentProjectSaveName += selectedProject.shortname;
              labelProject.Text = "Project: " + Projects.currentProjectSaveName;

              #region show in menu
              // remove all checked
              foreach (ToolStripMenuItem m in menuProject.DropDownItems)
              {
            m.Checked = false;
            foreach (ToolStripMenuItem m2 in m.DropDownItems)
              m2.Checked = false;
              }

              // set checked
              foreach (ToolStripMenuItem m in menuProject.DropDownItems)
              {
            Projects.Project project = ((Projects.Project)m.Tag);
            if (project == selectedProject)
            {
              if (project.languages.Count == 0)
            m.Checked = true;
              else
              {
            foreach (ToolStripMenuItem m2 in m.DropDownItems)
            {
              object[] properties = (object[])m2.Tag;
              Projects.ProjectLanguage lang = (Projects.ProjectLanguage)(properties[1]);
              if (lang == selectedLanguage)
              {
                m2.Checked = true;
                break;
              }
            }
              }
              break;
            }
              }

              #endregion
        }