예제 #1
0
 public static void Main()
 {
     MForm mf = new MForm();
     Application.Run(mf);
 }
예제 #2
0
        /// <summary>
        /// Draw
        /// </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);
            }

            // Avatar
            Rectangle           avatar = new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16 - 1), new Size(32, 32));
            LinearGradientBrush lgb    = new LinearGradientBrush(avatar, Color, MColor.AddRGB(70, Color), LinearGradientMode.ForwardDiagonal);

            g.FillRectangle(lgb, avatar);
            g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(), 1), avatar);

            // 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 + 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 + 48, Bounds.Y + Bounds.Height / 2 - 8, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);
        }
예제 #3
0
        /// <summary>
        /// Assign/UnAssign Forms from group to role
        /// </summary>
        /// <param name="AD_Group_ID"></param>
        /// <param name="AD_Role_ID"></param>
        /// <param name="grantAccess"></param>
        private void ProvideFormAccessToRole(int AD_Group_ID, int AD_Role_ID, bool grantAccess)
        {
            string                 sql                    = "SELECT AD_Form_ID from AD_Group_Form WHERE IsActive='Y' AND AD_GroupInfo_ID=" + AD_Group_ID;
            DataSet                ds                     = DB.ExecuteDataset(sql);
            List <int>             groupWindowIDs         = new List <int>();
            Dictionary <int, bool> roleWindowIDsDictinary = new Dictionary <int, bool>();
            StringBuilder          winIDs                 = new StringBuilder();

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["AD_Form_ID"] != null && ds.Tables[0].Rows[i]["AD_Form_ID"] != DBNull.Value)
                    {
                        if (winIDs.Length > 0)
                        {
                            winIDs.Append(",");
                        }
                        winIDs.Append(ds.Tables[0].Rows[i]["AD_Form_ID"].ToString());
                        groupWindowIDs.Add(Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Form_ID"]));
                    }
                }

                groupWindowIDs.Sort();

                sql = "SELECT AD_Form_ID,IsReadWrite FROM AD_Form_Access WHERE AD_Role_ID=" + AD_Role_ID + " AND AD_Form_ID IN(" + winIDs.ToString() + ")";
                ds  = DB.ExecuteDataset(sql);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        roleWindowIDsDictinary[Convert.ToInt32(ds.Tables[0].Rows[i]["AD_Form_ID"])] = ds.Tables[0].Rows[i]["IsReadWrite"].ToString() == "Y" ? true : false;
                    }
                }

                for (int i = 0; i < groupWindowIDs.Count(); i++)
                {
                    MForm       wind    = new MForm(ctx, groupWindowIDs[i], null);
                    MFormAccess wAccess = new MFormAccess(wind, AD_Role_ID);
                    if (roleWindowIDsDictinary.ContainsKey(groupWindowIDs[i]))
                    {
                        if (roleWindowIDsDictinary[groupWindowIDs[i]] != grantAccess)
                        {
                            //wAccess.SetIsReadWrite(grantAccess);
                            //wAccess.Save();
                            if (grantAccess)
                            {
                                sql = "UPDATE AD_Form_Access Set IsReadWrite='Y',IsActive='Y' WHERE AD_Form_ID=" + groupWindowIDs[i] + " AND AD_Role_ID=" + AD_Role_ID;
                            }
                            else
                            {
                                sql = "UPDATE AD_Form_Access Set IsReadWrite='N',IsActive='N' WHERE AD_Form_ID=" + groupWindowIDs[i] + " AND AD_Role_ID=" + AD_Role_ID;
                            }
                            DB.ExecuteQuery(sql, null, null);
                        }
                    }
                    else
                    {
                        wAccess.SetAD_Client_ID(ctx.GetAD_Client_ID());
                        wAccess.SetAD_Org_ID(ctx.GetAD_Org_ID());
                        wAccess.SetAD_Role_ID(AD_Role_ID);
                        wAccess.SetAD_Form_ID(groupWindowIDs[i]);
                        wAccess.SetIsReadWrite(grantAccess);
                        wAccess.Save();
                    }
                }
            }
        }
        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();
                }
            };
        }
예제 #5
0
        private void AddEditRow <M>(RenderTreeBuilder pBuilder, MGridAction pAction, bool pIsFilterRow, M pValue)
        {
            var visibleColumns = ColumnsList.Where(c => c.ShouldRenderColumn).ToArray();

            AddInlineTrHeight(pBuilder);

            pBuilder.OpenElement(577, "td");
            pBuilder.AddAttribute(578, "colspan", visibleColumns.Length);

            pBuilder.OpenElement(580, "table");
            pBuilder.OpenElement(581, "tbody");
            pBuilder.OpenElement(582, "tr");

            {
                pBuilder.OpenComponent <MForm <M> >(53);
                pBuilder.AddAttribute(587, nameof(MForm <M> .Model), pValue);
                pBuilder.AddAttribute(588, nameof(MForm <M> .IsInTableRow), true);
                pBuilder.AddAttribute(589, nameof(MForm <M> .Fields), (RenderFragment)((builder3) =>
                {
                    AddInlineFormFields(builder3, visibleColumns, pIsFilterRow);
                }));

                pBuilder.AddAttribute(594, nameof(MForm <M> .MFormGridContext), new MFormGridContext()
                {
                    Action = pAction
                });

                if (pIsFilterRow)
                {
                    pBuilder.AddAttribute(601, nameof(MForm <M> .EnableValidation), false);
                    pBuilder.AddAttribute(602, "data-is-filterrow", true);

                    pBuilder.AddAttribute(604, nameof(MForm <M> .OnValueChanged),
                                          EventCallback.Factory.Create <MFormValueChangedArgs <ExpandoObject> >(this, OnFilterValueChanged));
                }
                else
                {
                    //T == M here

                    pBuilder.AddAttribute(611, nameof(MForm <T> .OnValidSubmit), EventCallback.Factory.Create <MFormSubmitArgs>(this, async(a) =>
                    {
                        await OnFormSubmit(a);
                    }));

                    pBuilder.AddAttribute(616, nameof(MForm <T> .OnValueChanged), EventCallback.Factory.Create <MFormValueChangedArgs <T> >(this, OnEditValueChanged));

                    pBuilder.AddComponentReferenceCapture(618, (__value) =>
                    {
                        EditForm = (MForm <T>)__value;
                    });
                }

                pBuilder.CloseComponent();
            }

            pBuilder.CloseElement(); //tr
            pBuilder.CloseElement(); //tbody
            pBuilder.CloseElement(); //table

            pBuilder.CloseElement(); //td
        }
