예제 #1
0
 private void GUILogin_Load(object sender, EventArgs e)
 {
     uiTimer.Start();
     ControlManager.SetupControl(lblogintitle);
     ControlManager.SetupControls(pnlloginform);
     ControlManager.SetupControl(btnshutdown);
     pnlloginform.CenterParent();
     txtusername.CenterParent();
     txtusername.Location = new System.Drawing.Point(txtusername.Location.X, 77);
     txtpassword.CenterParent();
     btnlogin.CenterParent();
     btnlogin.Location          = new System.Drawing.Point(btnlogin.Location.X, 143);
     this.BackColor             = SkinEngine.LoadedSkin.LoginScreenColor;
     this.BackgroundImage       = SkinEngine.GetImage("login");
     this.BackgroundImageLayout = SkinEngine.GetImageLayout("login");
 }
예제 #2
0
        public static void SetCursor(Control ctrl)
        {
#if STUPID
            if (!(ctrl is WebBrowser))
            {
                var mouse = SkinEngine.GetImage("mouse");
                if (mouse == null)
                {
                    mouse = Properties.Resources.DefaultMouse;
                }

                var mBmp = new Bitmap(mouse);
                mBmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                var gfx    = Graphics.FromImage(mBmp);
                var handle = mBmp.GetHicon();

                var cursor = new Cursor(handle);
                ctrl.Cursor = cursor;
            }
#endif
        }
예제 #3
0
        /// <summary>
        /// Setups the desktop.
        /// </summary>
        /// <returns>The desktop.</returns>
        public void SetupDesktop()
        {
            if (DesktopFunctions.ShowDefaultElements == true)
            {
                desktoppanel.BackColor = Color.Green;

                //upgrades

                if (Shiftorium.IsInitiated == true)
                {
                    desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop");
                    lbtime.Visible       = Shiftorium.UpgradeInstalled("desktop_clock_widget");

                    //skinning
                    lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor;

                    panelbuttonholder.Top       = 0;
                    panelbuttonholder.Left      = LoadedSkin.PanelButtonHolderFromLeft;
                    panelbuttonholder.Height    = desktoppanel.Height;
                    panelbuttonholder.BackColor = Color.Transparent;
                    panelbuttonholder.Margin    = new Padding(0, 0, 0, 0);

                    sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher");

                    //The Color Picker can give us transparent colors - which Windows Forms f*****g despises when dealing with form backgrounds.
                    //To compensate, we must recreate the desktop color and make the alpha channel '255'.
                    pnldesktoppreview.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B);
                    //Not doing this will cause an ArgumentException.

                    pnldesktoppreview.BackgroundImage       = SkinEngine.GetImage("desktopbackground");
                    pnldesktoppreview.BackgroundImageLayout = GetImageLayout("desktopbackground");
                    desktoppanel.BackColor = LoadedSkin.DesktopPanelColor;

                    var pnlimg = GetImage("desktoppanel");
                    if (pnlimg != null)
                    {
                        var bmp = new Bitmap(pnlimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        pnlimg = bmp;
                    }

                    desktoppanel.BackgroundImage = pnlimg;
                    if (desktoppanel.BackgroundImage != null)
                    {
                        desktoppanel.BackColor = Color.Transparent;
                    }
                    var appimg = GetImage("applauncher");
                    if (appimg != null)
                    {
                        var bmp = new Bitmap(appimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        appimg = bmp;
                    }
                    menuStrip1.BackgroundImage = appimg;
                    lbtime.ForeColor           = LoadedSkin.DesktopPanelClockColor;
                    lbtime.Font = LoadedSkin.DesktopPanelClockFont;
                    if (desktoppanel.BackgroundImage == null)
                    {
                        lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor;
                    }
                    else
                    {
                        lbtime.BackColor = Color.Transparent;
                    }
                    apps.Text = LoadedSkin.AppLauncherText;
                    sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft;
                    sysmenuholder.Size     = LoadedSkin.AppLauncherHolderSize;
                    apps.Size           = sysmenuholder.Size;
                    menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable(LoadedSkin));
                    desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel");
                    desktoppanel.Height = LoadedSkin.DesktopPanelHeight;
                    if (LoadedSkin.DesktopPanelPosition == 1)
                    {
                        desktoppanel.Dock = DockStyle.Bottom;
                    }
                    else
                    {
                        desktoppanel.Dock = DockStyle.Top;
                    }
                }
            }
            else
            {
                desktoppanel.Hide();
            }

            PopulatePanelButtons();
        }
