コード例 #1
0
        /// <summary>
        /// Desktops the load.
        /// </summary>
        /// <returns>The load.</returns>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void Desktop_Load(object sender, EventArgs e)
        {
            SaveSystem.IsSandbox = this.IsSandbox;
            SaveSystem.Begin();

            SetupDesktop();

            SaveSystem.GameReady += () =>
            {
                this.Invoke(new Action(() =>
                {
                    LuaInterpreter.RaiseEvent("on_desktop_load", this);
                }));
            };
        }
コード例 #2
0
 public void OnUpgrade()
 {
     LuaInterpreter.RaiseEvent("on_window_upgrade", this);
 }
コード例 #3
0
 public bool OnUnload()
 {
     LuaInterpreter.RaiseEvent("on_window_unload", this);
     return(true);
 }
コード例 #4
0
 public void OnSkinLoad()
 {
     LuaInterpreter.RaiseEvent("on_window_skin_load", this);
 }
コード例 #5
0
        /// <summary>
        /// Populates the app launcher.
        /// </summary>
        /// <returns>The app launcher.</returns>
        /// <param name="items">Items.</param>
        public void PopulateAppLauncher(LauncherItem[] items)
        {
            if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
            {
                pnladvancedal.Visible        = false;
                flapps.BackColor             = LoadedSkin.Menu_ToolStripDropDownBackground;
                flcategories.BackColor       = LoadedSkin.Menu_ToolStripDropDownBackground;
                pnlalsystemactions.BackColor = LoadedSkin.SystemPanelBackground;
                lbalstatus.BackColor         = LoadedSkin.ALStatusPanelBackColor;
                //Fonts
                lbalstatus.Font      = LoadedSkin.ALStatusPanelFont;
                lbalstatus.ForeColor = LoadedSkin.ALStatusPanelTextColor;
                btnshutdown.Font     = LoadedSkin.ShutdownFont;

                //Upgrades
                btnshutdown.Visible = Shiftorium.UpgradeInstalled("al_shutdown");

                //Alignments and positions.
                lbalstatus.TextAlign = LoadedSkin.ALStatusPanelAlignment;
                if (LoadedSkin.ShutdownButtonStyle == 2)
                {
                    btnshutdown.Hide();
                }
                else if (LoadedSkin.ShutdownButtonStyle == 1)
                {
                    btnshutdown.Parent = pnlstatus;
                    btnshutdown.BringToFront();
                }
                else
                {
                    btnshutdown.Parent = pnlalsystemactions;
                }
                if (LoadedSkin.ShutdownOnLeft)
                {
                    btnshutdown.Location = LoadedSkin.ShutdownButtonFromSide;
                }
                else
                {
                    btnshutdown.Left = (btnshutdown.Parent.Width - btnshutdown.Width) - LoadedSkin.ShutdownButtonFromSide.X;
                    btnshutdown.Top  = LoadedSkin.ShutdownButtonFromSide.Y;
                }

                //Images
                lbalstatus.BackgroundImage       = GetImage("al_bg_status");
                lbalstatus.BackgroundImageLayout = GetImageLayout("al_bg_status");

                pnlalsystemactions.BackgroundImage       = GetImage("al_bg_system");
                pnlalsystemactions.BackgroundImageLayout = GetImageLayout("al_bg_system");
                if (pnlalsystemactions.BackgroundImage != null)
                {
                    btnshutdown.BackColor = Color.Transparent;
                }

                btnshutdown.Font      = LoadedSkin.ShutdownFont;
                btnshutdown.ForeColor = LoadedSkin.ShutdownForeColor;

                pnladvancedal.Size = LoadedSkin.AALSize;

                pnlalsystemactions.Height = LoadedSkin.ALSystemActionHeight;
                pnlstatus.Height          = LoadedSkin.ALSystemStatusHeight;

                flcategories.Width = LoadedSkin.AALCategoryViewWidth;
                this.flapps.Width  = LoadedSkin.AALItemViewWidth;
            }


            if (DesktopFunctions.ShowDefaultElements == true)
            {
                apps.DropDownItems.Clear();

                Dictionary <string, List <ToolStripMenuItem> > sortedItems = new Dictionary <string, List <ToolStripMenuItem> >();

                flcategories.Controls.Clear();

                LauncherItemList.Clear();


                foreach (var kv in items)
                {
                    var item = new ToolStripMenuItem();
                    item.Text   = (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType);
                    item.Image  = (kv.LaunchType == null) ? null : SkinEngine.GetIcon(kv.LaunchType.Name);
                    item.Click += (o, a) =>
                    {
                        if (kv is LuaLauncherItem)
                        {
                            var interpreter = new Engine.Scripting.LuaInterpreter();
                            interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath);
                        }
                        else
                        {
                            Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow);
                        }
                    };
                    if (sortedItems.ContainsKey(kv.DisplayData.Category))
                    {
                        sortedItems[kv.DisplayData.Category].Add(item);
                        LauncherItemList[kv.DisplayData.Category].Add(kv);
                    }
                    else
                    {
                        sortedItems.Add(kv.DisplayData.Category, new List <ToolStripMenuItem>());
                        sortedItems[kv.DisplayData.Category].Add(item);
                        LauncherItemList.Add(kv.DisplayData.Category, new List <LauncherItem> {
                            kv
                        });
                    }
                }

                foreach (var kv in sortedItems)
                {
                    if (Shiftorium.IsInitiated == true)
                    {
                        if (Shiftorium.UpgradeInstalled("app_launcher_categories"))
                        {
                            var cat = GetALCategoryWithName(kv.Key);
                            foreach (var subItem in kv.Value)
                            {
                                cat.DropDownItems.Add(subItem);
                            }
                            if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
                            {
                                var catbtn = new Button();
                                catbtn.Font      = LoadedSkin.AdvALItemFont;
                                catbtn.FlatStyle = FlatStyle.Flat;
                                catbtn.FlatAppearance.BorderSize         = 0;
                                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                                catbtn.TextAlign   = ContentAlignment.MiddleLeft;
                                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                                catbtn.MouseEnter += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                                };
                                catbtn.MouseLeave += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                                };
                                catbtn.Text   = kv.Key;
                                catbtn.Width  = flcategories.Width;
                                catbtn.Height = 24;
                                flcategories.Controls.Add(catbtn);
                                catbtn.Show();
                                catbtn.Click += (o, a) => SetupAdvancedCategory(catbtn.Text);
                            }
                        }

                        else
                        {
                            foreach (var subItem in kv.Value)
                            {
                                apps.DropDownItems.Add(subItem);
                            }
                        }
                    }
                }

                if (Shiftorium.IsInitiated == true)
                {
                    if (Shiftorium.UpgradeInstalled("al_shutdown"))
                    {
                        apps.DropDownItems.Add(new ToolStripSeparator());
                        var item = new ToolStripMenuItem();
                        item.Text   = Localization.Parse("{SHUTDOWN}");
                        item.Click += (o, a) =>
                        {
                            TerminalBackend.InvokeCommand("shutdown");
                        };
                        apps.DropDownItems.Add(item);
                        if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
                        {
                            if (LoadedSkin.ShutdownButtonStyle == 2)
                            {
                                var catbtn = new Button();
                                catbtn.Font      = LoadedSkin.AdvALItemFont;
                                catbtn.FlatStyle = FlatStyle.Flat;
                                catbtn.FlatAppearance.BorderSize         = 0;
                                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                                catbtn.MouseEnter += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                                };
                                catbtn.MouseLeave += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                                };

                                catbtn.TextAlign = ContentAlignment.MiddleLeft;
                                catbtn.Text      = "Shutdown";
                                catbtn.Width     = flcategories.Width;
                                catbtn.Height    = 24;
                                flcategories.Controls.Add(catbtn);
                                catbtn.Show();
                                catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown");
                            }
                        }
                    }
                }
            }
            LuaInterpreter.RaiseEvent("on_al_populate", items);
        }
