diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs
index 021af3e..0c3076d 100644
--- a/ShiftOS.WinForms/Applications/Downloader.cs
+++ b/ShiftOS.WinForms/Applications/Downloader.cs
@@ -50,7 +50,6 @@ namespace ShiftOS.WinForms.Applications
SetupUI();
}));
};
- DownloadManager.ProgressUpdate += pupdate;
DownloadManager.DownloadStarted += started;
DownloadManager.DownloadCompleted += completed;
}
@@ -62,7 +61,6 @@ namespace ShiftOS.WinForms.Applications
public bool OnUnload()
{
- DownloadManager.ProgressUpdate -= pupdate;
DownloadManager.DownloadStarted -= started;
DownloadManager.DownloadCompleted -= completed;
return true;
@@ -78,46 +76,22 @@ namespace ShiftOS.WinForms.Applications
int heightMultiplier = 0;
- foreach(var download in DownloadManager.Downloads)
+ for(int i = 0; i < DownloadManager.Downloads.Length; i++)
{
- var pnl = new Panel();
- pnl.Width = fllist.Width;
- pnl.Height = 50;
- var picpreview = new PictureBox();
- picpreview.Size = new Size(42, 42);
- picpreview.Image = FileSkimmerBackend.GetImage(download.Destination);
- picpreview.Location = new Point(4, 4);
- if (heightMultiplier < 5)
+ var dctrl = new DownloadControl(i);
+ if(heightMultiplier < 10)
+ {
heightMultiplier++;
- pnl.Controls.Add(picpreview);
- picpreview.Show();
- var prg = new ShiftedProgressBar();
- prg.Maximum = 100;
- prg.Value = download.Progress;
- prg.Width = pnl.Width - 8;
- prg.Left = 4;
- prg.Top = picpreview.Height + 8;
- prg.Height = 20;
- var lbtitle = new Label();
- lbtitle.Tag = "header1";
- lbtitle.Text = download.ShiftnetUrl;
- lbtitle.Top = 4;
- lbtitle.Left = 8 + picpreview.Height;
- pnl.Controls.Add(lbtitle);
- lbtitle.Show();
- lbtitle.AutoSize = true;
- pnl.Controls.Add(prg);
- prg.Show();
-
- fllist.Controls.Add(pnl);
- pnl.Show();
- ControlManager.SetupControls(pnl);
+ }
+
+ fllist.Controls.Add(dctrl);
+ dctrl.Show();
}
if (heightMultiplier == 0)
heightMultiplier = 1;
- this.Parent.Height = 50 * heightMultiplier;
+ this.ParentForm.Height = 150 * heightMultiplier;
}
}
@@ -149,8 +123,8 @@ namespace ShiftOS.WinForms.Applications
for (int i = 0; i < down.Bytes.Length; i += byteWrite)
{
Thread.Sleep(1000);
- _downloads[_downloads.IndexOf(down)].Progress = i / down.Bytes.Length;
- ProgressUpdate?.Invoke(_downloads.IndexOf(down), i / down.Bytes.Length);
+ _downloads[_downloads.IndexOf(down)].Progress = (int)((float)(i / down.Bytes.Length) * 100);
+ ProgressUpdate?.Invoke(_downloads.IndexOf(down), (int)((float)(i / down.Bytes.Length) * 100));
}
ShiftOS.Objects.ShiftFS.Utils.WriteAllBytes(down.Destination, down.Bytes);
_downloads.Remove(down);
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs
index eeb0439..164c79d 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.Designer.cs
@@ -102,6 +102,7 @@
// wbcanvas
//
this.wbcanvas.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.wbcanvas.IsWebBrowserContextMenuEnabled = false;
this.wbcanvas.Location = new System.Drawing.Point(0, 29);
this.wbcanvas.MinimumSize = new System.Drawing.Size(20, 20);
this.wbcanvas.Name = "wbcanvas";
@@ -109,6 +110,7 @@
this.wbcanvas.Size = new System.Drawing.Size(805, 510);
this.wbcanvas.TabIndex = 1;
this.wbcanvas.WebBrowserShortcutsEnabled = false;
+ this.wbcanvas.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbcanvas_Navigated);
this.wbcanvas.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(this.wbcanvas_Navigating);
//
// Shiftnet
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs
index 986eec6..d89b55a 100644
--- a/ShiftOS.WinForms/Applications/Shiftnet.cs
+++ b/ShiftOS.WinForms/Applications/Shiftnet.cs
@@ -89,11 +89,12 @@ namespace ShiftOS.WinForms.Applications
private void wbcanvas_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
- if (CurrentUrl != e.Url.ToString() && !e.Url.ToString().StartsWith("about:"))
+ string Url = e.Url.ToString().Replace("http://", "");
+ if (CurrentUrl != Url.ToString() && !Url.ToString().StartsWith("about:"))
{
e.Cancel = true;
Future.Clear();
- ShiftnetNavigate(e.Url.ToString());
+ ShiftnetNavigate(Url.ToString());
}
}
@@ -227,5 +228,10 @@ namespace ShiftOS.WinForms.Applications
e.SuppressKeyPress = true;
}
}
+
+ private void wbcanvas_Navigated(object sender, WebBrowserNavigatedEventArgs e)
+ {
+ }
}
}
+
diff --git a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
index ba4cbba..e5a2c33 100644
--- a/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
+++ b/ShiftOS.WinForms/Controls/ShiftedProgressBar.cs
@@ -111,7 +111,7 @@ namespace ShiftOS.WinForms.Controls
protected override void OnPaint(PaintEventArgs pe)
{
- pe.Graphics.Clear(this.BackColor);
+ pe.Graphics.Clear(Color.Black);
switch (_style)
{
case ProgressBarStyle.Continuous:
diff --git a/ShiftOS.WinForms/DownloadControl.Designer.cs b/ShiftOS.WinForms/DownloadControl.Designer.cs
new file mode 100644
index 0000000..cb99cd4
--- /dev/null
+++ b/ShiftOS.WinForms/DownloadControl.Designer.cs
@@ -0,0 +1,92 @@
+namespace ShiftOS.WinForms
+{
+ partial class DownloadControl
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.pcicon = new System.Windows.Forms.PictureBox();
+ this.lbshiftneturl = new System.Windows.Forms.Label();
+ this.pgprogress = new ShiftOS.WinForms.Controls.ShiftedProgressBar();
+ ((System.ComponentModel.ISupportInitialize)(this.pcicon)).BeginInit();
+ this.SuspendLayout();
+ //
+ // pcicon
+ //
+ this.pcicon.BackColor = System.Drawing.Color.Black;
+ this.pcicon.Location = new System.Drawing.Point(4, 4);
+ this.pcicon.Name = "pcicon";
+ this.pcicon.Size = new System.Drawing.Size(42, 42);
+ this.pcicon.TabIndex = 1;
+ this.pcicon.TabStop = false;
+ //
+ // lbshiftneturl
+ //
+ this.lbshiftneturl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.lbshiftneturl.Location = new System.Drawing.Point(52, 4);
+ this.lbshiftneturl.Name = "lbshiftneturl";
+ this.lbshiftneturl.Size = new System.Drawing.Size(323, 42);
+ this.lbshiftneturl.TabIndex = 2;
+ this.lbshiftneturl.Text = "label1";
+ this.lbshiftneturl.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // pgprogress
+ //
+ this.pgprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.pgprogress.BlockSize = 5;
+ this.pgprogress.Location = new System.Drawing.Point(4, 52);
+ this.pgprogress.Maximum = 100;
+ this.pgprogress.Name = "pgprogress";
+ this.pgprogress.Size = new System.Drawing.Size(371, 23);
+ this.pgprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
+ this.pgprogress.TabIndex = 0;
+ this.pgprogress.Text = "shiftedProgressBar1";
+ this.pgprogress.Value = 0;
+ //
+ // DownloadControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.lbshiftneturl);
+ this.Controls.Add(this.pcicon);
+ this.Controls.Add(this.pgprogress);
+ this.Name = "DownloadControl";
+ this.Size = new System.Drawing.Size(382, 82);
+ ((System.ComponentModel.ISupportInitialize)(this.pcicon)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Controls.ShiftedProgressBar pgprogress;
+ private System.Windows.Forms.PictureBox pcicon;
+ private System.Windows.Forms.Label lbshiftneturl;
+ }
+}
diff --git a/ShiftOS.WinForms/DownloadControl.cs b/ShiftOS.WinForms/DownloadControl.cs
new file mode 100644
index 0000000..b905167
--- /dev/null
+++ b/ShiftOS.WinForms/DownloadControl.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using ShiftOS.WinForms.Applications;
+using ShiftOS.Engine;
+
+namespace ShiftOS.WinForms
+{
+ public partial class DownloadControl : UserControl
+ {
+ public DownloadControl(int index)
+ {
+ InitializeComponent();
+ var d = DownloadManager.Downloads[index];
+ lbshiftneturl.Text = d.ShiftnetUrl;
+ pcicon.Image = FileSkimmerBackend.GetImage(d.Destination);
+ int bytesTransferred = 0;
+ DownloadManager.ProgressUpdate += (i, p) =>
+ {
+ try
+ {
+ this.Invoke(new Action(() =>
+ {
+ if (i == index)
+ {
+ bytesTransferred += 256;
+ pgprogress.Value = bytesTransferred;
+ lbshiftneturl.Text = $@"{d.ShiftnetUrl}
+{bytesTransferred} B out of {d.Bytes.Length} B transferred at 256 B per second.
+To {d.Destination}";
+ pgprogress.Maximum = d.Bytes.Length;
+ }
+ }));
+ }
+ catch
+ {
+
+ }
+ };
+ }
+ }
+}
diff --git a/ShiftOS.WinForms/DownloadControl.resx b/ShiftOS.WinForms/DownloadControl.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/ShiftOS.WinForms/DownloadControl.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/ShiftOS.WinForms/ShiftOS.WinForms.csproj b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
index d8b1517..249c670 100644
--- a/ShiftOS.WinForms/ShiftOS.WinForms.csproj
+++ b/ShiftOS.WinForms/ShiftOS.WinForms.csproj
@@ -206,6 +206,12 @@
Component
+
+ UserControl
+
+
+ DownloadControl.cs
+
Form
@@ -304,6 +310,9 @@
Terminal.cs
+
+ DownloadControl.cs
+
FakeSetupScreen.cs