aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/Skinning.cs
blob: 74340889b1594fab53e3d5be9b9acbb1b7540666 (plain) (blame)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
/*
 * MIT License
 * 
 * Copyright (c) 2017 Michael VanOverbeek and ShiftOS devs
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Windows.Forms;
using static ShiftOS.Engine.SaveSystem;
using ShiftOS.Objects.ShiftFS;
using System.Reflection;

namespace ShiftOS.Engine {
    public static class SkinEngine {
        public static ImageLayout GetImageLayout(string img) {
            if (LoadedSkin.SkinImageLayouts.ContainsKey(img)) {
                return LoadedSkin.SkinImageLayouts[img];
            } else {
                LoadedSkin.SkinImageLayouts.Add(img, ImageLayout.Tile);
                return ImageLayout.Tile;
            }
        }

        public static System.Drawing.Image GetImage(string img) {
            var type = typeof(Skin);

            foreach (var field in type.GetFields()) {
                foreach (var attr in field.GetCustomAttributes(false)) {
                    if (attr is ImageAttribute) {
                        var iattr = attr as ImageAttribute;
                        if (iattr.Name == img) {
                            byte[] image = (byte[])field.GetValue(LoadedSkin);
                            return ImageFromBinary(image);
                        }
                    }
                }
            }

            return null;
        }

        public static void SetIconProber(IIconProber prober)
        {
            _iconProber = prober;
        }

        public static Image ImageFromBinary(byte[] image) {
            if (image == null)
                return null;
            Image img = (Bitmap)((new ImageConverter()).ConvertFrom(image));
            return img;
        }

        private static Skin loadedSkin = new Skin();

        public static Skin LoadedSkin
        {
            get
            {
                return loadedSkin;
            }
            private set
            {
                loadedSkin = value;
            }
        }

        public static void Init() {
            Application.ApplicationExit += (o, a) => {
                SaveSkin();
            };

            if (!Utils.FileExists(Paths.GetPath("skin.json"))) {
                LoadedSkin = new ShiftOS.Engine.Skin();
                SaveSkin();
            } else {
                LoadSkin();
            }
            if (SaveSystem.CurrentSave != null) {
                SkinLoaded?.Invoke();
            }
        }

        public static event EmptyEventHandler SkinLoaded;

        public static void LoadSkin() {
            LoadedSkin = JsonConvert.DeserializeObject<Skin>(Utils.ReadAllText(Paths.GetPath("skin.json")));
            SkinLoaded?.Invoke();
            Desktop.ResetPanelButtons();
            Desktop.PopulateAppLauncher();
        }

        public static void SaveSkin() {
            Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(LoadedSkin, Formatting.Indented));
        }

        private static IIconProber _iconProber = null;

        public static Image GetDefaultIcon(string id)
        {
            if (_iconProber == null)
            {
                return new Bitmap(16, 16);
            }
            else
            {
                foreach(var f in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
                {
                    if(f.EndsWith(".exe") || f.EndsWith(".dll"))
                    {
                        try
                        {
                            var asm = Assembly.LoadFile(f);
                            foreach(var type in asm.GetTypes())
                            {
                                if(type.Name == id)
                                {
                                    foreach(var attr in type.GetCustomAttributes(true))
                                    {
                                        if(attr is DefaultIconAttribute)
                                        {
                                            return _iconProber.GetIcon(attr as DefaultIconAttribute);
                                        }
                                    }
                                }
                            }
                        }
                        catch { }
                    }
                }
                return new Bitmap(16, 16);
            }
        }

        public static Image GetIcon(string id)
        {
            if (!LoadedSkin.AppIcons.ContainsKey(id))
                LoadedSkin.AppIcons.Add(id, null);

            if (LoadedSkin.AppIcons[id] == null)
                return GetDefaultIcon(id);
            else
            {
                using (var sr = new MemoryStream(LoadedSkin.AppIcons[id]))
                {
                    return Image.FromStream(sr);
                }
            }
             
        }
    }

    public interface IIconProber
    {
        Image GetIcon(DefaultIconAttribute attr);
    }

    public class DefaultIconAttribute : Attribute
    {
        public DefaultIconAttribute(string id)
        {
            ID = id;
        }

        public string ID { get; private set; }
    }

    public class Skin {
        //borrowing from the discourse theme for the default skin
        private static readonly Color DefaultBackground = Color.FromArgb(0, 0x44, 0x00);
        private static readonly Color DefaultForeground = Color.FromArgb(0xDD, 0xDD, 0xDD);
        private static readonly Color Accent1 = Color.FromArgb(0x66, 0x66, 0x66);
        private static readonly Color Accent2 = Color.FromArgb(0x80, 0, 0);
        private static readonly Color DesktopBG = Color.FromArgb(0x22, 0x22, 0x22);
        private static readonly Font SysFont = new Font("Tahoma", 9F);
        private static readonly Font SysFont2 = new Font("Tahoma", 10F, FontStyle.Bold);
        private static readonly Font Header1 = new Font("Helvetica", 20F, FontStyle.Bold);
        private static readonly Font Header2 = new Font("Helvetica", 17.5F, FontStyle.Bold);
        private static readonly Font Header3 = new Font("Tahoma", 15F, FontStyle.Bold);

        private static readonly Color TitleBG = Color.FromArgb(0x11, 0x11, 0x11);
        private static readonly Color TitleFG = Color.FromArgb(0xaa, 0xaa, 0xaa);

        //Todo: When making Shifter GUI we need to label all these with proper Shifter attributes to get 'em displaying in the right places.

        public override string ToString()
        {
            return JsonConvert.SerializeObject(this, Formatting.Indented);
        }

        [ShifterHidden]
        public Dictionary<string, string> AppNames = new Dictionary<string, string>();

        [ShifterHidden]
        public Dictionary<string, byte[]> AppIcons = new Dictionary<string, byte[]>();


        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_title_text")]
        [ShifterName("Title Font")]
        [ShifterDescription("The font style for the title text.")]
        public Font TitleFont = SysFont2;

        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("System Font")]
        [ShifterDescription("The font style used by the system.")]
        public Font MainFont = SysFont;
        
        [ShifterEnumMask(new[] { "Right", "Left"})]
        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Title button position")]
        [ShifterDescription("Where should the title buttons be located?")]
        public int TitleButtonPosition = 0;

        [ShifterMeta("System")]
        [ShifterCategory("Header Fonts")]
        [ShifterName("1st level header")]
        [ShifterDescription("The font used in level 1 (title) headers.")]
        public Font HeaderFont = Header1;


        [ShifterMeta("System")]
        [ShifterCategory("Header Fonts")]
        [ShifterName("2nd level header")]
        [ShifterDescription("The font used in level 2 (subtitle) headers.")]
        public Font Header2Font = Header2;


        [ShifterMeta("System")]
        [ShifterCategory("Header Fonts")]
        [ShifterName("3rd level header")]
        [ShifterDescription("The font used in level 3 (section) headers.")]
        public Font Header3Font = Header3;



        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("System Background")]
        [ShifterDescription("The background color of all system controls in the UI.")]
        public Color ControlColor = DefaultBackground;

        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("System Foreground")]
        [ShifterDescription("The foreground color of all system controls in the UI.")]
        public Color ControlTextColor = DefaultForeground;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Title Text Color")]
        [RequiresUpgrade("shift_title_text")]
        [ShifterDescription("The color of the title text.")]
        public Color TitleTextColor = TitleFG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Title Background Color")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterDescription("The color of the titlebar's background.")]
        public Color TitleBackgroundColor = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [ShifterName("Left Border Background")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterDescription("The background color for the left border.")]
        public Color BorderLeftBackground = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [ShifterName("Right Border Background")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterDescription("The background color for the right border.")]
        public Color BorderRightBackground = TitleBG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel buttons from top")]
        [ShifterDescription("How far from the top should the panel buttons be?")]
        public int PanelButtonFromTop = 2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [ShifterName("Bottom Border Background")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterDescription("The background color for the bottom border.")]
        public Color BorderBottomBackground = TitleBG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [ShifterName("Panel button holder from left")]
        [ShifterDescription("How far from the left should the panel button holder be?")]
        [RequiresUpgrade("shift_panel_buttons")]
        public int PanelButtonHolderFromLeft = 68;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [ShifterName("Bottom Left Border Background")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterDescription("The background color for the bottom left border.")]
        public Color BorderBottomLeftBackground = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [ShifterName("Bottom Right Border Background")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterDescription("The background color for the bottom right border.")]
        public Color BorderBottomRightBackground = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Close Button Color")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The close button color")]
        public Color CloseButtonColor = Accent2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Maximize Button Color")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The maximize button color")]
        public Color MaximizeButtonColor = Accent1;

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Minimize Button Color")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The minimize button color")]
        public Color MinimizeButtonColor = Accent1;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Background")]
        [RequiresUpgrade("shift_desktop_panel")]
        [ShifterDescription("The background color used by the desktop panel")]
        public Color DesktopPanelColor = TitleBG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Clock Text Color")]
        [RequiresUpgrade("shift_panel_clock")]
        [ShifterDescription("The text color used by the desktop panel's clock.")]
        public Color DesktopPanelClockColor = TitleFG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Clock Background Color")]
        [RequiresUpgrade("shift_panel_clock")]
        [ShifterDescription("The background color used by the desktop panel's clock.")]
        public Color DesktopPanelClockBackgroundColor = TitleBG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Clock Font")]
        [RequiresUpgrade("shift_panel_clock")]
        [ShifterDescription("The font used by the desktop panel's clock.")]
        public Font DesktopPanelClockFont = Skin.SysFont2;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Clock From Right")]
        [RequiresUpgrade("shift_panel_clock")]
        [ShifterDescription("The position in pixels relative to the width of the desktop panel that the clock will sit at.")]
        public Point DesktopPanelClockFromRight = new Point(2, 2);


        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Height")]
        [RequiresUpgrade("shift_desktop_panel")]
        [ShifterDescription("The height in pixels of the desktop panel.")]
        public int DesktopPanelHeight = 24;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel Position")]
        [ShifterEnumMask(new[] { "Top", "Bottom" })]
        [RequiresUpgrade("shift_desktop_panel")]
        [ShifterDescription("The position of the desktop panel.")]
        public int DesktopPanelPosition = 0;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Titlebar Height")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterDescription("The height of the titlebar.")]
        public int TitlebarHeight = 30;

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Close Button Size")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The close button size")]
        public Size CloseButtonSize = new Size(24, 24);

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Maximize Button Size")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The maximize button size")]
        public Size MaximizeButtonSize = new Size(24, 24);

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Minimize Button Size")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The minimize button size")]
        public Size MinimizeButtonSize = new Size(24, 24);

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Close Button From Right")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The close button location from the right of the titlebar.")]
        public Point CloseButtonFromSide = new Point(3, (30 - 24) / 2);

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Maximize Button From Right")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The maximize button location from the right of the titlebar.")]
        public Point MaximizeButtonFromSide = new Point(24 + 6, (30 - 24) / 2);

        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Minimize Button From Right")]
        [RequiresUpgrade("shift_title_buttons")]
        [ShifterDescription("The minimize button location from the right of the titlebar.")]
        public Point MinimizeButtonFromSide = new Point(48 + 9, (30 - 24) / 2);

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Title text centered?")]
        [RequiresUpgrade("shift_title_text")]
        [ShifterDescription("Is the title text centered?")]
        public bool TitleTextCentered = false;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Title Text From Left")]
        [ShifterFlag("TitleTextCentered", false)]
        [RequiresUpgrade("shift_title_text")]
        [ShifterDescription("The title text location from the left of the titlebar.")]
        public Point TitleTextLeft = new Point(4, 4);

        [ShifterMeta("Desktop")]
        [ShifterCategory("General")]
        [ShifterName("Desktop Background Color")]
        [ShifterDescription("The background color of the desktop.")]
        public Color DesktopColor = DesktopBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button select highlight")]
        public Color Menu_ButtonSelectedHighlight = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button select border")]
        public Color Menu_ButtonSelectedHighlightBorder = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed highlight")]
        public Color Menu_ButtonPressedHighlight = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed border")]
        public Color Menu_ButtonPressedHighlightBorder = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button checked highlight")]
        public Color Menu_ButtonCheckedHighlight = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button checked border")]
        public Color Menu_ButtonCheckedHighlightBorder = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed gradient border")]
        public Color Menu_ButtonPressedBorder = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button selected gradient border")]
        public Color Menu_ButtonSelectedBorder = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button checked gradient start")]
        public Color Menu_ButtonCheckedGradientBegin = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button checked gradient middle")]
        public Color Menu_ButtonCheckedGradientMiddle = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button checked gradient end")]
        public Color Menu_ButtonCheckedGradientEnd = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button selected gradient start")]
        public Color Menu_ButtonSelectedGradientBegin = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button selected gradient middle")]
        public Color Menu_ButtonSelectedGradientMiddle = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button selected gradient end")]
        public Color Menu_ButtonSelectedGradientEnd = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed gradient start")]
        public Color Menu_ButtonPressedGradientBegin = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed gradient middle")]
        public Color Menu_ButtonPressedGradientMiddle = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Button pressed gradient end")]
        public Color Menu_ButtonPressedGradientEnd = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Check BG")]
        public Color Menu_CheckBackground = Skin.TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Check BG (Selected)")]
        public Color Menu_CheckSelectedBackground = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Check BG (Pressed)")]
        public Color Menu_CheckPressedBackground = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Margin gradient start")]
        public Color Menu_ImageMarginGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Margin gradient middle")]
        public Color Menu_ImageMarginGradientMiddle = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Margin gradient end")]
        public Color Menu_ImageMarginGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Menu gradient start")]
        public Color Menu_MenuStripGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Menu gradient end")]
        public Color Menu_MenuStripGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Menu item selected")]
        public Color Menu_MenuItemSelected = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Menu item border")]
        public Color Menu_MenuItemBorder = DefaultBackground;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu bars")]
        [ShifterName("Menu border")]
        public Color Menu_MenuBorder = DefaultBackground;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Menu item selected gradient start")]
        public Color Menu_MenuItemSelectedGradientBegin = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Menu item selected gradient end")]
        public Color Menu_MenuItemSelectedGradientEnd = Accent2;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Menu item pressed gradient start")]
        public Color Menu_MenuItemPressedGradientBegin = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Menu item pressed gradient middle")]
        public Color Menu_MenuItemPressedGradientMiddle = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Menu item pressed gradient end")]
        public Color Menu_MenuItemPressedGradientEnd = Accent1;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Rafter gradient start")]
        public Color Menu_RaftingContainerGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Rafter gradient end")]
        public Color Menu_RaftingContainerGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Separator Color 1")]
        public Color Menu_SeparatorDark = DefaultForeground;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Separator Color 2")]
        public Color Menu_SeparatorLight = TitleFG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Status bars")]
        [ShifterName("Status bar gradient start")]
        public Color Menu_StatusStripGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Status bars")]
        [ShifterName("Status bar gradient end")]
        public Color Menu_StatusStripGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Toolbar Border")]
        public Color Menu_ToolStripBorder = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Dropdown background")]
        public Color Menu_ToolStripDropDownBackground = DefaultBackground;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Toolbar gradient start")]
        public Color Menu_ToolStripGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Toolbar gradient middle")]
        public Color Menu_ToolStripGradientMiddle = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Toolbars")]
        [ShifterName("Toolbar gradient end")]
        public Color Menu_ToolStripGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu holders")]
        [ShifterName("Content panel gradient start")]
        public Color Menu_ToolStripContentPanelGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu holders")]
        [ShifterName("Content panel gradient end")]
        public Color Menu_ToolStripContentPanelGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu holders")]
        [ShifterName("Panel gradient start")]
        public Color Menu_ToolStripPanelGradientBegin = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("Menu holders")]
        [ShifterName("Panel gradient end")]
        public Color Menu_ToolStripPanelGradientEnd = TitleBG;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Menu text color")]
        public Color Menu_TextColor = DefaultForeground;

        [ShifterMeta("Menus")]
        [ShifterCategory("General")]
        [ShifterName("Menu selected text color")]
        public Color Menu_SelectedTextColor = TitleFG;



        //Images
        [Image("closebutton")]
        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Close Button Image")]
        [RequiresUpgrade("shift_title_buttons;skinning")]
        [ShifterDescription("Show an image on the Close Button using this setting.")]
        public byte[] CloseButtonImage = null;

        [Image("minimizebutton")]
        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Minimize Button Image")]
        [RequiresUpgrade("shift_title_buttons;skinning")]
        [ShifterDescription("Show an image on the Minimize Button using this setting.")]
        public byte[] MinimizeButtonImage = null;

        [Image("maximizebutton")]
        [ShifterMeta("Windows")]
        [ShifterCategory("Title Buttons")]
        [ShifterName("Maximize Button Image")]
        [RequiresUpgrade("shift_title_buttons;skinning")]
        [ShifterDescription("Show an image on the Maximize Button using this setting.")]
        public byte[] MaximizeButtonImage = null;

        [Image("desktopbackground")]
        [ShifterMeta("Desktop")]
        [ShifterCategory("General")]
        [ShifterName("Desktop Background Image")]
        [RequiresUpgrade("skinning")]
        [ShifterDescription("Use an image as your desktop background.")]
        public byte[] DesktopBackgroundImage = null;

        [ShifterMeta("Desktop")]
        [ShifterCategory("App Launcher")]
        [ShifterName("App launcher text")]
        [ShifterDescription("The text displayed on the app launcher.")]
        [RequiresUpgrade("shift_app_launcher")]
        public string AppLauncherText = "ShiftOS";

        [ShifterMeta("Desktop")]
        [ShifterCategory("App Launcher")]
        [ShifterName("App launcher from left")]
        [ShifterDescription("The position of the app launcher from the left of the Desktop Panel.")]
        [RequiresUpgrade("shift_app_launcher")]
        public Point AppLauncherFromLeft = new Point(0, 0);

        [ShifterMeta("Desktop")]
        [ShifterCategory("App Launcher")]
        [ShifterName("App launcher size")]
        [ShifterDescription("The size of the app launcher.")]
        [RequiresUpgrade("shift_app_launcher")]
        public Size AppLauncherHolderSize = new Size(68, 24);

        [ShifterMeta("Desktop")]
        [ShifterCategory("App Launcher")]
        [ShifterName("App launcher image")]
        [ShifterDescription("The image that will appear on the app launcher.")]
        [Image("applauncher")]
        [RequiresUpgrade("skinning;shift_app_launcher")]
        public byte[] AppLauncherImage = null;

        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("Terminal font")]
        public Font TerminalFont = new Font("Lucida Console", 9F, FontStyle.Regular);

        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("Terminal text color")]
        public Color TerminalForeColor = DefaultForeground;

        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("Terminal background color")]
        public Color TerminalBackColor = DesktopBG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Desktop Panel")]
        [ShifterName("Panel background image")]
        [Image("desktoppanel")]
        [RequiresUpgrade("skinning;shift_desktop_panel")]
        public byte[] DesktopPanelBackground = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("Titlebar background image")]
        [Image("titlebar")]
        [RequiresUpgrade("skinning;shift_titlebar")]
        public byte[] TitleBarBackground = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterName("Show title corners?")]
        [ShifterDescription("If checked, a left and a right section will appear on the titlebar which is useful for rounded corners, padding, or other useful properties.")]
        public bool ShowTitleCorners = false;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title left background color")]
        [ShifterDescription("What color should be used for the left title corner?")]
        public Color TitleLeftCornerBackground = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title right background color")]
        [ShifterDescription("What color should be used for the right title corner?")]
        public Color TitleRightCornerBackground = TitleBG;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title left corner width")]
        [ShifterDescription("How wide should the left title corner be?")]
        public int TitleLeftCornerWidth = 2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title right corner width")]
        [ShifterDescription("How wide should the right title corner be?")]
        public int TitleRightCornerWidth = 2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("skinning;shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title left corner background image")]
        [ShifterDescription("Select an image to appear as the background texture for the left titlebar corner.")]
        [Image("titleleft")]
        public byte[] TitleLeftBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [RequiresUpgrade("skinning;shift_titlebar")]
        [ShifterFlag("ShowTitleCorners", true)]
        [ShifterName("Title right corner background image")]
        [ShifterDescription("Select an image to appear as the background texture for the right titlebar corner.")]
        [Image("titleright")]
        public byte[] TitleRightBG = null;


        [ShifterMeta("System")]
        [ShifterCategory("General")]
        [ShifterName("System color key-out")]
        [ShifterDescription("This is a color that will be represented as \"transparent\" in windows. This does not affect the desktop.")]
        public Color SystemKey = Color.FromArgb(1, 0, 1);

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("skinning;shift_window_borders")]
        [Image("bottomborder")]
        [ShifterName("Bottom Border Image")]
        [ShifterDescription("Select an image to appear on the bottom border.")]
        public byte[] BottomBorderBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("skinning;shift_window_borders")]
        [Image("bottomrborder")]
        [ShifterName("Bottom Right Border Image")]
        [ShifterDescription("Select an image to appear on the bottom right border.")]
        public byte[] BottomRBorderBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("skinning;shift_window_borders")]
        [Image("bottomlborder")]
        [ShifterName("Bottom Left Border Image")]
        [ShifterDescription("Select an image to appear on the bottom left border.")]
        public byte[] BottomLBorderBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("skinning;shift_window_borders")]
        [Image("leftborder")]
        [ShifterName("Left Border Image")]
        [ShifterDescription("Select an image to appear on the left border.")]
        public byte[] LeftBorderBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("skinning;shift_window_borders")]
        [Image("rightborder")]
        [ShifterName("Right Border Image")]
        [ShifterDescription("Select an image to appear on the right border.")]
        public byte[] RightBorderBG = null;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterName("Left border width")]
        [ShifterDescription("How wide should the left border be?")]
        public int LeftBorderWidth = 2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterName("Right border width")]
        [ShifterDescription("How wide should the right border be?")]
        public int RightBorderWidth = 2;

        [ShifterMeta("Windows")]
        [ShifterCategory("Window border")]
        [RequiresUpgrade("shift_window_borders")]
        [ShifterName("Bottom border height")]
        [ShifterDescription("How tall should the bottom border be?")]
        public int BottomBorderWidth = 2;

        [Image("panelbutton")]
        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("skinning;shift_panel_buttons")]
        [ShifterName("Panel button background image")]
        [ShifterDescription("Select a texture to display as the panel button background.")]
        public byte[] PanelButtonBG = null;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel button size")]
        [ShifterDescription("How big should the panel button be?")]
        public Size PanelButtonSize = new Size(185, 20);

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel button background color")]
        [ShifterDescription("Select a background color for the panel button.")]
        public Color PanelButtonColor = Skin.Accent2;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel button text color")]
        [ShifterDescription("Select a text color for the panel button.")]
        public Color PanelButtonTextColor = Skin.TitleFG;

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel button text from left")]
        [ShifterDescription("The position relative to the panel button left in pixels that the text is placed at.")]
        public Point PanelButtonFromLeft = new Point(2, 2);

        [ShifterMeta("Desktop")]
        [ShifterCategory("Panel buttons")]
        [RequiresUpgrade("shift_panel_buttons")]
        [ShifterName("Panel button font")]
        [ShifterDescription("Select a font for the panel button.")]
        public Font PanelButtonFont = Skin.SysFont2;


        //we DO NOT want this showing in the shifter.
        [ShifterHidden]
        public Dictionary<string, ImageLayout> SkinImageLayouts = new Dictionary<string, ImageLayout>();

        [ShifterMeta("Windows")]
        [ShifterCategory("Titlebar")]
        [ShifterName("App icon from side")]
        [ShifterDescription("How far from the side should the icon be?")]
        [RequiresUpgrade("shift_titlebar;app_icons")]
        public Point TitlebarIconFromSide = new Point(4,4);
    }

    public class ShifterHiddenAttribute : Attribute {

    }

    public class ShifterFlagAttribute : Attribute {
        public ShifterFlagAttribute(string flag, bool expected) {
            Expected = expected;
            Flag = flag;
        }

        public bool Expected { get; set; }
        public string Flag { get; set; }
        public bool IsTrue(Skin skn) {
            foreach (var f in skn.GetType().GetFields()) {
                if (f.Name == Flag) {
                    if (f.FieldType == typeof(bool)) {
                        return (bool)f.GetValue(skn) == Expected;
                    }
                }
            }
            throw new ArgumentException("The flag attribute was given an incorrect flag variable name.");
        }
    }

    public class ImageAttribute : Attribute {
        /// <summary>
        /// Attribute a byte array within the Skin object with this attribute and the engine and Shifter will see it as an image and you'll be able to grab the image by calling SkinEngine.GetImage() passing the name you input here.
        /// </summary>
        /// <param name="name">The name you want to reference this image as in the code.</param>
        public ImageAttribute(string name) {
            Name = name;
        }

        public string Name { get; set; }
    }


    public class ShifterEnumMaskAttribute : Attribute {
        public ShifterEnumMaskAttribute(string[] items) {
            Items = items;
        }

        public string[] Items { get; set; }
    }



    public class ShifterNameAttribute : Attribute {
        public ShifterNameAttribute(string name) {
            Name = name;
        }

        public string Name { get; set; }
    }

    public class ShifterDescriptionAttribute : Attribute {
        public ShifterDescriptionAttribute(string description) {
            Description = description;
        }

        public string Description { get; set; }
    }

    public class ShifterCategoryAttribute : Attribute {

        public ShifterCategoryAttribute(string category) {
            Category = category;
        }

        public string Category { get; set; }
    }

    public class ShifterMetaAttribute : Attribute {

        public ShifterMetaAttribute(string meta) {
            Meta = meta;
        }

        public string Meta { get; set; }
    }
}