Fix menu rendering bug.

This commit is contained in:
Michael 2017-02-21 13:26:17 -05:00
parent 994f6b991a
commit 1c24beb100
8 changed files with 246 additions and 571 deletions

View file

@ -1,59 +0,0 @@
namespace ShiftOS.WinForms
{
partial class LuaDesktop
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.pnlcanvas = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// pnlcanvas
//
this.pnlcanvas.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlcanvas.Location = new System.Drawing.Point(0, 0);
this.pnlcanvas.Name = "pnlcanvas";
this.pnlcanvas.Size = new System.Drawing.Size(284, 261);
this.pnlcanvas.TabIndex = 0;
//
// LuaDesktop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.pnlcanvas);
this.Name = "LuaDesktop";
this.Text = "LuaDesktop";
this.Load += new System.EventHandler(this.LuaDesktop_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel pnlcanvas;
}
}

View file

@ -1,214 +0,0 @@
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;
using Newtonsoft.Json;
using ShiftOS.Engine;
using ShiftOS.Engine.Scripting;
using ShiftOS.Objects.ShiftFS;
using static ShiftOS.Engine.SkinEngine;
namespace ShiftOS.WinForms
{
public partial class LuaDesktop : Form, IDesktop
{
public LuaDesktop(string script)
{
InitializeComponent();
interpreter = new LuaInterpreter();
interpreter.Lua.getCanvas = new Func<Panel>(() =>
{
return this.pnlcanvas;
});
if (Utils.FileExists(script))
{
interpreter.ExecuteFile(script);
}
else
{
Desktop.Init(new WinformsDesktop(), true);
Infobox.Show("Script not found.", "Couldn't find a ShiftOS script to handle the desktop environment.");
this.Close();
}
}
private LuaInterpreter interpreter = null;
public string DesktopName
{
get
{
string name = "Unknown";
try
{
name = (string.IsNullOrWhiteSpace(interpreter.Lua.deskName)) ? "Unknown" : interpreter.Lua.deskName;
}
catch
{
}
return name;
}
}
private IWindowBorder focused = null;
public Size GetSize()
{
return this.Size;
}
public void InvokeOnWorkerThread(Action act)
{
this.Invoke(act);
}
public void PopulateAppLauncher(LauncherItem[] items)
{
interpreter.Lua.populateAppLauncher(interpreter.Lua.totable(new List<LauncherItem>(items)));
}
public void PopulatePanelButtons()
{
interpreter.Lua.populatePanelButtons();
}
public void SetupDesktop()
{
try
{
interpreter.Lua.setupDesktop();
}
catch (Exception ex)
{
Infobox.Show("Desktop setup error", "The desktop environment threw an exception: \r\n\r\n\r\n" + ex.Message);
Desktop.Init(new WinformsDesktop(), true);
this.Close();
}
}
public void ShowWindow(IWindowBorder border)
{
var brdr = border as Form;
focused = border;
brdr.GotFocus += (o, a) =>
{
focused = border;
};
brdr.FormBorderStyle = FormBorderStyle.None;
brdr.Show();
brdr.TopMost = true;
}
/// <summary>
/// Kills the window.
/// </summary>
/// <returns>The window.</returns>
/// <param name="border">Border.</param>
public void KillWindow(IWindowBorder border)
{
border.Close();
}
/// <summary>
/// Minimizes the window.
/// </summary>
/// <param name="brdr">Brdr.</param>
public void MinimizeWindow(IWindowBorder brdr)
{
var loc = (brdr as WindowBorder).Location;
var sz = (brdr as WindowBorder).Size;
(brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new
{
Size = sz,
Location = loc
});
(brdr as WindowBorder).Location = new Point(this.GetSize().Width * 2, this.GetSize().Height * 2);
}
/// <summary>
/// Maximizes the window.
/// </summary>
/// <returns>The window.</returns>
/// <param name="brdr">Brdr.</param>
public void MaximizeWindow(IWindowBorder brdr)
{
int startY = (LoadedSkin.DesktopPanelPosition == 1) ? 0 : LoadedSkin.DesktopPanelHeight;
int h = this.GetSize().Height - LoadedSkin.DesktopPanelHeight;
var loc = (brdr as WindowBorder).Location;
var sz = (brdr as WindowBorder).Size;
(brdr as WindowBorder).Tag = JsonConvert.SerializeObject(new
{
Size = sz,
Location = loc
});
(brdr as WindowBorder).Location = new Point(0, startY);
(brdr as WindowBorder).Size = new Size(this.GetSize().Width, h);
}
/// <summary>
/// Restores the window.
/// </summary>
/// <returns>The window.</returns>
/// <param name="brdr">Brdr.</param>
public void RestoreWindow(IWindowBorder brdr)
{
dynamic tag = JsonConvert.DeserializeObject<dynamic>((brdr as WindowBorder).Tag.ToString());
(brdr as WindowBorder).Location = tag.Location;
(brdr as WindowBorder).Size = tag.Size;
}
private void LuaDesktop_Load(object sender, EventArgs e)
{
this.LocationChanged += (o, a) =>
{
if (this.Left != 0)
this.Left = 0;
if (this.Top != 0)
this.Top = 0;
};
this.SizeChanged += (o, a) =>
{
if(this.DisplayRectangle != Screen.PrimaryScreen.Bounds)
{
this.WindowState = FormWindowState.Maximized;
}
};
interpreter.Lua.onLoadDesktop();
SetupDesktop();
SaveSystem.GameReady += () =>
{
InvokeOnWorkerThread(new Action(() =>
{
SetupDesktop();
}));
};
SkinEngine.SkinLoaded += () =>
{
if(this.Visible == true)
{
SetupDesktop();
}
};
Shiftorium.Installed += () =>
{
if (this.Visible == true)
{
SetupDesktop();
}
};
}
}
}