예제 #6
0
        public PagePanel_Basic(int Width, int Height) : base(Width, Height)
        {
            FunctionsNumber        = new Dictionary <Control, int>();
            ButtonsPanel           = new Panel();
            ButtonsPanel.Bounds    = new Rectangle(0, 0, 60, Height);
            ButtonsPanel.BackColor = Color.FromArgb(30, 255, 255, 255);
            Controls.Add(ButtonsPanel);

            ContentPanel           = new Panel();
            ContentPanel.Bounds    = new Rectangle(60, 3, Width - 60, Height - 6);
            ContentPanel.BackColor = TextButton.SelectedColor;
            Controls.Add(ContentPanel);

            Page1              = new Panel();
            Page1.Bounds       = new Rectangle(3, 0, Width - 60, Height);
            Page2              = new Panel();
            Page2.Bounds       = new Rectangle(3, 0, Width - 60, Height);
            Page3              = new Panel();
            Page3.Bounds       = new Rectangle(3, 0, Width - 60, Height);
            PageEvent          = new Panel();
            PageEvent.Bounds   = new Rectangle(3, 0, Width - 60, Height);
            PageBuilder        = new Panel();
            PageBuilder.Bounds = new Rectangle(3, 0, Width - 60, Height);
            PageMisc           = new Panel();
            PageMisc.Bounds    = new Rectangle(3, 0, Width - 60, Height);

            AddFunction(Page1, MainForm.CurrentLanguage["InfLife"], "3BD0E7860C0441E2B95E63C3F04B4871", true, Utils.InfiniteLife_E, Utils.InfiniteLife_D);
            AddFunction(Page1, MainForm.CurrentLanguage["InfOxygen"], "37EF93BAB687481F87D4D0F95941C781", true, Utils.InfiniteOxygen_E, Utils.InfiniteOxygen_D);
            AddFunction(Page1, MainForm.CurrentLanguage["InfMinion"], "D1808E759CBC533C332968E2603376AD", true, Utils.InfiniteMinion_E, Utils.InfiniteMinion_D);
            AddFunction(Page1, MainForm.CurrentLanguage["InfMana"], "E8A50F6CC601D8B3977E8E9D4677F6DD", true, Utils.InfiniteMana_E, Utils.InfiniteMana_D);
            AddFunction(Page1, MainForm.CurrentLanguage["InfItemAmmo"], "830D900B05074CD0A8DADD1D2EB5F6BC", true, Utils.InfiniteItemAmmo_E, Utils.InfiniteItemAmmo_D);
            AddFunction(Page1, MainForm.CurrentLanguage["InfFly"], "8669ADD79BBDD647B240409BE2094DDB", true, Utils.InfiniteFly_E, Utils.InfiniteFly_D);
            AddFunction(Page1, MainForm.CurrentLanguage["ImmuneDebuff"], "A339FE530BB6693DCA0ABC020138A880", true, Utils.ImmuneDebuffs_E, Utils.ImmuneDebuffs_D);
            AddFunction(Page1, MainForm.CurrentLanguage["HighLight"], "800DE5238B9475F09B2D49BAD8CF56D6", true, Utils.HighLight_E, Utils.HighLight_D);
            AddFunction(Page1, MainForm.CurrentLanguage["GhostMode"], "BC5F7996B2B89012715CFBCDBF9434CB", true, Utils.GhostMode_E, Utils.GhostMode_D);

            AddFunction(Page2, MainForm.CurrentLanguage["SlowFall"], "84E55372621C1D6FD4389456C0D64C33", true, Utils.LowGravity_E, Utils.LowGravity_D);
            AddFunction(Page2, MainForm.CurrentLanguage["FastSpeed"], "5B9B9517D95F6F86CCE0D6F0CF16EDAA", true, Utils.FastSpeed_E, Utils.FastSpeed_D);
            //AddFunction(Page2, MainForm.CurrentLanguage["ProjectileIgnoreTiles"], "9E594D35FA0657AFA83604C40FF88C76", true, Utils.ProjectileIgnoreTile_E, Utils.ProjectileIgnoreTile_D);
            AddFunction(Page2, MainForm.CurrentLanguage["GrabFarAway"], "BDBFD8A007CA446B01FC3D5DA7BA8560", true, Utils.GrabItemFarAway_E, Utils.GrabItemFarAway_D);
            AddFunction(Page2, MainForm.CurrentLanguage["BonusTwoSlots"], "265E7EE043E026964283772D666DD914", true, Utils.BonusTwoSlots_E, Utils.BonusTwoSlots_D);
            AddFunction(Page2, MainForm.CurrentLanguage["GoldHoleDropBags"], "4FB4064F1FEB6E155313756DCBB82203", true, Utils.GoldHoleDropsBag_E, Utils.GoldHoleDropsBag_D);
            //AddFunction(Page2, MainForm.CurrentLanguage["SlimeGunBurnNPCS"], "23280EF2B335403BEF698C2F6AB9CB8A", true, Utils.SlimeGunBurn_E, Utils.SlimeGunBurn_D);
            AddFunction(Page2, MainForm.CurrentLanguage["FishOnlyCrates"], "77D322DE31DDE8C328C44A8A7E63AD04", true, Utils.FishOnlyCrates_E, Utils.FishOnlyCrates_D);
            AddFunction(Page2, MainForm.CurrentLanguage["EnableAllRecipes"], "DA840529BCE9704EF4F1BA5CB6C6ECD4", true, Utils.EnableAllRecipes_E, Utils.EnableAllRecipes_D);
            AddFunction(Page2, MainForm.CurrentLanguage["StengthenedVampireKnives"], "418C48524EA50ECC6717C5D629AF7B32", true, Utils.StrengthenVampireKnives_E, Utils.StrengthenVampireKnives_D);
            //AddFunction(Page2, MainForm.CurrentLanguage["SwingIgnoringTiles"], "4B246B44592B441C9DC23E9EBC077A98", true, Utils.SwingIgnoringTils_E, Utils.SwingIgnoringTils_D);
            AddFunction(Page2, MainForm.CurrentLanguage["SwingingAttacksAll"], "1D2F13AE9E084743898A11EE64D744D2", true, Utils.SwingingAttacksAll_E, Utils.SwingingAttacksAll_D);

            AddFunction(Page3, MainForm.CurrentLanguage["BurnAllNPCS"], "9A3F870D0DDB5B46F6E1B1266D6882AD", false,
                        g =>
            {
                int i = 0;
                PopupProgressBar p        = new PopupProgressBar();
                p.MainProgressBar.Maximum = NPC.MAXNUMBER;
                System.Timers.Timer timer = new System.Timers.Timer(1);
                timer.Elapsed            += (sender, e) =>
                {
                    var b   = p.MainProgressBar;
                    b.Value = i;
                    b.Invalidate();
                    b.Text = b.Value + "/" + b.Maximum;
                    if (i >= b.Maximum)
                    {
                        p.Dispose();
                    }
                };
                timer.Start();
                p.Show();
                p.Location = new Point(MainForm.MainFormInstance.Location.X + MainForm.MainFormInstance.Width / 2 - p.ClientSize.Width / 2, MainForm.MainFormInstance.Location.Y + MainForm.MainFormInstance.Height / 2 - p.ClientSize.Height / 2);
                new Thread(() =>
                {
                    MainForm.MainFormInstance.Enabled = false;
                    var npc = HackContext.GameContext.NPC;
                    for (; i < NPC.MAXNUMBER; i++)
                    {
                        if (npc[i].Active)
                        {
                            npc[i].AddBuff(153, 216000);
                        }
                    }
                    MainForm.MainFormInstance.Enabled = true;
                }).Start();
            }, null);
            AddFunction(Page3, MainForm.CurrentLanguage["BurnAllPlayers"], "37EF93BAB687481F87D4D0F95941C781", false,
                        g =>
            {
                int i = 0;
                PopupProgressBar p        = new PopupProgressBar();
                p.MainProgressBar.Maximum = Player.MAXNUMBER;
                System.Timers.Timer timer = new System.Timers.Timer(1);
                timer.Elapsed            += (sender, e) =>
                {
                    var b   = p.MainProgressBar;
                    b.Value = i;
                    b.Invalidate();
                    b.Text = b.Value + "/" + b.Maximum;
                    if (i >= b.Maximum)
                    {
                        p.Dispose();
                    }
                };
                timer.Start();
                p.Show();
                p.Location = new Point(MainForm.MainFormInstance.Location.X + MainForm.MainFormInstance.Width / 2 - p.ClientSize.Width / 2, MainForm.MainFormInstance.Location.Y + MainForm.MainFormInstance.Height / 2 - p.ClientSize.Height / 2);
                new Thread(() =>
                {
                    MainForm.MainFormInstance.Enabled = false;
                    var player = HackContext.GameContext.Players;
                    for (; i < Player.MAX_PLAYER; i++)
                    {
                        if (player[i].Active)
                        {
                            player[i].AddBuff(44, 216000);
                        }
                    }
                    MainForm.MainFormInstance.Enabled = true;
                }).Start();
            }, null);
            AddFunction(Page3, MainForm.CurrentLanguage["PourLavaOntoPlayers"], "D1808E759CBC533C332968E2603376AD", false, Utils.DropLavaOntoPlayers, null);
            FunctionButton _b = null;

            _b = AddFunction(Page3, MainForm.CurrentLanguage["RandomUUID"], "E8A50F6CC601D8B3977E8E9D4677F6DD", false,
                             g =>
            {
                HackContext.GameContext.UUID = Guid.NewGuid().ToString();
                _b.Text = HackContext.GameContext.UUID;
            }, null);
            AddFunction(Page3, MainForm.CurrentLanguage["ExploreWholeWorld"], "830D900B05074CD0A8DADD1D2EB5F6BC", false, Utils.RevealMap, null);
            AddFunction(Page3, MainForm.CurrentLanguage["RightClickToTP"], "8669ADD79BBDD647B240409BE2094DDB", false, Utils.RightClickToTP, null);
            AddFunction(Page3, MainForm.CurrentLanguage["ProjectilePuzzle"], "A339FE530BB6693DCA0ABC020138A880", false,
                        g =>
            {
                OpenFileDialog ofd = new OpenFileDialog();

                ofd.Filter = "png files (*.png)|*.png";
                if (ofd.ShowDialog(this) == DialogResult.OK)
                {
                    var ctx       = HackContext.GameContext;
                    var config    = (MainForm.Configs["CFG_ProjDrawer"] as CFG_ProjDrawer);
                    ProjImage img = ProjImage.FromImage(ofd.FileName, config.ProjType, config.Resolution);
                    this.Enabled  = false;
                    img.Emit(ctx, new MPointF(ctx.MyPlayer.X, ctx.MyPlayer.Y));
                    this.Enabled = true;
                }
            }, null);
            AddFunction(Page3, MainForm.CurrentLanguage["RainbowTexting"], "89494BDF0C804010910932F71E5EC75E", false,
                        g =>
            {
                MForm Form = new MForm
                {
                    BackColor     = Color.FromArgb(90, 90, 90),
                    Text          = MainForm.CurrentLanguage["RainbowTexting"],
                    StartPosition = FormStartPosition.CenterParent,
                    ClientSize    = new Size(245, 72)
                };

                CheckBox ReloadAllFonts = new CheckBox()
                {
                    Text     = MainForm.CurrentLanguage["ReloadFonts"],
                    Location = new Point(10, 0),
                    Size     = new Size(200, 20),
                };
                Form.MainPanel.Controls.Add(ReloadAllFonts);

                Label Tip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["Text"] + ":",
                    Location  = new Point(0, 20),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                Form.MainPanel.Controls.Add(Tip);

                TextBox Box = new TextBox
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    BackColor   = Color.FromArgb(120, 120, 120),
                    Text        = "",
                    Location    = new Point(85, 20),
                    Size        = new Size(95, 20),
                    ImeMode     = ImeMode.On
                };
                Form.MainPanel.Controls.Add(Box);

                Button ConfirmButton    = new Button();
                ConfirmButton.Text      = MainForm.CurrentLanguage["Confirm"];
                ConfirmButton.FlatStyle = FlatStyle.Flat;
                ConfirmButton.Size      = new Size(65, 20);
                ConfirmButton.Location  = new Point(180, 20);
                ConfirmButton.Click    += (s1, e1) =>
                {
                    if (HackContext.Characters == null)
                    {
                        HackContext.Characters = new Dictionary <char, ProjImage>();
                        HackContext.LoadRainbowFonts(HackContext.Characters);
                    }
                    if (ReloadAllFonts.Checked)
                    {
                        HackContext.Characters.Clear();
                        HackContext.LoadRainbowFonts(HackContext.Characters);
                    }
                    RainbowTextDrawer rtd = new RainbowTextDrawer(HackContext.Characters);
                    rtd.DrawString(Box.Text, center: new MPointF());
                    var ctx    = HackContext.GameContext;
                    var player = ctx.MyPlayer;
                    rtd.Emit(ctx, new MPointF(player.X, player.Y));
                    Form.Dispose();
                };
                Form.MainPanel.Controls.Add(ConfirmButton);
                Form.Activated += (s, e) =>
                {
                    Box.Focus();
                };
                Form.ShowDialog(this);
            }, null);
            AddFunction(Page3, MainForm.CurrentLanguage["CoronaVirus"], "7FF4CE10ED9B4924BA63F92E2443C79A", false,
                        g =>
            {
                var player = g.MyPlayer;
                for (int i = 0; i < 3; i++)
                {
                    NPC.NewNPC(g, Convert.ToInt32(player.X), Convert.ToInt32(player.Y) - 2, 51);
                }
                player.AddBuff(44, 600, true);
                player.AddBuff(153, 600, true);
                player.AddBuff(67, 600, true);
                player.AddBuff(24, 600, true);
            }, null);
            //AddFunction(Page3, MainForm.CurrentLanguage["HarpLeftClickTP"], "800DE5238B9475F09B2D49BAD8CF56D6", true, Utils.HarpToTP_E, Utils.HarpToTP_D);

            AddFunction(PageEvent, MainForm.CurrentLanguage["ToggleDayNight"], "E6F33D980A95291E6D0C0033F39E6629", false, g => g.DayTime        = !g.DayTime, null);
            AddFunction(PageEvent, MainForm.CurrentLanguage["ToggleSunDial"], "6FFF093BA44EEFD41C9E3585FA18EBBA", false, g => g.FastForwardTime = !g.FastForwardTime, null);
            AddFunction(PageEvent, MainForm.CurrentLanguage["ToggleBloodMoon"], "C8DE8467590D278A312E9C5A0A63DF84", false, g => g.BloodMoon     = !g.BloodMoon, null);
            AddFunction(PageEvent, MainForm.CurrentLanguage["ToggleEclipse"], "DA4EFFA8EAC423555CF33536D6851570", false, g => g.Eclipse         = !g.Eclipse, null);
            AddFunction(PageEvent, MainForm.CurrentLanguage["ToggleSnowMoon"], "A74C10BB62FE043E1924AB2267570C42", false, g => g.SnowMoon       = !g.SnowMoon, null);
            AddFunction(PageEvent, MainForm.CurrentLanguage["TogglePumpkinMoon"], "192BB3BD522421DC4AC18EC61800EE04", false, g => g.PumpkinMoon = !g.PumpkinMoon, null);

            AddFunction(PageBuilder, MainForm.CurrentLanguage["SuperRange"], "2045F3ED1E8276545D86390FFFA9B02E", true, Utils.SuperRange_E, Utils.SuperRange_D);
            AddFunction(PageBuilder, MainForm.CurrentLanguage["FastTilingAndWallingSpeed"], "B5892B95C1D1C38DA5E8E0499E34235D", true, Utils.FastTileAndWallSpeed_E, Utils.FastTileAndWallSpeed_D);
            AddFunction(PageBuilder, MainForm.CurrentLanguage["MechanicalRulerEffect"], "B84EB7D6788F944E81654735A22DB528", true, Utils.MachinicalRulerEffect_E, Utils.MachinicalRulerEffect_D);
            AddFunction(PageBuilder, MainForm.CurrentLanguage["MechanicalGlassesEffect"], "62DC9F0484D233B9FB54A6BF15521354", true, Utils.ShowCircuit_E, Utils.ShowCircuit_D);

            AddFunction(PageMisc, MainForm.CurrentLanguage["ShadowDodge"], "4C930E9DB193D5E61AFEDB24E8D5392E", true, Utils.ShadowDodge_E, Utils.ShadowDodge_D);
            AddFunction(PageMisc, MainForm.CurrentLanguage["ShowInvisiblePlayers"], "1EE572824476A3BBB1AA367E70BFF790", true, Utils.ShowInvisiblePlayers_E, Utils.ShowInvisiblePlayers_D);

            AddTab(MainForm.CurrentLanguage["Basic_1"], Page1).Selected = true;
            AddTab(MainForm.CurrentLanguage["Basic_2"], Page2);
            AddTab(MainForm.CurrentLanguage["Advanced"], Page3);
            AddTab(MainForm.CurrentLanguage["Event"], PageEvent);
            AddTab(MainForm.CurrentLanguage["Builder"], PageBuilder);
            AddTab(MainForm.CurrentLanguage["Miscs"], PageMisc);
        }
