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


C# CanvasControl.Invalidate方法代码示例

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


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

示例1: Draw

        public void Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var size = sender.Size;
            using (var ds = args.DrawingSession)
            {
                ds.DrawImage(effect, (size.ToVector2() - currentEffectSize) / 2);
                var brush = new CanvasImageBrush(sender, this.effect)
                {
                    ExtendX = CanvasEdgeBehavior.Wrap,
                    ExtendY = CanvasEdgeBehavior.Wrap,
                    SourceRectangle = new Rect(0, bitmap.SizeInPixels.Height - 96, 96, 96)
                };

                ds.FillRectangle(0, 0, (float)this.ActualWidth, (float)this.ActualHeight, brush);
            }
            sender.Invalidate();
        }
开发者ID:Solocast,项目名称:solocast-clients,代码行数:17,代码来源:PodcastDetailsPage.xaml.cs

示例2: canvas_Draw

 private void canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
 {
     //only draw if image is loaded
     if (bitmapImg != null)
     {
         args.DrawingSession.DrawImage(bitmapImg, bitmapRect);
         sender.Invalidate();
     }
 }
开发者ID:clarkezone,项目名称:WinGraphics,代码行数:9,代码来源:MainPage.xaml.cs

示例3: UpdateJoystick

        private void UpdateJoystick(CanvasControl control, double posX, double posY, bool isFirstTime=false)
        {
            joystickDirection.X = (float)(posX - joystickCanvasSize.Width/2);
            joystickDirection.Y = (float)(posY - joystickCanvasSize.Height/2);

            float overRatio = joystickDirection.Length() / (float)JOYSTICK_HALF_SIZE;
            if (overRatio > 1.0f)
            {
                joystickDirection.X /= overRatio;
                joystickDirection.Y /= overRatio;
            }

            joystickDrawRect.X = joystickCanvasSize.Width / 2 + joystickDirection.X - JOYSTICK_HALF_SIZE;
            joystickDrawRect.Y = joystickCanvasSize.Height / 2 + joystickDirection.Y - JOYSTICK_HALF_SIZE;

            if (!isFirstTime)
            {
                control.Invalidate();
            }
        }
开发者ID:WowWeeLabs,项目名称:MiP-Windows-SDK,代码行数:20,代码来源:MainPage.xaml.cs

示例4: Canvas_Draw

        private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var size = sender.Size;
            var ds = args.DrawingSession;

            // Animate and then display the current image effect.
            animationFunction((float)timer.Elapsed.TotalSeconds);

            ds.DrawImage(effect, (size.ToVector2() - currentEffectSize) / 2);

            // Draw text showing which effects are in use, but only if the screen is large enough to fit it.
            const float minSizeToShowText = 500;

            if ((size.Width + size.Height) / 2 > minSizeToShowText && !ThumbnailGenerator.IsDrawingThumbnail)
            {
                string text = activeEffectNames;

                if (textLabel != null)
                {
                    text += "\n\n" + textLabel;
                }

                ds.DrawText(text, 0, 80, Colors.White, textFormat);
            }

            sender.Invalidate();
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:27,代码来源:EffectsExample.xaml.cs

示例5: canvasControl_Draw

        private void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            if (DesignMode.DesignModeEnabled)
                return;

            if (modeInstance == null)
            {
                frameCounter = 0;
                modeInstance = CurrentMode.Create(this, sender);
            }

            modeInstance.Draw(args.DrawingSession, frameCounter, (float)sender.ActualWidth, (float)sender.ActualHeight);

            frameCounter++;
            sender.Invalidate();
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:16,代码来源:DrawImageEmulations.xaml.cs

