private void InitializeGridLineManager() { lblPathILPFile = GlobalLayout.GenMetroLabel("<<Patch File>>"); lblPathNETFile = GlobalLayout.GenMetroLabel("<< .NET Assembly >>"); lbxPatchEntryListBox = new MListBox(); structureViever = new StructureViewer(dataStruct); loadingBox = new MLoadingCircle(); lbxErrors = new MListBox(); var grid = new GridLineManager(this, true); int line = grid.AddLineFixed(GlobalLayout.LineHeight); grid.AddElementFixed(line, GlobalLayout.GenMetroButton("Open patch file (*.ilp)", OpenILPatchFile_Click), GlobalLayout.LabelWidth); grid.AddElementFilling(line, lblPathILPFile, GlobalLayout.MinFill); grid.AddElementStretchable(line, GlobalLayout.GenMetroButton("Save", Save_Click), GlobalLayout.MinFill, GlobalLayout.LabelWidth); line = grid.AddLineFixed(GlobalLayout.LineHeight); grid.AddElementFixed(line, GlobalLayout.GenMetroButton("Open .NET assembly", OpenNETAssembly_Click), GlobalLayout.LabelWidth); grid.AddElementFilling(line, lblPathNETFile, GlobalLayout.MinFill); grid.AddElementFixed(line, loadingBox, GlobalLayout.LineHeight); line = grid.AddLineFilling(GlobalLayout.LineHeight); grid.AddElementFilling(line, structureViever, GlobalLayout.MinFill); grid.AddElementFilling(line, lbxPatchEntryListBox, GlobalLayout.MinFill); line = grid.AddLineFixed(GlobalLayout.LineHeight); grid.AddElementFilling(line, GlobalLayout.GenMetroButton("[Execute patches]", ExecutePatches_Click), GlobalLayout.MinFill); grid.AddElementFilling(line, GlobalLayout.GenMetroButton("(Testpatch)", Testpatch_Click), GlobalLayout.MinFill); grid.AddElementFilling(line, GlobalLayout.GenMetroButton("[New patch]", NewPatch_Click), GlobalLayout.MinFill); grid.AddElementFilling(line, GlobalLayout.GenMetroButton("[Edit patch]", EditPatch_Click), GlobalLayout.MinFill); }
/// <summary> /// Draw item /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(70); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush((Bounds.Contains(owner.MousePosition) ? owner.Tint : _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor())), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary); // Draw secondary text StringFormat sfSecondary = new StringFormat(); sfSecondary.LineAlignment = StringAlignment.Center; Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 10, Bounds.Y + Bounds.Height / 2 - 9, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary); }
/// <summary> /// Draw /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(50); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Avatar g.FillRectangle(new SolidBrush(owner.Tint), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32))); StringFormat sfAvatar = new StringFormat(); sfAvatar.LineAlignment = StringAlignment.Center; sfAvatar.Alignment = StringAlignment.Center; g.DrawString(PrimaryText[0].ToString(), new Font("Segoe UI Light", 12), new SolidBrush(Color.White), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)), sfAvatar); // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 48, Bounds.Y + 1, Bounds.Width + 50, Bounds.Height), sfPrimary); }
public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(30); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush((_sourceTheme.DARK_BASED) ? MColor.AddRGB(5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()) : MColor.AddRGB(-5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor())), Bounds); // Draw primary text Color color = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(); StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI Semibold", 8), new SolidBrush(color), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 5), sfPrimary); // Draw divider lines Color lineColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y), new Point(Bounds.X + Bounds.Width, Bounds.Y)); g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y + Bounds.Height - 1), new Point(Bounds.X + Bounds.Width, Bounds.Y + Bounds.Height - 1)); }
public PagePanel_Scripts(int Width, int Height) : base(Width, Height) { FilesBox = new MListBox() { Bounds = new Rectangle(3, 3, 210, 364) }; UpdateList(); Controls.Add(FilesBox); Button ExecuteButton = new Button() { Text = MainForm.CurrentLanguage["Execute"], Bounds = new Rectangle(214, 3, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; ExecuteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } var ctx = HackContext.GameContext; if (ctx == null) { MessageBox.Show(MainForm.CurrentLanguage["PleaseLockGame"]); return; } string h = $"./Scripts/{(string)FilesBox.SelectedItem}.qhscript"; string t = File.ReadAllText(($"./Scripts/{(string)FilesBox.SelectedItem}.qhscript")); var scope = HackContext.CreateScriptScope(MainForm.QHScriptEngine); MainForm.QHScriptEngine.Execute(t, scope); }; Controls.Add(ExecuteButton); Button CreateNewButton = new Button() { Text = MainForm.CurrentLanguage["Create"], Bounds = new Rectangle(214, 33, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; CreateNewButton.Click += (s, e) => { MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Create"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NameTip = new Label() { Text = MainForm.CurrentLanguage["Name"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NameTip); TextBox NameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; CreateNewMForm.MainPanel.Controls.Add(NameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Scripts/{NameTextBox.Text}.qhscript"; if (!File.Exists(str)) { File.Create(str).Close(); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(CreateNewButton); Button EditButton = new Button() { Text = MainForm.CurrentLanguage["Edit"], Bounds = new Rectangle(214, 63, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; EditButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } ScriptEditorForm p = new ScriptEditorForm((string)FilesBox.SelectedItem); p.Show(); }; Controls.Add(EditButton); Button RenameButton = new Button() { Text = MainForm.CurrentLanguage["Rename"], Bounds = new Rectangle(214, 93, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RenameButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Rename"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NewNameTip = new Label() { Text = MainForm.CurrentLanguage["NewName"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NewNameTip); TextBox NewNameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; NewNameTextBox.Text = (string)FilesBox.SelectedItem; CreateNewMForm.MainPanel.Controls.Add(NewNameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Scripts/{NewNameTextBox.Text}.qhscript"; if (!File.Exists(str)) { File.Move($"./Scripts/{(string)FilesBox.SelectedItem}.qhscript", str); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(RenameButton); Button DeleteButton = new Button() { Text = MainForm.CurrentLanguage["Delete"], Bounds = new Rectangle(214, 123, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; DeleteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } if (MessageBox.Show(MainForm.CurrentLanguage["SureToDelete"], "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } File.Delete(($"./Scripts/{(string)FilesBox.SelectedItem}.qhscript")); UpdateList(); }; this.Controls.Add(DeleteButton); Button RefreshButton = new Button() { Text = MainForm.CurrentLanguage["Refresh"], Bounds = new Rectangle(214, 153, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RefreshButton.Click += (s, e) => { UpdateList(); }; Controls.Add(RefreshButton); }
public PagePanel_Projectile(int Width, int Height) : base(Width, Height) { FilesBox = new MListBox() { Bounds = new Rectangle(3, 3, 210, 364) }; UpdateList(); Controls.Add(FilesBox); Button CompileButton = new Button() { Text = MainForm.CurrentLanguage["Compile"], Bounds = new Rectangle(214, 3, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; CompileButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } var ctx = HackContext.GameContext; if (ctx == null) { MessageBox.Show(MainForm.CurrentLanguage["PleaseLockGame"]); return; } Parser p = new Parser(File.ReadAllText(($"./Projs/{(string)FilesBox.SelectedItem}.projimg"))); try { var img = p.Parse(); img.Emit(ctx, new Functions.ProjectileImage.MPointF(ctx.MyPlayer.X, ctx.MyPlayer.Y)); } catch (ParseException ex) { MessageBox.Show($"{MainForm.CurrentLanguage["PleaseCheckCode"]}\n{MainForm.CurrentLanguage["Error"]}:\n" + ex.Message, $"{MainForm.CurrentLanguage["CompilationError"]}"); } catch (Exception) { MessageBox.Show(MainForm.CurrentLanguage["UnknownError"], MainForm.CurrentLanguage["UnknownError"]); } }; Controls.Add(CompileButton); Button CreateNewButton = new Button() { Text = MainForm.CurrentLanguage["Create"], Bounds = new Rectangle(214, 33, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; CreateNewButton.Click += (s, e) => { MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Create"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NameTip = new Label() { Text = MainForm.CurrentLanguage["Name"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NameTip); TextBox NameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; CreateNewMForm.MainPanel.Controls.Add(NameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Projs/{NameTextBox.Text}.projimg"; if (!File.Exists(str)) { File.Create(str).Close(); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(CreateNewButton); Button EditButton = new Button() { Text = MainForm.CurrentLanguage["Edit"], Bounds = new Rectangle(214, 63, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; EditButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } ProjMakerForm p = new ProjMakerForm((string)FilesBox.SelectedItem); p.ShowDialog(this); }; Controls.Add(EditButton); Button RenameButton = new Button() { Text = MainForm.CurrentLanguage["Rename"], Bounds = new Rectangle(214, 93, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RenameButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Rename"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NewNameTip = new Label() { Text = MainForm.CurrentLanguage["NewName"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NewNameTip); TextBox NewNameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; NewNameTextBox.Text = (string)FilesBox.SelectedItem; CreateNewMForm.MainPanel.Controls.Add(NewNameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Projs/{NewNameTextBox.Text}.projimg"; if (!File.Exists(str)) { File.Move($"./Projs/{(string)FilesBox.SelectedItem}.projimg", str); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(RenameButton); Button DeleteButton = new Button() { Text = MainForm.CurrentLanguage["Delete"], Bounds = new Rectangle(214, 123, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; DeleteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } if (MessageBox.Show(MainForm.CurrentLanguage["SureToDelete"], "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } File.Delete(($"./Projs/{(string)FilesBox.SelectedItem}.projimg")); UpdateList(); }; this.Controls.Add(DeleteButton); Button RefreshButton = new Button() { Text = MainForm.CurrentLanguage["Refresh"], Bounds = new Rectangle(214, 153, 80, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RefreshButton.Click += (s, e) => { UpdateList(); }; Controls.Add(RefreshButton); }
public ProjsBrowser() { InitializeComponent(); FilesBox = new MListBox() { Bounds = new Rectangle(2, 2, 300, 200) }; UpdateList(); this.Controls.Add(FilesBox); Button Compile = new Button() { Text = "编译", Bounds = new Rectangle(303, 2, 95, 30), FlatStyle = FlatStyle.Flat }; Compile.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } var ctx = MainForm.Context; if (ctx == null) { MessageBox.Show("请先锁定游戏"); return; } QTRHacker.Functions.ProjectileMaker.Parse.Parser p = new QTRHacker.Functions.ProjectileMaker.Parse.Parser(File.ReadAllText(($"./Projs/{(string)FilesBox.SelectedItem}.projimg"))); try { var img = p.Parse(); img.Emit(ctx, ctx.MyPlayer.X, ctx.MyPlayer.Y); } catch (QTRHacker.Functions.ProjectileMaker.Parse.ParseException ex) { MessageBox.Show("请检查代码\n错误:\n" + ex.Message, "出现编译错误"); } catch (Exception ex) { MessageBox.Show("出现未知错误", "出现未知错误"); } }; this.Controls.Add(Compile); Button CreateNew = new Button() { Text = "新建", Bounds = new Rectangle(303, 32, 95, 30), FlatStyle = FlatStyle.Flat }; CreateNew.Click += (s, e) => { Form f = new Form(); TextBox FileName = new TextBox() { Text = "" }; Button et = new Button(); f.Text = "新建"; f.StartPosition = FormStartPosition.CenterParent; f.FormBorderStyle = FormBorderStyle.FixedSingle; f.MaximizeBox = false; f.MinimizeBox = false; f.Size = new Size(265, 60); Label tip1 = new Label() { Text = "名称:", Location = new Point(0, 5), Size = new Size(80, 20) }; f.Controls.Add(tip1); FileName.Location = new Point(85, 0); FileName.Size = new Size(95, 20); f.Controls.Add(FileName); et.Text = Lang.confirm; et.Size = new Size(65, 20); et.Location = new Point(180, 0); et.Click += delegate(object sender1, EventArgs e1) { string str = $"./Projs/{FileName.Text}.projimg"; if (!File.Exists(str)) { File.Create(str).Close(); } else { MessageBox.Show("该名称的弹幕已存在"); } UpdateList(); f.Dispose(); }; f.Controls.Add(et); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(this); }; this.Controls.Add(CreateNew); Button Edit = new Button() { Text = "编辑", Bounds = new Rectangle(303, 62, 95, 30), FlatStyle = FlatStyle.Flat }; Edit.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } ProjMakerForm p = new ProjMakerForm((string)FilesBox.SelectedItem); p.ShowDialog(this); }; this.Controls.Add(Edit); Button Rename = new Button() { Text = "重命名", Bounds = new Rectangle(303, 92, 95, 30), FlatStyle = FlatStyle.Flat }; Rename.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } Form f = new Form(); TextBox FileName = new TextBox() { Text = "" }; Button et = new Button(); f.Text = "重命名"; f.StartPosition = FormStartPosition.CenterParent; f.FormBorderStyle = FormBorderStyle.FixedSingle; f.MaximizeBox = false; f.MinimizeBox = false; f.Size = new Size(265, 60); Label tip1 = new Label() { Text = "名称:", Location = new Point(0, 5), Size = new Size(80, 20) }; f.Controls.Add(tip1); FileName.Location = new Point(85, 0); FileName.Size = new Size(95, 20); f.Controls.Add(FileName); et.Text = Lang.confirm; et.Size = new Size(65, 20); et.Location = new Point(180, 0); et.Click += delegate(object sender1, EventArgs e1) { string str = $"./Projs/{FileName.Text}.projimg"; if (!File.Exists(str)) { File.Move($"./Projs/{(string)FilesBox.SelectedItem}.projimg", str); } else { MessageBox.Show("该名称的弹幕已存在"); } UpdateList(); f.Dispose(); }; f.Controls.Add(et); f.StartPosition = FormStartPosition.CenterParent; f.ShowDialog(this); }; this.Controls.Add(Rename); Button Delete = new Button() { Text = "删除", Bounds = new Rectangle(303, 122, 95, 30), FlatStyle = FlatStyle.Flat }; Delete.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } if (MessageBox.Show("确定删除吗?", "警告", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } File.Delete(($"./Projs/{(string)FilesBox.SelectedItem}.projimg")); UpdateList(); }; this.Controls.Add(Delete); Button Refresh = new Button() { Text = "刷新", Bounds = new Rectangle(303, 152, 95, 30), FlatStyle = FlatStyle.Flat }; Refresh.Click += (s, e) => { UpdateList(); }; this.Controls.Add(Refresh); }
public PagePanel_Sches(int Width, int Height) : base(Width, Height) { FilesBox = new MListBox() { Bounds = new Rectangle(3, 3, 200, 364) }; UpdateList(); Controls.Add(FilesBox); Button ExecuteButton = new Button() { Text = MainForm.CurrentLanguage["Generate"], Bounds = new Rectangle(204, 3, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; ExecuteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } var ctx = HackContext.GameContext; if (ctx == null) { MessageBox.Show(MainForm.CurrentLanguage["PleaseLockGame"]); return; } string h = $"./Sches/{(string)FilesBox.SelectedItem}.sche"; var bs = SerializeTiles(LoadTilesFromFile(h)); int maddr = NativeFunctions.VirtualAllocEx(ctx.HContext.Handle, 0, bs.Length, NativeFunctions.AllocationType.Commit, NativeFunctions.MemoryProtection.ExecuteReadWrite); NativeFunctions.WriteProcessMemory(ctx.HContext.Handle, maddr, bs, bs.Length, 0); CLRFunctionCaller.Call(ctx, "TRInjections.dll", "TRInjections.ScheMaker.ScheMaker", "LoadTiles", ctx.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Main", "DoUpdate"), maddr); ctx.HContext.GetAddressHelper("TRInjections.dll").SetStaticFieldValue("TRInjections.ScheMaker.ScheMaker", "BrushActive", true); NativeFunctions.VirtualFreeEx(ctx.HContext.Handle, maddr, 0); }; Controls.Add(ExecuteButton); Button CreateNewButton = new Button() { Text = MainForm.CurrentLanguage["Create"], Bounds = new Rectangle(204, 33, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; CreateNewButton.Click += (s, e) => { MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Create"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NameTip = new Label() { Text = MainForm.CurrentLanguage["Name"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NameTip); TextBox NameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; CreateNewMForm.MainPanel.Controls.Add(NameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Sches/{NameTextBox.Text}.sche"; if (!File.Exists(str)) { File.Create(str).Close(); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(CreateNewButton); Button EditButton = new Button() { Text = MainForm.CurrentLanguage["Edit"], Bounds = new Rectangle(204, 63, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; EditButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } ScriptEditorForm p = new ScriptEditorForm((string)FilesBox.SelectedItem); p.Show(); }; Controls.Add(EditButton); Button RenameButton = new Button() { Text = MainForm.CurrentLanguage["Rename"], Bounds = new Rectangle(204, 93, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RenameButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Rename"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NewNameTip = new Label() { Text = MainForm.CurrentLanguage["NewName"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NewNameTip); TextBox NewNameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; NewNameTextBox.Text = (string)FilesBox.SelectedItem; CreateNewMForm.MainPanel.Controls.Add(NewNameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./Sches/{NewNameTextBox.Text}.sche"; if (!File.Exists(str)) { File.Move($"./Sches/{(string)FilesBox.SelectedItem}.sche", str); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Controls.Add(RenameButton); Button DeleteButton = new Button() { Text = MainForm.CurrentLanguage["Delete"], Bounds = new Rectangle(204, 123, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; DeleteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } if (MessageBox.Show(MainForm.CurrentLanguage["SureToDelete"], "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } File.Delete(($"./Sches/{(string)FilesBox.SelectedItem}.sche")); UpdateList(); }; this.Controls.Add(DeleteButton); Button RefreshButton = new Button() { Text = MainForm.CurrentLanguage["Refresh"], Bounds = new Rectangle(204, 153, 90, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; RefreshButton.Click += (s, e) => { UpdateList(); }; Controls.Add(RefreshButton); }
public StartForm() { StartPosition = FormStartPosition.CenterScreen; ClientSize = new Size(400, 135); FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; Text = "选择要编辑的剧本"; BackColor = Color.FromArgb(80, 80, 80); ControlBox = false; moduleBox = new MListBox() { Size = new Size(400, 105), }; Label languageLabel = new Label() { Text = "语言:", Location = new Point(5, 110), Size = new Size(40, 20), TextAlign = ContentAlignment.MiddleCenter }; languageBox = new TextBox() { BorderStyle = BorderStyle.FixedSingle, Location = new Point(50, 110), BackColor = BackColor, Width = 250 }; Button OK = new Button() { Text = "确定", BackColor = Color.FromArgb(120, 120, 120), Location = new Point(320, 105), FlatStyle = FlatStyle.Flat, Size = new Size(80, 30) }; OK.Click += (s, e) => { if (moduleBox.SelectedIndex != -1) { if (!Directory.Exists(MainForm.MnBPath + "\\languages\\" + languageBox.Text)) { MessageBox.Show("该语言文件夹未找到,请核对后输入"); } else { MainForm.ModuleName = (string)moduleBox.Items[moduleBox.SelectedIndex]; MainForm.LanguageName = languageBox.Text; DialogResult = DialogResult.OK; INI.WriteIniKeys("MnB", "Module", moduleBox.SelectedItem.ToString(), MainForm.INIFile); INI.WriteIniKeys("MnB", "Language", languageBox.Text, MainForm.INIFile); Dispose(); } } }; Controls.Add(moduleBox); Controls.Add(languageLabel); Controls.Add(languageBox); Controls.Add(OK); }
public PagePanel_ChatSender(int Width, int Height) : base(Width, Height) { FilesBox = new MListBox() { Bounds = new Rectangle(63, 3, 170, 150) }; UpdateList(); Controls.Add(FilesBox); ContentPanel = new Panel(); ContentPanel.Bounds = new Rectangle(3, 150, 290, 215); ContentPanel.BackColor = Color.FromArgb(60, 60, 60); ContentPanel.AutoScroll = true; Controls.Add(ContentPanel); AddSnippetButton = new Button(); AddSnippetButton.FlatStyle = FlatStyle.Flat; AddSnippetButton.Text = MainForm.CurrentLanguage["Add"]; AddSnippetButton.ForeColor = Color.White; AddSnippetButton.Size = new Size(40, 20); AddSnippetButton.Font = new Font(AddSnippetButton.Font.Name, 7); AddSnippetButton.Click += (s, e) => { AddNewSnippet(); }; FilesBox.SelectedIndexChanged += FilesBox_SelectedIndexChanged; Button CreateButton = new Button() { Text = MainForm.CurrentLanguage["Create"], Bounds = new Rectangle(1, 2, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(CreateButton); CreateButton.Click += (s, e) => { MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Create"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NameTip = new Label() { Text = MainForm.CurrentLanguage["Name"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NameTip); TextBox NameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; CreateNewMForm.MainPanel.Controls.Add(NameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./ChatTemplates/{NameTextBox.Text}.chat"; if (!File.Exists(str)) { File.Create(str).Close(); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); return; } using (var bw = new BinaryWriter(File.Open(str, FileMode.Open))) { bw.Write(0); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Button RenameButton = new Button() { Text = MainForm.CurrentLanguage["Rename"], Bounds = new Rectangle(1, 32, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(RenameButton); RenameButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } MForm CreateNewMForm = new MForm { BackColor = Color.FromArgb(90, 90, 90), Text = MainForm.CurrentLanguage["Rename"], StartPosition = FormStartPosition.CenterParent, ClientSize = new Size(245, 52) }; Label NewNameTip = new Label() { Text = MainForm.CurrentLanguage["NewName"] + ":", Location = new Point(0, 0), Size = new Size(80, 20), TextAlign = ContentAlignment.MiddleCenter }; CreateNewMForm.MainPanel.Controls.Add(NewNameTip); TextBox NewNameTextBox = new TextBox { BorderStyle = BorderStyle.FixedSingle, BackColor = Color.FromArgb(120, 120, 120), Text = "", Location = new Point(85, 0), Size = new Size(95, 20) }; NewNameTextBox.Text = (string)FilesBox.SelectedItem; CreateNewMForm.MainPanel.Controls.Add(NewNameTextBox); Button ConfirmButton = new Button(); ConfirmButton.Text = MainForm.CurrentLanguage["Confirm"]; ConfirmButton.FlatStyle = FlatStyle.Flat; ConfirmButton.Size = new Size(65, 20); ConfirmButton.Location = new Point(180, 0); ConfirmButton.Click += (s1, e1) => { string str = $"./ChatTemplates/{NewNameTextBox.Text}.chat"; if (!File.Exists(str)) { File.Move($"./ChatTemplates/{(string)FilesBox.SelectedItem}.chat", str); } else { MessageBox.Show(MainForm.CurrentLanguage["NameRepeated"]); } UpdateList(); CreateNewMForm.Dispose(); }; CreateNewMForm.MainPanel.Controls.Add(ConfirmButton); CreateNewMForm.ShowDialog(this); }; Button DeleteButton = new Button() { Text = MainForm.CurrentLanguage["Delete"], Bounds = new Rectangle(1, 62, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(DeleteButton); DeleteButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count <= 0) { return; } if (MessageBox.Show(MainForm.CurrentLanguage["SureToDelete"], "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } File.Delete(($"./ChatTemplates/{(string)FilesBox.SelectedItem}.chat")); UpdateList(); }; Button RefreshButton = new Button() { Text = MainForm.CurrentLanguage["Refresh"], Bounds = new Rectangle(1, 92, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(RefreshButton); RefreshButton.Click += (s, e) => { UpdateList(); }; Button SaveButton = new Button() { Text = MainForm.CurrentLanguage["Save"], Bounds = new Rectangle(233, 2, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(SaveButton); SaveButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count > 0) { SaveFile("./ChatTemplates/" + FilesBox.SelectedItem.ToString() + ".chat"); } }; Button SendButton = new Button() { Text = MainForm.CurrentLanguage["Send"], Bounds = new Rectangle(233, 32, 60, 30), FlatStyle = FlatStyle.Flat, BackColor = Color.FromArgb(100, 150, 150, 150) }; Controls.Add(SendButton); SendButton.Click += (s, e) => { if (FilesBox.SelectedIndices.Count > 0) { SendChat(); } }; }
/// <summary> /// Draw item method /// </summary> abstract public void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds);
/// <summary> /// Draw /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic variables Height = DIP.Set(70); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control don't have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 21, Bounds.Y + 6, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary); // Draw secondary text StringFormat sfSecondary = new StringFormat(); sfSecondary.LineAlignment = StringAlignment.Center; Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 21, Bounds.Y + Bounds.Height / 2 - 6, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary); Color bad = new Hex("#F56C6C").ToColor(); Color medium = new Hex("#E6A23C").ToColor(); Color good = new Hex("#67C23A").ToColor(); string strength = ""; Color infoColor = Color.Beige; if (_passwordHash.Length >= 10) { infoColor = good; strength = "Strong"; } else if (_passwordHash.Length >= 6) { infoColor = medium; strength = "Good"; } else { infoColor = bad; strength = "Weak"; } // Draw password hash StringFormat sfPassword = new StringFormat(); sfPassword.LineAlignment = StringAlignment.Center; sfPassword.Alignment = StringAlignment.Far; Font passwordFont = new Font("Segoe UI", 9); SizeF size = g.MeasureString(strength, passwordFont); Color passwordColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(strength, passwordFont, new SolidBrush(infoColor), new Rectangle(Bounds.X, Bounds.Y, Convert.ToInt32(Bounds.Width - 20), Bounds.Height), sfPassword); // new Rectangle(Bounds.X + Bounds.Width - Convert.ToInt32(size.Width) - 21, Bounds.Y + Bounds.Height / 2 - Convert.ToInt32(size.Height/2), Bounds.Width, Bounds.Height / 2 - Convert.ToInt32(size.Height / 2)) }