aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/GraphicPicker.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-01-08 09:57:10 -0500
committerMichael <[email protected]>2017-01-08 09:57:10 -0500
commitf30dcf5ef41d54c588d7b42c48be8d941abba72e (patch)
tree7705f99b965673b1c034ac2b1c56e65072c827df /ShiftOS.WinForms/Applications/GraphicPicker.cs
parent69dfad54724d4176dfce238a8d7e73970e6eef24 (diff)
downloadshiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.tar.gz
shiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.tar.bz2
shiftos_thereturn-f30dcf5ef41d54c588d7b42c48be8d941abba72e.zip
Initial upload
Diffstat (limited to 'ShiftOS.WinForms/Applications/GraphicPicker.cs')
-rw-r--r--ShiftOS.WinForms/Applications/GraphicPicker.cs116
1 files changed, 116 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Applications/GraphicPicker.cs b/ShiftOS.WinForms/Applications/GraphicPicker.cs
new file mode 100644
index 0000000..a8cd3e8
--- /dev/null
+++ b/ShiftOS.WinForms/Applications/GraphicPicker.cs
@@ -0,0 +1,116 @@
+using ShiftOS.Objects.ShiftFS;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using ShiftOS.Engine;
+using ShiftOS.WinForms.Tools;
+
+namespace ShiftOS.WinForms.Applications
+{
+ public partial class GraphicPicker : UserControl, IShiftOSWindow
+ {
+ public GraphicPicker(Image old, string name, ImageLayout layout, Action<byte[], Image, ImageLayout> cb)
+ {
+ InitializeComponent();
+ SelectedLayout = layout;
+ Callback = cb;
+ lblobjecttoskin.Text = name;
+
+ }
+
+ public Action<byte[], Image, ImageLayout> Callback;
+
+ public ImageLayout SelectedLayout { get; private set; }
+
+ public void btncancel_Click(object s, EventArgs a)
+ {
+ this.Close(); //don't invoke callback
+ }
+
+ public void btnreset_Click(object s, EventArgs a)
+ {
+ this.ImageAsBinary = null;
+ this.Image = null;
+ Setup();
+ }
+
+ public void btnapply_Click(object s, EventArgs a)
+ {
+ Callback?.Invoke(this.ImageAsBinary, this.Image, this.SelectedLayout);
+ this.Close();
+ }
+
+ public byte[] ImageAsBinary { get; set; }
+ public Image Image { get; set; }
+
+ public void Setup()
+ {
+ picidle.BackgroundImage = Image;
+ picidle.BackgroundImageLayout = SelectedLayout;
+ }
+
+ public void btnidlebrowse_Click(object s, EventArgs a)
+ {
+ AppearanceManager.SetupDialog(new FileDialog(new[] { ".png", ".jpg", ".bmp", ".pic" }, FileOpenerStyle.Open, new Action<string>((file) =>
+ {
+ ImageAsBinary = Utils.ReadAllBytes(file);
+ System.IO.File.WriteAllBytes("temp_bin.bmp", ImageAsBinary);
+ Image = SkinEngine.ImageFromBinary(ImageAsBinary);
+ Image.Save("temp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
+ Setup();
+ })));
+ }
+
+ public void btnzoom_Click(object s, EventArgs a)
+ {
+ this.SelectedLayout = ImageLayout.Zoom;
+ Setup();
+ }
+
+ public void btncentre_Click(object s, EventArgs a)
+ {
+ this.SelectedLayout = ImageLayout.Center;
+ Setup();
+ }
+
+ public void btnstretch_Click(object s, EventArgs a)
+ {
+ this.SelectedLayout = ImageLayout.Stretch;
+ Setup();
+ }
+
+ public void btntile_Click(object s, EventArgs a)
+ {
+ this.SelectedLayout = ImageLayout.Tile;
+ Setup();
+ }
+
+ public void Graphic_Picker_Load(object s, EventArgs a)
+ {
+ Setup();
+ }
+
+ public void OnLoad()
+ {
+ }
+
+ public void OnSkinLoad()
+ {
+ }
+
+ public bool OnUnload()
+ {
+ return true;
+ }
+
+ public void OnUpgrade()
+ {
+ }
+ }
+}