aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/AlternateDesktop.cs
blob: 690977f0744a37b07cc7d6b7ca5b323241fb7124 (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
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;

namespace ShiftOS
{
    public partial class AlternateDesktop : Form
    {
        public AlternateDesktop()
        {
            InitializeComponent();
        }

        private void ClockTick_Tick(object sender, EventArgs e)
        {
            lbclock.Text = API.GetTime();
            
        }

        public void GetApps()
        {
            pnlsidebar.Controls.Clear();
            API.GetAppLauncherItems();
            Panel appbtn = new Panel();
            appbtn.BackColor = Color.Black;
            appbtn.Size = new Size(32, 32);
            appbtn.Visible = true;
            appbtn.Name = "ashow";
            appbtn.Click += new EventHandler(this.SidebarButton_Click);

            pnlsidebar.Controls.Add(appbtn);
            foreach(ApplauncherItem itm in API.AppLauncherItems)
            {
                if(itm.Display == true)
                {
                    Panel btn = new Panel();
                    btn.BackColor = Color.Gray;
                    btn.BackgroundImage = itm.Icon;
                    btn.BackgroundImageLayout = ImageLayout.Stretch;
                    btn.Size = new Size(32, 32);
                    btn.Name = $"al_{new Random().Next(1000, 9999)}";
                    btn.Tag = itm;
                    btn.MouseMove += new MouseEventHandler(this.SidebarButton_Hover);
                    btn.MouseLeave += new EventHandler(this.SidebarButton_Leave);
                    btn.Click += new EventHandler(this.SidebarButton_Click);
                    pnlsidebar.Controls.Add(btn);
                    btn.Show();
                }
            }
            foreach(PanelButton pbtn in API.PanelButtons)
            {
                Panel btn = new Panel();
                btn.Tag = pbtn;
                btn.Name = $"pnl_{new Random().Next(1000, 9999)}";
                btn.BackgroundImage = pbtn.Icon;
                btn.BackgroundImageLayout = ImageLayout.Stretch;
                btn.BackColor = Color.Black;
                btn.Size = new Size(32, 32);
                btn.MouseMove += new MouseEventHandler(this.SidebarButton_Hover);
                btn.MouseLeave += new EventHandler(this.SidebarButton_Leave);
                btn.Click += new EventHandler(this.SidebarButton_Click);
                pnlsidebar.Controls.Add(btn);
                btn.Show();
            }
        }

        public void SidebarButton_Hover(object sender, MouseEventArgs e)
        {
            Panel s = (Panel)sender;
            int labelLoc = pnlcontext.Height + (s.Bottom - (s.Height / 2));
            lblapplabel.Location = new Point(pnlsidebar.Width + 5, labelLoc);
            if(s.Name.Contains("al"))
            {
                var itm = (ApplauncherItem)s.Tag;
                lblapplabel.Text = itm.Name;
            }
            else
            {
                var itm = (PanelButton)s.Tag;
                lblapplabel.Text = itm.Name;
            }
            lblapplabel.Visible = true;
        }

        public void SidebarButton_Click(object sender, EventArgs e)
        {
            var s = (Panel)sender;
            if (s.Name.Contains("al"))
            {
                var itm = (ApplauncherItem)s.Tag;
                var li = new LuaInterpreter();
                li.mod(itm.Lua);
                li = null;
            }
            else if(s.Name.Contains("ashow"))
            {
                pnlapplauncher.Show();
                foreach(Control ctrl in this.Controls)
                {
                    ctrl.MouseDown += (object se, MouseEventArgs a) =>
                    {
                        pnlapplauncher.Hide();
                    };
                }
            }
            else
            {
                try
                {
                    PanelButton pbtn = (PanelButton)s.Tag;
                    API.ToggleMinimized(pbtn.FormToManage);
                }
                catch 
                {

                }
            }
        }

        public void SidebarButton_Leave(object sender, EventArgs e)
        {
            lblapplabel.Hide();
        }

        private void AlternateDesktop_Load(object sender, EventArgs e)
        {
            this.ShowInTaskbar = false;
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;
            GetApps();
        }

        private void apptick_Tick(object sender, EventArgs e)
        {
            //GetApps();
        }

        private bool unity = false;

        public void ToggleUnityMode()
        {
            if (unity == false)
            {
                unity = true;
                this.BackColor = Skinning.Utilities.globaltransparencycolour;
                this.BackgroundImage = null;
                this.TransparencyKey = Skinning.Utilities.globaltransparencycolour;
            }
            else
            {
                unity = false;
                this.BackColor = API.CurrentSkin.desktopbackgroundcolour;
                this.BackgroundImage = API.CurrentSkinImages.desktopbackground;
                this.BackgroundImageLayout = (ImageLayout)API.CurrentSkin.desktopbackgroundlayout;
                this.TransparencyKey = Skinning.Utilities.globaltransparencycolour;
            }
        }
    }
}