Dmitry Krypt0n 6 years ago
parent
commit
9e37b7650b
2 changed files with 41 additions and 1 deletions
  1. 17 1
      FactorioModManager/Form1.Designer.cs
  2. 24 0
      FactorioModManager/Form1.cs

+ 17 - 1
FactorioModManager/Form1.Designer.cs

@@ -51,6 +51,7 @@
             this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
             this.backgroundLoadInfo = new System.ComponentModel.BackgroundWorker();
             this.backgroundUpdateMods = new System.ComponentModel.BackgroundWorker();
+            this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
             this.menuStrip1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
             this.statusStrip1.SuspendLayout();
@@ -211,7 +212,8 @@
             // statusStrip1
             // 
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.toolStripProgressBar1});
+            this.toolStripProgressBar1,
+            this.toolStripStatusLabel1});
             this.statusStrip1.Location = new System.Drawing.Point(0, 501);
             this.statusStrip1.Name = "statusStrip1";
             this.statusStrip1.Size = new System.Drawing.Size(800, 22);
@@ -231,6 +233,19 @@
             this.backgroundLoadInfo.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.BackgroundLoadInfo_ProgressChanged);
             this.backgroundLoadInfo.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.BackgroundLoadInfo_RunWorkerCompleted);
             // 
+            // backgroundUpdateMods
+            // 
+            this.backgroundUpdateMods.WorkerReportsProgress = true;
+            this.backgroundUpdateMods.DoWork += new System.ComponentModel.DoWorkEventHandler(this.BackgroundUpdateMods_DoWork);
+            this.backgroundUpdateMods.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.BackgroundUpdateMods_ProgressChanged);
+            this.backgroundUpdateMods.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.BackgroundUpdateMods_RunWorkerCompleted);
+            // 
+            // toolStripStatusLabel1
+            // 
+            this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
+            this.toolStripStatusLabel1.Size = new System.Drawing.Size(46, 17);
+            this.toolStripStatusLabel1.Text = "Статус:";
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -278,6 +293,7 @@
         private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
         private System.ComponentModel.BackgroundWorker backgroundLoadInfo;
         private System.ComponentModel.BackgroundWorker backgroundUpdateMods;
+        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
     }
 }
 

+ 24 - 0
FactorioModManager/Form1.cs

@@ -21,6 +21,7 @@ namespace FactorioModManager
 
         string indexes_dir = @"data\indexes\";
         string API_URL = "https://mods.factorio.com/api/mods/";
+        string status_String = "Статус: ";
 #if (DEBUG)
         string mods_path = @"E:\FMM\mods\";
 #else
@@ -122,6 +123,7 @@ namespace FactorioModManager
             }
             if (Properties.Settings.Default.autoLoadInfo)
             {
+                toolStripStatusLabel1.Text = status_String + "Загрузка информации";
                 backgroundLoadInfo.RunWorkerAsync();
             }
             dataGridView1.Rows.Clear();
@@ -173,14 +175,36 @@ namespace FactorioModManager
         {
             dataGridView1.Rows.Clear();
             toolStripProgressBar1.Value = 0;
+            
             for (int i=0;i<mods.Count;i++)
             {
                 dataGridView1.Rows.Add(modlist.mods[i].enabled, mods[i].title);
             }
             if (Properties.Settings.Default.autoUpdateMods)
             {
+                toolStripStatusLabel1.Text = status_String + "Обновление модов";
                 backgroundUpdateMods.RunWorkerAsync();
             }
+            else
+            {
+                toolStripStatusLabel1.Text = status_String + "Готово";
+            }
+        }
+
+        private void BackgroundUpdateMods_DoWork(object sender, DoWorkEventArgs e)
+        {
+
+        }
+
+        private void BackgroundUpdateMods_ProgressChanged(object sender, ProgressChangedEventArgs e)
+        {
+            toolStripProgressBar1.Value = e.ProgressPercentage;
+        }
+
+        private void BackgroundUpdateMods_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
+        {
+            toolStripProgressBar1.Value = 0;
+            toolStripStatusLabel1.Text = status_String + "Готово";
         }
     }
 }