Пример #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 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);
            });
        }