当前位置: 首页>>代码示例>>C#>>正文


C# Rect.Offset方法代码示例

本文整理汇总了C#中Android.Graphics.Rect.Offset方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Offset方法的具体用法?C# Rect.Offset怎么用?C# Rect.Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Graphics.Rect的用法示例。


在下文中一共展示了Rect.Offset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLayout

		protected override void OnLayout (bool changed, int l, int t, int r, int b)
		{
			base.OnLayout (changed, l, t, r, b);
			if (changed) {
				var drawables = Control.GetCompoundDrawables ();
				if (drawables [0] != null) {
					Rect drawableBounds = new Rect ();
					drawables [0].CopyBounds (drawableBounds);
					int leftOffset = ((Control.Width - Control.PaddingLeft - Control.PaddingRight) - drawableBounds.Width ()) / 2;
					drawableBounds.Offset (leftOffset, 0);
					drawables [0].SetBounds (drawableBounds.Left, drawableBounds.Top, drawableBounds.Right, drawableBounds.Bottom);
				}
			}
		}
开发者ID:Vineland,项目名称:DarkestNight.App,代码行数:14,代码来源:CustomButtonRenderer.cs

示例2: InitCells

        private void InitCells() 
        {
            _calendar[,] tmp = new _calendar[6,7];

            for (int i = 0; i < tmp.GetUpperBound(0); i++)
            {
                int[] n = mHelper.GetDigitsForRow(i);
                for(int d=0; d<n.Length; d++)
                {
                    if(mHelper.IsWithinCurrentMonth(i, d))
                        tmp[i,d] = new _calendar(n[d], true);
                    else
                        tmp[i,d] = new _calendar(n[d]);        
                }
            }

            DateTime today = DateTime.Now;
            int thisDay = 0;
            mToday = null;
            if(mHelper.Year == today.Year && mHelper.Month == today.Month)
                thisDay = today.Day;

            // build cells
            Rect Bound = new Rect(CELL_MARGIN_LEFT, CELL_MARGIN_TOP, CELL_WIDTH+CELL_MARGIN_LEFT, CELL_HEIGH+CELL_MARGIN_TOP);

            int bound0 = mCells.GetUpperBound(0);
            int bound1 = mCells.GetUpperBound(1);
            for (int week = 0; week < bound0; week++)
            {
                for (int day = 0; day < bound1; day++)
                {
                        if(tmp[week,day].thisMonth) {
                                if(day==0 || day==6 )
                                        mCells[week,day] = new RedCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                                else 
                                        mCells[week,day] = new Cell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        } else {
                                mCells[week,day] = new GrayCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        }
                                
                        Bound.Offset(CELL_WIDTH, 0); // move to next column 
                                
                        // get today
                        if(tmp[week,day].day==thisDay && tmp[week,day].thisMonth) {
                                mToday = mCells[week,day];
                                mDecoration.SetBounds(mToday.Bounds.Left, mToday.Bounds.Top, mToday.Bounds.Right, mToday.Bounds.Bottom);
                        }
                }
                Bound.Offset(0, CELL_HEIGH); // move to next row and first column
                Bound.Left = CELL_MARGIN_LEFT;
                Bound.Right = CELL_MARGIN_LEFT+CELL_WIDTH;
            }
        }
开发者ID:Cheesebaron,项目名称:MonoDroid.Calendar,代码行数:53,代码来源:CalendarView.cs

