From f30dcf5ef41d54c588d7b42c48be8d941abba72e Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Jan 2017 09:57:10 -0500 Subject: Initial upload --- ShiftOS.WinForms/Applications/GraphicPicker.cs | 116 +++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 ShiftOS.WinForms/Applications/GraphicPicker.cs (limited to 'ShiftOS.WinForms/Applications/GraphicPicker.cs') 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 cb) + { + InitializeComponent(); + SelectedLayout = layout; + Callback = cb; + lblobjecttoskin.Text = name; + + } + + public Action 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((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() + { + } + } +} -- cgit v1.2.3