コード例 #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
        /// <summary>
        /// Populates the panel buttons.
        /// </summary>
        /// <returns>The panel buttons.</returns>
        public void PopulatePanelButtons()
        {
            if (DesktopFunctions.ShowDefaultElements == true)
            {
                panelbuttonholder.Controls.Clear();
                if (Shiftorium.IsInitiated == true)
                {
                    if (Shiftorium.UpgradeInstalled("wm_panel_buttons"))
                    {
                        foreach (WindowBorder form in Engine.AppearanceManager.OpenForms)
                        {
                            if (form != null)
                            {
                                if (form.Visible == true)
                                {
                                    EventHandler onClick = (o, a) =>
                                    {
                                        if (form == focused)
                                        {
                                            if (form.IsMinimized)
                                            {
                                                RestoreWindow(form);
                                            }
                                            else
                                            {
                                                MinimizeWindow(form);
                                            }
                                        }
                                        else
                                        {
                                            form.BringToFront();
                                            focused = form;
                                        }
                                        HideAppLauncher();
                                    };

                                    var pnlbtn = new Panel();
                                    pnlbtn.Margin                = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0);
                                    pnlbtn.BackColor             = LoadedSkin.PanelButtonColor;
                                    pnlbtn.BackgroundImage       = GetImage("panelbutton");
                                    pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton");

                                    var pnlbtntext = new Label();
                                    pnlbtntext.Text      = NameChangerBackend.GetName(form.ParentWindow);
                                    pnlbtntext.AutoSize  = true;
                                    pnlbtntext.Location  = LoadedSkin.PanelButtonFromLeft;
                                    pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor;
                                    pnlbtntext.BackColor = Color.Transparent;

                                    pnlbtn.BackColor = LoadedSkin.PanelButtonColor;
                                    if (pnlbtn.BackgroundImage != null)
                                    {
                                        pnlbtntext.BackColor = Color.Transparent;
                                    }
                                    pnlbtn.Size    = LoadedSkin.PanelButtonSize;
                                    pnlbtn.Tag     = "keepbg";
                                    pnlbtntext.Tag = "keepbg";
                                    pnlbtn.Controls.Add(pnlbtntext);
                                    this.panelbuttonholder.Controls.Add(pnlbtn);
                                    pnlbtn.Show();
                                    pnlbtntext.Show();

                                    if (Shiftorium.UpgradeInstalled("useful_panel_buttons"))
                                    {
                                        pnlbtn.Click     += onClick;
                                        pnlbtntext.Click += onClick;
                                    }
                                    pnlbtntext.Font = LoadedSkin.PanelButtonFont;
                                }
                            }
                        }
                    }
                }
            }

            LuaInterpreter.RaiseEvent("on_panelbutton_populate", this);
        }