Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the InfoBox class.
        /// It flashes an exclamation mark 2 times, then moves
        /// to the target location.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="target"></param>
        public InfoBox(Window parent, Vector target, string message)
        {
            CanBeMoved = true;
            Location = new Vector(target.X, target.Y);
            OKClicked = new MouseEventDel((pos) => { });
            ExclamationClicked = new MouseEventDel((pos) => { });

            ExclamationSize = new Vector(60, 55);
            ExclamationLocation = new Vector((parent.Width - ExclamationSize.X) / 2,
                (parent.Height - ExclamationSize.Y) / 2);
            Size = new Vector(200, 10);
            Parent = parent;

            frameAlpha = 0f;
            startAlpha = 0f;
            currentAlpha = startAlpha;
            frameTargetY = 200;
            targetAlpha = 1f;
            animationCoef = 0.0f;

            mainLabel = new Label();
            Message = message;
            mainLabel.Location = new Vector(Location.X - 50 + message.Length * 4, Location.Y + 30);
            mainLabel.Visible = false;

            buttonOk = new Button();
            buttonOk.Image = "data/img/bck.bmp";
            buttonOk.ApplyStylishEffect();
            buttonOk.Visible = false;
            buttonOk.Size.X = 70;
            buttonOk.Location = new Vector(Location.X + (Size.X - buttonOk.Size.X) / 2, Location.Y + 160);
            buttonOk.Text = "OK";
            buttonOk.MouseClick += (pos) =>
            {
                OKClicked.Invoke(pos);

                Parent.Children.Remove(buttonOk);
                Parent.Children.Remove(mainLabel);
                Parent.Children.Remove(this);
                MainTimer.Stop();
            };

            Parent.Mouse.Move += MouseMoveFunc;

            targetLocation = target;
            targetLocation.X += Size.X / 2;
            targetLocation.Y += Size.Y / 2;

            MainTimer = new Timer();
            MainTimer.Interval = 10;
            MainTimer.Tick += AnimationStep;
            MainTimer.Start();
        }
Exemplo n.º 2
0
 public GUIObject()
 {
     MouseOver = new MouseEventDel(InternalMouseOver);
     MouseOut = new MouseEventDel(InternalMouseOut);
     MouseClick = new MouseEventDel(InternalMouseClick);
     MouseDown = new MouseEventDel(InternalMouseDown);
     MouseMove = new MouseEventDel(InternalMouseMove);
     State = ObjectState.Normal;
     KeyDown = new KeyEventDel(InternalKeyDown);
     MouseUp = new MouseEventDel(InternalMouseUp);
     Visible = true;
     Location = new Vector(0f, 0f, 0f);
     Size = new Vector(150, 20);
 }