diff options
| -rw-r--r-- | ShiftOS.WinForms/Applications/Downloader.cs | 48 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/Shiftnet.Designer.cs | 2 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Applications/Shiftnet.cs | 10 | ||||
| -rw-r--r-- | ShiftOS.WinForms/Controls/ShiftedProgressBar.cs | 2 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DownloadControl.Designer.cs | 92 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DownloadControl.cs | 48 | ||||
| -rw-r--r-- | ShiftOS.WinForms/DownloadControl.resx | 120 | ||||
| -rw-r--r-- | ShiftOS.WinForms/ShiftOS.WinForms.csproj | 9 |
8 files changed, 291 insertions, 40 deletions
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 + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root>
\ 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 @@ <Compile Include="Controls\TerminalBox.cs"> <SubType>Component</SubType> </Compile> + <Compile Include="DownloadControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="DownloadControl.Designer.cs"> + <DependentUpon>DownloadControl.cs</DependentUpon> + </Compile> <Compile Include="FakeSetupScreen.cs"> <SubType>Form</SubType> </Compile> @@ -304,6 +310,9 @@ <EmbeddedResource Include="Applications\Terminal.resx"> <DependentUpon>Terminal.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="DownloadControl.resx"> + <DependentUpon>DownloadControl.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="FakeSetupScreen.resx"> <DependentUpon>FakeSetupScreen.cs</DependentUpon> </EmbeddedResource> |
