Наследование: Geometry, IRectangleGeometry
        protected override Size ArrangeOverride(Size finalSize)
        {
            Clip = new RectangleGeometry { Rect = new Rect(0, 0, finalSize.Width, finalSize.Height) };

            double positionLeft = 0d;

            foreach (var item in Children)
            {
                if (item != null)
                {
                    Size desiredSize = item.DesiredSize;

                    if (!double.IsNaN(desiredSize.Width) && !double.IsNaN(desiredSize.Height))
                    {
                        var rect = new Rect(positionLeft, 0, desiredSize.Width, desiredSize.Height);
                        item.Arrange(rect);
                        item.RenderTransform = new TranslateTransform();
                        positionLeft += desiredSize.Width;
                    }
                }
            }

            _templateApplied = true;

            return finalSize;
        }
Пример #2
0
 protected override Size ArrangeOverride(Size finalSize)
 {
     var r = new RectangleGeometry();
     r.Rect = new Rect(new Point(0, 0), finalSize);
     Clip = r;
     return base.ArrangeOverride(finalSize);
 }
Пример #3
0
            public void Reset()
            {
                Children.Clear();
                InvalidateArrange();
                content = null;
                contentsCenter = new Rect(0, 0, 1, 1);
                contentGravity = ContentGravity.Resize;
                Clip = null;
                InvOriginTransform = new TranslateTransform();
                ClipGeometry = new RectangleGeometry();
                ClipGeometry.Transform = InvOriginTransform;
                RenderTransform = new TranslateTransform();
                _position = new Point(0, 0);
                _origin = new Point(0, 0);
                _size = new Size(0, 0);
                _hidden = false;
                originSet = false;
                _createdTransforms = false;
                LayerOpacity = 1.0;
                backgroundBrush = TransparentBrush;
                backgroundColor.R = 0;
                backgroundColor.G = 0;
                backgroundColor.B = 0;
                backgroundColor.A = 0;

                Set("anchorPoint", new Point(0.5, 0.5));
                _masksToBounds = false;

                this.Background = TransparentBrush;
            }
Пример #4
0
 public void OnSizeChanged(object sender, SizeChangedEventArgs e)
 {
     Clip = new RectangleGeometry()
     {
         Rect = new Rect(0, 0, e.NewSize.Width, e.NewSize.Height)
     };
 }
Пример #5
0
        protected override void OnApplyTemplate()
        {
            _frame = base.GetTemplateChild("frame") as Panel;
            _panel = base.GetTemplateChild("panel") as CarouselPanel;

            _arrows = base.GetTemplateChild("arrows") as Grid;
            _left = base.GetTemplateChild("left") as Button;
            _right = base.GetTemplateChild("right") as Button;

            _gradient = base.GetTemplateChild("gradient") as LinearGradientBrush;
            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            _frame.ManipulationDelta += OnManipulationDelta;
            _frame.ManipulationCompleted += OnManipulationCompleted;
            _frame.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.System;

            _frame.PointerMoved += OnPointerMoved;
            _left.Click += OnLeftClick;
            _right.Click += OnRightClick;
            _left.PointerEntered += OnArrowPointerEntered;
            _left.PointerExited += OnArrowPointerExited;
            _right.PointerEntered += OnArrowPointerEntered;
            _right.PointerExited += OnArrowPointerExited;

            base.OnApplyTemplate();
        }
