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


C# Controls.Canvas类代码示例

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


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

示例1: TileRenderer

        public TileRenderer(Canvas canvas, string displayText, Tile tile)
        {
            storyboard = new Storyboard();
            Tile = tile;
            this.canvas = canvas;
            Width = DefaultWidth;
            Height = DefaultHeight;
            rectangle = new Rectangle
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Stroke = new SolidColorBrush(Colors.Black),
                Fill = new SolidColorBrush(Colors.WhiteSmoke)
            };
            Children.Add(rectangle);

            text = new TextBlock
            {
                Text = displayText,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                TextAlignment = TextAlignment.Center,
                FontSize = 36,
                Foreground = new SolidColorBrush(Colors.Black),
                FontWeight = FontWeights.Bold,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0, 26, 0, 26)

            };

            Children.Add(text);
            canvas.Children.Add(this);
            SetPosition();
            tile.PositionChanged += UpdatePosition;
        }
开发者ID:federico-ardila,项目名称:SlidePuzzle2,代码行数:34,代码来源:TileRenderer.cs

示例2: Game

 public Game(Canvas canvas, Action gameOverAction)
 {
     _canvas = canvas;
     gameOver = gameOverAction;
     timer = new Timer(Loop, Utility.GAME_TICK_MS);
     reinitialize = false;
 }
开发者ID:bramom,项目名称:Bug.RS,代码行数:7,代码来源:Game.cs

示例3: RenderContext

 /// <summary>
 /// Initializes a new instance of the <see cref="RenderContext" /> class.
 /// </summary>
 /// <param name="canvas">The canvas.</param>
 public RenderContext(Canvas canvas)
 {
     this.canvas = canvas;
     this.Width = canvas.ActualWidth;
     this.Height = canvas.ActualHeight;
     this.RendersToScreen = true;
 }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:11,代码来源:RenderContext.cs

示例4: SetTime

        private void SetTime(Canvas canvas)
        {
            var time = DateTime.Now;
            double curHour = time.Hour % 12;
            double curMinute = time.Minute;
            double curSecond = time.Second;

            List<Line> lines = TreeHelper.FindChildren<Line>(canvas);

            if(lines.Count < 3) return;
            var xhour = lines[2];
            var xminute = lines[1];
            var xsecond = lines[0];

            xhour.RenderTransform = new RotateTransform
            {
                CenterX = 100,
                CenterY = 100,
                Angle = curHour * 30 + curMinute / 2
            };

            xminute.RenderTransform = new RotateTransform
            {
                CenterX = 100,
                CenterY = 100,
                Angle = curMinute * 6 + curSecond / 10
            };

            xsecond.RenderTransform = new RotateTransform
            {
                CenterX = 100,
                CenterY = 100,
                Angle = curSecond * 6
            };
        }
开发者ID:simple0812,项目名称:uwp,代码行数:35,代码来源:MainPage.xaml.cs

示例5: OnApplyTemplate

        /// <summary>
        /// Builds the visual tree for the ColorPicker control when the template is applied. 
        /// </summary>
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            m_rootElement = GetTemplateChild("RootElement") as Panel;
            m_hueMonitor = GetTemplateChild("HueMonitor") as Rectangle;
            m_sampleSelector = GetTemplateChild("SampleSelector") as Canvas;
            m_hueSelector = GetTemplateChild("HueSelector") as Canvas;
            m_selectedColorView = GetTemplateChild("SelectedColorView") as Rectangle;
            m_colorSample = GetTemplateChild("ColorSample") as Rectangle;
            m_hexValue = GetTemplateChild("HexValue") as TextBlock;


            m_rootElement.RenderTransform = m_scale = new ScaleTransform();

            m_hueMonitor.PointerPressed += m_hueMonitor_PointerPressed;
            m_hueMonitor.PointerReleased += m_hueMonitor_PointerReleased;
            m_hueMonitor.PointerMoved += m_hueMonitor_PointerMoved;

            m_colorSample.PointerPressed += m_colorSample_PointerPressed;
            m_colorSample.PointerReleased += m_colorSample_PointerReleased;
            m_colorSample.PointerMoved += m_colorSample_PointerMoved;

            m_sampleX = m_colorSample.Width;
            m_sampleY = 0;
            m_huePos = 0;

            UpdateVisuals();
        }