예제 #4
0
 public Image GetImage(string id)
 {
     return(SkinEngine.GetImage(id));
 }
예제 #5
0
        public static void SetupControl(Control ctrl)
        {
            Desktop.InvokeOnWorkerThread(() =>
            {
                if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip))
                {
                    string tag = "";

                    try
                    {
                        if (ctrl.Tag != null)
                        {
                            tag = ctrl.Tag.ToString();
                        }
                    }
                    catch { }

                    if (!tag.Contains("ignoreal"))
                    {
                        ctrl.Click += (o, a) =>
                        {
                            Desktop.HideAppLauncher();
                        };
                    }

                    if (!tag.Contains("keepbg"))
                    {
                        if (ctrl.BackColor != Control.DefaultBackColor)
                        {
                            ctrl.BackColor = SkinEngine.LoadedSkin.ControlColor;
                        }
                    }

                    if (!tag.Contains("keepfont"))
                    {
                        ctrl.ForeColor = SkinEngine.LoadedSkin.ControlTextColor;
                        ctrl.Font      = SkinEngine.LoadedSkin.MainFont;
                        if (tag.Contains("header1"))
                        {
                            Desktop.InvokeOnWorkerThread(() =>
                            {
                                ctrl.Font = SkinEngine.LoadedSkin.HeaderFont;
                            });
                        }

                        if (tag.Contains("header2"))
                        {
                            ctrl.Font = SkinEngine.LoadedSkin.Header2Font;
                        }

                        if (tag.Contains("header3"))
                        {
                            ctrl.Font = SkinEngine.LoadedSkin.Header3Font;
                        }
                    }
                    try
                    {
#if !SLOW_LOCALIZATION
                        if (!string.IsNullOrWhiteSpace(ctrl.Text))
                        {
                            string ctrlText = Localization.Parse(ctrl.Text);
                            ctrl.Text       = ctrlText;
                        }
#endif
                    }
                    catch
                    {
                    }

                    if (ctrl is Button)
                    {
                        if (!tag.ToLower().Contains("nobuttonskin"))
                        {
                            Button b = ctrl as Button;
                            if (!tag.Contains("keepbg"))
                            {
                                b.BackColor             = SkinEngine.LoadedSkin.ButtonBackgroundColor;
                                b.BackgroundImage       = SkinEngine.GetImage("buttonidle");
                                b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
                            }
                            b.FlatAppearance.BorderSize = SkinEngine.LoadedSkin.ButtonBorderWidth;
                            if (!tag.Contains("keepfg"))
                            {
                                b.FlatAppearance.BorderColor = SkinEngine.LoadedSkin.ButtonForegroundColor;
                                b.ForeColor = SkinEngine.LoadedSkin.ButtonForegroundColor;
                            }
                            if (!tag.Contains("keepfont"))
                            {
                                b.Font = SkinEngine.LoadedSkin.ButtonTextFont;
                            }

                            Color orig_bg = b.BackColor;

                            b.MouseEnter += (o, a) =>
                            {
                                b.BackColor             = SkinEngine.LoadedSkin.ButtonHoverColor;
                                b.BackgroundImage       = SkinEngine.GetImage("buttonhover");
                                b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonhover");
                            };
                            b.MouseLeave += (o, a) =>
                            {
                                b.BackColor             = orig_bg;
                                b.BackgroundImage       = SkinEngine.GetImage("buttonidle");
                                b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
                            };
                            b.MouseUp += (o, a) =>
                            {
                                b.BackColor             = orig_bg;
                                b.BackgroundImage       = SkinEngine.GetImage("buttonidle");
                                b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonidle");
                            };

                            b.MouseDown += (o, a) =>
                            {
                                b.BackColor             = SkinEngine.LoadedSkin.ButtonPressedColor;
                                b.BackgroundImage       = SkinEngine.GetImage("buttonpressed");
                                b.BackgroundImageLayout = SkinEngine.GetImageLayout("buttonpressed");
                            };
                        }
                    }
                }

                if (ctrl is TextBox)
                {
                    (ctrl as TextBox).BorderStyle = BorderStyle.FixedSingle;
                }

                ctrl.KeyDown += (o, a) =>
                {
                    if (a.Control && a.KeyCode == Keys.T)
                    {
                        a.SuppressKeyPress = true;


                        Engine.AppearanceManager.SetupWindow(new Applications.Terminal());
                    }

                    ShiftOS.Engine.Scripting.LuaInterpreter.RaiseEvent("on_key_down", a);
                    //a.Handled = true;
                };
                if (ctrl is Button)
                {
                    (ctrl as Button).FlatStyle = FlatStyle.Flat;
                }
                else if (ctrl is WindowBorder)
                {
                    (ctrl as WindowBorder).Setup();
                }


                MakeDoubleBuffered(ctrl);
                ControlSetup?.Invoke(ctrl);
            });
        }