예제 #7
0
        public PagePanel_Player(int Width, int Height) : base(Width, Height)
        {
            EditPlayerInfoButton           = new Button();
            EditPlayerInfoButton.Enabled   = false;
            EditPlayerInfoButton.FlatStyle = FlatStyle.Flat;
            EditPlayerInfoButton.Text      = MainForm.CurrentLanguage["EditPlayer"];
            EditPlayerInfoButton.BackColor = Color.FromArgb(100, 150, 150, 150);
            EditPlayerInfoButton.Bounds    = new Rectangle(215, 3, 80, 30);
            EditPlayerInfoButton.Click    += (s, e) =>
            {
                int i = Convert.ToInt32(PlayerListView.SelectedItems[0].Text);
                PlayerEditorForm f = new PlayerEditorForm(HackContext.GameContext.Players[i], i == HackContext.GameContext.MyPlayerIndex);
                f.Show();
            };
            Controls.Add(EditPlayerInfoButton);

            TpToPlayerButton           = new Button();
            TpToPlayerButton.Enabled   = false;
            TpToPlayerButton.FlatStyle = FlatStyle.Flat;
            TpToPlayerButton.Text      = MainForm.CurrentLanguage["TpTo"];
            TpToPlayerButton.BackColor = Color.FromArgb(100, 150, 150, 150);
            TpToPlayerButton.Bounds    = new Rectangle(215, 33, 80, 30);
            TpToPlayerButton.Click    += (s, e) =>
            {
                var p  = HackContext.GameContext.Players[Convert.ToInt32(PlayerListView.SelectedItems[0].Text)];
                var mp = HackContext.GameContext.MyPlayer;
                mp.X = p.X;
                mp.Y = p.Y;
            };
            Controls.Add(TpToPlayerButton);

            AddBuffButton           = new Button();
            AddBuffButton.Enabled   = false;
            AddBuffButton.FlatStyle = FlatStyle.Flat;
            AddBuffButton.Text      = MainForm.CurrentLanguage["AddBuff"];
            AddBuffButton.BackColor = Color.FromArgb(100, 150, 150, 150);
            AddBuffButton.Bounds    = new Rectangle(215, 63, 80, 30);
            Controls.Add(AddBuffButton);
            AddBuffButton.Click += (s, e) =>
            {
                var ps = PlayerListView.SelectedIndices;
                if (ps.Count == 0)
                {
                    return;
                }

                MForm AddBuffMForm = new MForm
                {
                    BackColor     = Color.FromArgb(90, 90, 90),
                    Text          = MainForm.CurrentLanguage["AddBuff"],
                    StartPosition = FormStartPosition.CenterParent,
                    ClientSize    = new Size(245, 72)
                };

                Label BuffTypeTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["BuffType"],
                    Location  = new Point(0, 0),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                AddBuffMForm.MainPanel.Controls.Add(BuffTypeTip);

                TextBox BuffID = new TextBox
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    BackColor   = Color.FromArgb(120, 120, 120),
                    Text        = "0",
                    Location    = new Point(85, 0),
                    Size        = new Size(95, 20)
                };
                BuffID.KeyPress += (s1, e1) => e1.Handled = e1.Handled || (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8 && e1.KeyChar != '-');
                AddBuffMForm.MainPanel.Controls.Add(BuffID);


                Label BuffTimeTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["BuffTime"],
                    Location  = new Point(0, 20),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                AddBuffMForm.MainPanel.Controls.Add(BuffTimeTip);

                TextBox BuffTime = new TextBox
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    BackColor   = Color.FromArgb(120, 120, 120),
                    Text        = "0",
                    Location    = new Point(85, 20),
                    Size        = new Size(95, 20)
                };
                BuffTime.KeyPress += (s1, e1) => e1.Handled = e1.Handled || (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8 && e1.KeyChar != '-');
                AddBuffMForm.MainPanel.Controls.Add(BuffTime);

                Button ConfirmButton = new Button();
                ConfirmButton.Text      = MainForm.CurrentLanguage["Confirm"];
                ConfirmButton.FlatStyle = FlatStyle.Flat;
                ConfirmButton.Size      = new Size(65, 40);
                ConfirmButton.Location  = new Point(180, 0);
                ConfirmButton.Click    += (s1, e1) =>
                {
                    HackContext.GameContext.Players[ps[0]].AddBuff(Convert.ToInt32(BuffID.Text), Convert.ToInt32(BuffTime.Text), false);
                    AddBuffMForm.Dispose();
                };
                AddBuffMForm.MainPanel.Controls.Add(ConfirmButton);
                AddBuffMForm.ShowDialog(this);
            };

            SetPetButton           = new Button();
            SetPetButton.Enabled   = false;
            SetPetButton.FlatStyle = FlatStyle.Flat;
            SetPetButton.Text      = MainForm.CurrentLanguage["SetPet"];
            SetPetButton.BackColor = Color.FromArgb(100, 150, 150, 150);
            SetPetButton.Bounds    = new Rectangle(215, 93, 80, 30);
            Controls.Add(SetPetButton);
            SetPetButton.Click += (s, e) =>
            {
                var ps = PlayerListView.SelectedIndices;
                if (ps.Count == 0)
                {
                    return;
                }

                MForm SetPetMForm = new MForm
                {
                    BackColor     = Color.FromArgb(90, 90, 90),
                    Text          = MainForm.CurrentLanguage["SetPet"],
                    StartPosition = FormStartPosition.CenterParent,
                    ClientSize    = new Size(245, 52)
                };

                Label PetTypeTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["Pet"],
                    Location  = new Point(0, 0),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                SetPetMForm.MainPanel.Controls.Add(PetTypeTip);

                ComboBox PetComboBox = new ComboBox()
                {
                    DropDownStyle  = ComboBoxStyle.DropDownList,
                    DropDownHeight = 150,
                    Location       = new Point(85, 0),
                    Size           = new Size(95, 20)
                };
                foreach (var o in GameResLoader.Pets)
                {
                    PetComboBox.Items.Add(o);
                }
                PetComboBox.SelectedIndex = 0;
                SetPetMForm.MainPanel.Controls.Add(PetComboBox);

                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) =>
                {
                    HackContext.GameContext.Players[ps[0]].AddBuff(GetPetFromIndex(PetComboBox.SelectedIndex), 18000, false);
                    SetPetMForm.Dispose();
                };
                SetPetMForm.MainPanel.Controls.Add(ConfirmButton);
                SetPetMForm.ShowDialog(this);
            };

            SetMountButton           = new Button();
            SetMountButton.Enabled   = false;
            SetMountButton.FlatStyle = FlatStyle.Flat;
            SetMountButton.Text      = MainForm.CurrentLanguage["SetMount"];
            SetMountButton.BackColor = Color.FromArgb(100, 150, 150, 150);
            SetMountButton.Bounds    = new Rectangle(215, 123, 80, 30);
            Controls.Add(SetMountButton);
            SetMountButton.Click += (s, e) =>
            {
                var ps = PlayerListView.SelectedIndices;
                if (ps.Count == 0)
                {
                    return;
                }

                MForm SetMountMForm = new MForm
                {
                    BackColor     = Color.FromArgb(90, 90, 90),
                    Text          = MainForm.CurrentLanguage["SetMount"],
                    StartPosition = FormStartPosition.CenterParent,
                    ClientSize    = new Size(245, 52)
                };

                Label MountTypeTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["Mount"],
                    Location  = new Point(0, 0),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                SetMountMForm.MainPanel.Controls.Add(MountTypeTip);

                ComboBox MountComboBox = new ComboBox()
                {
                    DropDownStyle  = ComboBoxStyle.DropDownList,
                    DropDownHeight = 150,
                    Location       = new Point(85, 0),
                    Size           = new Size(95, 20)
                };
                foreach (var o in GameResLoader.Mounts)
                {
                    MountComboBox.Items.Add(o);
                }
                MountComboBox.SelectedIndex = 0;
                SetMountMForm.MainPanel.Controls.Add(MountComboBox);

                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) =>
                {
                    HackContext.GameContext.Players[ps[0]].AddBuff(GetMountFromIndex(MountComboBox.SelectedIndex), 18000, false);
                    SetMountMForm.Dispose();
                };
                SetMountMForm.MainPanel.Controls.Add(ConfirmButton);
                SetMountMForm.ShowDialog(this);
            };

            PlayerAttributePanel             = new Panel();
            PlayerAttributePanel.Bounds      = new Rectangle(3, 203, 210, 165);
            PlayerAttributePanel.BorderStyle = BorderStyle.FixedSingle;
            Controls.Add(PlayerAttributePanel);

            PlayerNameInfoView    = AddPlayerAttribute(MainForm.CurrentLanguage["PlayerName"], 120);
            PlayerLifeInfoView    = AddPlayerAttribute(MainForm.CurrentLanguage["Life"], 120);
            PlayerManaInfoView    = AddPlayerAttribute(MainForm.CurrentLanguage["Mana"], 120);
            PlayerMaxLifeInfoView = AddPlayerAttribute(MainForm.CurrentLanguage["MaxLife"], 120);
            PlayerMaxManaInfoView = AddPlayerAttribute(MainForm.CurrentLanguage["MaxMana"], 120);
            PlayerXInfoView       = AddPlayerAttribute(MainForm.CurrentLanguage["X_Coor"], 120);
            PlayerYInfoView       = AddPlayerAttribute(MainForm.CurrentLanguage["Y_Coor"], 120);
            PlayerInventoryBaseAddressInfoView = AddPlayerAttribute(MainForm.CurrentLanguage["PlayerInvAddress"], 120);


            PlayerListView = new MListView();
            PlayerListView.SelectedIndexChanged += (s, e) =>
            {
                var m = s as MListView;
                if (m.SelectedIndices.Count > 0)
                {
                    EditPlayerInfoButton.Enabled = true;
                    TpToPlayerButton.Enabled     = true;
                    AddBuffButton.Enabled        = m.SelectedIndices[0] == HackContext.GameContext.MyPlayerIndex;
                    SetPetButton.Enabled         = m.SelectedIndices[0] == HackContext.GameContext.MyPlayerIndex;
                    SetMountButton.Enabled       = m.SelectedIndices[0] == HackContext.GameContext.MyPlayerIndex;
                }
                else
                {
                    EditPlayerInfoButton.Enabled = false;
                    TpToPlayerButton.Enabled     = false;
                    AddBuffButton.Enabled        = false;
                    SetPetButton.Enabled         = false;
                    SetMountButton.Enabled       = false;
                    ClearPlayerAttribute();
                }
            };
            PlayerListView.Bounds = new Rectangle(3, 3, 210, 200);
            PlayerListView.Columns.Add(MainForm.CurrentLanguage["Index"], 40);
            PlayerListView.Columns.Add(MainForm.CurrentLanguage["Name"], 70);
            PlayerListView.Columns.Add(MainForm.CurrentLanguage["Life"], 50);
            PlayerListView.Columns.Add(MainForm.CurrentLanguage["Mana"], 50);
            Controls.Add(PlayerListView);


            UpdatePlayerTimer          = new System.Timers.Timer();
            UpdatePlayerTimer.Interval = 100;            //每隔500ms进行一次玩家列表的检查和更新
            UpdatePlayerTimer.Elapsed += (s, e) =>
            {
                if (!Visible)
                {
                    return;
                }
                if (PlayerListView.SelectedIndices.Count > 0)
                {
                    UpdatePlayerAttribute(HackContext.GameContext.Players[Convert.ToInt32(PlayerListView.SelectedItems[0].Text)]);
                }
                UpdatePlayerList();
            };
            UpdatePlayerTimer.Start();            //开启更新线程
        }