开发者ID:tupunco,项目名称:Tup.WinRTControls,代码行数:32,代码来源:ColorPicker.cs

示例6: CreateMarker

        private UIElement CreateMarker() {
            Canvas marker = new Canvas();
            Ellipse outer = new Ellipse() {
                Width = 25,
                Height = 25,
            };
            outer.Fill = new SolidColorBrush(Color.FromArgb(255,240,240,240));
            outer.Margin = new Thickness(-12.5, -12.5, 0, 0);

            Ellipse inner = new Ellipse() {
                Width = 20,
                Height = 20,
            };
            inner.Fill = new SolidColorBrush(Colors.Black);
            inner.Margin = new Thickness(-10, -10, 0, 0);

            Ellipse core = new Ellipse() {
                Width = 10,
                Height = 10,
            };
            core.Fill = new SolidColorBrush(Colors.White);
            core.Margin = new Thickness(-5, -5, 0, 0);
            marker.Children.Add(outer);
            marker.Children.Add(inner);
            marker.Children.Add(core);

            return marker;
        }
开发者ID:Vedolin,项目名称:wheelmap-windows-app,代码行数:28,代码来源:MyLocationOverlay.cs

示例7: Render

        public static void Render(Viewport viewport, Canvas canvas, IEnumerable<Tile<Image>> tiles)
        {
            if (viewport == null) return;

            canvas.Children.Clear();

            var tileList = tiles.ToList();
            for (int i = 0; i < tileList.Count; i++)
            {
                var tile = tileList[i];
                if (tile.Image == null) continue;
                var point1 = viewport.WorldToScreen(tile.Info.Extent.MinX, tile.Info.Extent.MaxY);
                var point2 = viewport.WorldToScreen(tile.Info.Extent.MaxX, tile.Info.Extent.MinY);

                var dest = new Rect(point1.ToMetroPoint(), point2.ToMetroPoint());
                dest = RoundToPixel(dest);

                Canvas.SetLeft(tile.Image, dest.X);
                Canvas.SetTop(tile.Image, dest.Y);
                tile.Image.Width = dest.Width;
                tile.Image.Height = dest.Height;
                canvas.Children.Add(tile.Image);

                if (tile.StartAnimation == default(long))
                {
                    tile.StartAnimation = DateTime.Now.Ticks;
                    Animate(tile.Image, "Opacity", 0, 1, 600, (s, e) => { });
                }
            }
        }
开发者ID:galchen,项目名称:brutile,代码行数:30,代码来源:Renderer.cs

示例8: FaceTrackerProxy

        public FaceTrackerProxy (Canvas canvas, MainPage page, CaptureElement capture, MediaCapture mediacapture ) {


            if (this.faceTracker == null)
            {
                this.faceTracker = FaceTracker.CreateAsync().AsTask().Result;
            }

            rootPage = page;
            VisualizationCanvas = canvas;

            this.VisualizationCanvas.Children.Clear();

            mediaCapture = mediacapture;

            var deviceController = mediaCapture.VideoDeviceController;
            this.videoProperties = deviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;
            currentState = ScenarioState.Streaming;

            // Ensure the Semaphore is in the signalled state.
            this.frameProcessingSemaphore.Release();

            // Use a 66 milisecond interval for our timer, i.e. 15 frames per second 
            TimeSpan timerInterval = TimeSpan.FromMilliseconds(200);
            this.frameProcessingTimer = Windows.System.Threading.ThreadPoolTimer.CreatePeriodicTimer(new Windows.System.Threading.TimerElapsedHandler(ProcessCurrentVideoFrame), timerInterval);


        }
开发者ID:evangelism,项目名称:DXHackathons,代码行数:28,代码来源:FaceTrackerProxy.cs

