• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CanvasControl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: canvasCtrl_Draw

        private void canvasCtrl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            if (!this.initialized) {
                return;
            }
            this.host.CallFunction("drawScene");
            var target = (CanvasRenderTarget)this.host.Window.Render();

            args.DrawingSession.DrawImage(target);


            if (drawCount == 0) {
                this.start = DateTime.Now;
            }
            drawCount++;
            var seconds = (DateTime.Now - this.start).TotalSeconds;
            if (seconds > 0) {
                var fps = drawCount / seconds;

                args.DrawingSession.DrawText(fps.ToString("0.#") + "fps", 10, 10, Colors.Red);
            }

            // triggers next Draw event at max 60fps
            this.canvasCtrl.Invalidate();
        }
开发者ID:modulexcite,项目名称:JsBridge,代码行数:25,代码来源:PaperJS.xaml.cs


示例2: ExportSVG

 /// <summary>
 /// Export SVG file.
 /// </summary>
 /// <param name="canvas"></param>
 /// <param name="filename"></param>
 public static void ExportSVG(CanvasControl canvas, string filename)
 {
     // Start writing SVG format.
     StreamWriter writer = new StreamWriter(filename);
     writer.WriteLine(XML_HEADER);
     writer.WriteLine(CreateSVGHeader(canvas));
     // Create brushes.
     foreach (ComponentSetting setting in canvas.Control.ComponentManager.GetAllSettings())
         writer.WriteLine(GetGradationBrush(setting));
     // Create SVG objects.
     foreach (PNode node in canvas.PCanvas.Root.ChildrenReference)
     {
         if (!(node is PPathwayLayer) || !node.Visible)
             continue;
         PPathwayLayer layer = (PPathwayLayer)node;
         foreach (PPathwayObject obj in layer.GetNodes())
             writer.WriteLine(CreateSVGObject(obj));
     }
     // Create Graph
     foreach (PNode node in canvas.ControlLayer.ChildrenReference)
     {
         if (!(node is PPathwayGraph))
             continue;
         writer.WriteLine(CreateSVGGraph((PPathwayGraph)node));
     }
     // Close SVG file.
     writer.WriteLine(SVG_FOOTER);
     writer.Flush();
     writer.Close();
 }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:35,代码来源:GraphicsExporter.cs


示例3: Canvas_Draw

        private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var a = new Vector2(10, 10);
            var b = new Vector2(100, 100);

            args.DrawingSession.DrawLine(a, b, Colors.Yellow);
        }
开发者ID:chrisi,项目名称:IoTCanvas,代码行数:7,代码来源:MainPage.xaml.cs


示例4: POverviewCanvas

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="canvas"></param>
        public POverviewCanvas(CanvasControl canvas)
        {
            m_canvas = canvas;
            this.Dock = DockStyle.Fill;
            m_area = new PDisplayedArea();

            m_transparentNode = PPath.CreateRectangle(-500, -500, 1300, 1300);
            m_transparentNode.Brush = new SolidBrush(Color.Transparent);
            m_transparentNode.Pickable = true;

            this.AnimatingRenderQuality = RenderQuality.HighQuality;
            this.DefaultRenderQuality = RenderQuality.HighQuality;
            this.InteractingRenderQuality = RenderQuality.HighQuality;
            this.Interacting = true;

            this.Camera.AddLayer(canvas.PCanvas.Layer);
            this.RemoveInputEventListener(this.PanEventHandler);
            this.RemoveInputEventListener(this.ZoomEventHandler);
            this.Camera.AddInputEventListener(new AreaDragEventHandler(canvas.PCanvas.Camera));
            this.Camera.ScaleViewBy(REDUCTION_SCALE);
            this.Camera.TranslateViewBy(500, 500);
            this.Layer.AddChild(m_transparentNode);
            this.Layer.AddChild(m_area);
            m_ctrlLayer = this.Layer;
            this.Camera.AddLayer(this.Layer);
            this.Camera.ChildrenPickable = false;
            this.Camera.BoundsChanged += new PPropertyEventHandler(Camera_BoundsChanged);
        }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:32,代码来源:POverviewCanvas.cs