예제 #6
0
        /// <summary>
        /// Setups the desktop.
        /// </summary>
        /// <returns>The desktop.</returns>
        public void SetupDesktop()
        {
            if (DesktopFunctions.ShowDefaultElements == true)
            {
                ToolStripManager.Renderer = new ShiftOSMenuRenderer();

                this.DoubleBuffered    = true;
                this.FormBorderStyle   = FormBorderStyle.None;
                this.WindowState       = FormWindowState.Maximized;
                desktoppanel.BackColor = Color.Green;

                //upgrades

                if (Shiftorium.IsInitiated == true)
                {
                    desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop");
                    lbtime.Visible       = Shiftorium.UpgradeInstalled("desktop_clock_widget");

                    ControlManager.SetupControls(pnlnotificationbox);

                    //skinning
                    lbtime.BackColor = Color.Transparent;
                    pnlnotifications.BackgroundImage       = GetImage("panelclockbg");
                    pnlnotifications.BackgroundImageLayout = GetImageLayout("panelclockbg");
                    pnlnotifications.BackColor             = LoadedSkin.DesktopPanelClockBackgroundColor;

                    panelbuttonholder.Top       = 0;
                    panelbuttonholder.Left      = LoadedSkin.PanelButtonHolderFromLeft;
                    panelbuttonholder.Height    = desktoppanel.Height;
                    panelbuttonholder.BackColor = Color.Transparent;
                    panelbuttonholder.Margin    = new Padding(0, 0, 0, 0);

                    sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher");

                    //The Color Picker can give us transparent colors - which Windows Forms f*****g despises when dealing with form backgrounds.
                    //To compensate, we must recreate the desktop color and make the alpha channel '255'.
                    this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B);
                    //Not doing this will cause an ArgumentException.

                    this.BackgroundImage       = SkinEngine.GetImage("desktopbackground");
                    this.BackgroundImageLayout = GetImageLayout("desktopbackground");
                    desktoppanel.BackColor     = LoadedSkin.DesktopPanelColor;

                    var pnlimg = GetImage("desktoppanel");
                    if (pnlimg != null)
                    {
                        var bmp = new Bitmap(pnlimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        pnlimg = bmp;
                    }

                    desktoppanel.BackgroundImage = pnlimg;
                    if (desktoppanel.BackgroundImage != null)
                    {
                        desktoppanel.BackColor = Color.Transparent;
                    }
                    var appimg = GetImage("applauncher");
                    if (appimg != null)
                    {
                        var bmp = new Bitmap(appimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        appimg = bmp;
                    }
                    menuStrip1.BackgroundImage = appimg;
                    lbtime.ForeColor           = LoadedSkin.DesktopPanelClockColor;
                    lbtime.Font = LoadedSkin.DesktopPanelClockFont;
                    if (desktoppanel.BackgroundImage == null)
                    {
                        lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor;
                    }
                    else
                    {
                        lbtime.BackColor = Color.Transparent;
                    }
                    apps.Text = LoadedSkin.AppLauncherText;
                    sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft;
                    sysmenuholder.Size     = LoadedSkin.AppLauncherHolderSize;
                    apps.Size           = sysmenuholder.Size;
                    menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable());
                    desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel");
                    desktoppanel.Height = LoadedSkin.DesktopPanelHeight;
                    if (LoadedSkin.DesktopPanelPosition == 1)
                    {
                        desktoppanel.Dock = DockStyle.Bottom;
                    }
                    else
                    {
                        desktoppanel.Dock = DockStyle.Top;
                    }
                }

                pnlwidgetlayer.Show();
                pnlwidgetlayer.BringToFront();

                if (Shiftorium.UpgradeInstalled("desktop_widgets"))
                {
                    Widgets.Clear();
                    pnlwidgetlayer.Controls.Clear();
                    foreach (var widget in WidgetManager.GetAllWidgetTypes())
                    {
                        UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null);

                        w.Location = WidgetManager.LoadDetails(w.GetType()).Location;
                        pnlwidgetlayer.Controls.Add(w);
                        MakeWidgetMovable(w);
                        Widgets.Add(w as IDesktopWidget);
                    }
                }

                int lastHeight = 5;
                foreach (var widget in Widgets)
                {
                    if (WidgetManager.LoadDetails(widget.GetType()).IsVisible&& Shiftorium.UpgradeInstalled("desktop_widgets"))
                    {
                        widget.OnSkinLoad();

                        widget.OnUpgrade();
                        widget.Setup();
                        widget.Show();
                        if (widget.Location.X == -1 && widget.Location.Y == -1)
                        {
                            widget.Location = new Point(5, lastHeight);
                            lastHeight     += widget.Size.Height + 5;
                        }
                    }
                    else
                    {
                        widget.Hide();
                    }
                }
                pnlwidgetlayer.Show();
                pnlwidgetlayer.BringToFront();
            }
            else
            {
                desktoppanel.Hide();
            }

            LuaInterpreter.RaiseEvent("on_desktop_skin", this);

            PopulatePanelButtons();
        }
