Inheritance: Panel, ICanvas
        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;
        }
Beispiel #2
0
 public Game(Canvas canvas, Action gameOverAction)
 {
     _canvas = canvas;
     gameOver = gameOverAction;
     timer = new Timer(Loop, Utility.GAME_TICK_MS);
     reinitialize = false;
 }
Beispiel #3
0
 /// <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;
 }
Beispiel #4
0
        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
            };
        }
        /// <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();
        }
Beispiel #6
0
        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) => { });
                }
            }
        }
        public static void addOverlay(Windows.UI.Xaml.Controls.Canvas canvas, float cameraAspectRatio)
        {
            cameraAR = cameraAspectRatio;

            if (viewportLayer != null)
            {
                removeOverlay();
            }

            viewportLayer = new Image();
            lineLayer     = new Image();

            currentCanvas = canvas;
            canvas.Children.Add(viewportLayer);
            canvas.Children.Add(lineLayer);
            updateOverlay();
            addAnimation();

            checkTimer          = new DispatcherTimer();
            checkTimer.Interval = TimeSpan.FromSeconds(0.2);
            checkTimer.Tick    += delegate
            {
                checkChange();
            };
            checkTimer.Start();
        }
Beispiel #8
0
 public void Dispose()
 {
     if (_mainCanvas != null)
     {
         if (_popMenuOverlayRenderer != null)
         {
             _popMenuOverlayRenderer.PointerPressed  -= menuOverlayRenderer_PointerPressed;
             _popMenuOverlayRenderer.PointerMoved    -= menuOverlayRenderer_PointerMoved;
             _popMenuOverlayRenderer.PointerReleased -= menuOverlayRenderer_PointerReleased;
             _popMenuOverlayRenderer.PointerExited   -= menuOverlayRenderer_PointerReleased;
             _mainCanvas.Children.Remove(_popMenuOverlayRenderer);
         }
         if (_backgroundOverlay != null)
         {
             _backgroundOverlay.Tapped -= _backgroundOverlay_Tapped;
             _mainCanvas.Children.Remove(_backgroundOverlay);
         }
         if (_popupRenderer != null)
         {
             _mainCanvas.Children.Remove(_popupRenderer);
         }
         _mainCanvas.SizeChanged -= mainCanvas_SizeChanged;
     }
     _mainCanvas             = null;
     _popMenuOverlayRenderer = null;
     _backgroundOverlay      = null;
     _popupRenderer          = null;
 }
        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;
        }
        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);


        }
Beispiel #11
0
 //constructor
 public Game(Canvas canvas)
 {
     this.canvas = canvas;
     CreateBall();
     CreatePaddle();
     CreateBlocks();
 }
Beispiel #12
0
        // --- 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");
        }
Beispiel #13
0
        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 { }
        }
        //-------------------------------------------------------------------------------
        #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
            };
        }
        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;
        }
        //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;
                }
            }
        }
        public MosaicImage()
        {
            _layoutRoot = new Canvas();
            Content = _layoutRoot;
            MaxImageSize = 300;

            SizeChanged += MosaicImage_SizeChanged;
        }
Beispiel #18
0
 // Create a node for trails test B
 public TrailNode(char l, Point p, Canvas c, bool r = true)
 {
     number = 0;
     letter = l;
     position = p;
     rotate = r;
     createShapes(letter.ToString(), position, c);
 }
Beispiel #19
0
 // Create a node for trails test A
 public TrailNode(int n, Point p, Canvas c, bool r = true)
 {
     number = n;
     letter = '0';
     position = p;
     rotate = r;
     createShapes(number.ToString(), position, c);
 }
Beispiel #20
0
 public Scale()
 {
     // Maybe add containers for ranges as well
     indicatorContainer = new Canvas();
     Children.Add(indicatorContainer);
     //CreateLabels();
     //CreateTicks();
 }
Beispiel #21
0
 public GameBoard(int rows, int cols, Canvas gameCanvas)
 {
     _cCols = cols;
     _cRows = rows;
     _gameCanvas = gameCanvas;
     _solution = new List<Point>();
     CreateAndInitBoard(rows, cols);
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="textCanvas">Канва.</param>
 /// <param name="factory">Фабрика элементов.</param>
 /// <param name="splitter">Средство разбивки на слова.</param>
 public CanvasTextRenderCommandExecutor(Canvas textCanvas, ICanvasElementFactory factory, IWordSplitter splitter)
 {
     if (textCanvas == null) throw new ArgumentNullException("textCanvas");
     if (factory == null) throw new ArgumentNullException("factory");
     if (splitter == null) throw new ArgumentNullException("splitter");
     TextCanvas = textCanvas;
     Factory = factory;
     Splitter = splitter;
     FirstInLine = true;
 }
Beispiel #23
0
        private void Canvas_PointerPressed_1(object sender, PointerRoutedEventArgs e)
        {
            Canvas canvas = (sender as Canvas);
            if (canvas == null) return;
            canvasElement = canvas;

            Windows.UI.Input.PointerPoint pt = e.GetCurrentPoint(canvas);
            contacts[pt.PointerId] = pt.Position;
            e.Handled = true;
        }
Beispiel #24
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_cvMainContainer == null)
            {
                _cvMainContainer = GetTemplateChild("cvMainContainer") as Windows.UI.Xaml.Controls.Canvas;
                _cvMainContainer.Children.Add((UIElement)this.Content);
            }
        }
        public ContentPresenterCache(Canvas canvas, DataTemplate dataTemplate)
        {
            _canvas = canvas;
            _dataTemplate = dataTemplate;

            for (int i = 0; i < 10; i++)
            {
                _cpList.Enqueue(GenerateNewPresenter());
            }
        }
