1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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()
{
}
}
}
|