예제 #7
0
        public void SetupDesktop()
        {
            ToolStripManager.Renderer = new ShiftOSMenuRenderer();

            this.DoubleBuffered    = true;
            this.FormBorderStyle   = FormBorderStyle.None;
            this.WindowState       = FormWindowState.Maximized;
            desktoppanel.BackColor = Color.Green;

            //upgrades

            if (SaveSystem.CurrentSave != null)
            {
                desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop");
                lbtime.Visible       = Shiftorium.UpgradeInstalled("desktop_clock_widget");

                //skinning
                lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor;

                panelbuttonholder.Top       = 0;
                panelbuttonholder.Left      = LoadedSkin.PanelButtonHolderFromLeft;
                panelbuttonholder.Height    = desktoppanel.Height;
                panelbuttonholder.BackColor = Color.Transparent;
                panelbuttonholder.Margin    = new Padding(0, 0, 0, 0);

                sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher");

                //The Color Picker can give us transparent colors - which Windows Forms f*****g despises when dealing with form backgrounds.
                //To compensate, we must recreate the desktop color and make the alpha channel '255'.
                this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B);
                //Not doing this will cause an ArgumentException.

                DitheringEngine.DitherImage(SkinEngine.GetImage("desktopbackground"), new Action <Image>((img) =>
                {
                    this.BackgroundImage = img;
                }));
                this.BackgroundImageLayout   = GetImageLayout("desktopbackground");
                desktoppanel.BackgroundImage = GetImage("desktoppanel");
                menuStrip1.BackgroundImage   = GetImage("applauncher");
                lbtime.ForeColor             = LoadedSkin.DesktopPanelClockColor;
                lbtime.Font = LoadedSkin.DesktopPanelClockFont;
                if (desktoppanel.BackgroundImage == null)
                {
                    lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor;
                }
                else
                {
                    lbtime.BackColor = Color.Transparent;
                }
                apps.Text = LoadedSkin.AppLauncherText;
                sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft;
                sysmenuholder.Size     = LoadedSkin.AppLauncherHolderSize;
                apps.Size                          = sysmenuholder.Size;
                menuStrip1.Renderer                = new ShiftOSMenuRenderer(new AppLauncherColorTable());
                desktoppanel.BackColor             = LoadedSkin.DesktopPanelColor;
                desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel");
                desktoppanel.Height                = LoadedSkin.DesktopPanelHeight;
                if (LoadedSkin.DesktopPanelPosition == 1)
                {
                    desktoppanel.Dock = DockStyle.Bottom;
                }
                else
                {
                    desktoppanel.Dock = DockStyle.Top;
                }
            }

            PopulatePanelButtons();
        }