public void Open(string title, string msg) { Dialog frm = new Dialog(); frm.Text = title; var pnl = new Panel(); var flow = new FlowLayoutPanel(); var btnok = new Button(); btnok.AutoSize = true; btnok.AutoSizeMode = AutoSizeMode.GrowAndShrink; flow.Height = btnok.Height + 4; btnok.Text = "ok"; flow.Dock = DockStyle.Bottom; flow.Controls.Add(btnok); btnok.Show(); btnok.Click += (o, a) => { frm.Close(); }; pnl.Controls.Add(flow); flow.Show(); var lbl = new Label(); lbl.Text = msg; lbl.TextAlign = ContentAlignment.MiddleCenter; lbl.Dock = DockStyle.Fill; lbl.AutoSize = false; pnl.Controls.Add(lbl); lbl.Show(); frm.Controls.Add(pnl); pnl.Dock = DockStyle.Fill; frm.Size = new Size(320, 200); AppearanceManager.SetupDialog(frm); }
private void btnimport_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action <string>((filename) => { LoadedSkin = JsonConvert.DeserializeObject <Skin>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename)); SetupUI(); }))); }
private void panel1_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new ColorPicker(panel1.BackColor, "Text Color", new Action <Color>((col) => { panel1.ForeColor = col; panel1.BackColor = col; }))); }
public void SetupUI() { flbody.Controls.Clear(); //Clear the icon list. Type[] types = Array.FindAll(ReflectMan.Types, x => x.GetCustomAttributes(false).FirstOrDefault(y => y is DefaultIconAttribute) != null); pageCount = types.GetPageCount(pageSize); foreach (var type in Array.FindAll(types.GetItemsOnPage(currentPage, pageSize), t => Shiftorium.UpgradeAttributesUnlocked(t))) { var pnl = new Panel(); pnl.Height = 30; pnl.Width = flbody.Width - 15; flbody.Controls.Add(pnl); pnl.Show(); var pic = new PictureBox(); pic.SizeMode = PictureBoxSizeMode.StretchImage; pic.Size = new Size(24, 24); pic.Image = GetIcon(type.Name); pnl.Controls.Add(pic); pic.Left = 5; pic.Top = (pnl.Height - pic.Height) / 2; pic.Show(); var lbl = new Label(); lbl.Tag = "header3"; lbl.AutoSize = true; lbl.Text = NameChangerBackend.GetNameRaw(type); ControlManager.SetupControl(lbl); pnl.Controls.Add(lbl); lbl.CenterParent(); lbl.Show(); var btn = new Button(); btn.Text = "Change..."; btn.AutoSize = true; btn.AutoSizeMode = AutoSizeMode.GrowAndShrink; pnl.Controls.Add(btn); btn.Left = (pnl.Width - btn.Width) - 5; btn.Top = (pnl.Height - btn.Height) / 2; btn.Click += (o, a) => { var gfp = new GraphicPicker(pic.Image, lbl.Text + " icon", ImageLayout.Stretch, (raw, img, layout) => { pic.Image = img; SetIcon(type.Name, raw); }); AppearanceManager.SetupDialog(gfp); }; btn.Show(); ControlManager.SetupControls(pnl); } btnnext.Visible = (currentPage < pageCount - 1); btnprev.Visible = (currentPage > 0); lbcurrentpage.Text = "Page " + (currentPage + 1).ToString() + " of " + pageCount.ToString(); }
public void btnidlebrowse_Click(object s, EventArgs a) { AppearanceManager.SetupDialog(new FileDialog(new[] { ".png", ".gif", ".jpg", ".bmp", ".pic" }, FileOpenerStyle.Open, new Action <string>((file) => { ImageAsBinary = Utils.ReadAllBytes(file); System.IO.File.WriteAllBytes("temp_bin.bmp", ImageAsBinary); Image = SkinEngine.ImageFromBinary(ImageAsBinary); Setup(); }))); }
internal void OpenInternal(string title, string msg, Action c) { Title = title; AppearanceManager.SetupDialog(this); lbmessage.Text = msg; txtinput.Hide(); flyesno.Hide(); btnok.Show(); btnok.Click += (o, a) => { AppearanceManager.Close(this); c?.Invoke(); }; }
private void btnexport_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Save, new Action <string>((filename) => { ShiftOS.Objects.ShiftFS.Utils.WriteAllText(filename, JsonConvert.SerializeObject(LoadedSkin)); string fname = filename.Split('/')[filename.Split('/').Length - 1]; if (!System.IO.Directory.Exists(Paths.SharedFolder + "\\skins")) { System.IO.Directory.CreateDirectory(Paths.SharedFolder + "\\skins"); } string path = Paths.SharedFolder + "\\skins\\" + SaveSystem.CurrentSave.Username + "-" + fname; System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(LoadedSkin)); }))); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { var types = new List <string>(); types.Add(".txt"); if (ShiftoriumFrontend.UpgradeInstalled("textpad_lua_support")) { types.Add(".lua"); } if (ShiftoriumFrontend.UpgradeInstalled("textpad_python_support")) { types.Add(".py"); } AppearanceManager.SetupDialog(new FileDialog(types.ToArray(), FileOpenerStyle.Save, new Action <string>((file) => this.SaveFile(file)))); }
private void btnimport_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new FileDialog(new[] { ".skn" }, FileOpenerStyle.Open, new Action <string>((filename) => { try { LoadedSkin = JsonConvert.DeserializeObject <Skin>(ShiftOS.Objects.ShiftFS.Utils.ReadAllText(filename)); } catch { Infobox.Show("Invalid Skin", "This skin is not compatible with this version of ShiftOS."); } SetupUI(); }))); }
public void PromptYesNoInternal(string title, string message, Action <bool> callback) { Title = title; AppearanceManager.SetupDialog(this); lbmessage.Text = message; txtinput.Hide(); flyesno.Show(); btnok.Hide(); btnyes.Click += (o, a) => { callback?.Invoke(true); AppearanceManager.Close(this); }; btnno.Click += (o, a) => { callback?.Invoke(false); AppearanceManager.Close(this); }; }
public void PromptTextInternal(string title, string message, Action <string> callback, bool isPassword) { Title = title; AppearanceManager.SetupDialog(this); lbmessage.Text = message; txtinput.UseSystemPasswordChar = isPassword; txtinput.Show(); flyesno.Hide(); btnok.Show(); btnok.Click += (o, a) => { callback?.Invoke(txtinput.Text); AppearanceManager.Close(this); }; txtinput.KeyDown += (o, a) => { if (a.KeyCode == Keys.Enter) { a.SuppressKeyPress = true; callback?.Invoke(txtinput.Text); AppearanceManager.Close(this); } }; }
private void save_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new FileDialog(new string[] { ".bf" }, FileOpenerStyle.Save, new Action <string>((file) => Objects.ShiftFS.Utils.WriteAllText(file, programinput.Text)))); }
public void PopulateBody(string cat, string subcat) { flbody.Controls.Clear(); List <ShifterSetting> cats = new List <ShifterSetting>(); foreach (var c in this.settings) { if (c.SubCategory == subcat && c.Category == cat) { if (c.Field.FlagFullfilled(LoadedSkin)) { if (!cats.Contains(c)) { cats.Add(c); } } } } foreach (var c in cats) { var lbl = new Label(); int labelHeight = 0; lbl.AutoSize = true; lbl.Text = c.Name + ":"; flbody.Controls.Add(lbl); lbl.TextAlign = ContentAlignment.MiddleLeft; lbl.Show(); //Cool - label's in. if (c.Field.FieldType == typeof(Point)) { var width = new TextBox(); var height = new TextBox(); labelHeight = width.Height; //irony? width.Width = 30; height.Width = width.Width; width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); flbody.SetFlowBreak(height, true); ControlManager.SetupControl(width); ControlManager.SetupControl(height); flbody.Controls.Add(width); width.Show(); flbody.Controls.Add(height); height.Show(); EventHandler tc = (o, a) => { try { int x = Convert.ToInt32(width.Text); int y = Convert.ToInt32(height.Text); int oldx = ((Point)c.Field.GetValue(this.LoadedSkin)).X; int oldy = ((Point)c.Field.GetValue(this.LoadedSkin)).Y; if (x != oldx || y != oldy) { c.Field.SetValue(LoadedSkin, new Point(x, y)); CodepointValue += 200; } } catch { width.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).X.ToString(); height.Text = ((Point)c.Field.GetValue(this.LoadedSkin)).Y.ToString(); } }; width.TextChanged += tc; height.TextChanged += tc; } else if (c.Field.FieldType == typeof(string)) { var str = new TextBox(); str.Width = 120; ControlManager.SetupControl(str); labelHeight = str.Height; str.Text = c.Field.GetValue(LoadedSkin).ToString(); flbody.SetFlowBreak(str, true); str.TextChanged += (o, a) => { c.Field.SetValue(LoadedSkin, str.Text); CodepointValue += 100; }; flbody.Controls.Add(str); str.Show(); } else if (c.Field.FieldType == typeof(byte[])) { //We'll assume that this is an image file. var color = new Button(); color.Width = 40; labelHeight = color.Height; //just so it's flat like the system. ControlManager.SetupControl(color); flbody.SetFlowBreak(color, true); color.BackgroundImage = SkinEngine.ImageFromBinary((byte[])c.Field.GetValue(this.LoadedSkin)); color.Click += (o, a) => { AppearanceManager.SetupDialog(new GraphicPicker(color.BackgroundImage, c.Name, GetLayout(c.Field.GetImageName()), new Action <byte[], Image, ImageLayout>((col, gdiImg, layout) => { c.Field.SetValue(LoadedSkin, col); color.BackgroundImage = SkinEngine.ImageFromBinary(col); color.BackgroundImageLayout = layout; LoadedSkin.SkinImageLayouts[c.Field.GetImageName()] = layout; CodepointValue += 700; }))); }; flbody.Controls.Add(color); color.Show(); } else if (c.Field.FieldType == typeof(Size)) { var width = new TextBox(); var height = new TextBox(); width.Width = 30; height.Width = width.Width; labelHeight = width.Height; flbody.SetFlowBreak(height, true); width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); ControlManager.SetupControl(width); ControlManager.SetupControl(height); flbody.Controls.Add(width); width.Show(); flbody.Controls.Add(height); height.Show(); EventHandler tc = (o, a) => { try { int x = Convert.ToInt32(width.Text); int y = Convert.ToInt32(height.Text); int oldx = ((Size)c.Field.GetValue(this.LoadedSkin)).Width; int oldy = ((Size)c.Field.GetValue(this.LoadedSkin)).Height; if (x != oldx || y != oldy) { c.Field.SetValue(LoadedSkin, new Size(x, y)); CodepointValue += 200; } } catch { width.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Width.ToString(); height.Text = ((Size)c.Field.GetValue(this.LoadedSkin)).Height.ToString(); } }; width.TextChanged += tc; height.TextChanged += tc; } else if (c.Field.FieldType == typeof(bool)) { var check = new CheckBox(); check.Checked = ((bool)c.Field.GetValue(LoadedSkin)); labelHeight = check.Height; check.CheckedChanged += (o, a) => { c.Field.SetValue(LoadedSkin, check.Checked); CodepointValue += 50; }; flbody.SetFlowBreak(check, true); flbody.Controls.Add(check); check.Show(); } else if (c.Field.FieldType == typeof(Font)) { var name = new ComboBox(); var size = new TextBox(); var style = new ComboBox(); name.Width = 120; labelHeight = name.Height; size.Width = 40; style.Width = 80; flbody.SetFlowBreak(style, true); ControlManager.SetupControl(name); ControlManager.SetupControl(size); ControlManager.SetupControl(style); //populate the font name box foreach (var font in FontFamily.Families) { name.Items.Add(font.Name); } name.Text = ((Font)c.Field.GetValue(LoadedSkin)).Name; size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); //populate the style box foreach (var s in (FontStyle[])Enum.GetValues(typeof(FontStyle))) { style.Items.Add(s.ToString()); } style.Text = ((Font)c.Field.GetValue(LoadedSkin)).Style.ToString(); name.SelectedIndexChanged += (o, a) => { var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); var f = en[style.SelectedIndex]; c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToInt32(size.Text), f)); CodepointValue += 100; }; style.SelectedIndexChanged += (o, a) => { var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); var f = en[style.SelectedIndex]; c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToInt32(size.Text), f)); CodepointValue += 50; }; size.TextChanged += (o, a) => { try { var en = (FontStyle[])Enum.GetValues(typeof(FontStyle)); var f = en[style.SelectedIndex]; c.Field.SetValue(LoadedSkin, new Font(name.Text, (float)Convert.ToInt32(size.Text), f)); } catch { size.Text = ((Font)c.Field.GetValue(LoadedSkin)).Size.ToString(); } CodepointValue += 50; }; flbody.Controls.Add(name); flbody.Controls.Add(size); flbody.Controls.Add(style); name.Show(); size.Show(); style.Show(); } else if (c.Field.FieldType == typeof(Color)) { var color = new Button(); color.Width = 40; labelHeight = color.Height; //just so it's flat like the system. ControlManager.SetupControl(color); color.BackColor = ((Color)c.Field.GetValue(LoadedSkin)); color.BackColorChanged += (o, a) => { c.Field.SetValue(LoadedSkin, color.BackColor); }; color.Click += (o, a) => { AppearanceManager.SetupDialog(new ColorPicker(color.BackColor, c.Name, new Action <Color>((col) => { color.BackColor = col; CodepointValue += 300; }))); }; flbody.SetFlowBreak(color, true); flbody.Controls.Add(color); color.Show(); } else if (c.Field.FieldType == typeof(int)) { if (c.Field.HasShifterEnumMask()) { var name = new ComboBox(); name.Width = 120; ControlManager.SetupControl(name); string[] items = c.Field.GetShifterEnumMask(); foreach (var item in items) { name.Items.Add(item); } name.SelectedIndex = (int)c.Field.GetValue(LoadedSkin); name.SelectedIndexChanged += (o, a) => { c.Field.SetValue(LoadedSkin, name.SelectedIndex); CodepointValue += 75; }; labelHeight = name.Height; flbody.Controls.Add(name); name.Show(); flbody.SetFlowBreak(name, true); } else { var width = new TextBox(); width.Width = 30; width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); ControlManager.SetupControl(width); labelHeight = width.Height; flbody.Controls.Add(width); width.Show(); EventHandler tc = (o, a) => { try { int x = Convert.ToInt32(width.Text); int oldx = ((int)c.Field.GetValue(this.LoadedSkin)); if (x != oldx) { c.Field.SetValue(LoadedSkin, x); CodepointValue += 75; } } catch { width.Text = ((int)c.Field.GetValue(this.LoadedSkin)).ToString(); } }; width.TextChanged += tc; flbody.SetFlowBreak(width, true); } } lbl.AutoSize = false; lbl.Width = (int)this.CreateGraphics().MeasureString(lbl.Text, SkinEngine.LoadedSkin.MainFont).Width + 15; lbl.Height = labelHeight; lbl.TextAlign = ContentAlignment.MiddleLeft; if (!string.IsNullOrWhiteSpace(c.Description)) { var desc = new Label(); flbody.SetFlowBreak(desc, true); desc.Text = c.Description; desc.AutoSize = true; flbody.Controls.Add(desc); desc.Show(); } } }
public void GetPath(string[] filetypes, FileOpenerStyle style, Action <string> callback) { AppearanceManager.SetupDialog(new Applications.FileDialog(filetypes, style, callback)); }
private void load_Click(object sender, EventArgs e) { AppearanceManager.SetupDialog(new FileDialog(new string[] { ".bf" }, FileOpenerStyle.Open, new Action <string>((file) => programinput.Text = Objects.ShiftFS.Utils.ReadAllText(file)))); }
public static void DoStory() { Applications.Terminal term = null; TerminalBackend.PrefixEnabled = false; Desktop.InvokeOnWorkerThread(() => { term = new Applications.Terminal(); AppearanceManager.SetupWindow(term); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Welcome to ShiftOS."); Console.WriteLine(); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.White; Console.WriteLine("Before we can bring you to your new system, we must perform some system tasks."); Console.WriteLine(); Console.WriteLine("Here's the installation outline."); Console.WriteLine(); Console.Write(" - "); ConsoleEx.Bold = true; Console.Write("Storage preparation"); ConsoleEx.Bold = false; Console.Write(" First, we have to prepare your computer's storage device for ShiftOS. This \r\nincludes formatting your drive with the ShiftFS file \r\nsystem, creating system directories, and generating system files."); Console.WriteLine(); Console.Write(" - "); ConsoleEx.Bold = true; Console.Write("User configuration"); ConsoleEx.Bold = false; Console.Write(" Next it's up to you to set up a system hostname, create a user account, and personalize it."); Console.WriteLine(); Console.Write(" - "); ConsoleEx.Bold = true; Console.Write("System tutorial"); ConsoleEx.Bold = false; Console.WriteLine("Finally, we'll teach you how to use ShiftOS."); Console.WriteLine(); ConsoleEx.Bold = true; ConsoleEx.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Let's get started!"); }); int position = 0; Thread.Sleep(5000); ConsoleEx.Bold = true; Console.WriteLine("System preparation"); Console.WriteLine(); ConsoleEx.Bold = false; ConsoleEx.ForegroundColor = ConsoleColor.White; Console.WriteLine(@"We'll now begin formatting your drive. Please be patient."); Console.WriteLine(); double bytesFree, totalBytes; string type, name; dynamic dinf; try { if (Lunix.InWine) { dinf = new Lunix.DFDriveInfo("/"); } else { dinf = new DriveInfo("C:\\"); } bytesFree = dinf.AvailableFreeSpace / 1073741824.0; totalBytes = dinf.TotalSize / 1073741824.0; type = dinf.DriveFormat.ToString(); name = dinf.Name; ConsoleEx.Bold = true; Console.Write("Drive name: "); ConsoleEx.Bold = false; Console.WriteLine(name); ConsoleEx.Bold = true; Console.Write("Drive type: "); ConsoleEx.Bold = false; Console.WriteLine(type); ConsoleEx.Bold = true; Console.Write("Total space: "); ConsoleEx.Bold = false; Console.WriteLine(String.Format("{0:F1}", totalBytes) + " GB"); ConsoleEx.Bold = true; Console.Write("Free space: "); Console.WriteLine(String.Format("{0:F1}", bytesFree) + " GB"); Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } ConsoleEx.Bold = false; ConsoleEx.BackgroundColor = ConsoleColor.Black; Console.Write("Formatting: ["); ConsoleEx.OnFlush?.Invoke(); int formatProgress = 3; while (formatProgress <= 100) { if (formatProgress % 3 == 0) { ConsoleEx.BackgroundColor = ConsoleColor.White; Console.Write(" "); ConsoleEx.OnFlush?.Invoke(); ConsoleEx.BackgroundColor = ConsoleColor.Black; } Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.typesound)); formatProgress++; Thread.Sleep(175); } Console.WriteLine("] ..done."); Thread.Sleep(1000); ConsoleEx.Bold = true; Console.WriteLine("Creating directories..."); ConsoleEx.Bold = false; foreach (var dir in Paths.GetAllWithoutKey()) { if (!dir.Contains(".") && dir.StartsWith("0:/")) { Console.WriteLine("Creating: " + dir); Thread.Sleep(125); Desktop.InvokeOnWorkerThread(() => Engine.AudioManager.PlayStream(Properties.Resources.writesound)); } } Console.WriteLine(); Console.WriteLine("Next, let's get user information."); Console.WriteLine(); Desktop.InvokeOnWorkerThread(() => { var uSignUpDialog = new UniteSignupDialog((result) => { var sve = new Save(); sve.SystemName = result.SystemName; sve.Codepoints = 0; sve.Upgrades = new Dictionary <string, bool>(); sve.ID = Guid.NewGuid(); sve.StoriesExperienced = new List <string>(); sve.StoriesExperienced.Add("mud_fundamentals"); sve.Users = new List <ClientSave> { new ClientSave { Username = "******", Password = result.RootPassword, Permissions = 0 } }; sve.StoryPosition = 8675309; SaveSystem.CurrentSave = sve; Shiftorium.Silent = true; SaveSystem.SaveGame(); Shiftorium.Silent = false; }); AppearanceManager.SetupDialog(uSignUpDialog); }); }
public void Open(string title, string msg) { var inf = new Applications.Infobox(title, msg); AppearanceManager.SetupDialog(inf); }