示例9: Game

 //constructor
 public Game(Canvas canvas)
 {
     this.canvas = canvas;
     CreateBall();
     CreatePaddle();
     CreateBlocks();
 }
开发者ID:Lawryy,项目名称:Ekat20tehtavaa,代码行数:8,代码来源:Game.cs

示例10: Pit

        // --- Methods of the class ---
        /// <summary>Constructor takes as parameters the x and y coordinate on the 1000-page</summary>
        public Pit(Canvas canvasToPaintOn,
                    PitType pitType,
                    int x, int y, int width, int height,
                    int pitFrameThicknessX, int pitFrameThicknessY,
                    PitPosition position)
        {
            _pitId = _staticPitCounter++;
            _canvasToPaintOn = canvasToPaintOn;
            _pitType = pitType;
            _seeds = new List<Seed>();
            _topLeftCorner = new Point(0, 0);
            _height = 0;
            _width = 0;
            _image = new Image[_numImageTypes];
            _touchField = null;
            _numberField = null;
            SetTopLeftCorner(x, y);
            _width = width;
            _height = height;
            _pitFrameThicknessX = pitFrameThicknessX;
            _pitFrameThicknessY = pitFrameThicknessY;
            _position = position;

            //DEBUG     Logging.Inst.LogMessage("Created " + this.ToString() + " at " + _topLeftCorner + " with width " + _width + ", height " + _height +
            //DEBUG                             ", xPitFrameThickness " + _xPitFrameThickness + ", and yPitFrameThickness " + _yPitFrameThickness + "\n");
        }
开发者ID:tempestrock,项目名称:Kalaha,代码行数:28,代码来源:Pit.cs

示例11: InitializeControl

        private void InitializeControl()
        {
            try
            {

                if (root == null)
                {
                    root = (Canvas)GetTemplateChild("root");
                    layerStoryboard = (Storyboard)root.Resources["layerStoryboard"];

                    layerAnimationX = (DoubleAnimation)layerStoryboard.Children[0];
                    layerAnimationY = (DoubleAnimation)layerStoryboard.Children[1];

                    layerState = new LayerState(SensitivityX, SensitivityY);

                    Conductor.Beat += Conductor_Beat;

                    rootParent = (Canvas)this.Parent;
                    //rootParent.PointerPressed += rootParent_PointerPressed;
                    rootParent.ManipulationDelta += rootParent_ManipulationDelta;
                    rootParent.ManipulationMode = this.ManipulationMode; // &ManipulationModes.TranslateY;

                }


            }
            catch { }
        }
开发者ID:liquidboy,项目名称:X,代码行数:28,代码来源:InnertialLayer.cs

示例12: ListPage

        //-------------------------------------------------------------------------------
        #endregion (Util)

        //-------------------------------------------------------------------------------
        #region Constructor
        //-------------------------------------------------------------------------------
        //
        public ListPage()
        {
            this.InitializeComponent();
            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            CANVASES = new Canvas[] {
                    canvasMap1_E123, canvasMap1_E456, canvasMap1_W,
                    canvasMap2_E123, canvasMap2_E456, canvasMap2_W,
                    canvasMap3_E123, canvasMap3_E456, canvasMap3_W
                };
            SCROLLVIEWERS = new ScrollViewer[] {
                    scImgMap1_E123, scImgMap1_E456, scImgMap1_W,
                    scImgMap2_E123, scImgMap2_E456, scImgMap2_W,
                    scImgMap3_E123, scImgMap3_E456, scImgMap3_W
                };
            SELECT_BORDERS = new Border[] {
                borderMap1_E123, borderMap1_E456, borderMap1_W,
                borderMap2_E123, borderMap2_E456, borderMap2_W,
                borderMap3_E123, borderMap3_E456, borderMap3_W
            };
            RADIOBUTTONS = new RadioButton[] {
                rbSearch_Checklist, rbSearch_SearchString, rbSearch_Genre
            };
        }
开发者ID:kavenblog,项目名称:ComicStarViewer,代码行数:33,代码来源:ListPage.xaml.cs