Пример #6
0
        //public LoginPageViewModel vm { get; private set; }
        public LoginPage()
        {
            this.InitializeComponent();
            DataContextChanged += LoginPage_DataContextChanged;
            _toRegSb = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.2));
            _logspda = new DoubleAnimation()
            {
                From = 0,
                To = -FrameWidth,
                AutoReverse = false,
                Duration = duration
            };
            _regspda = new DoubleAnimation()
            {
                From = FrameWidth,
                To = 0,
                AutoReverse = false,
                Duration = duration
            };
            Storyboard.SetTargetProperty(_regspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(_logspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTarget(_logspda, logSP);
            Storyboard.SetTarget(_regspda, regSP);

            _toRegSb.Children.Add(_regspda);
            _toRegSb.Children.Add(_logspda);

            Rect rect = new Rect(0, 0, FrameWidth, 300);
            RectangleGeometry reo = new RectangleGeometry();
            reo.Rect = rect;
            this.infoBorder.Clip = reo;
        }
Пример #7
0
        protected override void OnApplyTemplate()
        {
            _container = base.GetTemplateChild("container") as Grid;
            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            base.OnApplyTemplate();
        }
        public void Update()
        {
            var r = new RectangleGeometry();
            r.Rect = new Rect(0, 0, Math.Max(ActualWidth, 0), Math.Max(500, 0));
            Clip = r;

            Scroll(1,0);
        }
Пример #9
0
	    protected override void OnApplyTemplate()
	    {
            base.OnApplyTemplate();
            
            _clip = this.GetTemplateChild("CLIPRECTANGLE") as RectangleGeometry;
            this.ValueChanged += ImageProgressBar_ValueChanged;
            this.SizeChanged += ImageProgressBar_SizeChanged;
        }
Пример #10
0
        protected override void OnApplyTemplate()
        {
            _content = base.GetTemplateChild("content") as ContentPresenter;
            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            _transform = _content.RenderTransform as CompositeTransform;

            base.OnApplyTemplate();
        }
Пример #11
0
 private static void ClipToBounds(FrameworkElement fe)
 {
     if (Clip.GetToBounds(fe))
     {
         RectangleGeometry rectangleGeometry = new RectangleGeometry();
         rectangleGeometry.Rect = new Rect(0.0, 0.0, fe.ActualWidth, fe.ActualHeight);
         fe.Clip = rectangleGeometry;
         return;
     }
     fe.Clip = null;
 }
Пример #12
0
        protected override void OnApplyTemplate()
        {
            _frame = base.GetTemplateChild("frame") as Grid;
            _webView = base.GetTemplateChild("webView") as WebView;
            _glass = base.GetTemplateChild("glass") as Grid;

            _container = base.GetTemplateChild("container") as Grid;
            _header = base.GetTemplateChild("header") as ContentPresenter;
            _footer = base.GetTemplateChild("footer") as ContentPresenter;
            _asideLeft = base.GetTemplateChild("asideLeft") as ContentPresenter;
            _asideRight = base.GetTemplateChild("asideRight") as ContentPresenter;

            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            _progress = base.GetTemplateChild("progress") as ProgressRing;

            _webView.NavigationStarting += OnNavigationStarting;
            _webView.NavigationCompleted += OnNavigationCompleted;
            _webView.ScriptNotify += OnScriptNotify;

            _glass.ManipulationStarting += OnGlassManipulationStarting;
            _glass.ManipulationStarted += OnGlassManipulationStarted;
            _glass.PointerPressed += OnGlassPointerPressed;

            _header.PointerWheelChanged += OnPointerWheelChanged;
            _footer.PointerWheelChanged += OnPointerWheelChanged;
            _asideLeft.PointerWheelChanged += OnPointerWheelChanged;
            _asideRight.PointerWheelChanged += OnPointerWheelChanged;

            _header.ManipulationStarted += OnAdornManipulationStarted;
            _footer.ManipulationStarted += OnAdornManipulationStarted;
            _asideLeft.ManipulationStarted += OnAdornManipulationStarted;
            _asideRight.ManipulationStarted += OnAdornManipulationStarted;

            _header.ManipulationDelta += OnAdornManipulationDelta;
            _footer.ManipulationDelta += OnAdornManipulationDelta;
            _asideLeft.ManipulationDelta += OnAdornManipulationDelta;
            _asideRight.ManipulationDelta += OnAdornManipulationDelta;

            _header.ManipulationCompleted += OnAdornManipulationCompleted;
            _footer.ManipulationCompleted += OnAdornManipulationCompleted;
            _asideLeft.ManipulationCompleted += OnAdornManipulationCompleted;
            _asideRight.ManipulationCompleted += OnAdornManipulationCompleted;

            _header.SizeChanged += AdornSizeChanged;
            _footer.SizeChanged += AdornSizeChanged;
            _asideLeft.SizeChanged += AdornSizeChanged;
            _asideRight.SizeChanged += AdornSizeChanged;

            this.SizeChanged += OnSizeChanged;

            base.OnApplyTemplate();
        }
Пример #13
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _leftThumb = (Thumb) GetTemplateChild(LeftThumbName);
            _leftThumb.DragDelta += LeftThumbDragDelta;
            _leftThumb.DragCompleted += ThumbDragCompleted;
            _leftThumb.Loaded += LeftThumbLoaded;

            _rightThumb = (Thumb) GetTemplateChild(RightThumbName);
            _rightThumb.DragDelta += RightThumbDragDelta;
            _rightThumb.DragCompleted += ThumbDragCompleted;
            _rightThumb.Loaded += RightThumbLoaded;

            _trackGeometry = (RectangleGeometry) GetTemplateChild("TrackRectangle");
            _trackRect = (Rectangle) GetTemplateChild(TrackRectName);
        }