示例6: OnIOGraphDraw

        private void OnIOGraphDraw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var ds = args.DrawingSession;

            var mostRecentBytesRead = imageStream == null ? 0 : imageStream.GetBytesRead();

            bytesRead.Add(mostRecentBytesRead);

            // Flash the control red when there's some IO
            if (mostRecentBytesRead != 0)
                flash = 1;
            else
                flash *= 0.95f;

            ds.Clear(new Vector4(flash, 0, 0, 1));

            ds.DrawText("Bytes read", new Rect(0, 0, sender.ActualWidth, sender.ActualHeight), Colors.DarkRed,
                new CanvasTextFormat()
                {
                    VerticalAlignment = CanvasVerticalAlignment.Center,
                    HorizontalAlignment = CanvasHorizontalAlignment.Left,
                    FontSize = 12
                });


            int maxBytesRead = bytesRead.Max();
            maxBytesRead = Math.Max(1, maxBytesRead);

            int displayCount = 120;

            // Draw a moving vertical tick to allow us to see that the graph is
            // updating even if nothing is being read.
            drawCount = (drawCount + 1) % displayCount;
            var vx = (1.0f - (float)drawCount / (float)displayCount) * (float)sender.ActualWidth;
            ds.DrawLine(vx, (float)sender.ActualHeight - 5, vx, (float)sender.ActualHeight, Colors.Gray);


            // Draw the graph
            if (bytesRead.Count > 2)
            {
                var p = new CanvasPathBuilder(sender);
                for (int i = 0; i < Math.Min(displayCount, bytesRead.Count); ++i)
                {
                    var x = ((float)i / (float)displayCount) * (float)sender.ActualWidth;
                    var y = (float)sender.ActualHeight - ((float)bytesRead[i] / (float)maxBytesRead) * (float)sender.ActualHeight;

                    if (i == 0)
                        p.BeginFigure(x, y);
                    else
                        p.AddLine(x, y);
                }
                p.EndFigure(CanvasFigureLoop.Open);

                using (var g = CanvasGeometry.CreatePath(p))
                {
                    ds.DrawGeometry(g, Colors.White, 3, new CanvasStrokeStyle()
                    {
                        LineJoin = CanvasLineJoin.Round
                    });
                }

                int toRemove = bytesRead.Count - displayCount;
                if (toRemove > 0)
                    bytesRead.RemoveRange(0, toRemove);
            }

            sender.Invalidate();
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:68,代码来源:VirtualBitmapExample.xaml.cs

示例7: MainCanvas_Draw

        void MainCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var ds = args.DrawingSession;
            ds.Clear(Colors.Black);

            float dt = m_stopwatch.ElapsedMilliseconds / 1000.0f;
            m_stopwatch.Restart();

            // We are abusing the Draw call as our "game loop" = create new fireworks here
            // independent of the timing of input events.
            //if (m_wasPointerPressed == true) // Disable check so we always are rendering.
            {
                for (int i = 0; i < Constants.NumPerFrame; i++)
                {
                    var firework = new Firework(
                        (float)m_pointerPos.X + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)m_pointerPos.Y + RndFloat(-Constants.PosRndMax, Constants.PosRndMax),
                        (float)(m_pointerPos.X - m_pointerPrevPos.X) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        (float)(m_pointerPos.Y - m_pointerPrevPos.Y) / dt * Constants.PointerVelCoeff + RndFloat(-Constants.VelRndMax, Constants.VelRndMax),
                        RndFloat(Constants.RadiusMin, Constants.RadiusMax),
                        Color.FromArgb(
                            255,
                            RndByte(0, 255),
                            RndByte(0, 255),
                            RndByte(0, 255)
                        ));

                    m_controller.AddFirework(firework);
                }
            }

            m_controller.UpdateFireworks(dt);
            m_controller.RenderFireworks(ds);

            // We snap the pointer position with each Draw call, independent of the frequency of input events.
            m_pointerPrevPos = m_pointerPos;

            // Render loop.
            sender.Invalidate();
        }
开发者ID:13thsymphony,项目名称:Toys,代码行数:40,代码来源:MainPage.xaml.cs


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