public Point GetOffset(Point mousePoint)
        {
            var smp = PointToScreen(mousePoint);
            var cp  = Parent.PointToScreen(Location);

            return(PointUtil.Minus(smp, cp));
        }
        public override void PointerMove(object sender, MouseEventArgs e)
        {
            if (isClick)
            {
                Point dPoint = PointUtil.Minus(PointToScreen(e.Location), mouse0);
                //Console.WriteLine("delta : " + dPoint.X + ", " + dPoint.Y);
                //Console.WriteLine("room : " + thisRoom.Location.X + ", " + thisRoom.Location.Y);
                switch (where)
                {
                case Where.leftbottom:
                    thisRoom.Location = new Point(location0.X + dPoint.X, location0.Y);
                    thisRoom.Size     = new Size(size0.Width - dPoint.X, size0.Height + dPoint.Y);
                    break;

                case Where.lefttop:
                    thisRoom.Location = PointUtil.Plus(location0, dPoint);
                    thisRoom.Size     = new Size(PointUtil.Minus(new Point(size0), dPoint));
                    break;

                case Where.rightbottom:
                    thisRoom.Size = new Size(PointUtil.Plus(new Point(size0), dPoint));
                    break;

                case Where.righttop:
                    thisRoom.Location = new Point(location0.X, location0.Y + dPoint.Y);
                    thisRoom.Size     = new Size(size0.Width + dPoint.X, size0.Height - dPoint.Y);
                    break;

                default:
                    break;
                }
                thisRoom.UpdateScalerPosition();
            }
        }
예제 #3
0
        public override void PointerMove(object sender, MouseEventArgs e)
        {
            base.PointerMove(sender, e);
            foreach (UCObject obj in objects)
            {
                obj.PointerMove(sender, e);
            }

            if (isClicked)
            {
                foreach (UCDoor door in doors)
                {
                    door.Dragging(PointUtil.Minus(Location, startLoc));
                }
            }
        }
예제 #4
0
        public int makeWhat = -1;               // -1 : none, 0 : room, 1 : door

        public Canvas()
        {
            InitializeComponent();
            this.AutoScroll = true;
            position        = Location;
            OnDrag
            .CombineLatest(OnDown.Select(a => PointUtil.Minus(Location, position)), (a, i) => PointUtil.Minus(Location, i))
            .SkipUntil(OnDown)
            .TakeUntil(OnUp)
            .Repeat()
            .Buffer(2)
            .Select(b => PointUtil.Minus(b[1], b[0]))
            .Subscribe(d => MoveChild(d));
            OnUp.Subscribe(d => position = Location);

            instance = this;
        }
        private void UserControl1_Load(object sender, EventArgs e)
        {
            OnDrag.CombineLatest(OnDown.Select(p => GetOffset(p.Location)), (a, o) => PointUtil.Minus(a.Location, o))
            .SkipUntil(OnDown)
            .TakeUntil(OnUp)
            .Repeat()
            .Subscribe(p => Location = Clamp(Parent.PointToClient(PointToScreen(p))));

            OnUp.Subscribe(arg => Invalidate());
        }
예제 #6
0
        public UCDoor MakeDoor(Door door)
        {
            UCDoor uDoor = new UCDoor();

            this.Controls.Add(uDoor);
            this.Controls.SetChildIndex(uDoor, 0);

            uDoor.pA       = door.pA;
            uDoor.Location = uDoor.pA;
            uDoor.kind     = door.kind;
            uDoor.pB       = uDoor.pA;
            uDoor.isDoor   = door.isDoor;
            if (door.kind % 2 == 0)
            {
                uDoor.pB = PointUtil.Plus(door.pB, new Point(0, 50));
            }
            else
            {
                uDoor.pB = PointUtil.Plus(door.pB, new Point(50, 0));
            }

            if (door.isDoor)
            {
                switch (door.kind)
                {
                case 0:                         // right
                    uDoor.BackgroundImage = Properties.Resources.rDoor0;
                    break;

                case 1:                         // up
                    uDoor.BackgroundImage = Properties.Resources.rDoor1;
                    uDoor.Location        = PointUtil.Minus(uDoor.Location, new Point(0, 50));
                    break;

                case 2:                         // left
                    uDoor.BackgroundImage = Properties.Resources.rDoor2;
                    uDoor.Location        = PointUtil.Minus(uDoor.Location, new Point(50, 0));
                    break;

                case 3:
                    uDoor.BackgroundImage = Properties.Resources.rDoor3;
                    break;
                }
            }
            else
            {
                if (uDoor.kind % 2 == 0)
                {
                    uDoor.BackgroundImage = Properties.Resources.rWindow1;
                    uDoor.Location        = PointUtil.Minus(uDoor.Location, new Point(10, 0));
                    uDoor.Size            = new Size(new Point(20, 50));
                }
                else
                {
                    uDoor.BackgroundImage = Properties.Resources.rWindow0;
                    uDoor.Location        = PointUtil.Minus(uDoor.Location, new Point(0, 10));
                    uDoor.Size            = new Size(new Point(50, 20));
                }
            }
            m_listDoor.Add(uDoor);

            return(uDoor);
        }