Пример #14
0
        protected override void OnApplyTemplate()
        {
            _frame = base.GetTemplateChild("frame") as Panel;

            _headerContainer = base.GetTemplateChild("headerContainer") as Panel;
            _header = base.GetTemplateChild("header") as PivoramaPanel;
            _header.SelectedIndexChanged += OnSelectedIndexChanged;

            _tabsContainer = base.GetTemplateChild("tabsContainer") as Panel;
            _tabs = base.GetTemplateChild("tabs") as PivoramaTabs;
            _tabs.SelectedIndexChanged += OnSelectedIndexChanged;

            _panelContainer = base.GetTemplateChild("panelContainer") as Panel;
            _panel = base.GetTemplateChild("panel") as PivoramaPanel;

            _arrows = base.GetTemplateChild("arrows") as Grid;
            _left = base.GetTemplateChild("left") as Button;
            _right = base.GetTemplateChild("right") as Button;

            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            _frame.ManipulationDelta += OnManipulationDelta;
            _frame.ManipulationCompleted += OnManipulationCompleted;
            _frame.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateInertia | ManipulationModes.System;
            _frame.PointerWheelChanged += OnPointerWheelChanged;

            _panelContainer.ManipulationDelta += OnManipulationDelta;
            _panelContainer.ManipulationCompleted += OnManipulationCompleted;
            _panelContainer.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateInertia | ManipulationModes.System;

            _frame.PointerMoved += OnPointerMoved;
            _left.Click += OnLeftClick;
            _right.Click += OnRightClick;
            _left.PointerEntered += OnArrowPointerEntered;
            _left.PointerExited += OnArrowPointerExited;
            _right.PointerEntered += OnArrowPointerEntered;
            _right.PointerExited += OnArrowPointerExited;

            _isInitialized = true;

            this.ItemWidthEx = this.ItemWidth;

            this.SizeChanged += OnSizeChanged;

            base.OnApplyTemplate();
        }
Пример #15
0
 /// <summary>
 /// Назначить значения.
 /// </summary>
 protected override void SetValues()
 {
     if (!IsNarrowView)
     {
         ImagePreviewHeight = 100;
         ImagePreviewWidth = 160;
         ThreadPrevewImageHeight = 100;
         ThreadPreviewImageWidth = 160;
         BoardTileEngineNameVisibility = Visibility.Visible;
         BoardTileBoardFontSize = 16;
         BoardTileEngineLogoSize = 16;
         BoardTileEngineNameFontSize = 14;
         BoardTileDescFontSize = 12;
         BoardTileHeight = 80;
         BoardTileWidth = 160;
         CatalogTileWidth = 160;
         CatalogTileHeight = 90;
         PostingMediaTileHeight = 240;
         PostingMediaTileWidth = 320;
     }
     else
     {
         ImagePreviewHeight = 90;
         ImagePreviewWidth = 130;
         ThreadPreviewImageWidth = 100;
         ThreadPrevewImageHeight = 100;
         BoardTileEngineNameVisibility = Visibility.Collapsed;
         BoardTileBoardFontSize = 14;
         BoardTileEngineLogoSize = 14;
         BoardTileEngineNameFontSize = 12;
         BoardTileDescFontSize = 11;
         BoardTileHeight = 80;
         BoardTileWidth = 90;
         CatalogTileWidth = 100;
         CatalogTileHeight = 90;
         PostingMediaTileHeight = 240;
         PostingMediaTileWidth = 320;
     }
     BoardTileClip = new RectangleGeometry()
     {
         Rect = new Rect(new Point(0, 0), new Size(BoardTileWidth, BoardTileHeight))
     };
 }