示例5: OnNavigatedTo

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var currentView = SystemNavigationManager.GetForCurrentView();

            displayRequest.RequestActive(); //to request keep display on

            currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            currentView.BackRequested += CurrentView_BackRequested;

            if (e.NavigationMode != NavigationMode.Back)
            {
                try
                {
                    _mainPageViewModel = MainPage.Current.MainPageViewModel;
                    LayoutRoot.DataContext = _mainPageViewModel;
                    _currentTrack = _mainPageViewModel.PlayingTrack;
                    _canvasControl = new CanvasControl();
                    _canvasControl.Draw += _canvasControl_Draw;
                    App.AudioPlayer.CurrentTrackChanged += AudioPlayer_CurrentTrackChanged;
                    ContentPresenter.Content = _canvasControl;
                    CreateWaveForm();
                }
                catch (Exception ex)
                {
                    ErrorLogProxy.LogError(ex.ToString());
                    ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
                }
            }
        }
开发者ID:justijndepover,项目名称:Soundcloudplus,代码行数:30,代码来源:PlayingPage.xaml.cs


示例6: OnApplyTemplate

		protected override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			this._canvasControl = (CanvasControl)this.GetTemplateChild(CANVAS_CONTROL_NAME);
			this._canvasControl.Draw += OnDraw;
		}
开发者ID:lallous,项目名称:SvgForXaml,代码行数:7,代码来源:SvgImage.cs


示例7: DrawLine

        private void DrawLine(CanvasControl sender, CanvasDrawingSession ds)
        {
            var width = (float)sender.ActualWidth;
            var height = (float)sender.ActualHeight;

            var middle = height / 2;

            int steps = Math.Min((int)(width / 10), 30);

            for (int i = 0; i < steps; ++i)
            {
                var mu = (float)i / steps;
                var a = (float)(mu * Math.PI * 2);

                var color = GradientColor(mu);

                var x = width * mu;
                var y = (float)(middle + Math.Sin(a) * (middle * 0.3));

                var strokeWidth = (float)(Math.Cos(a) + 1) * 5;

                ds.DrawLine(x, 0, x, y, color, strokeWidth);
                ds.DrawLine(x, height, x, y, color, 10 - strokeWidth);
            }
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:25,代码来源:ShapesExample.xaml.cs


示例8: TextDirectionControl_Loaded

        void TextDirectionControl_Loaded(object sender, RoutedEventArgs e)
        {
            canvas = new CanvasControl();
            canvas.Draw += OnDraw;

            Content = canvas;
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:7,代码来源:TextDirectionControl.cs


示例9: WindowsPurchase

 public WindowsPurchase(CanvasControl _screen)
 {
     screen = _screen;
     grantedConsumableTransactionIds = new Dictionary<string, List<Guid>>();
     CurrentApp.LicenseInformation.LicenseChanged += licenseChangeHandler;
     grantedConsumableTransactionIds = new Dictionary<string, List<Guid>>();
 }
开发者ID:Pmovil,项目名称:CN1WindowsPort,代码行数:7,代码来源:WindowsPurchase.cs


示例10: OnApplyTemplate

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _canvasControl = GetTemplateChild(CanvasControlPartName) as CanvasControl;
            if (_canvasControl != null)
                _canvasControl.Draw += Draw;

            _contentPresenter = GetTemplateChild(ContentPresenterPartName) as ContentPresenter;
        }
开发者ID:ItsJustSean,项目名称:MaterialDesignInXamlToolkit,代码行数:10,代码来源:Shadow.cs


示例11: CanvasControl_Draw

 private void CanvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
 {
     CubeHelper helper = new CubeHelper(GetLength());
     foreach (Tuple<Vector2, Vector2> edge in helper.GetEdges(currentTransformation))
     {
         ColorValue colorValue = ColorComboBox.SelectedValue as ColorValue;
         Color color = (colorValue == null ? Colors.Black : colorValue.Color);
         args.DrawingSession.DrawLine(edge.Item1, edge.Item2, color);
     }
 }
开发者ID:jf367,项目名称:Cube,代码行数:10,代码来源:MainPage.xaml.cs


示例12: Canvas_Draw

 private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
 {
     GaussianBlurEffect effect = new GaussianBlurEffect()
     {
         Source = _bitmap,
         BlurAmount = 5,
         BorderMode = EffectBorderMode.Hard
     };
     args.DrawingSession.DrawImage(effect);
 }
开发者ID:h82258652,项目名称:SoftwareKobo.U148For10,代码行数:10,代码来源:MainView.xaml.cs


示例13: Canvas_CreateResourcesAsync

        async Task Canvas_CreateResourcesAsync(CanvasControl sender)
        {
            bitmap = await CanvasBitmap.LoadAsync(sender, "imageTiger.jpg");

            redBrush   = CreateGradientBrush(sender, 255, 0, 0);
            greenBrush = CreateGradientBrush(sender, 0, 255, 0);
            blueBrush  = CreateGradientBrush(sender, 0, 0, 255);

            brightnessEffect = new BrightnessEffect  { Source = bitmap };
            saturationEffect = new SaturationEffect  { Source = brightnessEffect };
            hueEffect        = new HueRotationEffect { Source = saturationEffect };
        }
开发者ID:ben-sheeran,项目名称:Win2D,代码行数:12,代码来源:HistogramExample.xaml.cs


示例14: BackgroundCanvas_CreateResources

        private void BackgroundCanvas_CreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args)
        {
            args.TrackAsyncAction(Task.Run(async () =>
            {
                // Load the background image and create an image brush from it
                this.backgroundImage = await CanvasBitmap.LoadAsync(sender, new Uri("ms-appx:///Background.jpg"));
                this.backgroundBrush = new CanvasImageBrush(sender, this.backgroundImage);

                // Set the brush's edge behaviour to wrap, so the image repeats if the drawn region is too big
                this.backgroundBrush.ExtendX = this.backgroundBrush.ExtendY = CanvasEdgeBehavior.Wrap;

                this.resourcesLoaded = true;
            }).AsAsyncAction());
        }
