コード例 #1
0
ファイル: OgmoWindow.cs プロジェクト: hach-que/OgmoEditor
        public OgmoWindow(HorizontalSnap startHSnap, VerticalSnap startVSnap)
        {
            this.startHSnap = startHSnap;
            this.startVSnap = startVSnap;
            InitializeComponent();

            userVisible = true;
            editorVisible = false;

            //Events
            Shown += onShown;
            Resize += enforceSnap;
            Move += checkSnap;
            if (Ogmo.MainWindow != null)
            {
                Ogmo.MainWindow.Resize += enforceSnap;
                Ogmo.MainWindow.LocationChanged += enforceSnap;
                Ogmo.MainWindow.KeyDown += onKeyDown;
            }
            KeyDown += onKeyDown;
            if (Ogmo.MainWindow != null)
            {
                Ogmo.OnProjectClose += onProjectClose;
                Ogmo.OnLevelClosed += onLevelClose;
                Ogmo.OnLevelChanged += new Ogmo.LevelCallback(Ogmo_OnLevelChanged);
            }
        }
コード例 #2
0
        public OgmoWindow(HorizontalSnap startHSnap, VerticalSnap startVSnap)
        {
            this.startHSnap = startHSnap;
            this.startVSnap = startVSnap;
            InitializeComponent();

            userVisible   = true;
            editorVisible = false;

            //Events
            Shown  += onShown;
            Resize += enforceSnap;
            Move   += checkSnap;
            Ogmo.MainWindow.Resize          += enforceSnap;
            Ogmo.MainWindow.LocationChanged += enforceSnap;
            Ogmo.MainWindow.KeyDown         += onKeyDown;
            KeyDown             += onKeyDown;
            Ogmo.OnProjectClose += onProjectClose;
            Ogmo.OnLevelClosed  += onLevelClose;
            Ogmo.OnLevelChanged += new Ogmo.LevelCallback(Ogmo_OnLevelChanged);
        }
コード例 #3
0
        /*
         *  Snapping to edges helpers
         */
        private void checkSnap(object sender = null, EventArgs e = null)
        {
            Rectangle r = Ogmo.MainWindow.EditBounds;
            Point     p = Location;

            //Check for X snap
            if (Math.Abs(p.X - r.X) <= SNAP_RANGE)
            {
                hSnap = HorizontalSnap.Left;
                p.X   = r.X;
            }
            else if (Math.Abs((p.X + Width) - (r.X + r.Width)) <= SNAP_RANGE)
            {
                hSnap = HorizontalSnap.Right;
                p.X   = r.X + r.Width - Width;
            }
            else
            {
                hSnap = HorizontalSnap.None;
            }

            //Check for Y snap
            if (Math.Abs(p.Y - r.Y) <= SNAP_RANGE)
            {
                vSnap = VerticalSnap.Top;
                p.Y   = r.Y;
            }
            else if (Math.Abs((p.Y + Height) - (r.Y + r.Height)) <= SNAP_RANGE)
            {
                vSnap = VerticalSnap.Bottom;
                p.Y   = r.Y + r.Height - Height;
            }
            else
            {
                vSnap = VerticalSnap.None;
            }

            Location = p;
        }
コード例 #4
0
 private void onShown(object sender, EventArgs e)
 {
     hSnap = startHSnap;
     vSnap = startVSnap;
     enforceSnap();
 }
コード例 #5
0
ファイル: OgmoWindow.cs プロジェクト: hach-que/OgmoEditor
 private void onShown(object sender, EventArgs e)
 {
     hSnap = startHSnap;
     vSnap = startVSnap;
     enforceSnap();
 }
コード例 #6
0
ファイル: OgmoWindow.cs プロジェクト: hach-que/OgmoEditor
        /*
         *  Snapping to edges helpers
         */
        private void checkSnap(object sender = null, EventArgs e = null)
        {
            if (Ogmo.MainWindow == null)
                return;

            Rectangle r = Ogmo.MainWindow.EditBounds;
            Point p = Location;

            //Check for X snap
            if (Math.Abs(p.X - r.X) <= SNAP_RANGE)
            {
                hSnap = HorizontalSnap.Left;
                p.X = r.X;
            }
            else if (Math.Abs((p.X + Width) - (r.X + r.Width)) <= SNAP_RANGE)
            {
                hSnap = HorizontalSnap.Right;
                p.X = r.X + r.Width - Width;
            }
            else
                hSnap = HorizontalSnap.None;

            //Check for Y snap
            if (Math.Abs(p.Y - r.Y) <= SNAP_RANGE)
            {
                vSnap = VerticalSnap.Top;
                p.Y = r.Y;
            }
            else if (Math.Abs((p.Y + Height) - (r.Y + r.Height)) <= SNAP_RANGE)
            {
                vSnap = VerticalSnap.Bottom;
                p.Y = r.Y + r.Height - Height;
            }
            else
                vSnap = VerticalSnap.None;

            Location = p;
        }