View file

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -203,12 +203,6 @@
</Compile>
<Compile Include="GUIFunctions.cs" />
<Compile Include="JobTasks.cs" />
<Compile Include="LuaDesktop.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LuaDesktop.Designer.cs">
<DependentUpon>LuaDesktop.cs</DependentUpon>
</Compile>
<Compile Include="Oobe.cs">
<SubType>Form</SubType>
</Compile>
@ -304,9 +298,6 @@
<EmbeddedResource Include="FakeSetupScreen.resx">
<DependentUpon>FakeSetupScreen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LuaDesktop.resx">
<DependentUpon>LuaDesktop.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Oobe.resx">
<DependentUpon>Oobe.cs</DependentUpon>
</EmbeddedResource>

View file

@ -71,8 +71,19 @@ namespace ShiftOS.WinForms.Tools
e.TextColor = LoadedSkin.Menu_TextColor;
}
}
e.TextRectangle = GenRect(e.Text, e.TextFont, e.Item.Size, e.Graphics);
base.OnRenderItemText(e);
}
private Rectangle GenRect(string t, Font f, Size s, Graphics g)
{
Rectangle rect = new Rectangle();
var fSize = g.MeasureString(t, f);
var loc = new Point((s.Width - (int)fSize.Width) / 2, (s.Height - (int)fSize.Height) / 2);
var rSize = new Size(loc.X + (int)fSize.Width, loc.Y + (int)fSize.Height);
rect = new Rectangle(loc, rSize);
return rect;
}
}
public class ShiftOSColorTable : ProfessionalColorTable

View file