开发者ID:r2d2rigo,项目名称:Win2D-Samples,代码行数:14,代码来源:MainPage.xaml.cs


示例15: Canvas_Draw

        void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var ds = args.DrawingSession;
            ds.Clear(Color.FromArgb(0,0,0,0));

            var shape = this.Shapes.SelectedItem as Shape;
            if (shape == null)
                return;

            var width = sender.ActualWidth;
            var height = sender.ActualHeight;

            if (shape.Drawer != null)
                shape.Drawer(sender, ds);
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:15,代码来源:ShapesExample.xaml.cs


示例16: PPathwayCanvas

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="canvas">CanvasControl instance</param>
 public PPathwayCanvas(CanvasControl canvas)
 {
     m_canvas = canvas;
     m_con = canvas.Control;
     // Preparing context menus.
     this.ContextMenuStrip = m_con.Menu.PopupMenu;
     this.KeyDown += new KeyEventHandler(m_con.Menu.Canvas_KeyDown);
     //
     this.HighQuality = m_con.HighQuality;
     //
     this.RemoveInputEventListener(PanEventHandler);
     this.RemoveInputEventListener(ZoomEventHandler);
     this.Dock = DockStyle.Fill;
     this.Name = canvas.ModelID;
     this.Camera.ScaleViewBy(1.0f);
 }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:20,代码来源:PPathwayCanvas.cs


示例17: OnDraw

        void OnDraw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            float strokeWidth = 1;

            sharedResources = GetSharedResources(sender);
            var arrow = sharedResources.GetArrow(TextDirection);
            var bounds = arrow.ComputeStrokeBounds(strokeWidth);

            var ds = args.DrawingSession;

            var foregroundBrush = (SolidColorBrush)this.Foreground;
            var color = foregroundBrush.Color;

            arrow = arrow.Transform(CalculateTransform(bounds, new Rect(new Point(0, 0), sender.Size)));

            ds.DrawGeometry(arrow, color, strokeWidth, ArrowStrokeStyle);
        }