Beispiel #26
0
        public void RemoveOverlay()
        {
            if (_Overlay == null) return;

            _Timer.Stop();
            _Timer = null;

            _Parent.Children.Remove(_Overlay);
            _Overlay = null;
        }
        public Platform(Windows.UI.Xaml.Controls.Page page)
        {
            _page = page;
            _renderer = new Canvas();
            _renderer.SizeChanged += renderer_SizeChanged;
            NavigationService.Current.OnNewPage += Current_OnNewPage;
            _tracker = new ToolbarTracker();
            _tracker.CollectionChanged += (s, e) => UpdateAppBar();

        }
Beispiel #28
0
        public void Draw(Canvas canvas, Image player)
        {
            if (count % 45 == 1) toggleSprite = true;

            if (isMovingDown)
            {
                for (int r = 0; r < 11; r++)
                {
                    for (int c = 0; c < 5; c++)
                    {
                        isMovingDown = false;
                        Canvas.SetTop(invaderGrid[r, c], Canvas.GetTop(invaderGrid[r, c]) + 50);
                    }
                }
            }

            if (isMovingLeft)
            {
                for (int r = 0; r < 11; r++)
                {
                    for (int c = 0; c < 5; c++)
                    {
                        if (Canvas.GetLeft(invaderGrid[r, c]) <= 0 + invaderGrid[r, c].Width)
                        {
                            isMovingDown = true;
                            isMovingLeft = false;
                        }
                        if (toggleSprite) toggle(invaderGrid[r, c]);

                        Canvas.SetLeft(invaderGrid[r, c], Canvas.GetLeft(invaderGrid[r, c]) - 1);
                    }
                }
            }
            else
            {
                for (int r = 0; r < 11; r++)
                {
                    for (int c = 0; c < 5; c++)
                    {
                        if (Canvas.GetLeft(invaderGrid[r, c]) >= Window.Current.Bounds.Width - invaderGrid[r, c].Width)
                        {
                            isMovingDown = true;
                            isMovingLeft = true;
                        }
                        if (toggleSprite) toggle(invaderGrid[r, c]);

                        Canvas.SetLeft(invaderGrid[r, c], Canvas.GetLeft(invaderGrid[r, c]) + 1);
                    }
                }
            }

            toggleSprite = false;
            count++;
        }
Beispiel #29
0
        public UWPNativeAdView(NativeAdView view)
        {
            View = view;

            Result = new controls.Canvas();

            Agent = view.Agent ?? throw new Exception(".NativeAdView.Agent is null");

            view.RotateRequested += LoadNext;
            LoadNext();
        }
 /// <summary>
 /// Отрисовать.
 /// </summary>
 /// <param name="map">Карта расположений.</param>
 /// <returns>Результат.</returns>
 public FrameworkElement Render(ITextRender2MeasureMap map)
 {
     if (map == null) throw new ArgumentNullException(nameof(map));
     var canvas = new Canvas()
     {
         Height = map.Bounds.Height,
         Width = map.Bounds.Width
     };
     DoRender(canvas, map);
     return canvas;
 }
Beispiel #31
0
        public CanvasManager(WinRT.Canvas canvas)
        {
            m_Canvas = canvas;

            InkMode();

            m_Canvas.PointerPressed += OnCanvasPointerPressed;
            m_Canvas.PointerMoved += OnCanvasPointerMoved;
            m_Canvas.PointerReleased += OnCanvasPointerReleased;
            m_Canvas.PointerExited += OnCanvasPointerReleased;
        }
 public override void Draw(Canvas canvas)
 {
     if (this.shape != null)
     {
         canvas.Children.Remove(this.shape);
     }
     else
     {
         this.shape = new Rectangle();
     }
     base.Draw(canvas);
 }