示例3: drawPlaces

        private void drawPlaces(Canvas canvas, double pixelsPerDegree, double offset) 
        {
            try
            {
                if (OrientationManager.HasLocation && NearbyPlaces != null)
                {
                    lock (NearbyPlaces)
                    {
                        var userLocation = OrientationManager.Location;
                        var latitude1 = userLocation.Latitude;
                        var longitude1 = userLocation.Longitude;

                        _allBounds.Clear();


                        // Loop over the list of nearby places (those within 10 km of the user's current
                        // location), and compute the relative bearing from the user's location to the
                        // place's location. This determines the position on the compass view where the
                        // pin will be drawn.
                        foreach (var place in NearbyPlaces)
                        {
                            var latitude2 = place.Latitiude;
                            var longitude2 = place.Longitude;
                            var bearing = MathUtils.getBearing(latitude1, longitude1, latitude2, longitude2);

                            var name = place.Name;
                            var distanceKm = MathUtils.getDistance(latitude1, longitude1, latitude2, longitude2);
                            var text = this.Context.Resources.GetString(
                                Resource.String.place_text_format, name, _distanceFormat.Format(distanceKm));

                            // Measure the text and offset the text bounds to the location where the text
                            // will finally be drawn.
                            var textBounds = new Rect();
                            _placePaint.GetTextBounds(text, 0, text.Length, textBounds);
                            textBounds.OffsetTo((int)(offset + bearing * pixelsPerDegree
                                    + PLACE_PIN_WIDTH / 2 + PLACE_TEXT_MARGIN), canvas.Height / 2
                                    - (int)PLACE_TEXT_HEIGHT);

                            // Extend the bounds rectangle to include the pin icon and a small margin
                            // to the right of the text, for the overlap calculations below.
                            textBounds.Left -= (int)(PLACE_PIN_WIDTH + PLACE_TEXT_MARGIN);
                            textBounds.Right += (int)PLACE_TEXT_MARGIN;

                            // This loop attempts to find the best vertical position for the string by
                            // starting at the bottom of the display and checking to see if it overlaps
                            // with any other labels that were already drawn. If there is an overlap, we
                            // move up and check again, repeating this process until we find a vertical
                            // position where there is no overlap, or when we reach the limit on
                            // overlapping place names.
                            bool intersects;
                            var numberOfTries = 0;
                            do
                            {
                                intersects = false;
                                numberOfTries++;
                                textBounds.Offset(0, (int)-(PLACE_TEXT_HEIGHT + PLACE_TEXT_LEADING));

                                foreach (var existing in _allBounds)
                                {
                                    if (Rect.Intersects(existing, textBounds))
                                    {
                                        intersects = true;
                                        break;
                                    }
                                }
                            } while (intersects && numberOfTries <= MAX_OVERLAPPING_PLACE_NAMES);

                            // Only draw the string if it would not go high enough to overlap the compass
                            // directions. This means some places may not be drawn, even if they're nearby.
                            if (numberOfTries <= MAX_OVERLAPPING_PLACE_NAMES)
                            {
                                _allBounds.Add(textBounds);

                                canvas.DrawBitmap(_placeBitmap, (float)(offset + bearing * pixelsPerDegree - PLACE_PIN_WIDTH / 2), textBounds.Top + 2, _paint);
                                canvas.DrawText(
                                    text,
                                    (float)(offset + bearing * pixelsPerDegree + PLACE_PIN_WIDTH / 2 + PLACE_TEXT_MARGIN),
                                    (float)(textBounds.Top + PLACE_TEXT_HEIGHT),
                                    _placePaint);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Debug("Exception", e.Message);
            }
        }
开发者ID:42Spikes,项目名称:F2S,代码行数:89,代码来源:CompassView.cs

示例4: getChildViewRect

 private static Rect getChildViewRect(View parentView, View childView)
 {
     Rect childRect = new Rect(childView.Left, childView.Top, childView.Right, childView.Bottom);
     if (!parentView.Equals(childView))
     {
         View workingChildView = childView;
         ViewGroup parent;
         while (!(parent = (ViewGroup)workingChildView.Parent).Equals(parentView))
         {
             childRect.Offset(parent.Left, parent.Top);
             workingChildView = parent;
         }
     }
     return childRect;
 }
开发者ID:skywolf888,项目名称:ListviewAnimations.Net,代码行数:15,代码来源:SwipeTouchListener.cs

示例5: ZoomImageFromThumb

        /// <summary>
        ///   The event handler for the thumbnails. Called when they are clicked, it display
        ///   the full sized image, animating the transition from thumbnail to full sized image.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ZoomImageFromThumb(object sender, EventArgs eventArgs)
        {
            View thumbView = (View)sender;
            ImageView expandedImageView = GetExpandedImageView(thumbView);

            if (_currentAnimator != null)
            {
                _currentAnimator.Cancel();
            }
            Rect startBounds = new Rect();
            Rect finalBounds = new Rect();
            Point globalOffset = new Point();

            // The start bounds are the global visible rectangle of the thumbnail
            thumbView.GetGlobalVisibleRect(startBounds);

            // The final bounds are the global visible rectangle of the container view. Also
            // set the container view's offset as the origin for the bounds, since that's
            // the origin for the positioning animation properties (X, Y).
            FindViewById(Resource.Id.container).GetGlobalVisibleRect(finalBounds, globalOffset);
            startBounds.Offset(-globalOffset.X, -globalOffset.Y);
            finalBounds.Offset(-globalOffset.X, -globalOffset.Y);

            float startScale = CalculateStartScale(startBounds, finalBounds);

            // Construct and run the parallel animation of the four translation and scale properties
            // (X, Y, SCALE_X, and SCALE_Y).
            AnimatorSet expandSet = BuildExpandingAnimatorSet(expandedImageView, startBounds, finalBounds, startScale);
            expandSet.Start();
            _currentAnimator = expandSet;

            // Upon clicking the zoomed image, it should zoom back down to the original bounds
            // and show the thumbnail instead of the expanded image.
            expandedImageView.Click += (o, args) =>{
                if (_currentAnimator != null)
                {
                    _currentAnimator.Cancel();
                }

                AnimatorSet shrinkSet = BuildShrinkingAnimatorSet(expandedImageView, thumbView, startBounds, startScale);
                shrinkSet.Start();
                _currentAnimator = shrinkSet;
            };
        }
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:50,代码来源:ZoomActivity.cs


注:本文中的Android.Graphics.Rect.Offset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。