示例13: BoundaryHelperBox2d

        public BoundaryHelperBox2d(Canvas cnvGame)
        {
            _cnvGame = cnvGame;

            // TODO: tweak margin/etc of Canvas

            if (Double.IsNaN(_cnvGame.Width) || Double.IsNaN(_cnvGame.Height))
            {
                if (Double.IsNaN(_cnvGame.ActualWidth) || Double.IsNaN(_cnvGame.ActualHeight)
                    || _cnvGame.ActualWidth == 0 || _cnvGame.ActualHeight == 0)
                {
                    _cnvGame.Width = 1366;
                    _cnvGame.Height = 768;
                }
                else
                {
                    _cnvGame.Width = _cnvGame.ActualWidth;
                    _cnvGame.Height = _cnvGame.ActualHeight;
                }
                System.Diagnostics.Debug.WriteLine("Your game canvas did not specify a width and height, so it was forced to 1366x768.");
            }

            ScreenTopLeft = new xna.Vector2(0, 0);
            ScreenBottomRight = new xna.Vector2((float)_cnvGame.Width, (float)_cnvGame.Height);

            xna.Vector2 screenSize = new xna.Vector2((float)cnvGame.Width, (float)cnvGame.Height);
            float ratio = screenSize.X / screenSize.Y;
            float halfWorldSize = (float)GetWorldSize(screenSize) / 2.0f;
            xna.Vector2 extent = new xna.Vector2(-ratio * halfWorldSize, halfWorldSize);

            WorldTopLeft = extent;
            WorldBottomRight = -extent;
        }
开发者ID:badreddine-dlaila,项目名称:PhysicsHelper.UAP,代码行数:33,代码来源:BoundaryHelperBox2d.cs

示例14: Invaders

        //default invaders contructor accepted the canvas and current level
        public Invaders(Canvas canvas, int lvl)
        {
            //initialize variables and grid
            createRowsAndColumns();
            invaderGrid = new Image[columns, rows];
            invaderBullets = new Image[3];
            
            isMovingLeft = invadersAreMoving = isMovingDown = toggleSprite = false;
            isShooting = true;
            isPlayerAlive = true;
            count = 0;
            speed = lvl;

            //loops to set the alien grid and images
            for (int c = 0; c < columns; c++)
            {
                for (int r = 0; r < rows; r++)
                {
                    Image invader = new Image();
                    BitmapImage bitmapSource;

                    //If the row number is smaller than 1, use this sprite
                    if (r < 1)
                    {
                        invader.Height = 24 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-1-1.png"));
                    }
                    //If the row number is smaller than 3, use this sprite
                    else if (r < 3)
                    {
                        invader.Height = 28 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-2-1.png"));
                    }
                    //If the row number is bigger than 3, use this sprite
                    else
                    {
                        invader.Height = 32 * sizeModifier();
                        invader.Tag = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-2.png"));
                        bitmapSource = new BitmapImage(new Uri("ms-appx:///Assets/sprites/alien-3-1.png"));
                    }

                    //Set the x coords for selected the invader
                    Canvas.SetLeft(invader, 32 + (50 * c));
                    
                    //Set the y coords for the selected invader
                    if (rows * 32 >= Window.Current.Bounds.Height / 2) Canvas.SetTop(invader, -((rows * 32) - 64) + (50 * r));
                    else Canvas.SetTop(invader, 32 + (50 * r));

                    invader.Width = 32 * sizeModifier();
                    invader.Source = bitmapSource;

                    //add invader to the canvas and invaderGrid
                    canvas.Children.Add(invader);
                    invaderGrid[c, r] = invader;
                }
            }
        }
开发者ID:dube0141,项目名称:Space-Invaders-Mobile,代码行数:60,代码来源:Invaders.cs

示例15: GameBoard

 public GameBoard(int rows, int cols, Canvas gameCanvas)
 {
     _cCols = cols;
     _cRows = rows;
     _gameCanvas = gameCanvas;
     _solution = new List<Point>();
     CreateAndInitBoard(rows, cols);
 }
开发者ID:roydor,项目名称:Flipper,代码行数:8,代码来源:GameBoard.cs


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