开发者ID:fengweijp,项目名称:Win2D,代码行数:17,代码来源:TextDirectionControl.cs


示例18: 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


示例19: DrawCircles

        private void DrawCircles(CanvasControl sender, CanvasDrawingSession ds)
        {
            float width = (float)sender.ActualWidth;
            float height = (float)sender.ActualHeight;

            float endpointMargin = Math.Min(width, height) / 8;
            float controlMarginX = endpointMargin * 4;
            float controlMarginY = endpointMargin * 2;

            for (int i = 0; i < 25; i++)
            {
                Vector2[] bez = new Vector2[4];
                int n = (i * 24) + 9 - (i / 2);

                for (int k = 0; k < 3; k++)
                {
                    int j = 4 - (2 * k);
                    bez[k].X = (0 + (((n >> (j + 1)) & 1) * (width - controlMarginX)));
                    bez[k].Y = (0 + (((n >> j) & 1) * (height - controlMarginY)));
                }
                bez[3].X = width - endpointMargin; // Collect the ends in the lower right
                bez[3].Y = height - endpointMargin;

                const int nSteps = 80;
                const float tStep = 1.0f / nSteps;
                float t = 0;
                for (int step = 0; step < nSteps; step++)
                {
                    float s = 1 - t;
                    float ss = s * s;
                    float sss = ss * s;
                    float tt = t * t;
                    float ttt = tt * t;
                    float x = (sss * bez[0].X) + (3 * ss * t * bez[1].X) + (3 * s * tt * bez[2].X) + (ttt * bez[3].X);
                    float y = (sss * bez[0].Y) + (3 * ss * t * bez[1].Y) + (3 * s * tt * bez[2].Y) + (ttt * bez[3].Y);
                    float radius = ttt * endpointMargin;
                    float strokeWidth = (0.5f - Math.Abs(ss - 0.5f)) * 10;

                    ds.DrawCircle(x, y, radius, GradientColor(t), strokeWidth);
                    t += tStep;
                }
            }
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:43,代码来源:ShapesExample.xaml.cs


示例20: canvas_CreateResources

        void canvas_CreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args)
        {
            switch (args.Reason)
            {
                case CanvasCreateResourcesReason.FirstTime:
                    // First time initialization: either restore suspended app state, load a
                    // photo that was passed in from the shell, or bring up the file selector.
                    if (launchArg is ApplicationExecutionState && (ApplicationExecutionState)launchArg == ApplicationExecutionState.Terminated)
                    {
                        var restoreTask = RestoreSuspendedState(sender.Device);

                        args.TrackAsyncAction(restoreTask.AsAsyncAction());
                    }
                    else
                    {
                        if (!TryLoadPhoto(launchArg as IReadOnlyList<IStorageItem>))
                        {
                            LoadButton_Click(null, null);
                        }
                    }
                    break;

                case CanvasCreateResourcesReason.NewDevice:
                    // Recovering after a lost device (GPU reset).
                    if (photo.SourceBitmap != null)
                    {
                        photo.RecoverAfterDeviceLost(sender.Device);
                    }

                    cachedImage.RecoverAfterDeviceLost();
                    break;

                case CanvasCreateResourcesReason.DpiChanged:
                    // We mostly work in pixels rather than DIPs, so only need
                    // minimal layout updates in response to DPI changes.
                    if (photo.SourceBitmap != null)
                    {
                        ZoomToFitPhoto();
                    }
                    break;
            }
        }
开发者ID:shawnhar,项目名称:stuart,代码行数:42,代码来源:MainPage.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CanvasDevice类代码示例发布时间:2022-05-24
下一篇:
C# CanvasAnimatedDrawEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap