Custom buttons and progress bars.
This commit is contained in:
parent
b1cace7807
commit
7919afa133
11 changed files with 251 additions and 32 deletions
|
@ -141,12 +141,10 @@ namespace ShiftOS.WinForms.Applications
|
|||
//
|
||||
// pgplaytime
|
||||
//
|
||||
this.pgplaytime.BlockSize = 5;
|
||||
this.pgplaytime.Location = new System.Drawing.Point(46, 3);
|
||||
this.pgplaytime.Maximum = 100;
|
||||
this.pgplaytime.Name = "pgplaytime";
|
||||
this.pgplaytime.Size = new System.Drawing.Size(749, 23);
|
||||
this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pgplaytime.TabIndex = 1;
|
||||
this.pgplaytime.Tag = "keepbg";
|
||||
this.pgplaytime.Text = "shiftedProgressBar1";
|
||||
|
|
|
@ -118,12 +118,10 @@
|
|||
//
|
||||
this.pginstall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pginstall.BlockSize = 5;
|
||||
this.pginstall.Location = new System.Drawing.Point(17, 161);
|
||||
this.pginstall.Maximum = 100;
|
||||
this.pginstall.Name = "pginstall";
|
||||
this.pginstall.Size = new System.Drawing.Size(414, 23);
|
||||
this.pginstall.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pginstall.TabIndex = 2;
|
||||
this.pginstall.Text = "shiftedProgressBar1";
|
||||
this.pginstall.Value = 0;
|
||||
|
|
|
@ -242,12 +242,10 @@ namespace ShiftOS.WinForms.Applications
|
|||
//
|
||||
this.pgupgradeprogress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pgupgradeprogress.BlockSize = 5;
|
||||
this.pgupgradeprogress.Location = new System.Drawing.Point(146, 390);
|
||||
this.pgupgradeprogress.Maximum = 100;
|
||||
this.pgupgradeprogress.Name = "pgupgradeprogress";
|
||||
this.pgupgradeprogress.Size = new System.Drawing.Size(254, 23);
|
||||
this.pgupgradeprogress.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pgupgradeprogress.TabIndex = 1;
|
||||
this.pgupgradeprogress.Value = 25;
|
||||
//
|
||||
|
|
|
@ -64,12 +64,10 @@
|
|||
//
|
||||
this.pgdownload.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pgdownload.BlockSize = 5;
|
||||
this.pgdownload.Location = new System.Drawing.Point(86, 4);
|
||||
this.pgdownload.Maximum = 100;
|
||||
this.pgdownload.Name = "pgdownload";
|
||||
this.pgdownload.Size = new System.Drawing.Size(427, 23);
|
||||
this.pgdownload.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pgdownload.TabIndex = 2;
|
||||
this.pgdownload.Text = "Updating...";
|
||||
this.pgdownload.Value = 0;
|
||||
|
|
|
@ -91,12 +91,10 @@
|
|||
//
|
||||
// pgplaytime
|
||||
//
|
||||
this.pgplaytime.BlockSize = 5;
|
||||
this.pgplaytime.Location = new System.Drawing.Point(46, 3);
|
||||
this.pgplaytime.Maximum = 100;
|
||||
this.pgplaytime.Name = "pgplaytime";
|
||||
this.pgplaytime.Size = new System.Drawing.Size(749, 23);
|
||||
this.pgplaytime.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pgplaytime.TabIndex = 1;
|
||||
this.pgplaytime.Tag = "keepbg";
|
||||
this.pgplaytime.Text = "shiftedProgressBar1";
|
||||
|
|
|
@ -31,6 +31,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ShiftOS.Engine;
|
||||
|
||||
namespace ShiftOS.WinForms.Controls
|
||||
{
|
||||
|
@ -46,7 +47,7 @@ namespace ShiftOS.WinForms.Controls
|
|||
t.Interval = 100;
|
||||
t.Tick += (o, a) =>
|
||||
{
|
||||
if(this._style == ProgressBarStyle.Marquee)
|
||||
if(this.Style == ProgressBarStyle.Marquee)
|
||||
{
|
||||
if(_marqueePos >= this.Width)
|
||||
{
|
||||
|
@ -89,46 +90,100 @@ namespace ShiftOS.WinForms.Controls
|
|||
}
|
||||
}
|
||||
|
||||
public ProgressBarStyle _style = ProgressBarStyle.Continuous;
|
||||
|
||||
public ProgressBarStyle Style
|
||||
{
|
||||
get { return _style; }
|
||||
set { _style = value; this.Refresh(); }
|
||||
get
|
||||
{
|
||||
return SkinEngine.LoadedSkin.ProgressBarStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private int _blocksize = 5;
|
||||
|
||||
public int BlockSize
|
||||
{
|
||||
get { return _blocksize; }
|
||||
set
|
||||
get
|
||||
{
|
||||
_blocksize = value;
|
||||
this.Refresh();
|
||||
return SkinEngine.LoadedSkin.ProgressBarBlockSize;
|
||||
}
|
||||
}
|
||||
|
||||
public Color RealBackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return SkinEngine.LoadedSkin.ProgressBarBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
public Image RealBackgroundImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return SkinEngine.GetImage("progressbarbg");
|
||||
}
|
||||
}
|
||||
|
||||
public Image ProgressImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return SkinEngine.GetImage("progress");
|
||||
}
|
||||
}
|
||||
|
||||
public Color ProgressColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return SkinEngine.LoadedSkin.ProgressColor;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs pe)
|
||||
{
|
||||
pe.Graphics.Clear(Color.Black);
|
||||
switch (_style)
|
||||
pe.Graphics.Clear(this.RealBackColor);
|
||||
if(RealBackgroundImage != null)
|
||||
{
|
||||
pe.Graphics.FillRectangle(new TextureBrush(RealBackgroundImage), new Rectangle(0, 0, this.Width, this.Height));
|
||||
}
|
||||
switch (Style)
|
||||
{
|
||||
case ProgressBarStyle.Continuous:
|
||||
double width = linear(this.Value, 0, this.Maximum, 0, this.Width);
|
||||
pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new RectangleF(0, 0, (float)width, this.Height));
|
||||
if (ProgressImage != null)
|
||||
{
|
||||
pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new RectangleF(0, 0, (float)width, this.Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new RectangleF(0, 0, (float)width, this.Height));
|
||||
}
|
||||
break;
|
||||
case ProgressBarStyle.Blocks:
|
||||
int block_count = this.Width / (this._blocksize + 2);
|
||||
int block_count = this.Width / (this.BlockSize + 2);
|
||||
int blocks = (int)linear(this.Value, 0, this.Maximum, 0, block_count);
|
||||
for(int i = 0; i < blocks - 1; i++)
|
||||
{
|
||||
int position = i * (_blocksize + 2);
|
||||
pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(position, 0, _blocksize, this.Height));
|
||||
int position = i * (BlockSize + 2);
|
||||
if (ProgressImage != null)
|
||||
{
|
||||
pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(position, 0, BlockSize, this.Height));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(position, 0, BlockSize, this.Height));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ProgressBarStyle.Marquee:
|
||||
pe.Graphics.FillRectangle(new SolidBrush(Color.Green), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
|
||||
if (ProgressImage != null)
|
||||
{
|
||||
pe.Graphics.FillRectangle(new TextureBrush(ProgressImage), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
pe.Graphics.FillRectangle(new SolidBrush(ProgressColor), new Rectangle(_marqueePos, 0, this.Width / 4, this.Height));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,11 @@
|
|||
//
|
||||
// pgupgrades
|
||||
//
|
||||
this.pgupgrades.BlockSize = 5;
|
||||
this.pgupgrades.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.pgupgrades.Location = new System.Drawing.Point(0, 99);
|
||||
this.pgupgrades.Maximum = 100;
|
||||
this.pgupgrades.Name = "pgupgrades";
|
||||
this.pgupgrades.Size = new System.Drawing.Size(227, 23);
|
||||
this.pgupgrades.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
|
||||
this.pgupgrades.TabIndex = 0;
|
||||
this.pgupgrades.Text = "shiftedProgressBar1";
|
||||
this.pgupgrades.Value = 0;
|
||||
|
|
2
ShiftOS.WinForms/DownloadControl.Designer.cs
generated
2
ShiftOS.WinForms/DownloadControl.Designer.cs
generated
|
@ -83,12 +83,10 @@ namespace ShiftOS.WinForms
|
|||
//
|
||||
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;
|
||||
|
|
|
@ -7,6 +7,20 @@
|
|||
Dependencies: "desktop",
|
||||
Category: "Enhancements",
|
||||
},
|
||||
{
|
||||
Name: "Shift Progress Bar",
|
||||
Cost: 150,
|
||||
Description: "Want to customize the look of all ShiftOS Progress Bars? Buy this upgrade today and you'll get the ability to set the foreground and background color of the progress bar, and many more things!.",
|
||||
Dependencies: "shifter;shift_buttons",
|
||||
Category: "Customization"
|
||||
},
|
||||
{
|
||||
Name: "Shift Buttons",
|
||||
Cost: 150,
|
||||
Description: "Want to customize the look of all ShiftOS buttons? This Shifter upgrade gives you a new \"Buttons\" category in the System category to do just that.",
|
||||
Dependencies: "shifter",
|
||||
Category: "Customization"
|
||||
},
|
||||
{
|
||||
Name: "GUI Based Login Screen",
|
||||
Cost: 500,
|
||||
|
|
|
@ -214,6 +214,49 @@ namespace ShiftOS.WinForms.Tools
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
if(ctrl is Button)
|
||||
{
|
||||
Desktop.InvokeOnWorkerThread(() =>
|
||||
{
|
||||
Button b = ctrl as Button;
|
||||
b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor;
|
||||
b.BackgroundImage = SkinEngine.GetImage("buttonidle");
|
||||
b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
|
||||
b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth;
|
||||
b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor;
|
||||
b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor;
|
||||
b.Font = SkinEngine.LoadedSkin.ButtonTextFont;
|
||||
|
||||
b.MouseEnter += (o, a) =>
|
||||
{
|
||||
b.BackColor = SkinEngine.LoadedSkin.ButtonHoverColor;
|
||||
b.BackgroundImage = SkinEngine.GetImage("buttonhover");
|
||||
b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonhover");
|
||||
};
|
||||
b.MouseLeave += (o, a) =>
|
||||
{
|
||||
b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor;
|
||||
b.BackgroundImage = SkinEngine.GetImage("buttonidle");
|
||||
b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
|
||||
};
|
||||
b.MouseUp += (o, a) =>
|
||||
{
|
||||
b.BackColor = SkinEngine.LoadedSkin.ButtonBackgroundColor;
|
||||
b.BackgroundImage = SkinEngine.GetImage("buttonidle");
|
||||
b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
|
||||
};
|
||||
|
||||
b.MouseDown += (o, a) =>
|
||||
{
|
||||
b.BackColor = SkinEngine.LoadedSkin.ButtonPressedColor;
|
||||
b.BackgroundImage = SkinEngine.GetImage("buttonpressed");
|
||||
b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed");
|
||||
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
ctrl.KeyDown += (o, a) =>
|
||||
{
|
||||
if (a.Control && a.KeyCode == Keys.T)
|
||||
|
|
|
@ -276,6 +276,127 @@ namespace ShiftOS.Engine
|
|||
[ShifterHidden]
|
||||
public Dictionary<string, byte[]> AppIcons = new Dictionary<string, byte[]>();
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar;skinning")]
|
||||
[Image("progressbarbg")]
|
||||
[ShifterName("Progress Bar Background Image")]
|
||||
[ShifterDescription("Set an image for the background of a progress bar.")]
|
||||
public byte[] ProgressBarBG = null;
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar;skinning")]
|
||||
[Image("progress")]
|
||||
[ShifterName("Progress Image")]
|
||||
[ShifterDescription("Set the image for the progress inside a progress bar.")]
|
||||
public byte[] Progress = null;
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar")]
|
||||
[ShifterName("Progress bar foreground color")]
|
||||
[ShifterDescription("Set the color of the progress indicator.")]
|
||||
public Color ProgressColor = Accent1;
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar")]
|
||||
[ShifterName("Progress bar background color")]
|
||||
[ShifterDescription("The background color of the progress bar.")]
|
||||
public Color ProgressBarBackgroundColor = Color.Black;
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar")]
|
||||
[ShifterName("Progress bar block size")]
|
||||
[ShifterDescription("If the progress bar style is set to Blocks, this determines how wide each block should be.")]
|
||||
public int ProgressBarBlockSize = 15;
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Progress Bar")]
|
||||
[RequiresUpgrade("shift_progress_bar")]
|
||||
[ShifterDescription("Set the style of a progress bar.\r\nMarquee: The progress bar will render a box that moves from the left to the right in a loop.\r\nContinuous: Progress is shown by a single, continuous box.\r\nBlocks: Just like Continuous, but the box is split into even smaller boxes of a set width.")]
|
||||
[ShifterName("Progress bar style")]
|
||||
public ProgressBarStyle ProgressBarStyle = ProgressBarStyle.Continuous;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button background color")]
|
||||
[ShifterDescription("Set the background color for each button's Idle state.")]
|
||||
public Color ButtonBackgroundColor = Skin.DefaultBackground;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons;skinning")]
|
||||
[Image("buttonhover")]
|
||||
[ShifterName("Button hover image")]
|
||||
[ShifterDescription("Set the image that's displayed when the mouse hovers over a button.")]
|
||||
public byte[] ButtonHoverImage = null;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("skinning;shift_buttons")]
|
||||
[Image("buttonpressed")]
|
||||
[ShifterName("Button pressed image")]
|
||||
[ShifterDescription("Select an image to show when the user presses a button.")]
|
||||
public byte[] ButtonPressedImage = null;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button hover color")]
|
||||
[ShifterDescription("Choose the color that displays on a button when the mouse hovers over it.")]
|
||||
public Color ButtonHoverColor = Skin.Accent1;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button pressed color")]
|
||||
[ShifterDescription("Select the background color for the button when the mouse clicks it.")]
|
||||
public Color ButtonPressedColor = Skin.Accent2;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button foreground color")]
|
||||
[ShifterDescription("Select the text and border color for each button.")]
|
||||
public Color ButtonForegroundColor = Skin.DefaultForeground;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button border width")]
|
||||
[ShifterDescription("Set the width, in pixels, of the button's border.")]
|
||||
public int ButtonBorderWidth = 2;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons")]
|
||||
[ShifterName("Button font")]
|
||||
[ShifterDescription("Select the font for the button's text.")]
|
||||
public Font ButtonTextFont = Skin.SysFont;
|
||||
|
||||
[ShifterMeta("System")]
|
||||
[ShifterCategory("Buttons")]
|
||||
[RequiresUpgrade("shift_buttons;skinning")]
|
||||
[Image("buttonidle")]
|
||||
[ShifterName("Button background color")]
|
||||
[ShifterDescription("Select an image to show as the button's Idle state.")]
|
||||
public byte[] ButtonBG = null;
|
||||
|
||||
|
||||
[Image("panelclockbg")]
|
||||
[ShifterMeta("Desktop")]
|
||||
[ShifterCategory("Panel Clock")]
|
||||
|
|
Reference in a new issue