예제 #8
0
        public PagePanel_Scripts(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["Execute"],
                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     = $"./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(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 = $"./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(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 = $"./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(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(($"./Scripts/{(string)FilesBox.SelectedItem}.qhscript"));
                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);
        }
예제 #9
0
        public PagePanel_Misc(int Width, int Height) : base(Width, Height)
        {
            ButtonsCount = 0;
            Image img_Wiki, img_Player;

            using (Stream st = new MemoryStream(GameResLoader.ItemImageData["Item_3628"]))
                img_Wiki = Image.FromStream(st);
            using (Stream st = Assembly.GetExecutingAssembly().GetManifestResourceStream("QTRHacker.NewDimension.Res.Image.player.png"))
                img_Player = Image.FromStream(st);
            AddButton(img_Wiki, "Wiki", () => { new WikiForm().Show(); });
            AddButton(img_Player, MainForm.CurrentLanguage["SummonNPC"], () =>
            {
                MForm SummonNPCMForm = new MForm
                {
                    BackColor     = Color.FromArgb(90, 90, 90),
                    Text          = MainForm.CurrentLanguage["SummonNPC"],
                    StartPosition = FormStartPosition.CenterParent,
                    ClientSize    = new Size(245, 72)
                };

                Label NPCTypeTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["NPCType"],
                    Location  = new Point(0, 0),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                SummonNPCMForm.MainPanel.Controls.Add(NPCTypeTip);

                TextBox NPCID = new TextBox
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    BackColor   = Color.FromArgb(120, 120, 120),
                    Text        = "50",
                    Location    = new Point(85, 0),
                    Size        = new Size(95, 20)
                };
                NPCID.KeyPress += (s1, e1) => e1.Handled = e1.Handled || (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8 && e1.KeyChar != '-');
                SummonNPCMForm.MainPanel.Controls.Add(NPCID);


                Label TimesTip = new Label()
                {
                    Text      = MainForm.CurrentLanguage["Number"],
                    Location  = new Point(0, 20),
                    Size      = new Size(80, 20),
                    TextAlign = ContentAlignment.MiddleCenter
                };
                SummonNPCMForm.MainPanel.Controls.Add(TimesTip);

                TextBox Times = new TextBox
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    BackColor   = Color.FromArgb(120, 120, 120),
                    Text        = "10",
                    Location    = new Point(85, 20),
                    Size        = new Size(95, 20)
                };
                Times.KeyPress += (s1, e1) => e1.Handled = e1.Handled || (!Char.IsNumber(e1.KeyChar) && e1.KeyChar != 8 && e1.KeyChar != '-');
                SummonNPCMForm.MainPanel.Controls.Add(Times);

                Button ConfirmButton    = new Button();
                ConfirmButton.Text      = MainForm.CurrentLanguage["Confirm"];
                ConfirmButton.FlatStyle = FlatStyle.Flat;
                ConfirmButton.Size      = new Size(65, 40);
                ConfirmButton.Location  = new Point(180, 0);
                ConfirmButton.Click    += (s1, e1) =>
                {
                    var ctx = HackContext.GameContext;
                    var plr = ctx.MyPlayer;
                    for (int i = 0; i < Convert.ToInt32(Times.Text); i++)
                    {
                        NPC.NewNPC(ctx, (int)plr.X, (int)plr.Y - 50, Convert.ToInt32(NPCID.Text));
                    }
                    SummonNPCMForm.Dispose();
                };
                SummonNPCMForm.MainPanel.Controls.Add(ConfirmButton);
                SummonNPCMForm.ShowDialog(this);
            });
        }