Пример #16
0
        public MainPage()
        {
            InitializeComponent();

            Settings.DpiRatio = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
        
            foreach (var pointerDevice in Windows.Devices.Input.PointerDevice.GetPointerDevices())
            {
                Settings.InputDevices.Add(pointerDevice.PointerDeviceType);
            }

            Clip = new RectangleGeometry {Rect = new Rect(0, 0, 2000, 2000)};
            Loaded += OnLoaded;

            IsDoubleTapEnabled = true;
            DoubleTapped += delegate(object sender, DoubleTappedRoutedEventArgs args)
            {
                Controller.Instance.AddQueryBox(args.GetPosition(this).X - 180 * Settings.ZoomLevel, args.GetPosition(this).Y - 265 * Settings.ZoomLevel);
            };
        }
Пример #17
0
        protected override void OnApplyTemplate()
        {
            _frame = base.GetTemplateChild("frame") as Panel;
            _panel = base.GetTemplateChild("panel") as SliderViewPanel;

            _arrows = base.GetTemplateChild("arrows") as Grid;
            _left = base.GetTemplateChild("left") as Button;
            _right = base.GetTemplateChild("right") as Button;

            _clip = base.GetTemplateChild("clip") as RectangleGeometry;

            _frame.ManipulationDelta += OnManipulationDelta;
            _frame.ManipulationCompleted += OnManipulationCompleted;
            _frame.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.System;

            this.PointerEntered += OnPointerEntered;
            this.PointerExited += OnPointerExited;
            _left.Click += OnPrevArrowClick;
            _right.Click += OnNextArrowClick;

            base.OnApplyTemplate();
        }
Пример #18
0
 public static void AddRectangleGeometry(
     this D2D.GeometrySink sink, Jupiter.Media.RectangleGeometry rectangleGeometry)
 {
     sink.BeginFigure(
         new Vector2(
             (float)(rectangleGeometry.Rect.Left),
             (float)(rectangleGeometry.Rect.Top)),
         D2D.FigureBegin.Filled);
     sink.AddLines(
         new []
     {
         new Vector2(
             (float)(rectangleGeometry.Rect.Right),
             (float)(rectangleGeometry.Rect.Top)),
         new Vector2(
             (float)(rectangleGeometry.Rect.Right),
             (float)(rectangleGeometry.Rect.Bottom)),
         new Vector2(
             (float)(rectangleGeometry.Rect.Left),
             (float)(rectangleGeometry.Rect.Bottom)),
     });
     sink.EndFigure(D2D.FigureEnd.Closed);
 }
Пример #19
0
        private void CoverFlow_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            RectangleGeometry visibleArea = new RectangleGeometry();
            Rect clip = new Rect(0, 0, ActualWidth, ActualHeight);
            visibleArea.Rect = clip;
            Clip = visibleArea;

            if (Orientation == Orientation.Horizontal)
                pageCount = (int)Math.Ceiling(((ActualWidth / 2) - k) / l);
            else
                pageCount = (int)Math.Ceiling(((ActualHeight / 2) - k) / l);

            SetItemPositions();
        }
Пример #20
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ContentDragTransform = (TranslateTransform)GetTemplateChild("ContentDragTransform");
            LeftOrTopTransform = (TranslateTransform)GetTemplateChild("LeftOrTopTransform");
            RightOrButtomTransform = (TranslateTransform)GetTemplateChild("RightOrButtomTransform");

            LeftOrTopContainer = (Border)GetTemplateChild("LeftOrTopContainer");
            RightOrButtomContainer = (Border)GetTemplateChild("RightOrButtomContainer");

            DragBackground = (Grid)GetTemplateChild("DragBackground");
            DragClip = (RectangleGeometry)GetTemplateChild("DragClip");
            DragClipTransform1 = (TranslateTransform)GetTemplateChild("DragClipTransform");
            DragContainer = (Border)GetTemplateChild("DragContainer");

            if (HorizontalMode)
            {
                // configure manipulation
                DragContainer.ManipulationMode = ManipulationModes.System | ManipulationModes.TranslateX;

                // reconfigure contents
                Grid.SetColumn(LeftOrTopContainer, 0);
                Grid.SetColumn(RightOrButtomContainer, 2);
            }
            else
            {
                // configure manipulation
                DragContainer.ManipulationMode = ManipulationModes.System | ManipulationModes.TranslateY;

                // reconfigure contents
                Grid.SetRow(LeftOrTopContainer, 0);
                Grid.SetRow(RightOrButtomContainer, 2);
                Grid.SetColumn(LeftOrTopContainer, 0);
                Grid.SetColumn(RightOrButtomContainer, 0);
            }

            MinWidth = 0;
        }
