예제 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (OldMouseEventArgs == null)
                {
                    OldMouseEventArgs = e;
                    OldScreenPosition = e.GetPosition(this);
                    return;
                }

                Point ScreenPosition = e.GetPosition(this);

                Point newPosition = VisibleRegion.Center;
                newPosition.X += (OldScreenPosition.X - ScreenPosition.X) * VisibleRegion.Downsample;
                newPosition.Y -= (OldScreenPosition.Y - ScreenPosition.Y) * VisibleRegion.Downsample;
                Size VisibleArea = new Size(this.ActualWidth * VisibleRegion.Downsample, this.ActualHeight * VisibleRegion.Downsample);
                VisibleRegion = new VisibleRegionInfo(newPosition, VisibleArea, VisibleRegion.Downsample);

                OldScreenPosition = ScreenPosition;

                OldMouseEventArgs = e;
            }

            base.OnMouseMove(e);
        }
예제 #2
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            //Tell each child where they go in the grid...
            int numCells = this.NumRows * this.NumCols;
            double CellWidth = finalSize.Width / NumCols;
            double CellHeight = finalSize.Height / NumRows;

            Trace.WriteLine("Arrange Override: " + this.NumRows.ToString() + " x " + this.NumCols.ToString());

            LastValidCellHeight = CellHeight;
            LastValidCellWidth = CellWidth;

            int iChild = 0;

            if (CenterNumber < (numCells / 2))
            {
                iChild = CenterNumber - (numCells / 2);
            }

            Debug.Assert(Children.Count <= NumRows * NumCols);

            for (int iY = 0; iY < NumRows; iY++)
            {
                for (int iX = 0; iX < NumCols; iX++, iChild++ )
                {
                    if (iChild < 0)
                        continue;

                    Rect childRect = new Rect(new Point(iX * CellWidth, iY * CellHeight), new Size(CellWidth, CellHeight));
                    if(iChild < Children.Count)
                        Children[iChild].Arrange(childRect);
                }
            }

            double Aspect = LastValidCellHeight / LastValidCellWidth;
            double visWidth = LastValidCellWidth * VisibleRegion.Downsample;
            double visHeight = LastValidCellWidth * Aspect * VisibleRegion.Downsample;

            Rect visRect = new Rect(VisibleRegion.Center.X - (visWidth / 2),
                                    VisibleRegion.Center.Y - (visHeight / 2),
                                    visWidth,
                                    visHeight);

            VisibleRegion = new VisibleRegionInfo(visRect, VisibleRegion.Downsample);

            return finalSize;
        }
예제 #3
0
        protected void StepCameraDistance(float multiplier)
        {
            double ds = VisibleRegion.Downsample;
            if (multiplier > 0)
                ds *= 0.86956521739130434782608695652174;
            else
                ds *= 1.15;

            if (ds < 0.25)
                ds = 0.25;

            //double Aspect = LastValidCellHeight / LastValidCellWidth;
            //double visWidth = LastValidCellWidth * ds;
            //double visHeight = LastValidCellWidth * Aspect * ds;
            double Aspect = this.ActualHeight / this.ActualWidth;
            double visWidth = this.ActualWidth * ds;
            double visHeight = visWidth * Aspect;

            Rect visRect = new Rect(VisibleRegion.Center.X - (visWidth / 2),
                                    VisibleRegion.Center.Y - (visHeight / 2),
                                    visWidth,
                                    visHeight);

            VisibleRegion = new VisibleRegionInfo(visRect, ds);
        }
예제 #4
0
 protected void VisibleRegionChanged(VisibleRegionInfo newValue, VisibleRegionInfo oldValue)
 {
     //if (oldValue.Contains(newValue) == false)
     {
         System.Diagnostics.Trace.WriteLine("VisibleRegionChanged");
         UpdateTiles(newValue.VisibleRect, newValue.Downsample);
     }
 }