예제 #10
0
        /// <summary>
        /// Draw
        /// </summary>
        public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds)
        {
            // DIP
            DIP.GetGraphics(g);

            // Basic varibles
            Height   = DIP.Set(90);
            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);
            }

            // Logo
            g.FillRectangle(new SolidBrush(owner.Tint), new Rectangle(new Point(Bounds.X + 21, Bounds.Y + (Bounds.Height / 2) - 24), new Size(48, 48)));
            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 + 21, Bounds.Y + (Bounds.Height / 2) - 24), new Size(48, 48)), sfAvatar);

            // Draw primary text
            StringFormat sfPrimary = new StringFormat();

            sfPrimary.LineAlignment = StringAlignment.Center;
            g.DrawString(PrimaryText, new Font("Segoe UI", 9, FontStyle.Bold), new SolidBrush((owner.SelectedItem == this) ? owner.Tint : _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 84, Bounds.Y + 12, 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 + 84, Bounds.Y + Bounds.Height / 2 - 12, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary);
        }
예제 #11
0
        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, 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);
        }
예제 #12
0
        /// <summary>
        /// Draw method
        /// </summary>
        /// <param name="e">Paint event arguments</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // Base painting
            base.OnPaint(e);

            // Graphics
            Graphics g = e.Graphics;

            // Clear control
            g.Clear(Parent.BackColor);

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control dont have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // Colors
            Color fill   = new Color();
            Color border = new Color();
            Color fore   = new Color();

            if (Enabled)
            {
                fill   = _sourceTheme.CONTROL_FILL.Normal.ToColor();
                border = MColor.Mix(Color.FromArgb(_tintAlpha, _tint), _sourceTheme.CONTROL_BORDER.Normal.ToColor());
                fore   = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor();
            }
            else
            {
                fill   = _sourceTheme.CONTROL_FILL.Disabled.ToColor();
                border = _sourceTheme.CONTROL_BORDER.Disabled.ToColor();
                fore   = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor();
            }

            // Fill control
            g.FillRectangle(new SolidBrush(fill), ClientRectangle);

            // Handles prefix
            if (_prefix != "")
            {
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(_prefix, this.Font, new SolidBrush(fore), _prefixRectangle, sf);
            }

            // Handles postfix
            if (_postfix != "")
            {
                StringFormat sf = new StringFormat();
                sf.Alignment     = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(_postfix, this.Font, new SolidBrush(fore), _postfixRectangle, sf);
            }

            // Draw borders
            g.DrawRectangle(new Pen(border), new Rectangle(new Point(0, 0), new Size(ClientRectangle.Width - 1, ClientRectangle.Height - 1)));
        }
