Ejemplo n.º 1
0
        void TellRightPoint()
        {
            var temp = EventLocationChanged;

            if (temp != null)
            {
                Point           point = this.Location;
                LocationChanged tem   = new LocationChanged(point, this.Width, this.Height);
                EventLocationChanged(this, tem);
            }
        }
Ejemplo n.º 2
0
        public void form_EventLocationChanged(object sender, LocationChanged e)
        {
            //check is out of range or not
            Point BoundPoint = new Point();
            Point LocForSelf = new Point();

            switch (direc)
            {
            case Direction.right:
                BoundPoint = new Point(e.pointNow.X + e.SelfWidth + this.Width, e.pointNow.Y);
                LocForSelf = new Point(e.pointNow.X + e.SelfWidth, e.pointNow.Y);
                break;

            case Direction.left:
                BoundPoint = new Point(e.pointNow.X - this.Width, e.pointNow.Y);
                LocForSelf = new Point(e.pointNow.X - this.Width, e.pointNow.Y);
                break;

            case Direction.top:
                BoundPoint = new Point(e.pointNow.X, e.pointNow.Y - this.Height);
                LocForSelf = new Point(e.pointNow.X, e.pointNow.Y - this.Height);
                break;

            case Direction.down:
                BoundPoint = new Point(e.pointNow.X, e.pointNow.Y + e.SelfHeight + this.Height);
                LocForSelf = new Point(e.pointNow.X, e.pointNow.Y + e.SelfHeight);
                break;
            }

            if (Screen.PrimaryScreen.Bounds.Contains(BoundPoint))
            {
                this.Location  = LocForSelf;
                LocationN      = this.Location;
                IsLoadLocation = true;
            }
            else
            {
                int offset = 0;
                switch (direc)
                {
                case Direction.right:
                    offset        = e.pointNow.X + e.SelfWidth + this.Width - Screen.PrimaryScreen.Bounds.Width;
                    this.Location = new Point(LocForSelf.X - offset, e.pointNow.Y);
                    break;

                case Direction.left:
                    offset        = e.pointNow.X - this.Width;
                    this.Location = new Point(LocForSelf.X - offset, e.pointNow.Y);
                    break;

                case Direction.top:
                    offset        = e.pointNow.Y - this.Height;
                    this.Location = new Point(e.pointNow.X, LocForSelf.Y - offset);
                    break;

                case Direction.down:
                    offset        = e.pointNow.Y + e.SelfHeight + this.Height - Screen.PrimaryScreen.Bounds.Height;
                    this.Location = new Point(e.pointNow.X, LocForSelf.Y - offset);
                    break;
                }

                TellMatherReLocated(sender as SmartForm, this, this.Location);
                LocationN      = this.Location;
                IsLoadLocation = true;
            }
        }