Пример #21
0
        public static WMedia.Geometry ToWindows(this Geometry geometry)
        {
            WMedia.Geometry wGeometry = null;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;
                wGeometry = new WMedia.LineGeometry
                {
                    StartPoint = lineGeometry.StartPoint.ToWindows(),
                    EndPoint   = lineGeometry.EndPoint.ToWindows()
                };
            }
            else if (geometry is RectangleGeometry)
            {
                var rect = (geometry as RectangleGeometry).Rect;
                wGeometry = new WMedia.RectangleGeometry
                {
                    Rect = new WFoundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
                wGeometry = new WMedia.EllipseGeometry
                {
                    Center  = ellipseGeometry.Center.ToWindows(),
                    RadiusX = ellipseGeometry.RadiusX,
                    RadiusY = ellipseGeometry.RadiusY
                };
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;
                wGeometry = new WMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(geometryGroup.FillRule)
                };

                foreach (Geometry children in geometryGroup.Children)
                {
                    WMedia.Geometry winChild = children.ToWindows();
                    (wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                WMedia.PathGeometry wPathGeometry = new WMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(pathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in pathGeometry.Figures)
                {
                    WMedia.PathFigure wPathFigure = new WMedia.PathFigure
                    {
                        StartPoint = xamPathFigure.StartPoint.ToWindows(),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    wPathGeometry.Figures.Add(wPathFigure);

                    foreach (PathSegment pathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            WMedia.LineSegment winSegment = new WMedia.LineSegment
                            {
                                Point = lineSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment        polyLineSegment = pathSegment as PolyLineSegment;
                            WMedia.PolyLineSegment wSegment        = new WMedia.PolyLineSegment();

                            foreach (var point in polyLineSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // BezierSegment
                        if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            WMedia.BezierSegment wSegment = new WMedia.BezierSegment
                            {
                                Point1 = bezierSegment.Point1.ToWindows(),
                                Point2 = bezierSegment.Point2.ToWindows(),
                                Point3 = bezierSegment.Point3.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment        polyBezierSegment = pathSegment as PolyBezierSegment;
                            WMedia.PolyBezierSegment wSegment          = new WMedia.PolyBezierSegment();

                            foreach (var point in polyBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // QuadraticBezierSegment
                        if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment quadraticBezierSegment = pathSegment as QuadraticBezierSegment;

                            WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
                            {
                                Point1 = quadraticBezierSegment.Point1.ToWindows(),
                                Point2 = quadraticBezierSegment.Point2.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment        polyQuadraticBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            WMedia.PolyQuadraticBezierSegment wSegment = new WMedia.PolyQuadraticBezierSegment();

                            foreach (var point in polyQuadraticBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            WMedia.ArcSegment wSegment = new WMedia.ArcSegment
                            {
                                Size           = new WFoundation.Size(arcSegment.Size.Width, arcSegment.Size.Height),
                                RotationAngle  = arcSegment.RotationAngle,
                                IsLargeArc     = arcSegment.IsLargeArc,
                                SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
                                Point          = arcSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                    }
                }

                wGeometry = wPathGeometry;
            }

            return(wGeometry);
        }
Пример #22
0
        private void OnFirstContainerChanged(object sender, SizeChangedEventArgs e)
        {
            try
            {
                ToastMsg.Width = LayoutRoot.ActualWidth - 10 - e.NewSize.Width - Padding.Left - Padding.Right;
            }
            catch
            {
                ToastMsg.Width = Width - 20;
            }

            if (Clipped)
                Clip = new RectangleGeometry
                {
                    Rect = new Rect(0, 0, ActualWidth, ActualHeight + 10)
                };
            else
                Clip = null;
        }
Пример #23
0
        public object ConvertToNative(Geometry geometry)
        {
            winMedia.Geometry winGeometry = null;

            // Determine what type of geometry we're dealing with.
            if (geometry is LineGeometry)
            {
                LineGeometry xamGeometry = geometry as LineGeometry;
                winGeometry = new winMedia.LineGeometry
                {
                    StartPoint = ConvertPoint(xamGeometry.StartPoint),
                    EndPoint   = ConvertPoint(xamGeometry.EndPoint)
                };
            }

            else if (geometry is RectangleGeometry)
            {
                Rect rect = (geometry as RectangleGeometry).Rect;
                winGeometry = new winMedia.RectangleGeometry
                {
                    Rect = new winFound.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }

            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry xamGeometry = geometry as EllipseGeometry;
                winGeometry = new winMedia.EllipseGeometry
                {
                    Center  = ConvertPoint(xamGeometry.Center),
                    RadiusX = xamGeometry.RadiusX,
                    RadiusY = xamGeometry.RadiusY
                };
            }

            else if (geometry is GeometryGroup)
            {
                GeometryGroup xamGeometry = geometry as GeometryGroup;
                winGeometry = new winMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(xamGeometry.FillRule)
                };

                foreach (Geometry xamChild in xamGeometry.Children)
                {
                    winMedia.Geometry winChild = ConvertToNative(xamChild) as winMedia.Geometry;
                    (winGeometry as winMedia.GeometryGroup).Children.Add(winChild);
                }
            }

            else if (geometry is PathGeometry)
            {
                PathGeometry xamPathGeometry = geometry as PathGeometry;

                winMedia.PathGeometry winPathGeometry = new winMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(xamPathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in xamPathGeometry.Figures)
                {
                    winMedia.PathFigure winPathFigure = new winMedia.PathFigure
                    {
                        StartPoint = ConvertPoint(xamPathFigure.StartPoint),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    winPathGeometry.Figures.Add(winPathFigure);

                    foreach (PathSegment xamPathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (xamPathSegment is LineSegment)
                        {
                            LineSegment xamSegment = xamPathSegment as LineSegment;

                            winMedia.LineSegment winSegment = new winMedia.LineSegment
                            {
                                Point = ConvertPoint(xamSegment.Point)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (xamPathSegment is PolyLineSegment)
                        {
                            PolyLineSegment          xamSegment = xamPathSegment as PolyLineSegment;
                            winMedia.PolyLineSegment winSegment = new winMedia.PolyLineSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // BezierSegment
                        if (xamPathSegment is BezierSegment)
                        {
                            BezierSegment xamSegment = xamPathSegment as BezierSegment;

                            winMedia.BezierSegment winSegment = new winMedia.BezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                                Point3 = ConvertPoint(xamSegment.Point3)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyBezierSegment
                        else if (xamPathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment          xamSegment = xamPathSegment as PolyBezierSegment;
                            winMedia.PolyBezierSegment winSegment = new winMedia.PolyBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // QuadraticBezierSegment
                        if (xamPathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment xamSegment = xamPathSegment as QuadraticBezierSegment;

                            winMedia.QuadraticBezierSegment winSegment = new winMedia.QuadraticBezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyQuadraticBezierSegment
                        else if (xamPathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment          xamSegment = xamPathSegment as PolyQuadraticBezierSegment;
                            winMedia.PolyQuadraticBezierSegment winSegment = new winMedia.PolyQuadraticBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }


                        // ArcSegment
                        else if (xamPathSegment is ArcSegment)
                        {
                            ArcSegment          xamSegment = xamPathSegment as ArcSegment;
                            winMedia.ArcSegment winSegment = new winMedia.ArcSegment();

                            winSegment.Size           = new winFound.Size(xamSegment.Size.Width, xamSegment.Size.Height);
                            winSegment.RotationAngle  = xamSegment.RotationAngle;
                            winSegment.IsLargeArc     = xamSegment.IsLargeArc;
                            winSegment.SweepDirection = xamSegment.SweepDirection == SweepDirection.Clockwise ? winMedia.SweepDirection.Clockwise : winMedia.SweepDirection.Counterclockwise;
                            winSegment.Point          = ConvertPoint(xamSegment.Point);

                            winPathFigure.Segments.Add(winSegment);
                        }
                    }
                }

                winGeometry = winPathGeometry;
            }

            // Set transform.
            if (geometry.Transform != null)
            {
                winGeometry.Transform = (winMedia.Transform)geometry.Transform.GetNativeObject();
            }

            return(winGeometry);
        }
Пример #24
0
        /// <summary>
        /// Inherited code: Requires comment.
        /// </summary>
        /// <param name="sender">Inherited code: Requires comment 1.</param>
        /// <param name="e">Inherited code: Requires comment 2.</param>
        private void Calendar_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            Debug.Assert(sender is Calendar, "The sender should be a Calendar!");

            RectangleGeometry rg = new RectangleGeometry();
            rg.Rect = new Rect(0, 0, e.NewSize.Width, e.NewSize.Height);

            if (Root != null)
            {
                Root.Clip = rg;
            }
        }
Пример #25
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Size size = base.ArrangeOverride(finalSize);
            RectangleGeometry visibleArea = new RectangleGeometry();
            Rect clip = new Rect(0, 0, ItemsPresenter.ActualWidth, ItemsPresenter.ActualHeight);
            foreach (CoverFlowItem item in items)
            {
                item.Height = ItemsPresenter.ActualHeight;
            }
            visibleArea.Rect = clip;
            ItemsPresenter.Clip = visibleArea;

            double m = ItemsPresenter.ActualWidth / 2;

            for (int index = 0; index < items.Count; index++)
            {
                CoverFlowItem item = items[index];
                int b = index - SelectedIndex;
                double mu = 0;
                if (b < 0)
                    mu = -1;
                else if (b > 0)
                    mu = 1;
                double x = (m + ((double)b * l + (k * mu))) - (item.ActualWidth / 2);

                double s = mu == 0 ? 1 : Scale;

                int zindex = items.Count - Math.Abs(b);

                item.X = x;
                item.YRotation = r * mu;
                item.ZOffset = z * Math.Abs(mu);
                item.Scale = s;
            }

            return size;
        }
Пример #26
0
 //model change and refresh canvas
 private void RefreshCanvas()
 {
     //創造一個矩形範圍
     RectangleGeometry myRectangleGeometry = new RectangleGeometry();
     //設定矩形大小
     myRectangleGeometry.Rect = new Rect(0, 0, _canvas.ActualWidth, _canvas.ActualHeight);
     //畫布超出矩形大小的都會被截掉
     _canvas.Clip = myRectangleGeometry;
     IGraphics graphics = new WindowsStoreGraphics(_canvas);
     _pModel.DrawShapes(graphics);
 }
 private void OnSizeChanged(object sender, SizeChangedEventArgs sizeChangedEventArgs)
 {
     RippleSize = Math.Max(sizeChangedEventArgs.NewSize.Width, sizeChangedEventArgs.NewSize.Height) * RippleSizeMultiplier;
     Clip = new RectangleGeometry { Rect = new Windows.Foundation.Rect(0, 0, sizeChangedEventArgs.NewSize.Width, sizeChangedEventArgs.NewSize.Height) };
 }
Пример #28
0
 /// <summary>
 /// Handler for SizeChanged event, handles cliping
 /// </summary>
 private void RefreshableListView_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     Clip = new RectangleGeometry()
     {
         Rect = new Rect(0, 0, e.NewSize.Width, e.NewSize.Height)
     };
 }
Пример #29
0
		static void AddNativeControls (NestedNativeControlGalleryPage page)
		{
			if (page.NativeControlsAdded) {
				return;
			}

			StackLayout sl = page.Layout;

			// Create and add a native TextBlock
			var originalText = "I am a native TextBlock";
			var textBlock = new TextBlock {
				Text = originalText,
				FontSize = 14,
				FontFamily = new FontFamily ("HelveticaNeue")
			};

			sl?.Children.Add (textBlock);

			// Create and add a native Button 
			var button = new global::Windows.UI.Xaml.Controls.Button { Content = "Click to toggle font size", Height = 80 };
			button.Click += (sender, args) => { textBlock.FontSize = textBlock.FontSize == 14 ? 24 : 14; };

			sl?.Children.Add (button.ToView ());

			// Create a control which we know doesn't behave correctly with regard to measurement
			var difficultControl = new BrokenNativeControl {
				Text = "Not Sized/Arranged Properly"
			};

			var difficultControl2 = new BrokenNativeControl {
				Text = "Fixed"
			};

			// Add the misbehaving controls, one with a custom delegate for ArrangeOverrideDelegate
			sl?.Children.Add (difficultControl);
			sl?.Children.Add (difficultControl2,
				arrangeOverrideDelegate: (renderer, finalSize) => {
					if (finalSize.Width <= 0 || double.IsInfinity (finalSize.Width)) {
						return null;
					}

					FrameworkElement frameworkElement = renderer.Control;

					frameworkElement.Measure (finalSize);

					// The broken control tries sizes itself to be the width of the screen
					var wrongSize = Window.Current.Bounds.Width * (int)DisplayProperties.ResolutionScale / 100;

					// We can re-center it by offsetting it during the Arrange call
					double diff = Math.Abs(finalSize.Width - wrongSize) / -2;
					frameworkElement.Arrange (new Rect (diff, 0, finalSize.Width - diff, finalSize.Height));

					// Arranging the control to the left will make it show up past the edge of the stack layout
					// We can fix that by clipping it manually
					var clip = new RectangleGeometry { Rect = new Rect (-diff, 0, finalSize.Width, finalSize.Height) };
					frameworkElement.Clip = clip;

					return finalSize;
				}
			);

			page.NativeControlsAdded = true;
		}
        void OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (Orientation == Orientation.Vertical)
                _centeringTransform.Y = Math.Round(e.NewSize.Height / 2);
            else
                _centeringTransform.X = Math.Round(e.NewSize.Width / 2);

            Clip = new RectangleGeometry() { Rect = new Rect(0, 0, e.NewSize.Width, e.NewSize.Height) };
            UpdateData();
        }
Пример #31
0
        private void Rebuild()
        {
            var bmp = ImageSource as BitmapSource;
            if (bmp == null)
            {
                return;
            }

            var width = bmp.PixelWidth;
            var height = bmp.PixelHeight;

            if (width == 0 || height == 0)
            {
                return;
            }

            if (ActualWidth == 0 || ActualHeight == 0)
            {
                return;
            }

            double currentTiledWidth = -1;
            double currentTiledHeight = -1;
            foreach (var child in this.Children.ToList().Where(c => c is Image).Cast<Image>())
            {
                int childTop = (int)Canvas.GetTop(child);
                int childLeft = (int)Canvas.GetLeft(child);
                if (childLeft >= ActualWidth)
                {
                    Children.Remove(child);
                }
                else if (childTop >= ActualHeight)
                {
                    Children.Remove(child);
                }
                else
                {
                    if (childLeft > currentTiledWidth) currentTiledWidth = childLeft;
                    if (childTop > currentTiledHeight) currentTiledHeight = childTop;
                }
            }

            for (int x = 0; x < ActualWidth; x += width)
            {
                for (int y = 0; y < ActualHeight; y += height)
                {
                    if (x > currentTiledWidth || y > currentTiledHeight)
                    {
                        var image = new Image { Source = ImageSource };
                        Canvas.SetLeft(image, x);
                        Canvas.SetTop(image, y);
                        Children.Add(image);
                    }
                }
            }
            Clip = new RectangleGeometry { Rect = new Rect(0, 0, ActualWidth, ActualHeight) };
        }
 /// <summary>
 /// Initializes a new instance of the DataPointSeries class.
 /// </summary>
 protected DataPointSeries()
 {
     this.DefaultStyleKey = typeof(DataPointSeries);
     ClipGeometry = new RectangleGeometry();
     Clip = ClipGeometry;
 }
        protected override Size MeasureOverride(Size availableSize)
        {
            var maxItemHeight = 0d;
            var size = base.MeasureOverride(availableSize);
            Clip = new RectangleGeometry { Rect = new Rect(0, 0, size.Width, size.Height) };

            foreach (var container in Children)
            {
                container.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

                if (container.DesiredSize.Height > maxItemHeight)
                {
                    maxItemHeight = container.DesiredSize.Height;
                }

                if (_itemWidth != container.DesiredSize.Width)
                {
                    _itemWidth = container.DesiredSize.Width;
                }
            }
            size.Height = maxItemHeight;
            return (size);
        }