예제 #13
0
        /// <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))
        }
예제 #14
0
        /// <summary>
        /// Draw click effect
        /// </summary>
        /// <param name="e"></param>
        private void DrawClick(PaintEventArgs e)
        {
            // Control's graphics object
            Graphics g = e.Graphics;

            // Handles control's source theme
            // Check if control has set own theme
            if (_usedTheme != null)
            {
                // Set custom theme as source theme
                _sourceTheme = _usedTheme;
            }
            else
            {
                // Control don't have its own theme
                // Try cast control's parent form to MForm
                try
                {
                    MForm form = (MForm)FindForm();
                    _sourceTheme = form.UsedTheme;
                }
                catch
                {
                    // Control's parent form is not MForm type
                    // Set application wide theme
                    _sourceTheme = Minimal.UsedTheme;
                }
            }

            // ClickEffect
            if (_clickEffect != ClickEffect.None)
            {
                // Color of ClickEffect
                Color color;
                Color fill = _sourceTheme.CONTROL_FILL.Normal.ToColor();

                if (_sourceTheme.DARK_BASED == true)
                {
                    // Dark based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(150, fill));
                }
                else
                {
                    // Light based themes
                    color = Color.FromArgb(_alpha, MColor.AddRGB(-150, fill));
                }

                // Draws ClickEffect
                // Set up anti-aliasing
                g.SmoothingMode = SmoothingMode.AntiAlias;

                // Ink
                if (_clickEffect == ClickEffect.Ink)
                {
                    // Ink's brush and graphics path
                    SolidBrush   brush = new SolidBrush(color);
                    GraphicsPath ink   = Draw.GetEllipsePath(_mouse, (int)_radius);

                    // Draws ink ClickEffect
                    g.FillPath(brush, ink);
                }

                // Square
                if (_clickEffect == ClickEffect.Square || _clickEffect == ClickEffect.SquareRotate)
                {
                    // Square's brush and graphics path
                    SolidBrush   brush  = new SolidBrush(color);
                    GraphicsPath square = Draw.GetSquarePath(_mouse, (int)_radius);

                    // Rotates square
                    if (_clickEffect == ClickEffect.SquareRotate)
                    {
                        Matrix matrix = new Matrix();
                        matrix.RotateAt(_rotation, _mouse);
                        square.Transform(matrix);
                    }

                    // Draws square ClickEffect
                    g.FillPath(brush, square);
                }

                // Remove anti-aliasing
                g.SmoothingMode = SmoothingMode.Default;
            }
        }