@ -131,71 +131,73 @@ namespace ShiftOS.WinForms
/// <returns>The panel buttons.</returns>
public void PopulatePanelButtons()
{
panelbuttonholder.Controls.Clear();
if (Shiftorium.IsInitiated == true)
if (DesktopFunctions.ShowDefaultElements == true)
{
if (Shiftorium.UpgradeInstalled("wm_panel_buttons"))
panelbuttonholder.Controls.Clear();
if (Shiftorium.IsInitiated == true)
{
foreach (WindowBorder form in Engine.AppearanceManager.OpenForms)
if (Shiftorium.UpgradeInstalled("wm_panel_buttons"))
{
if (form != null)
foreach (WindowBorder form in Engine.AppearanceManager.OpenForms)
{
if (form.Visible == true)
if (form != null)
{
EventHandler onClick = (o, a) =>
if (form.Visible == true)
{
if (form == focused)
EventHandler onClick = (o, a) =>
{
if (form.IsMinimized)
if (form == focused)
{
RestoreWindow(form);
if (form.IsMinimized)
{
RestoreWindow(form);
}
else
{
MinimizeWindow(form);
}
}
else
{
MinimizeWindow(form);
form.BringToFront();
focused = form;
}
}
else
{
form.BringToFront();
focused = form;
}
};
};
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 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)
{
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.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;
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;
}
}
}
}
@ -211,70 +213,77 @@ namespace ShiftOS.WinForms
/// <returns>The desktop.</returns>
public void SetupDesktop()
{
ToolStripManager.Renderer = new ShiftOSMenuRenderer();
this.DoubleBuffered = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
desktoppanel.BackColor = Color.Green;
//upgrades
if (Shiftorium.IsInitiated == true)
if (DesktopFunctions.ShowDefaultElements == true)
{
desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop");
lbtime.Visible = Shiftorium.UpgradeInstalled("desktop_clock_widget");
ToolStripManager.Renderer = new ShiftOSMenuRenderer();
//skinning
lbtime.ForeColor = LoadedSkin.DesktopPanelClockColor;
this.DoubleBuffered = true;
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
desktoppanel.BackColor = Color.Green;
panelbuttonholder.Top = 0;
panelbuttonholder.Left = LoadedSkin.PanelButtonHolderFromLeft;
panelbuttonholder.Height = desktoppanel.Height;
panelbuttonholder.BackColor = Color.Transparent;
panelbuttonholder.Margin = new Padding(0, 0, 0, 0);
//upgrades
sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher");
//The Color Picker can give us transparent colors - which Windows Forms fucking 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) =>
if (Shiftorium.IsInitiated == true)
{
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;
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 fucking 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;
}
}
}
else
{
desktoppanel.Hide();
}
LuaInterpreter.RaiseEvent("on_desktop_skin", this);
@ -302,80 +311,82 @@ namespace ShiftOS.WinForms
/// <param name="items">Items.</param>
public void PopulateAppLauncher(LauncherItem[] items)
{
apps.DropDownItems.Clear();
Dictionary<string, List<ToolStripMenuItem>> sortedItems = new Dictionary<string, List<ToolStripMenuItem>>();
foreach (var kv in items)
if (DesktopFunctions.ShowDefaultElements == true)
{
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);
}
apps.DropDownItems.Clear();
};
if (sortedItems.ContainsKey(kv.DisplayData.Category))
{
sortedItems[kv.DisplayData.Category].Add(item);
}
else
{
sortedItems.Add(kv.DisplayData.Category, new List<ToolStripMenuItem>());
sortedItems[kv.DisplayData.Category].Add(item);
}
}
Dictionary<string, List<ToolStripMenuItem>> sortedItems = new Dictionary<string, List<ToolStripMenuItem>>();
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);
}
}
else
{
foreach (var subItem in kv.Value)
{
apps.DropDownItems.Add(subItem);
}
}
}
}
if (Shiftorium.IsInitiated == true)
{
if (Shiftorium.UpgradeInstalled("al_shutdown"))
foreach (var kv in items)
{
apps.DropDownItems.Add(new ToolStripSeparator());
var item = new ToolStripMenuItem();
item.Text = Localization.Parse("{SHUTDOWN}");
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) =>
{
TerminalBackend.InvokeCommand("sos.shutdown");
};
apps.DropDownItems.Add(item);
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);
}
else
{
sortedItems.Add(kv.DisplayData.Category, new List<ToolStripMenuItem>());
sortedItems[kv.DisplayData.Category].Add(item);
}
}
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);
}
}
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("sos.shutdown");
};
apps.DropDownItems.Add(item);
}
}
}
LuaInterpreter.RaiseEvent("on_al_populate", items);
}
@ -501,6 +512,13 @@ namespace ShiftOS.WinForms
this.Invoke(act);
}
public void OpenAppLauncher(Point loc)
{
apps.DropDown.Left = loc.X;
apps.DropDown.Top = loc.Y;
apps.ShowDropDown();
}
/// <summary>
/// Gets the size.
/// </summary>
@ -514,9 +532,50 @@ namespace ShiftOS.WinForms
[ShiftOS.Engine.Scripting.Exposed("desktop")]
public class DesktopFunctions
{
public static bool ShowDefaultElements = true;
public dynamic getWindow()
{
return Desktop.CurrentDesktop;
}
public void showDefaultElements(bool val)
{
ShowDefaultElements = val;
SkinEngine.LoadSkin();
}
public dynamic getOpenWindows()
{
return AppearanceManager.OpenForms;
}
public string getALItemName(LauncherItem kv)
{
return (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType);
}
public void openAppLauncher(Point loc)
{
Desktop.OpenAppLauncher(loc);
}
public string getWindowTitle(IWindowBorder form)
{
return NameChangerBackend.GetName(form.ParentWindow);
}
public void openApp(LauncherItem kv)
{
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);
}
}
}
}

View file

@ -86,6 +86,8 @@ namespace ShiftOS.Engine
void InvokeOnWorkerThread(Action act);
Size GetSize();
void OpenAppLauncher(Point loc);
void Show();
void Close();
}
@ -154,6 +156,11 @@ namespace ShiftOS.Engine
{
_desktop.PopulateAppLauncher(AppLauncherDaemon.Available().ToArray());
}
public static void OpenAppLauncher(Point loc)
{
_desktop.OpenAppLauncher(loc);
}
}
}

View file

@ -348,7 +348,7 @@ namespace ShiftOS.Engine {
[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;
public int PanelButtonHolderFromLeft = 100;
[ShifterMeta("Windows")]
[ShifterCategory("Window border")]
@ -832,7 +832,7 @@ namespace ShiftOS.Engine {
[ShifterName("App launcher size")]
[ShifterDescription("The size of the app launcher.")]
[RequiresUpgrade("shift_app_launcher")]
public Size AppLauncherHolderSize = new Size(68, 24);
public Size AppLauncherHolderSize = new Size(100, 24);
[ShifterMeta("Desktop")]
[ShifterCategory("App Launcher")]