コード例 #1
0
        public FormStateControlor(System.Windows.Forms.PictureBox formState)
        {
            formState.Paint += (sender, e) =>
            {
                Point ptMouse = formState.PointToClient(Control.MousePosition);
                if (formState.ClientRectangle.Contains(ptMouse))
                {
                    int        mousePosition = (int)(ptMouse.X / (formState.Width / 3f));
                    float      step          = formState.Width / 3f;
                    RectangleF rect          = new RectangleF(mousePosition * step, 0, step, formState.Height);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Blue)), rect);
                }
            };
            formState.MouseMove += (sender, e) =>
            {
                formState.Refresh();
            };
            formState.MouseEnter += (sender, e) =>
            {
                formState.Refresh();
            };
            formState.MouseLeave += (sender, e) =>
            {
                formState.Refresh();
            };
            formState.MouseClick += (sender, e) =>
            {
                switch ((int)(e.X / (formState.Width / 3f)))
                {
                case 0:
                    formState.FindForm().WindowState = System.Windows.Forms.FormWindowState.Minimized;
                    break;

                case 1:
                    if (formState.FindForm().WindowState == System.Windows.Forms.FormWindowState.Maximized)
                    {
                        formState.FindForm().WindowState = System.Windows.Forms.FormWindowState.Normal;
                        formState.Image = Properties.Resources.Normall;
                    }
                    else
                    {
                        formState.FindForm().WindowState = System.Windows.Forms.FormWindowState.Maximized;
                        formState.Image = Properties.Resources.Maxum;
                    }
                    break;

                case 2:
                    if (MessageBox.Show("您确认要退出系统吗?", "确定?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        formState.FindForm().Close();
                    }
                    break;
                }
            };
        }
コード例 #2
0
ファイル: ObjectsList.cs プロジェクト: Zergatul/ulHelper
        public ObjectsList(ObjectsPanel panel, PictureBox pb, GameWorld world, int x, int y, int width, int height,
            CheckTextButton showWar, CheckTextButton showCharacters, CheckTextButton showNpc, CheckTextButton showDrop,
            CharacterToolTip characterToolTip, NpcToolTip npcToolTip)
        {
            this.panel = panel;
            this.pb = pb;
            this.x = x;
            this.y = y;
            this.width = width;
            this.height = height;
            this.world = world;
            this.world.L2LiveObjectUpdate += world_L2LiveObjectUpdate;
            this.world.AddCharacter += (s, e) => { world_ObjectsChanged(); };
            //this.world.AddDrop += (s, e) => { world_ObjectsChanged(); };
            this.world.AddNpc += (s, e) => { world_ObjectsChanged(); };
            this.world.DeleteCharacter += (s, e) => { world_ObjectsChanged(); };
            //this.world.DeleteDrop += (s, e) => { world_ObjectsChanged(); };
            this.world.DeleteNpc += (s, e) => { world_ObjectsChanged(); };
            this.hoveredIndex = -1;
            this.showWar = showWar;
            this.showCharacters = showCharacters;
            this.showNpc = showNpc;
            this.showDrop = showDrop;
            this.objList = new List<L2Object>();
            this.characterToolTip = characterToolTip;
            this.npcToolTip = npcToolTip;

            scroll = new VScrollBar();
            scroll.Height = height - 1;
            scroll.Left = pb.Left + x + width - scroll.Width;
            scroll.Top = pb.Top + y + 1;
            scroll.LargeChange = height / itemHeight;
            pb.FindForm().Controls.Add(scroll);
            scroll.BringToFront();
            scroll.ValueChanged += scroll_ValueChanged;

            this.clip = new Rectangle(x + 1, y + 1, width - 2 - scroll.Width, height - 2);

            pb.MouseMove += pb_MouseMove;
            pb.MouseLeave += pb_MouseLeave;
            pb.MouseClick += pb_MouseClick;
            pb.FindForm().MouseWheel += ObjectsList_MouseWheel;

            hpBar = new MiniHPBar(72);
            hpBar5 = new Mini5HPBar(72);
            mpBar5 = new Mini5MPBar(72);
        }
コード例 #3
0
        private void Refresh(Image image, PictureBox pictureBox)
        {
            if (pictureBox.FindForm().WindowState == FormWindowState.Minimized)
                return;

            int sourceWidth = image.Width;
            int sourceHeight = image.Height;

            float nPercent = 0;
            float nPercentW = 0;
            float nPercentH = 0;

            nPercentW = ((float)pictureBox.Size.Width / (float)sourceWidth);
            nPercentH = ((float)pictureBox.Size.Height / (float)sourceHeight);

            nPercent = nPercentH < nPercentW ? nPercentH : nPercentW;

            int destWidth = (int)(sourceWidth * nPercent);
            int destHeight = (int)(sourceHeight * nPercent);

            Bitmap b = new Bitmap(destWidth, destHeight);
            Graphics g = Graphics.FromImage(b);
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(image, 0, 0, destWidth, destHeight);
                pictureBox.Image = b;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: HaavardM/RudrevyenTheGame
 //Checks if a shot and an enemy collides (panel and picturebox).
 private bool collision(Panel shot, PictureBox enemy)
 {
     Point enemyPoint = enemy.FindForm().PointToClient(enemy.Parent.PointToScreen(enemy.Location)); //Get absolute position of control in window - because of enemies parent
     return shot.Right >= enemyPoint.X - (enemy.Width / 2) + 5 && shot.Left <= enemyPoint.X + (enemy.Width / 2) + 20 && shot.Bottom >= enemyPoint.Y - (enemy.Height / 2) + 50 && shot.Top <= enemyPoint.Y + (enemy.Height / 2); //Checks if the shot is within the enemy boundries - values is based on testing
 }