Beispiel #33
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Stage = GetTemplateChild( StageName ) as Canvas;
            if ( Stage == null ) return;

            StageTransform.CenterX = 0.5 * Stage.Width;
            StageTransform.CenterY = 0.5 * Stage.Height;
            Stage.RenderTransform = StageTransform;

            StageDim = new Size( Stage.Width, Stage.Height );
        }
Beispiel #34
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (_cvMainContainer == null)
            {
                _cvMainContainer = GetTemplateChild("cvMainContainer") as Windows.UI.Xaml.Controls.Canvas;
                _cvMainContainer.Children.Add( (UIElement) this.Content);
            }


        }
Beispiel #35
0
        public void Unload()
        {
            if (vm != null)
            {
                if (cvMain.Children.Count > 0)
                {
                    foreach (var nc in cvMain.Children)
                    {
                        if (nc is PageLayout)
                        {
                            var ncpl = nc as PageLayout;
                            ncpl.PerformAction -= PageLayout_PerformAction;
                            ncpl.DataContext    = null;
                        }
                    }
                    cvMain.Children.Clear();
                }

                if (vm.Pages != null)
                {
                    foreach (var pg in vm.Pages)
                    {
                        pg.Layers.Clear();
                    }
                    vm.Pages.Clear();
                }
                if (cvMain.Children.Count > 0)
                {
                    //foreach (var nc in cvMain.Children) {
                    //    if (nc is PageLayout) {
                    //        var ncpl = nc as PageLayout;
                    //        ncpl.PerformAction -= PageLayout_PerformAction;
                    //    }
                    //}
                    cvMain.Children.Clear();
                }

                vm = null;
            }

            cvMainContainer.Content = null;
            cvMain.RenderTransform  = null;
            cvMain = null;



            layoutRoot.Children.Remove(cvMainContainer);
            //cvMainContainer.Content = null;
            cvMainContainer = null;
        }
Beispiel #36
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="element">
        /// Manipulation target.
        /// </param>
        /// <param name="reference">
        /// Element that contains the coordinate space used for expressing transformations
        /// during manipulations, usually the parent element of Target in the UI tree.
        /// </param>
        /// <remarks>
        /// Transformations during manipulations cannot be expressed in the coordinate space of the manipulation target.
        /// Thus <paramref name="element"/> and <paramref name="reference"/> must be different. Usually <paramref name="reference"/>
        /// will be an ancestor of <paramref name="element"/> in the UI tree.
        /// </remarks>
        internal InputProcessor(Windows.UI.Xaml.FrameworkElement element, Windows.UI.Xaml.Controls.Canvas reference)
        {
            _target    = element;
            _reference = reference;


            _target.AddHandler(UIElement.PointerCanceledEvent, new PointerEventHandler(OnPointerCanceled), true);
            _target.AddHandler(UIElement.PointerCaptureLostEvent, new PointerEventHandler(OnPointerCaptureLost), true);
            _target.AddHandler(UIElement.PointerReleasedEvent, new PointerEventHandler(OnPointerReleased), true);
            _target.AddHandler(UIElement.PointerExitedEvent, new PointerEventHandler(OnPointerExited), true);
            _target.AddHandler(UIElement.PointerMovedEvent, new PointerEventHandler(OnPointerMoved), true);
            _target.AddHandler(UIElement.PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true);
            _target.AddHandler(UIElement.PointerWheelChangedEvent, new PointerEventHandler(OnPointerWheelChanged), true);

            // Create the gesture recognizer
            _gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            _gestureRecognizer.GestureSettings = Windows.UI.Input.GestureSettings.None;
        }
Beispiel #37
0
        public void Load()
        {
            //changed to creating zcanvas by code rather than xaml, it was causing a memory leak
            cvMainContainer = new UI.ZoomCanvas.Canvas()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = new SolidColorBrush(Colors.White), RenderTransformOrigin = new Point(0, 0)
            };
            cvMain = new Windows.UI.Xaml.Controls.Canvas()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Background = new SolidColorBrush(Colors.White), RenderTransformOrigin = new Point(0.5d, 0.5d)
            };
            cvMain.RenderTransform = new CompositeTransform()
            {
                ScaleX = 1, ScaleY = 1, TranslateX = 0, TranslateY = 0
            };
            cvMainContainer.Content = cvMain;
            layoutRoot.Children.Insert(0, cvMainContainer);

            var ct = cvMain.RenderTransform as CompositeTransform;

            cvMainContainer.Scale = ct.ScaleX;
        }
Beispiel #38
0
 void FindRootCanvas(UIElement root)
 {
     if (root == null)
     {
         return;
     }
     if (root is Canvas)
     {
         _mainCanvas = root as Canvas;
         return;
     }
     if (root is ContentControl)
     {
         FindRootCanvas((root as ContentControl).Content as UIElement);
         return;
     }
     if (root is UserControl)
     {
         FindRootCanvas((root as UserControl).Content as UIElement);
         return;
     }
 }