partial         void Initialize()
        {
            Background = new SolidColorBrush(Colors.Transparent);
            Clip = new RectangleGeometry();

            SizeChanged += OnRenderSizeChanged;
        }
예제 #2
0
        public static void UpdateClipSize(FrameworkElement element, Size clipSize)
        {
            if (element != null)
            {
                RectangleGeometry clipRectangle = null;

                if (element.Clip == null)
                {
                    clipRectangle = new RectangleGeometry();
                    element.Clip = clipRectangle;
                }
                else
                {
                    if (element.Clip is RectangleGeometry)
                    {
                        clipRectangle = (RectangleGeometry)element.Clip;
                    }
                }

                if (clipRectangle != null)
                {
                    clipRectangle.Rect = new Rect(new Point(0, 0), clipSize);
                }
            }
        }
예제 #3
0
            override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            PaneClipRectangle = (RectangleGeometry)GetTemplateChild("PaneClipRectangle");
            PaneClipRectangle.Rect = new Rect(0, 0, OpenPaneLength, ActualHeight);

            LightDismissLayer = (Rectangle)GetTemplateChild("LightDismissLayer");
#if SILVERLIGHT
            LightDismissLayer.Tap += OnLightDismiss;
#else
            LightDismissLayer.PointerPressed += OnLightDismiss;
#endif
        }
예제 #4
0
            override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            ContentDragTransform = (TranslateTransform)GetTemplateChild("ContentDragTransform");
            LeftTransform = (TranslateTransform)GetTemplateChild("LeftTransform");
            RightTransform = (TranslateTransform)GetTemplateChild("RightTransform");

            LeftContainer = (Border)GetTemplateChild("LeftContainer");
            RightContainer = (Border)GetTemplateChild("RightContainer");

            DragBackground = (Grid)GetTemplateChild("DragBackground");
            DragClip = (RectangleGeometry)GetTemplateChild("DragClip");
            DragClipTransform = (TranslateTransform)GetTemplateChild("DragClipTransform");
            DragContainer = (Border)GetTemplateChild("DragContainer");
        }
partial         void Initialize()
        {
            // set Background by Style to enable resetting by ClearValue in RemoveTileLayers
            var style = new Style(typeof(MapBase));
            style.Setters.Add(new Setter(Panel.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
            Style = style;

            var clip = new RectangleGeometry();
            Clip = clip;

            SizeChanged += (s, e) =>
            {
                clip.Rect = new Rect(new Point(), e.NewSize);
                ResetTransformOrigin();
                UpdateTransform();
            };
        }
예제 #6
0
		public override void OnApplyTemplate()
#endif
		{
			base.OnApplyTemplate();

			ApplyPlatformFeatures();

			_horizontalThumb = GetTemplateChild(HorizontalThumbName) as Thumb;
			_horizontalTrack = GetTemplateChild(HorizontalTrackName) as Rectangle;
			_horizontalFill = GetTemplateChild(HorizontalFillName) as Rectangle;
			_horizontalRectangleGeometry = GetTemplateChild(HorizontalRectangleGeometryName) as RectangleGeometry;
			_horizontalThumbTranslateTransform = GetTemplateChild(HorizontalThumbTranslateTransformName) as TranslateTransform;

			SyncValueAndPosition(Value, Value);

			_isLayoutInit = true;
		}
예제 #7
0
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();

			var listener = GestureService.GetGestureListener(this);
			listener.PinchStarted += OnPinchStarted;
			listener.PinchDelta += OnPinchDelta;
			listener.DragDelta += OnDragDelta;			
#endif

			content = (ContentPresenter)GetTemplateChild("content");
			if (content.Content == null)
				content.Content = Content;
			
			geometry = new RectangleGeometry();
			Clip = geometry;

			SizeChanged += delegate { UpdateGeometry(); };
			UpdateGeometry();
		}
예제 #8
0
 public MapRectangle()
 {
     Data = new RectangleGeometry();
     StrokeThickness = 0d;
 }
        protected override void OnRender(DrawingContext dc)
        {
            // setup clipping
            RectangleGeometry clip_area = new RectangleGeometry(new Rect(0, 0, RenderSize.Width, RenderSize.Height));

            dc.PushClip(clip_area);


            Pen pen = new Pen(Stroke, StrokeThickness);

            dc.DrawRectangle(Background, pen, new Rect(0, 0, RenderSize.Width, RenderSize.Height));

            Typeface tf = GetTypeface();

            string path = GetTrimmedPath(RenderSize.Width, tf);


            // draw tick value
            FormattedText ft;

            if (!string.IsNullOrEmpty(FilePath))
            {
                ft = new FormattedText(path, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, tf, FontSize, Foreground);

                // Draw the text at a location
                double x = 0, y = 0;

                switch (VerticalAlignment)
                {
                case System.Windows.VerticalAlignment.Top:
                    y = 0;
                    break;

                case System.Windows.VerticalAlignment.Center:
                    y = (RenderSize.Height - ft.Height) / 2;
                    break;

                case System.Windows.VerticalAlignment.Bottom:
                    y = RenderSize.Height - ft.Height;
                    break;
                }

                switch (HorizontalAlignment)
                {
                case System.Windows.HorizontalAlignment.Left:
                    x = 0;
                    break;

                case System.Windows.HorizontalAlignment.Center:
                    x = (RenderSize.Width - ft.Width) / 2;
                    break;

                case System.Windows.HorizontalAlignment.Right:
                    x = RenderSize.Width - ft.Width;
                    break;
                }

                dc.DrawText(ft, new Point(x, y));
            }

            dc.Pop();
        }
예제 #10
0
        public void Setup()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
//      ListPickerItemsUC.<>c__DisplayClass35_0 cDisplayClass350 = new ListPickerItemsUC.<>c__DisplayClass35_0();
            // ISSUE: reference to a compiler-generated field
//      cDisplayClass350.<>4__this = this;
            if (this.ItemTemplate != null)
            {
                this.listBox.ItemTemplate = this.ItemTemplate;
            }
            this.listBox.ItemsSource = ((IList)this.ItemsSource);
            // ISSUE: reference to a compiler-generated field
            int    selectedIndex = this.ItemsSource.IndexOf(this.SelectedItem);
            double val2          = 13.0 + (double)this.ItemsSource.Count * 64.0 + 27.0;
            double num           = this.PickerMaxHeight > 0.0 ? Math.Min(this.PickerMaxHeight, val2) : val2;
            double pickerWidth   = this.PickerWidth;
            Point  showPosition1 = this.ShowPosition;

            // ISSUE: explicit reference operation
            this._verticalOffset = ((Point)@showPosition1).Y;
            // ISSUE: reference to a compiler-generated field
            if (selectedIndex > -1)
            {
                this.listBox.SizeChanged += (delegate(object o, SizeChangedEventArgs eventArgs)
                {
                    this.listBox.SelectedItem = (this.ItemsSource[selectedIndex]);
                    this.ScrollToSelectedItem(selectedIndex);
                });
                this._verticalOffset -= 64.0;
            }
            if (this._verticalOffset < 40.0)
            {
                this._verticalOffset = 40.0;
            }
            else if (this._verticalOffset + num > this.ParentElement.ActualHeight - 16.0)
            {
                this._verticalOffset = this._verticalOffset - (this._verticalOffset + num - this.ParentElement.ActualHeight + 16.0);
            }
            ((FrameworkElement)this.containerGrid).Height = num;
            ((FrameworkElement)this.containerGrid).Width  = pickerWidth;
            Grid  containerGrid = this.containerGrid;
            Point showPosition2 = this.ShowPosition;
            // ISSUE: explicit reference operation
            Thickness thickness = new Thickness(((Point)@showPosition2).X, this._verticalOffset, 0.0, 0.0);

            ((FrameworkElement)containerGrid).Margin = thickness;
            Point showPosition3 = this.ShowPosition;

            // ISSUE: explicit reference operation
            this.scaleTransform.CenterY = (((Point)@showPosition3).Y - this._verticalOffset);
            RectangleGeometry rectGeometry = this.rectGeometry;
            Rect rect1 = new Rect();

            // ISSUE: explicit reference operation
            rect1.X = 0.0;
            // ISSUE: explicit reference operation
            rect1.Y = 0.0;
            // ISSUE: explicit reference operation
            rect1.Height = num;
            // ISSUE: explicit reference operation
            rect1.Width = pickerWidth;
            Rect rect2 = rect1;

            rectGeometry.Rect = rect2;
        }
예제 #11
0
 private static RectangleGeometry CreateRectGeometry(Rect rect)
 {
     RectangleGeometry result = new RectangleGeometry();
     result.Rect = rect;
     return result;
 }
예제 #12
0
        private void UpdateDrawerClip(bool refresh, RectangleGeometry oldGeometry)
        {
            double clipOffset = 0;

            if (this.DrawerTransition == DrawerTransition.SlideAlong)
            {
                if (this.DrawerLocation == DrawerLocation.Left)
                {
                    clipOffset = Canvas.GetLeft(this.drawer);
                }
                else if (this.DrawerLocation == DrawerLocation.Top)
                {
                    clipOffset = Canvas.GetTop(this.drawer);
                }
            }

            double currentLength;

            switch (this.DrawerLocation)
            {
            case DrawerLocation.Left:
                if (oldGeometry == null)
                {
                    return;
                }
                else
                {
                    currentLength = refresh ? oldGeometry.Bounds.Width : Math.Max(this.DrawerClip - clipOffset, 0);
                }

                this.drawer.Clip = new RectangleGeometry()
                {
                    Rect = new Windows.Foundation.Rect(0, 0, currentLength, this.drawer.Height)
                };
                break;

            case DrawerLocation.Right:

                this.drawer.Clip = new RectangleGeometry()
                {
                    Rect = new Windows.Foundation.Rect(this.DrawerClip, 0, this.drawer.Width, this.drawer.Height)
                };
                break;

            case DrawerLocation.Top:
                if (oldGeometry == null)
                {
                    return;
                }
                else
                {
                    currentLength = refresh ? oldGeometry.Bounds.Height : Math.Max(this.DrawerClip - clipOffset, 0);
                }
                this.drawer.Clip = new RectangleGeometry()
                {
                    Rect = new Windows.Foundation.Rect(0, 0, this.drawer.Width, currentLength)
                };
                break;

            case DrawerLocation.Bottom:
                this.drawer.Clip = new RectangleGeometry()
                {
                    Rect = new Windows.Foundation.Rect(0, this.DrawerClip, this.drawer.Width, this.drawer.Height)
                };
                break;
            }
        }
        public void InfoBadgeSupportsAllIconTypes()
        {
            InfoBadge          infoBadge          = null;
            SymbolIconSource   symbolIconSource   = null;
            PathIconSource     pathIconSource     = null;
            AnimatedIconSource animatedIconSource = null;
            BitmapIconSource   bitmapIconSource   = null;
            ImageIconSource    imageIconSource    = null;
            FontIconSource     fontIconSource     = null;

            RunOnUIThread.Execute(() =>
            {
                infoBadge               = new InfoBadge();
                symbolIconSource        = new SymbolIconSource();
                symbolIconSource.Symbol = Symbol.Setting;

                fontIconSource            = new FontIconSource();
                fontIconSource.Glyph      = "99+";
                fontIconSource.FontFamily = new FontFamily("XamlAutoFontFamily");

                bitmapIconSource = new BitmapIconSource();
                bitmapIconSource.ShowAsMonochrome = false;
                Uri bitmapUri = new Uri("ms-appx:/Assets/ingredient1.png");
                bitmapIconSource.UriSource = bitmapUri;

                imageIconSource             = new ImageIconSource();
                var imageUri                = new Uri("https://raw.githubusercontent.com/DiemenDesign/LibreICONS/master/svg-color/libre-camera-panorama.svg");
                imageIconSource.ImageSource = new SvgImageSource(imageUri);

                pathIconSource = new PathIconSource();
                var geometry   = new RectangleGeometry();
                geometry.Rect  = new Windows.Foundation.Rect {
                    Width = 5, Height = 2, X = 0, Y = 0
                };
                pathIconSource.Data = geometry;

                animatedIconSource        = new AnimatedIconSource();
                animatedIconSource.Source = new AnimatedSettingsVisualSource();

                Content = infoBadge;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Log.Comment("Switch to Symbol Icon");
                infoBadge.IconSource = symbolIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Path Icon");
                infoBadge.IconSource = pathIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Font Icon");
                infoBadge.IconSource = fontIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to bitmap Icon");
                infoBadge.IconSource = bitmapIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Image Icon");
                infoBadge.IconSource = imageIconSource;
                Content.UpdateLayout();

                Log.Comment("Switch to Animated Icon");
                infoBadge.IconSource = animatedIconSource;
                Content.UpdateLayout();
            });
        }
예제 #14
0
        private void DrawHallways(int tileSize, int hallwaySize)
        {
            // Create a path for drawing the hallways
            Path hallwayPath = new Path();

            hallwayPath.Stroke          = Brushes.Black;
            hallwayPath.StrokeThickness = 1;
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            mySolidColorBrush.Color = Colors.White;
            hallwayPath.Fill        = mySolidColorBrush;

            // Use a composite geometry for adding the hallways to
            CombinedGeometry hallwayGeometryGroup = new CombinedGeometry();

            hallwayGeometryGroup.GeometryCombineMode = GeometryCombineMode.Union;
            hallwayGeometryGroup.Geometry1           = null;
            hallwayGeometryGroup.Geometry2           = null;

            for (int top = 0; top < fpHeight; top++)
            {
                for (int left = 0; left < fpWidth; left++)
                {
                    if (fp.floorGrid[top, left] != null)
                    {
                        FloorSegment thisSegment = fp.floorGrid[top, left];

                        // If the segment above is in bounds and from a different group, we draw a hallway.
                        // Otherwise, if it's a different room of the same group, we draw a wall.

                        FloorSegment northSegment = fp.IsInBounds(top - 1, left) ? fp.floorGrid[top - 1, left] : null;
                        if (northSegment != null)
                        {
                            if (northSegment.GroupID != thisSegment.GroupID)
                            {
                                RectangleGeometry newHallwayGeometry = new RectangleGeometry(
                                    new Rect(
                                        (left * tileSize) - (hallwaySize / 2),
                                        (top * tileSize) - (hallwaySize / 2),
                                        tileSize + hallwaySize,
                                        hallwaySize));
                                hallwayGeometryGroup = new CombinedGeometry()
                                {
                                    Geometry1 = hallwayGeometryGroup,
                                    Geometry2 = newHallwayGeometry
                                };
                            }
                        }

                        FloorSegment southSegment = fp.IsInBounds(top + 1, left) ? fp.floorGrid[top + 1, left] : null;
                        if (southSegment != null)
                        {
                            if (southSegment.GroupID != thisSegment.GroupID)
                            {
                                RectangleGeometry newHallwayGeometry = new RectangleGeometry(
                                    new Rect(
                                        (left * tileSize) - (hallwaySize / 2),
                                        ((top * tileSize) + tileSize) - (hallwaySize / 2),
                                        tileSize + hallwaySize,
                                        hallwaySize));
                                hallwayGeometryGroup = new CombinedGeometry()
                                {
                                    Geometry1 = hallwayGeometryGroup,
                                    Geometry2 = newHallwayGeometry
                                };
                            }
                        }

                        FloorSegment eastSegment = fp.IsInBounds(top, left + 1) ? fp.floorGrid[top, left + 1] : null;
                        if (eastSegment != null)
                        {
                            if (eastSegment.GroupID != thisSegment.GroupID)
                            {
                                RectangleGeometry newHallwayGeometry = new RectangleGeometry(
                                    new Rect(
                                        ((left * tileSize) + tileSize) - (hallwaySize / 2),
                                        (top * tileSize) - (hallwaySize / 2),
                                        hallwaySize,
                                        tileSize + hallwaySize));
                                hallwayGeometryGroup = new CombinedGeometry()
                                {
                                    Geometry1 = hallwayGeometryGroup,
                                    Geometry2 = newHallwayGeometry
                                };
                            }
                        }

                        FloorSegment westSegment = fp.IsInBounds(top, left - 1) ? fp.floorGrid[top, left - 1] : null;
                        if (westSegment != null)
                        {
                            if (westSegment.GroupID != thisSegment.GroupID)
                            {
                                RectangleGeometry newHallwayGeometry = new RectangleGeometry(
                                    new Rect(
                                        (left * tileSize) - (hallwaySize / 2),
                                        (top * tileSize) - (hallwaySize / 2),
                                        hallwaySize,
                                        tileSize + hallwaySize));
                                hallwayGeometryGroup = new CombinedGeometry()
                                {
                                    Geometry1 = hallwayGeometryGroup,
                                    Geometry2 = newHallwayGeometry
                                };
                            }
                        }
                    }
                }
            }
            hallwayPath.Data = hallwayGeometryGroup;
            RenderOptions.SetEdgeMode(hallwayPath, EdgeMode.Aliased);
            MainCanvas.Children.Add(hallwayPath);

            // Draw the remaining eligible segments
            if (fp.pause)
            {
                foreach (DirectionalSegment ds in fp.eligibleFloorSegments)
                {
                    Rectangle newRect = new Rectangle()
                    {
                        Width           = tileSize,
                        Height          = tileSize,
                        Stroke          = Brushes.Black,
                        StrokeThickness = 1
                    };
                    MainCanvas.Children.Add(newRect);
                    Canvas.SetLeft(newRect, ds.Left * tileSize);
                    Canvas.SetTop(newRect, ds.Top * tileSize);
                }
            }
            // Signal the algorithm to continue
            fp.waitEvent.Set();
            labelCountRoom.Content = fp.currRoomID.ToString();
        }
예제 #15
0
        public void RenderRectangle(Rect rectangle, Brush foreground)
        {
            var rectangleGeometry = new RectangleGeometry(GeometryHelper.ScaleRectangle(_scale, rectangle));

            _geometry.Children.Add(rectangleGeometry);
        }
예제 #16
0
 private void UpdateUI()
 {
     rectGeometry = new RectangleGeometry(new Rect(new Size(XSize, YSize / 2)));
 }
예제 #17
0
        private void DrawDoors(int tileSize, int hallwaySize)
        {
            // Create a path for drawing the hallways
            Path doorsPath = new Path();

            doorsPath.Stroke          = Brushes.Black;
            doorsPath.StrokeThickness = 1;
            SolidColorBrush mySolidColorBrush = new SolidColorBrush();

            mySolidColorBrush.Color = Colors.Black;
            doorsPath.Fill          = mySolidColorBrush;

            // Use a composite geometry for adding the doors to
            CombinedGeometry doorsGeometryGroup = new CombinedGeometry();

            doorsGeometryGroup.GeometryCombineMode = GeometryCombineMode.Union;
            doorsGeometryGroup.Geometry1           = null;
            doorsGeometryGroup.Geometry2           = null;

            for (int top = 0; top < fpHeight; top++)
            {
                for (int left = 0; left < fpWidth; left++)
                {
                    if (fp.floorGrid[top, left] != null)
                    {
                        FloorSegment thisSegment = fp.floorGrid[top, left];
                        double       doorX       = 0;
                        double       doorY       = 0;
                        double       doorWidth   = 0;
                        double       doorHeight  = 0;
                        // position the doors differently depending on weather or not there's a hallway.  Math, bitches.
                        foreach (enumDirection nextDoorDir in thisSegment.Doors)
                        {
                            switch (nextDoorDir)
                            {
                            case enumDirection.North:
                                FloorSegment northSegment = fp.IsInBounds(top - 1, left) ? fp.floorGrid[top - 1, left] : null;
                                doorX      = (left * tileSize) + (tileSize / 2) - (hallwaySize / 2);
                                doorY      = northSegment != null ? northSegment.GroupID != thisSegment.GroupID ? (top * tileSize) + (hallwaySize / 4) : (top * tileSize) - (hallwaySize / 4) : (top * tileSize) - (hallwaySize / 4);
                                doorWidth  = hallwaySize;
                                doorHeight = hallwaySize / 2;
                                break;

                            case enumDirection.South:
                                FloorSegment southSegment = fp.IsInBounds(top + 1, left) ? fp.floorGrid[top + 1, left] : null;
                                doorX      = (left * tileSize) + (tileSize / 2) - (hallwaySize / 2);
                                doorY      = southSegment != null ? southSegment.GroupID != thisSegment.GroupID ? ((top * tileSize) + tileSize) - ((hallwaySize / 4) * 3) : ((top * tileSize) + tileSize) - (hallwaySize / 4) : ((top * tileSize) + tileSize) - (hallwaySize / 4);
                                doorWidth  = hallwaySize;
                                doorHeight = hallwaySize / 2;
                                break;

                            case enumDirection.East:
                                FloorSegment eastSegment = fp.IsInBounds(top, left + 1) ? fp.floorGrid[top, left + 1] : null;
                                doorX      = eastSegment != null ? eastSegment.GroupID != thisSegment.GroupID ? ((left * tileSize) + tileSize) - ((hallwaySize / 4) * 3) : ((left * tileSize) + tileSize) - (hallwaySize / 4) : ((left * tileSize) + tileSize) - (hallwaySize / 4);
                                doorY      = (top * tileSize) + (tileSize / 2) - (hallwaySize / 2);
                                doorWidth  = hallwaySize / 2;
                                doorHeight = hallwaySize;
                                break;

                            case enumDirection.West:
                                FloorSegment westSegment = fp.IsInBounds(top, left - 1) ? fp.floorGrid[top, left - 1] : null;
                                doorX      = westSegment != null ? westSegment.GroupID != thisSegment.GroupID ? (left * tileSize) + (hallwaySize / 4) : (left * tileSize) - (hallwaySize / 4) : (left * tileSize) - (hallwaySize / 4);
                                doorY      = (top * tileSize) + (tileSize / 2) - (hallwaySize / 2);
                                doorWidth  = hallwaySize / 2;
                                doorHeight = hallwaySize;
                                break;
                            }
                            RectangleGeometry newDoorGeometry = new RectangleGeometry(new Rect(doorX, doorY, doorWidth, doorHeight));
                            doorsGeometryGroup = new CombinedGeometry()
                            {
                                Geometry1 = doorsGeometryGroup,
                                Geometry2 = newDoorGeometry
                            };
                        }
                    }
                }
            }

            doorsPath.Data = doorsGeometryGroup;
            RenderOptions.SetEdgeMode(doorsPath, EdgeMode.Aliased);
            MainCanvas.Children.Add(doorsPath);
        }
예제 #18
0
        /// <summary>
        /// Get visual object for CandleStick chart
        /// </summary>
        /// <param name="width">Width of the chart</param>
        /// <param name="height">Height of the chart</param>
        /// <param name="plotDetails">plotDetails</param>
        /// <param name="seriesList">List of DataSeries</param>
        /// <param name="chart">Chart</param>
        /// <param name="plankDepth">Plank depth</param>
        /// <param name="animationEnabled">Whether animation is enabled</param>
        /// <returns>CandleStick chart canvas</returns>
        internal static Canvas GetVisualObjectForCandleStick(Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, List <DataSeries> seriesList, Chart chart, Double plankDepth, bool animationEnabled)
        {
            // return new Canvas() { Background = Graphics.GetRandonColor() , Width = width, Height = height};

            if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0)
            {
                return(null);
            }

            Canvas visual, labelCanvas, candleStickCanvas;

            RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out candleStickCanvas, width, height);

            Double depth3d      = plankDepth / (plotDetails.Layer3DCount == 0 ? 1 : plotDetails.Layer3DCount) * (chart.View3D ? 1 : 0);
            Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[seriesList[0]] + 1 - (plotDetails.Layer3DCount == 0 ? 0 : 1));

            visual.SetValue(Canvas.TopProperty, visualOffset);
            visual.SetValue(Canvas.LeftProperty, -visualOffset);

            Double     animationBeginTime = 0;
            DataSeries _tempDataSeries    = null;

            // Calculate width of a DataPoint
            Double dataPointWidth = CalculateDataPointWidth(width, height, chart);

            foreach (DataSeries series in seriesList)
            {
                if (series.Enabled == false)
                {
                    continue;
                }

                Faces dsFaces = new Faces()
                {
                    Visual = candleStickCanvas, LabelCanvas = labelCanvas
                };
                series.Faces = dsFaces;

                PlotGroup plotGroup = series.PlotGroup;
                _tempDataSeries = series;

                foreach (DataPoint dataPoint in series.InternalDataPoints)
                {
                    CreateOrUpdateACandleStick(dataPoint, candleStickCanvas, labelCanvas, width, height, dataPointWidth);
                }

                // Apply animation to series
                if (animationEnabled)
                {
                    if (_tempDataSeries.Storyboard == null)
                    {
                        _tempDataSeries.Storyboard = new Storyboard();
                    }

                    _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(candleStickCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1);
                    animationBeginTime        += 0.5;
                }
            }

            // Label animation
            if (animationEnabled && _tempDataSeries != null)
            {
                _tempDataSeries.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, _tempDataSeries, _tempDataSeries.Storyboard, animationBeginTime, 1, 0, 1);
            }

            candleStickCanvas.Tag = null;

            // ColumnChart.CreateOrUpdatePlank(chart, seriesList[0].PlotGroup.AxisY, candleStickCanvas, depth3d, Orientation.Horizontal);

            // Remove old visual and add new visual in to the existing panel
            if (preExistingPanel != null)
            {
                visual.Children.RemoveAt(1);
                visual.Children.Add(candleStickCanvas);
            }
            else
            {
                labelCanvas.SetValue(Canvas.ZIndexProperty, 1);
                visual.Children.Add(labelCanvas);
                visual.Children.Add(candleStickCanvas);
            }

            RectangleGeometry clipRectangle = new RectangleGeometry();

            clipRectangle.Rect = new Rect(0, -chart.ChartArea.PLANK_DEPTH, width + chart.ChartArea.PLANK_OFFSET, height + chart.ChartArea.PLANK_DEPTH);
            visual.Clip        = clipRectangle;

            return(visual);

            // visual.Children.Add(candleStickCanvas);
            // visual.Children.Add(labelCanvas);

            // return visual;
        }
        private void SetImageDefault(ImageInfo imageInfo)
        {
            try
            {
                bi    = new CreateBitmapImage().BitmapImageShow(ImageInfo.Image_FullPath, 0);
                image = new Image()
                {
                    Source = bi
                };

                //Control Image (X,Y)
                double imageStartX = 0;
                double imageStartY = 0;

                if (bi.PixelHeight < Cvs.ActualHeight && bi.PixelWidth < Cvs.ActualWidth)
                {
                    heightRatio     = 1;
                    widthRatio      = 1;
                    image.MaxHeight = bi.PixelHeight;
                    image.Height    = image.MaxHeight;
                    image.MaxWidth  = bi.PixelWidth;
                    image.Width     = image.MaxWidth;
                    imageStartX     = (Cvs.ActualWidth - bi.PixelWidth) / 2;
                    imageStartY     = (Cvs.ActualHeight - bi.PixelHeight) / 2;
                }
                else
                {
                    //Canvas 的寬高關係
                    if (Cvs.ActualWidth > Cvs.ActualHeight)
                    {
                        //高的比例
                        heightRatio = Cvs.ActualHeight / bi.PixelHeight;
                        //高填滿
                        image.MaxHeight = Cvs.ActualHeight;
                        image.Height    = image.MaxHeight;
                        //計算寬比例
                        image.Width = bi.PixelWidth * heightRatio;

                        //如果圖片是橫的 但是寬度超過CVS
                        if (image.Width > Cvs.ActualWidth)
                        {
                            widthRatio     = Cvs.ActualWidth / bi.PixelWidth;
                            image.MaxWidth = Cvs.ActualWidth;
                            image.Width    = image.MaxWidth;
                            image.Height   = bi.PixelHeight * widthRatio;

                            //Image 起始座標 高度置中
                            imageStartX = 0;
                            imageStartY = (Cvs.ActualHeight - image.Height) / 2;
                        }
                        else
                        {
                            //Image 起始座標 寬度置中
                            imageStartX = (Cvs.ActualWidth - image.Width) / 2;
                            imageStartY = 0;
                        }
                    }
                    else
                    {
                        //寬的比例
                        widthRatio = Cvs.ActualWidth / bi.PixelWidth;
                        //寬填滿
                        image.MaxWidth = Cvs.ActualWidth;
                        image.Width    = ActualWidth;
                        //計算高比例
                        image.Height = bi.PixelHeight * widthRatio;
                        if (image.Height > Cvs.ActualHeight)
                        {
                            heightRatio     = Cvs.ActualHeight / bi.PixelHeight;
                            image.MaxHeight = Cvs.ActualHeight;
                            image.Height    = image.MaxHeight;
                            image.Width     = bi.PixelWidth * heightRatio;

                            //Image 起始座標 寬度置中
                            imageStartX = (Cvs.ActualWidth - image.Width) / 2;
                            imageStartY = 0;
                        }
                        else
                        {
                            //Image 起始座標 高度置中
                            imageStartX = 0;
                            imageStartY = (Cvs.ActualHeight - image.Height) / 2;
                        }
                    }
                }

                Cvs.Children.Add(image);

                Canvas.SetTop(image, imageStartY);
                Canvas.SetLeft(image, imageStartX);

                //CombinedGeometry.Geometry1 Setting
                //包圍Image的Rect(反灰)
                RectangleGeometry rectangleGeometry = new RectangleGeometry(new Rect(0, 0, Cvs.ActualWidth, Cvs.ActualHeight));

                rect2 = new Rect(imageStartX, imageStartY, image.Width, image.Height);
                //CombinedGeometry.Geometry2 Setting
                //包圍Image的Rect(透明區)初始與圖片一樣
                rectangleGeometry2 = new RectangleGeometry(rect2);

                //Path 的 CombinedGeometry
                combinedGeometry = new CombinedGeometry()
                {
                    GeometryCombineMode = GeometryCombineMode.Xor,
                    Geometry1           = rectangleGeometry,
                    Geometry2           = rectangleGeometry2
                };

                //建立Rect 覆蓋Image
                path = new Path
                {
                    Fill = (Brush)(new BrushConverter().ConvertFromString("#AA000000")),
                    Data = combinedGeometry
                };

                Cvs.Children.Add(path);

                ButtonSave.IsEnabled = false;
                ButtonUndo.IsEnabled = false;

                RotateAngle.Value = 0;
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorMessageOutput(ex.ToString());
            }
        }
예제 #20
0
        /// <summary>
        /// Geomtries are created, a tube icon is added to the geometries. Patient is in
        /// a flat lying position in this facility. Staff is displayed  on the bottom of the facility
        /// </summary>
        /// <param name="correspondingEntity">Treatment facility the drawing object represents</param>
        /// <param name="startPosition">Position where the treatment facility should be drawn</param>
        /// <param name="size">Size of treatment facility</param>
        /// <param name="personSize">Height used to visualize persons</param>
        /// <param name="color">Color in which the facility should be displayed</param>
        public DrawMRICTFacility(Entity correspondingEntity,
                                 Point startPosition,
                                 Size size,
                                 double personSize,
                                 Color color)
            : base(correspondingEntity, startPosition, size, personSize, color)
        {
            double lineSize = personSize / 15;

            _patientPositionType = PatientPositionInRoomType.FlatLying;

            Point origin = new Point(0, 0);

            GeometryGroup geometries = new GeometryGroup();

            // outline
            geometries.Children.Add(Geometry.Combine(new RectangleGeometry(new Rect(origin, size), lineSize, lineSize),
                                                     new RectangleGeometry(new Rect(origin + new Vector(lineSize, lineSize), new Size(size.Width - 2 * lineSize, size.Height - 2 * lineSize)), lineSize, lineSize),
                                                     GeometryCombineMode.Exclude,
                                                     Transform.Identity));

            // bed
            GeometryGroup bed = new GeometryGroup();

            bed.FillRule = FillRule.Nonzero;

            Point bedStart = origin + new Vector(origin.X + personSize / 1.5 + lineSize, personSize * 1.6);

            bed.Children.Add(new RectangleGeometry(new Rect(bedStart, new Size(personSize - lineSize, lineSize)), lineSize / 2, lineSize / 2));

            geometries.Children.Add(bed);

            // tube

            EllipseGeometry tubeBig = new EllipseGeometry(bedStart + new Vector(personSize - lineSize, lineSize), personSize / 2, personSize / 2);

            EllipseGeometry tubeInner = new EllipseGeometry(bedStart + new Vector(personSize - lineSize, lineSize), personSize / 4, personSize / 4);

            PathGeometry tubeCutoutInner = Geometry.Combine(tubeBig, tubeInner, GeometryCombineMode.Exclude, Transform.Identity);

            RectangleGeometry rectCutout = new RectangleGeometry(new Rect(bedStart + new Vector(0.4 * personSize, -personSize / 10), new Size(personSize / 2, personSize / 2.8)));

            PathGeometry tube = Geometry.Combine(tubeCutoutInner, rectCutout, GeometryCombineMode.Exclude, Transform.Identity);

            geometries.Children.Add(tube);

            // monitor
            double monitorLineSize = lineSize / 2;
            Size   monitorSize     = new Size(personSize / 3, personSize / 4);

            Point monitorStart = bedStart - new Vector(0, personSize / 3);

            GeometryGroup monitor = new GeometryGroup();

            monitor.FillRule = FillRule.Nonzero;

            monitor.Children.Add(Geometry.Combine(new RectangleGeometry(new Rect(monitorStart + new Vector(-personSize / 2, personSize / 2), monitorSize), monitorLineSize, monitorLineSize),
                                                  new RectangleGeometry(new Rect(monitorStart + new Vector(-personSize / 2 + monitorLineSize, personSize / 2 + monitorLineSize), new Size(monitorSize.Width - 2 * monitorLineSize, monitorSize.Height - 2 * monitorLineSize)), monitorLineSize, monitorLineSize),
                                                  GeometryCombineMode.Exclude,
                                                  Transform.Identity));

            monitor.Children.Add(new RectangleGeometry(new Rect(monitorStart + new Vector(-personSize / 2 + monitorSize.Width / 2 - monitorLineSize / 2, monitorLineSize), new Size(monitorLineSize, personSize / 2 - monitorLineSize)), monitorLineSize, monitorLineSize));
            monitor.Children.Add(new RectangleGeometry(new Rect(monitorStart + new Vector(-personSize / 2 + monitorLineSize, 0), new Size(monitorSize.Width - 2 * monitorLineSize, monitorLineSize)), monitorLineSize, monitorLineSize));


            geometries.Children.Add(monitor);

            _staffStartPosition = new Point(origin.X + 2 * lineSize + personSize / 4, origin.Y + 2 * lineSize);

            _patientInRoomPosition = bedStart + new Vector(0, 1.5 * lineSize);

            _drawingShape.Data = geometries;
        } // end of Constructor
예제 #21
0
        private bool HitTestDrawing(GeometryDrawing drawing, Point pt)
        {
            Pen   pen   = drawing.Pen;
            Brush brush = drawing.Brush;

            if (pen != null && brush == null)
            {
                if (drawing.Geometry.StrokeContains(pen, pt))
                {
                    return(true);
                }
                else
                {
                    Geometry geometry = drawing.Geometry;

                    EllipseGeometry   ellipse   = null;
                    RectangleGeometry rectangle = null;
                    PathGeometry      path      = null;
                    if (TryCast.Cast(geometry, out ellipse))
                    {
                        if (ellipse.FillContains(pt))
                        {
                            return(true);
                        }
                    }
                    else if (TryCast.Cast(geometry, out rectangle))
                    {
                        if (rectangle.FillContains(pt))
                        {
                            return(true);
                        }
                    }
                    else if (TryCast.Cast(geometry, out path))
                    {
                        PathFigureCollection pathFigures = path.Figures;
                        int itemCount = pathFigures.Count;
                        if (itemCount == 1)
                        {
                            if (pathFigures[0].IsClosed && path.FillContains(pt))
                            {
                                return(true);
                            }
                        }
                        else
                        {
                            for (int f = 0; f < itemCount; f++)
                            {
                                PathFigure pathFigure = pathFigures[f];
                                if (pathFigure.IsClosed)
                                {
                                    PathFigureCollection testFigures = new PathFigureCollection();
                                    testFigures.Add(pathFigure);

                                    PathGeometry testPath = new PathGeometry();
                                    testPath.Figures = testFigures;

                                    if (testPath.FillContains(pt))
                                    {
                                        return(true);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (brush != null && drawing.Geometry.FillContains(pt))
            {
                return(true);
            }

            return(false);
        }
예제 #22
0
        public Geometry GetMarkerGeometry(Span span)
        {
            if (span == null)
            {
                throw new ArgumentNullException("span");
            }
            if ((span.Start < 0) || (span.End > _textView.TextBuffer.Length))
            {
                throw new ArgumentOutOfRangeException("span");
            }
            if (span.IsEmpty)
            {
                return(null);
            }
            PathGeometry geometry = new PathGeometry();

            geometry.FillRule = FillRule.Nonzero;
            IList <ITextLine> textLines = _textView.TextLines;

            if (textLines.Count == 0)
            {
                return(null);
            }
            if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
            {
                return(null);
            }
            ITextLine item = null;
            ITextLine textLineClosestTo = null;

            if (span.Start < base.FirstRenderedCharacter)
            {
                item = textLines[0];
            }
            if (span.End > base.LastRenderedCharacter)
            {
                textLineClosestTo = textLines[textLines.Count - 1];
            }
            if (item == null)
            {
                item = base.GetTextLineClosestTo(span.Start);
            }
            if (textLineClosestTo == null)
            {
                textLineClosestTo = base.GetTextLineClosestTo(span.End);
            }
            if (item == textLineClosestTo)
            {
                foreach (TextBounds bounds in item.GetTextBounds(span))
                {
                    RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
                    geometry2.Freeze();
                    geometry.AddGeometry(geometry2);
                }
            }
            else
            {
                foreach (TextBounds bounds2 in item.GetTextBounds(span))
                {
                    RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
                    geometry3.Freeze();
                    geometry.AddGeometry(geometry3);
                }
                Int32 num   = textLines.IndexOf(item) + 1;
                Int32 index = textLines.IndexOf(textLineClosestTo);
                for (Int32 i = num; i < index; i++)
                {
                    ITextLine         line3     = textLines[i];
                    RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
                    geometry4.Freeze();
                    geometry.AddGeometry(geometry4);
                }
                foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
                {
                    RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
                    geometry5.Freeze();
                    geometry.AddGeometry(geometry5);
                }
            }
            geometry.Freeze();
            return(geometry.GetOutlinedPathGeometry());
        }
예제 #23
0
        object drawPath(Point p)
        {
            double scaleX, scaleY;

            scaleX = scaleY = Zoom;
            Geometry geo = null;

            switch (CurrentShape)
            {
            case RoiShape.Polygon:
            {
                geo = new StreamGeometry();
                using (var ctx = ((StreamGeometry)geo).Open())
                {
                    Point t = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                    ctx.BeginFigure(t, true, false);
                    List <Point> data = new List <Point>();
                    for (int i = 1; i < PathPoints.Count; i++)
                    {
                        t = new Point(PathPoints[i].X * scaleX, PathPoints[i].Y * scaleY);
                        data.Add(t);
                    }
                    t = new Point(p.X, p.Y);
                    data.Add(t);
                    ctx.PolyLineTo(data, true, false);
                }
                geo.Freeze();
            }
            break;

            case RoiShape.Rectangle:
                if (PathPoints.Count == 1)
                {
                    Point t0 = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                    Point t1 = new Point(p.X, p.Y);
                    geo = new RectangleGeometry(new Rect(t0, t1));
                }
                //else if (PathPoints.Count == 3)
                //{
                //    Point t0 = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                //    Point t1 = new Point(PathPoints[1].X * scaleX, PathPoints[1].Y * scaleY);
                //    Point t2 = new Point(PathPoints[2].X * scaleX, PathPoints[2].Y * scaleY);
                //    Point center = new Point(Math.Abs(t0.X - t1.X), Math.Abs(t0.Y - t1.Y));
                //    center = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                //    double angle = Math.Atan2(t2.Y - center.Y, t2.X - center.X) * 180 / Math.PI;
                //    RotateTransform rotation = new RotateTransform(angle, t1.X, t1.Y);
                //    Rect = new RectangleGeometry(new Rect(t0, t1), center.X, center.Y, rotation);
                //}
                break;

            case RoiShape.Circle:
            {
                Point  t0     = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                Point  t1     = new Point(p.X, p.Y);
                Vector radius = new Vector();
                radius = t0 - t1;
                geo    = new EllipseGeometry(t0, radius.Length, radius.Length);
            }
            break;

            case RoiShape.Ellipse:
            {
                Point  t0; Point t1; Point t2;
                Vector radiusX = new Vector();
                Vector radiusY = new Vector();
                double angle;
                if (PathPoints.Count == 1)
                {
                    t0 = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                    t1 = new Point(p.X, p.Y);
                }
                else         //if (PathPoints.Count == 2)
                {
                    t0      = new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY);
                    t1      = new Point(PathPoints[1].X * scaleX, PathPoints[1].Y * scaleY);
                    t2      = new Point(p.X, p.Y);
                    radiusY = t0 - t2;
                }

                radiusX = t0 - t1;
                angle   = Math.Atan2(t1.Y - t0.Y, t1.X - t0.X) * 180 / Math.PI;

                RotateTransform Rotation = new RotateTransform(angle, t0.X, t0.Y);
                geo = new EllipseGeometry(new Point(PathPoints[0].X * scaleX, PathPoints[0].Y * scaleY), radiusX.Length, radiusY.Length, Rotation);
            }
            break;
            }
            return(geo);
        }
예제 #24
0
        private void UpdateCanvas()
        {
            if (Width == 0 || Double.IsNaN(Width))
            {
                return;
            }

            image.Children.Clear();

            double maxHeight = Double.IsNaN(Max) ? Range.Max : Max;
            double minHeight = Double.IsNaN(Min) ? Range.Min : Min;

            double visHeight = Math.Min(maxHeight, MaxHeight);

            image.Width  = Width;
            axis.Width   = Width;
            image.Height = visHeight;

            PathFigure pathFigure = new PathFigure();

            pathFigure.StartPoint = new Point(0, maxHeight);

            LineSegment lineSegment1 = new LineSegment();

            lineSegment1.Point = new Point(Width, maxHeight);
            LineSegment lineSegment2 = new LineSegment();

            lineSegment2.Point = new Point(Width, 0);
            LineSegment lineSegment3 = new LineSegment();

            lineSegment3.Point = new Point(0, maxHeight - minHeight);
            LineSegment lineSegment4 = new LineSegment();

            lineSegment4.Point = new Point(0, maxHeight);

            PathSegmentCollection pathSegmentCollection = new PathSegmentCollection();

            pathSegmentCollection.Add(lineSegment1);
            pathSegmentCollection.Add(lineSegment2);
            pathSegmentCollection.Add(lineSegment3);
            pathSegmentCollection.Add(lineSegment4);

            pathFigure.Segments = pathSegmentCollection;
            PathFigureCollection pathFigureCollection = new PathFigureCollection();

            pathFigureCollection.Add(pathFigure);
            PathGeometry pathGeometry = new PathGeometry();

            pathGeometry.Figures = pathFigureCollection;

            Path path = new Path();

            // TODO: Make it dependency property of SizeControl
            path.Fill = new SolidColorBrush(Colors.LightGray);

            path.Data   = pathGeometry;
            path.Stroke = new SolidColorBrush(Color);

            if (!Double.IsNaN(MaxHeight))
            {
                RectangleGeometry clip = new RectangleGeometry();
                clip.Rect = new Rect(0, maxHeight - this.MaxHeight, Width, this.MaxHeight);
                path.Clip = clip;
            }

            Canvas.SetTop(path, image.Height - maxHeight);
            image.Children.Add(path);

            if (visHeight < maxHeight)
            {
                Line top;
                if (minHeight >= visHeight)
                {
                    top = new Line {
                        X1 = 0, Y1 = 0, X2 = Width, Y2 = 0
                    }
                }
                ;
                else
                {
                    top = new Line
                    {
                        X1 = Width * (visHeight - minHeight) / (maxHeight - minHeight),
                        Y1 = 0,
                        X2 = Width,
                        Y2 = 0
                    }
                };
                top.Stroke          = new SolidColorBrush(Colors.Black);
                top.StrokeDashArray = new DoubleCollection();
                top.StrokeDashArray.Add(5);
                top.StrokeDashArray.Add(5);
                image.Children.Add(top);
            }
        }
예제 #25
0
        void BuildGeometry()
        {
            m_geometry = new GeometryGroup();
            var r = GetBodyRadius();

            if (IsFunction())
            {
                var cosRadian = Math.Cos(20.0 / 180.0 * Math.PI);
                var sinRadian = Math.Sin(20.0 / 180.0 * Math.PI);

                var r0 = r;
                if (m_customData["nCaller"].m_int > 0)
                {
                    var cr = m_customData["callerR"].m_double;

                    var figure = new PathFigure();
                    figure.StartPoint = new Point(-r0, 0);
                    figure.Segments.Add(new LineSegment(new Point(-r0 - cr * cosRadian, cr * sinRadian), true));
                    //figure.Segments.Add(new LineSegment(new Point(-r0 - cr * cosRadian, -sinRadian), true));
                    figure.Segments.Add(new ArcSegment(new Point(-r0 - cr * cosRadian, cr * -sinRadian), new Size(cr, cr), 0.0, false, SweepDirection.Clockwise, true));
                    figure.IsClosed = true;
                    figure.IsFilled = true;
                    var pathGeo = new PathGeometry();
                    pathGeo.Figures.Add(figure);
                    m_geometry.Children.Add(pathGeo);
                }
                if (m_customData["nCallee"].m_int > 0)
                {
                    var cr = m_customData["calleeR"].m_double;

                    var figure = new PathFigure();
                    figure.StartPoint = new Point(r0, 0);
                    figure.Segments.Add(new LineSegment(new Point(r0 + cr * cosRadian, cr * sinRadian), true));
                    figure.Segments.Add(new ArcSegment(new Point(r0 + cr * cosRadian, cr * -sinRadian), new Size(cr, cr), 0.0, false, SweepDirection.Counterclockwise, true));
                    figure.IsClosed = true;
                    figure.IsFilled = true;
                    var pathGeo = new PathGeometry();
                    pathGeo.Figures.Add(figure);
                    m_geometry.Children.Add(pathGeo);
                }

                m_highLightGeometry = new EllipseGeometry(new Point(0.0, 0.0), r, r);
                if (m_lines == 0 || (m_customData.ContainsKey("hasDef") && m_customData["hasDef"].m_int == 0))
                {
                    var innerCircle = new EllipseGeometry(new Point(0.0, 0.0), 1.5, 1.5);
                    m_highLightGeometry = Geometry.Combine(m_highLightGeometry, innerCircle, GeometryCombineMode.Exclude, null);
                }
                m_geometry.Children.Add(m_highLightGeometry);
            }
            else if (m_kind == DoxygenDB.EntKind.VARIABLE)
            {
                var figure = new PathFigure();
                figure.StartPoint = new Point(-r, 0.0);
                figure.Segments.Add(new LineSegment(new Point(r * 0.5, r * 0.85), true));
                figure.Segments.Add(new LineSegment(new Point(r * 0.5, -r * 0.85), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                var pathGeo = new PathGeometry();
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else if (IsClassOrStruct())
            {
                var figure = new PathFigure();
                figure.StartPoint = new Point(r, 0.0);
                figure.Segments.Add(new LineSegment(new Point(0.0, r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, 0.0), true));
                figure.Segments.Add(new LineSegment(new Point(0.0, -r), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                var pathGeo = new PathGeometry();
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else if (m_kind == DoxygenDB.EntKind.TYPEDEF)
            {
                var figure = new PathFigure();
                figure.StartPoint = new Point(r, 0.0);
                figure.Segments.Add(new LineSegment(new Point(0.5 * r, 0.5 * r), true));
                figure.Segments.Add(new LineSegment(new Point(-0.5 * r, 0.5 * r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, 0.0), true));
                figure.Segments.Add(new LineSegment(new Point(0.0, -r), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                var pathGeo = new PathGeometry();
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else if (m_kind == DoxygenDB.EntKind.FILE)
            {
                var rect = new RectangleGeometry(new Rect(new Point(-r, -r), new Point(r, r)));
                m_geometry.Children.Add(rect);
                m_highLightGeometry = rect;
            }
            else if (m_kind == DoxygenDB.EntKind.GROUP)
            {
                var pathGeo = new PathGeometry();
                var figure  = new PathFigure();
                figure.StartPoint = new Point(r, r);
                figure.Segments.Add(new LineSegment(new Point(-r, r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, -r * 0.2), true));
                figure.Segments.Add(new LineSegment(new Point(-r * 0.7, -r * 0.2), true));
                figure.Segments.Add(new LineSegment(new Point(-r * 0.7, -r * 0.5), true));
                figure.Segments.Add(new LineSegment(new Point(-r, -r * 0.5), true));
                figure.Segments.Add(new LineSegment(new Point(-r, -r), true));

                figure.Segments.Add(new LineSegment(new Point(r, -r), true));
                figure.Segments.Add(new LineSegment(new Point(r, -r * 0.5), true));
                figure.Segments.Add(new LineSegment(new Point(r * 0.7, -r * 0.5), true));
                figure.Segments.Add(new LineSegment(new Point(r * 0.7, -r * 0.2), true));
                figure.Segments.Add(new LineSegment(new Point(r, -r * 0.2), true));

                figure.Segments.Add(new LineSegment(new Point(r, r), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else if (m_kind == DoxygenDB.EntKind.DIR)
            {
                var figure = new PathFigure();
                figure.StartPoint = new Point(r, r);
                figure.Segments.Add(new LineSegment(new Point(-r, r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, -r * 0.6), true));
                figure.Segments.Add(new LineSegment(new Point(-r * 0.8, -r), true));
                figure.Segments.Add(new LineSegment(new Point(r * 0.2, -r), true));
                figure.Segments.Add(new LineSegment(new Point(r * 0.4, -r * 0.6), true));
                figure.Segments.Add(new LineSegment(new Point(r, -r * 0.6), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                var pathGeo = new PathGeometry();
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else if (m_kind == DoxygenDB.EntKind.PAGE)
            {
                var figure = new PathFigure();
                figure.StartPoint = new Point(r, 0.0);
                figure.Segments.Add(new LineSegment(new Point(0, 0.5 * r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, 0.5 * r), true));
                figure.Segments.Add(new LineSegment(new Point(-r, -0.5 * r), true));
                figure.Segments.Add(new LineSegment(new Point(0, -0.5 * r), true));
                figure.IsClosed = true;
                figure.IsFilled = true;
                var pathGeo = new PathGeometry();
                pathGeo.Figures.Add(figure);
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
            else
            {
                float w = 3.0f;

                var pathGeo = new PathGeometry();
                var figure  = new PathFigure();
                figure.StartPoint = new Point(w, w);
                figure.Segments.Add(new LineSegment(new Point(-w, -w), true));
                figure.IsClosed = false;
                figure.IsFilled = false;
                pathGeo.Figures.Add(figure);

                figure            = new PathFigure();
                figure.StartPoint = new Point(w, -w);
                figure.Segments.Add(new LineSegment(new Point(-w, w), true));
                figure.IsClosed = false;
                figure.IsFilled = false;
                pathGeo.Figures.Add(figure);

                var outlinePen = new Pen();
                outlinePen.Thickness = 2.0;
                outlinePen.LineJoin  = PenLineJoin.Round;
                pathGeo = pathGeo.GetWidenedPathGeometry(outlinePen).GetOutlinedPathGeometry();
                m_geometry.Children.Add(pathGeo);
                m_highLightGeometry = pathGeo;
            }
        }
예제 #26
0
        public void ExcludeClipRect(double left, double top, double right, double bottom)
        {
            var clipRegion = _currentState.CurrentClipRegion;
            var clipRect = new RectangleGeometry
                {
                    Rect = new Rect(
                            new Point(
                                LtoDX(left),
                                LtoDY(top)),
                            new Point(
                                LtoDX(right),
                                LtoDY(bottom))
                            )
                };

            if (clipRegion == null)
            {
                clipRegion = GetDefaultClipRegion();
            }

            #if !NETFX_CORE
            _currentState.CurrentClipRegion = new LogRegion(
                    Geometry.Combine(
                        clipRegion.Geometry,
                        clipRect,
                        GeometryCombineMode.Exclude,
                        null)
                );
            #endif
        }
예제 #27
0
        /// <summary>
        /// 解析指定的XML对象
        /// </summary>
        /// <param name="messageXML"></param>
        private void ParseXML(XmlReader xmlReader)
        {
            Geometry2D shape = null;

            switch (xmlReader.Name)
            {
            case "ArcGeometry":
                shape = new ArcGeometry();
                break;

            case "BeamGeometry":
                shape = new BeamGeometry();
                break;

            case "CircleGeometry":
                shape = new CircleGeometry();
                break;

            case "CSectionGeometry":
                shape = new CSectionGeometry();
                break;

            case "EllipseGeometry":
                shape = new EllipseGeometry();
                break;

            case "FloorGeometry":
                shape = new FloorGeometry();
                break;

            case "LineGeometry":
                shape = new LineGeometry();
                break;

            case "MeasureGeometry":
                shape = new MeasureGeometry();
                break;

            case "MemberGeometry":
                shape = new MemberGeometry();
                break;

            case "OSBGeometry":
                shape = new OSBGeometry();
                break;

            case "PointGeometry":
                shape = new PointGeometry();
                break;

            case "PolygonGeometry":
                shape = new PolygonGeometry();
                break;

            case "PolylineGeometry":
                shape = new PolylineGeometry();
                break;

            case "RectangleGeometry":
                shape = new RectangleGeometry();
                break;

            case "SteelBeamGeometry":
                shape = new SteelBeamGeometry();
                break;

            case "TextGeometry":
                shape = new TextGeometry();
                break;

            case "WallGeometry":
                shape = new WallGeometry();
                break;
            }

            if (shape != null)
            {
                //将信息写入数据流中
                shape.ReadXML(xmlReader);
                //将图形添加都界面上
                this.drawingKernel.AddShape(shape);
            }
        }
예제 #28
0
 private void OnSizeChanged(object sender, SizeChangedEventArgs e)
 {
     Clip = new RectangleGeometry {
         Rect = new Rect(0, 0, ActualWidth, ActualHeight)
     };
 }
예제 #29
0
        // Token: 0x06003019 RID: 12313 RVA: 0x000D8494 File Offset: 0x000D6694
        private void _UpdateHighlightBackground(DrawingContext dc, ArrayList highlights)
        {
            PathGeometry pathGeometry = null;
            Brush        brush        = null;
            Rect         rect         = Rect.Empty;

            foreach (object obj in highlights)
            {
                FixedHighlight fixedHighlight = (FixedHighlight)obj;
                Brush          brush2         = null;
                if (fixedHighlight.HighlightType != FixedHighlightType.None)
                {
                    Rect rect2 = fixedHighlight.ComputeDesignRect();
                    if (!(rect2 == Rect.Empty))
                    {
                        GeneralTransform generalTransform = fixedHighlight.Element.TransformToAncestor(this._page);
                        Transform        transform        = generalTransform.AffineTransform;
                        if (transform == null)
                        {
                            transform = Transform.Identity;
                        }
                        Glyphs glyphs = fixedHighlight.Glyphs;
                        if (fixedHighlight.HighlightType == FixedHighlightType.TextSelection)
                        {
                            brush2 = ((glyphs == null) ? SelectionHighlightInfo.ObjectMaskBrush : SelectionHighlightInfo.BackgroundBrush);
                        }
                        else if (fixedHighlight.HighlightType == FixedHighlightType.AnnotationHighlight)
                        {
                            brush2 = fixedHighlight.BackgroundBrush;
                        }
                        if (fixedHighlight.Element.Clip != null)
                        {
                            Rect bounds = fixedHighlight.Element.Clip.Bounds;
                            rect2.Intersect(bounds);
                        }
                        Geometry geometry = new RectangleGeometry(rect2);
                        geometry.Transform = transform;
                        rect2 = generalTransform.TransformBounds(rect2);
                        if (brush2 != brush || rect2.Top > rect.Bottom + 0.1 || rect2.Bottom + 0.1 < rect.Top || rect2.Left > rect.Right + 0.1 || rect2.Right + 0.1 < rect.Left)
                        {
                            if (brush != null)
                            {
                                pathGeometry.FillRule = FillRule.Nonzero;
                                dc.DrawGeometry(brush, null, pathGeometry);
                            }
                            brush        = brush2;
                            pathGeometry = new PathGeometry();
                            pathGeometry.AddGeometry(geometry);
                            rect = rect2;
                        }
                        else
                        {
                            pathGeometry.AddGeometry(geometry);
                            rect.Union(rect2);
                        }
                    }
                }
            }
            if (brush != null)
            {
                pathGeometry.FillRule = FillRule.Nonzero;
                dc.DrawGeometry(brush, null, pathGeometry);
            }
        }
예제 #30
0
 private void AddGeometry(StringBuilder svgString, RectangleGeometry rectangle)
 {
     svgString.AppendFormat(CultureInfo.InvariantCulture, "<rect x=\"{0}\" y=\"{1}\" width=\"{2}\" height=\"{3}\" />"
                            , rectangle.Rect.Left, rectangle.Rect.Top, rectangle.Rect.Width, rectangle.Rect.Height);
     svgString.Append(Environment.NewLine);
 }
예제 #31
0
        public void IntersectClipRect(double left, double top, double right, double bottom)
        {
            LogRegion clipRegion = _currentState.CurrentClipRegion;
            var clipRect = new RectangleGeometry
                {
                    Rect = new Rect(
                        new Point(
                            LtoDX(left),
                            LtoDY(top)),
                        new Point(
                            LtoDX(right),
                            LtoDY(bottom))
                        )
                };

            if (clipRegion == null)
            {
                _currentState.CurrentClipRegion = new LogRegion(clipRect);
            }
            else
            {
            #if !NETFX_CORE
                _currentState.CurrentClipRegion = new LogRegion(
                        Geometry.Combine(
                            clipRegion.Geometry,
                            clipRect,
                            GeometryCombineMode.Intersect,
                            null)
                    );
            #endif
            }
        }
예제 #32
0
        /// <summary>
        /// Handles the SizeChanged event of the ContainerCollection control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SizeChangedEventArgs"/> instance containing the event data.</param>
        void ContainerCollection_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            #if !WPF
            RectangleGeometry clipRectGeometry = new RectangleGeometry();
            clipRectGeometry.Rect = new Rect(new Point(0, 0), new Size(this.ActualWidth,this.ActualHeight));
            this.Clip = clipRectGeometry;
            #endif

            Refresh();
        }
예제 #33
0
 public MapRectangle()
 {
     StrokeThickness = 0d;
     Data = new RectangleGeometry();
     boundingBoxValid = true;
 }
예제 #34
0
 private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     Rect r = new Rect(e.NewSize);
     RectangleGeometry gm = new RectangleGeometry(r, 3, 3); // 40 is radius here
                ((UIElement)sender).Clip = gm;
 }
예제 #35
0
 private void generatePreview(Rect rectangle)
 {
     NewRectangle       = new RectangleGeometry(rectangle, 0, 0, rotationPreview);
     resizePreview.Data = NewRectangle;
     resizePreview.Arrange(new Rect(new Size(canvas.ActualWidth, canvas.ActualHeight)));
 }
예제 #36
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Rect rc = new Rect(0.0, 0.0, finalSize.Width, finalSize.Height);

            _rowsLayer.Arrange(rc);
            _borderLayer.Arrange(rc);
            _selectionLayer.Arrange(rc);
            _dragFillLayer.Arrange(_cachedDragFillRect);
            _decorationLayer?.Arrange(rc);

#if !IOS
            // 正在编辑时滚动页面若不重新布局会造成编辑框没跟着滚动
            // iOS始终重新布局,再调用 InvalidateArrange 会死循环!
            if (IsEditing())
            {
                _editorLayer.InvalidateArrange();
            }
#endif
            _editorLayer.Arrange(rc);

            _floatingLayer.Arrange(rc);
            _floatingEditLayer.Arrange(rc);

            Size viewportSize = GetViewportSize(finalSize);
            if (Excel.IsTouching)
            {
                if (Clip == null)
                {
                    Clip = new RectangleGeometry {
                        Rect = new Rect(new Point(), viewportSize)
                    }
                }
                ;
            }
            else
            {
                Clip = new RectangleGeometry {
                    Rect = new Rect(new Point(), viewportSize)
                };
            }

            if (Clip != null)
            {
                _borderLayer.Clip = new RectangleGeometry {
                    Rect = Clip.Rect
                }
            }
            ;
            return(finalSize);
        }

        void BuildSpanGraph()
        {
            _cachedSpanGraph.Reset();
            SheetSpanModelBase spanModel = GetSpanModel();

            if ((spanModel != null) && !spanModel.IsEmpty())
            {
                int rowStart    = Excel.GetViewportTopRow(RowViewportIndex);
                int rowEnd      = Excel.GetViewportBottomRow(RowViewportIndex);
                int columnStart = Excel.GetViewportLeftColumn(ColumnViewportIndex);
                int columnEnd   = Excel.GetViewportRightColumn(ColumnViewportIndex);

                if ((rowStart <= rowEnd) && (columnStart <= columnEnd))
                {
                    int num5 = -1;
                    for (int i = rowStart - 1; i > -1; i--)
                    {
                        if (Excel.ActiveSheet.GetActualRowVisible(i, SheetArea.Cells))
                        {
                            num5 = i;
                            break;
                        }
                    }
                    rowStart = num5;
                    int count = GetDataContext().Rows.Count;
                    for (int j = rowEnd + 1; j < count; j++)
                    {
                        if (Excel.ActiveSheet.GetActualRowVisible(j, SheetArea.Cells))
                        {
                            rowEnd = j;
                            break;
                        }
                    }
                    int num9 = -1;
                    for (int k = columnStart - 1; k > -1; k--)
                    {
                        if (Excel.ActiveSheet.GetActualColumnVisible(k, SheetArea.Cells))
                        {
                            num9 = k;
                            break;
                        }
                    }
                    columnStart = num9;
                    int num11 = GetDataContext().Columns.Count;
                    for (int m = columnEnd + 1; m < num11; m++)
                    {
                        if (Excel.ActiveSheet.GetActualColumnVisible(m, SheetArea.Cells))
                        {
                            columnEnd = m;
                            break;
                        }
                    }
                    _cachedSpanGraph.BuildGraph(columnStart, columnEnd, rowStart, rowEnd, GetSpanModel(), CellCache);
                }
            }
        }
    }
}
예제 #37
0
        /// <summary>
        /// Draw the hatches and the transparent area where isn't covering the elements.
        /// </summary>
        /// <param name="drawingContext"></param>
        private void DrawBackgound(DrawingContext drawingContext)
        {
            PathGeometry hatchGeometry = null;
            Geometry     rectGeometry  = null;

            int count = _elementsBounds.Count;

            if (count != 0)
            {
                // Create a union collection of the element regions.
                for (int i = 0; i < count; i++)
                {
                    Rect hatchRect = _elementsBounds[i];

                    if (hatchRect.IsEmpty)
                    {
                        continue;
                    }

                    hatchRect.Inflate(HatchBorderMargin / 2, HatchBorderMargin / 2);

                    if (hatchGeometry == null)
                    {
                        PathFigure path = new PathFigure();
                        path.StartPoint = new Point(hatchRect.Left, hatchRect.Top);

                        PathSegmentCollection segments = new PathSegmentCollection();

                        PathSegment line = new LineSegment(new Point(hatchRect.Right, hatchRect.Top), true);
                        line.Freeze();
                        segments.Add(line);

                        line = new LineSegment(new Point(hatchRect.Right, hatchRect.Bottom), true);
                        line.Freeze();
                        segments.Add(line);

                        line = new LineSegment(new Point(hatchRect.Left, hatchRect.Bottom), true);
                        line.Freeze();
                        segments.Add(line);

                        line = new LineSegment(new Point(hatchRect.Left, hatchRect.Top), true);
                        line.Freeze();
                        segments.Add(line);

                        segments.Freeze();
                        path.Segments = segments;

                        path.IsClosed = true;
                        path.Freeze();

                        hatchGeometry = new PathGeometry();
                        hatchGeometry.Figures.Add(path);
                    }
                    else
                    {
                        rectGeometry = new RectangleGeometry(hatchRect);
                        rectGeometry.Freeze();

                        hatchGeometry = Geometry.Combine(hatchGeometry, rectGeometry, GeometryCombineMode.Union, null);
                    }
                }
            }

            // Then, create a region which equals to "SelectionFrame - element1 bounds - element2 bounds - ..."
            GeometryGroup      backgroundGeometry = new GeometryGroup( );
            GeometryCollection geometryCollection = new GeometryCollection();

            // Add the entile rectanlge to the group.
            rectGeometry = new RectangleGeometry(new Rect(0, 0, RenderSize.Width, RenderSize.Height));
            rectGeometry.Freeze();
            geometryCollection.Add(rectGeometry);

            // Add the union of the element rectangles. Then the group will do oddeven operation.
            Geometry outlineGeometry = null;

            if (hatchGeometry != null)
            {
                hatchGeometry.Freeze();

                outlineGeometry = hatchGeometry.GetOutlinedPathGeometry();
                outlineGeometry.Freeze();
                if (count == 1 && ((InkCanvasInnerCanvas)AdornedElement).InkCanvas.GetSelectedStrokes().Count == 0)
                {
                    geometryCollection.Add(outlineGeometry);
                }
            }

            geometryCollection.Freeze();
            backgroundGeometry.Children = geometryCollection;
            backgroundGeometry.Freeze();

            // Then, draw the region which may contain holes so that the elements cannot be covered.
            // After that, the underneath elements can receive the messages.
#if DEBUG_OUTPUT
            // Draw the debug feedback
            drawingContext.DrawGeometry(new SolidColorBrush(Color.FromArgb(128, 255, 255, 0)), null, backgroundGeometry);
#else
            drawingContext.DrawGeometry(Brushes.Transparent, null, backgroundGeometry);
#endif

            // At last, draw the hatch borders
            if (outlineGeometry != null)
            {
                drawingContext.DrawGeometry(null, _hatchPen, outlineGeometry);
            }
        }
        public static DrawingGroup GenerateLegend(VisualComplement Complement, View Target)
        {
            var Result = new DrawingGroup();

            var LabelCaptionFormat = new TextFormat("Arial", 9, Brushes.Black, false, false, false, TextAlignment.Right);
            var LabelContentFormat = new TextFormat("Arial", 9, Brushes.Black, true, false, false, TextAlignment.Left);

            var Foreground = Complement.GetPropertyField <Brush>(PROP_FIELD_FOREGROUND);
            var Background = Complement.GetPropertyField <Brush>(PROP_FIELD_BACKGROUND);
            var Pencil     = new Pen(Foreground, Complement.GetPropertyField <double>(PROP_FIELD_LINETHICK));

            Pencil.DashStyle = Complement.GetPropertyField <DashStyle>(PROP_FIELD_LINEDASH);

            var Shape = new RectangleGeometry(Complement.BaseArea, 5, 5);

            double VerticalOffset = Complement.BaseArea.Top;
            double Margin         = 2.0;
            double VerticalTab    = 60;
            double LabelHeight    = 18;

            using (var Context = Result.Append())
            {
                Context.DrawGeometry(Background, Pencil, Shape);

                if (Complement.BaseArea.Width <= VerticalTab)
                {
                    DrawLabel(Context, "...", LabelContentFormat, Complement.BaseArea.Left, Complement.BaseArea.Right, VerticalOffset - 2.0, LabelHeight, Margin);
                    goto Exit;
                }

                // Text "Domain"
                DrawLabel(Context, "Domain:", LabelCaptionFormat, Complement.BaseArea.Left, Complement.BaseArea.Left + VerticalTab, VerticalOffset, LabelHeight, Margin);
                DrawLabel(Context, Complement.Target.OwnerGlobal.OwnerCompositeContainer.CompositeContentDomain.Name, LabelContentFormat,
                          Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Right, VerticalOffset, LabelHeight, Margin);

                // Text "Summary"
                var SummaryHeight = LabelHeight;

                if (!Complement.Target.OwnerGlobal.OwnerCompositeContainer.CompositeContentDomain.Summary.Trim().IsAbsent())
                {
                    SummaryHeight   = LabelHeight * 2.65;
                    VerticalOffset += LabelHeight;
                    if (VerticalOffset + SummaryHeight >= Complement.BaseArea.Bottom)
                    {
                        Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Top),
                                                                                  new Point(Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Bottom)));
                        goto Exit;
                    }
                    Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left, VerticalOffset), new Point(Complement.BaseArea.Right, VerticalOffset)));
                    DrawLabel(Context, "Summary:", LabelCaptionFormat, Complement.BaseArea.Left, Complement.BaseArea.Left + VerticalTab, VerticalOffset, SummaryHeight, Margin);
                    DrawLabel(Context, Complement.Target.OwnerGlobal.OwnerCompositeContainer.CompositeContentDomain.Summary, LabelContentFormat,
                              Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Right, VerticalOffset, SummaryHeight, Margin);
                }

                VerticalOffset += SummaryHeight;

                var CalcHeight = VerticalOffset;

                if (VerticalOffset < Complement.BaseArea.Bottom)
                {
                    Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left, VerticalOffset), new Point(Complement.BaseArea.Right, VerticalOffset)));
                }
                else
                {
                    CalcHeight = Complement.BaseArea.Bottom;
                }

                Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Top),
                                                                          new Point(Complement.BaseArea.Left + VerticalTab, CalcHeight)));

                // Legends zone
                if (VerticalOffset + SummaryHeight + Display.ICOSIZE_LIT >= Complement.BaseArea.Bottom)
                {
                    goto Exit;
                }

                var UsedIdeaDefinitions = Complement.Target.OwnerGlobal.ViewChildren
                                          .Where(child => child.Key is VisualElement)
                                          .Select(child => ((VisualElement)child.Key).OwnerRepresentation.RepresentedIdea.IdeaDefinitor)
                                          .Distinct().OrderBy(idef => idef.Name);

                var UsedConHeight = DrawColumn(Context, "Concepts", Pencil,
                                               new Rect(Complement.BaseArea.Left, VerticalOffset,
                                                        Complement.BaseArea.Width / 2.0, Complement.BaseArea.Bottom - VerticalOffset),
                                               UsedIdeaDefinitions.Where(idea => idea is ConceptDefinition));

                var UsedRelHeight = DrawColumn(Context, "Relationships", Pencil,
                                               new Rect(Complement.BaseArea.Left + Complement.BaseArea.Width / 2.0, VerticalOffset,
                                                        Complement.BaseArea.Width / 2.0, Complement.BaseArea.Bottom - VerticalOffset),
                                               GetRelationshipDefsAndVariations(UsedIdeaDefinitions.CastAs <RelationshipDefinition, IdeaDefinition>(), Pencil));

                var UsedHeight = Math.Max(UsedConHeight, UsedRelHeight) + 1;

                var MaxHeight = (VerticalOffset + UsedHeight).EnforceMaximum(Complement.BaseArea.Bottom);
                Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + Complement.BaseArea.Width / 2.0, VerticalOffset),
                                                                          new Point(Complement.BaseArea.Left + Complement.BaseArea.Width / 2.0, MaxHeight)));

                Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left, MaxHeight), new Point(Complement.BaseArea.Right, MaxHeight)));

                VerticalOffset += UsedHeight;

                // Versioning zone
                var VersionInfo = Complement.Target.OwnerGlobal.OwnerCompositeContainer.CompositeContentDomain.Version;

                var VerticalTab2Ini = 150;
                var VerticalTab2End = 210;

                // Text "Creator"
                if (VerticalOffset + LabelHeight >= Complement.BaseArea.Bottom)
                {
                    goto Exit;
                }
                var LocalZoneTop = VerticalOffset;

                Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + VerticalTab, LocalZoneTop),
                                                                          new Point(Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Bottom)));

                DrawLabel(Context, "Creator:", LabelCaptionFormat, Complement.BaseArea.Left, Complement.BaseArea.Left + VerticalTab, VerticalOffset, LabelHeight, Margin);
                DrawLabel(Context, VersionInfo.Creator, LabelContentFormat,
                          Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Left + VerticalTab2Ini, VerticalOffset, LabelHeight, Margin);

                // Text "Last Modifier"
                VerticalOffset += LabelHeight; if (VerticalOffset + LabelHeight < Complement.BaseArea.Bottom)
                {
                    Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left, VerticalOffset), new Point(Complement.BaseArea.Right, VerticalOffset)));
                    DrawLabel(Context, "Last Modifier:", LabelCaptionFormat, Complement.BaseArea.Left, Complement.BaseArea.Left + VerticalTab, VerticalOffset, LabelHeight, Margin);
                    DrawLabel(Context, VersionInfo.LastModifier, LabelContentFormat,
                              Complement.BaseArea.Left + VerticalTab, Complement.BaseArea.Left + VerticalTab2Ini, VerticalOffset, LabelHeight, Margin);
                }

                if (Complement.BaseArea.Right - (Complement.BaseArea.Left + VerticalTab2End) >= 10)
                {
                    Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + VerticalTab2Ini, LocalZoneTop),
                                                                              new Point(Complement.BaseArea.Left + VerticalTab2Ini, Complement.BaseArea.Bottom)));
                    Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left + VerticalTab2End, LocalZoneTop),
                                                                              new Point(Complement.BaseArea.Left + VerticalTab2End, Complement.BaseArea.Bottom)));

                    // Text "Creation"
                    VerticalOffset = LocalZoneTop;
                    DrawLabel(Context, "Creation:", LabelCaptionFormat, Complement.BaseArea.Left + VerticalTab2Ini, Complement.BaseArea.Left + VerticalTab2End, VerticalOffset, LabelHeight, Margin);
                    DrawLabel(Context, VersionInfo.Creation.ToString(), LabelContentFormat,
                              Complement.BaseArea.Left + VerticalTab2End, Complement.BaseArea.Right, VerticalOffset, LabelHeight, Margin);

                    // Text "Last Modification"
                    VerticalOffset += LabelHeight; if (VerticalOffset + LabelHeight >= Complement.BaseArea.Bottom)
                    {
                        goto Exit;
                    }
                    //Supressed: Context.DrawGeometry(Background, Pencil, new LineGeometry(new Point(Complement.BaseArea.Left, BaseLineOffset), new Point(Complement.BaseArea.Right, BaseLineOffset)));
                    DrawLabel(Context, "Modification:", LabelCaptionFormat, Complement.BaseArea.Left + VerticalTab2Ini, Complement.BaseArea.Left + VerticalTab2End, VerticalOffset, LabelHeight, Margin);
                    DrawLabel(Context, VersionInfo.LastModification.ToString(), LabelContentFormat,
                              Complement.BaseArea.Left + VerticalTab2End, Complement.BaseArea.Right, VerticalOffset, LabelHeight, Margin);
                }

                Exit :;
            }

            return(Result);
        }
예제 #39
0
        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 Windows.UI.Xaml.Controls.Button {
                Content = "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 always tries to size itself to the screen width
                // So figure that out and we'll know how far off it's laying itself out
                WRect bounds       = ApplicationView.GetForCurrentView().VisibleBounds;
                double scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
                var screenWidth    = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor);

                // We can re-center it by offsetting it during the Arrange call
                double diff = Math.Abs(screenWidth.Width - finalSize.Width) / -2;
                frameworkElement.Arrange(new WRect(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 WRect(-diff, 0, finalSize.Width, finalSize.Height)
                };
                frameworkElement.Clip = clip;

                return(finalSize);
            }
                             );

            page.NativeControlsAdded = true;
        }
예제 #40
0
        private static ObjectAnimationUsingKeyFrames CreateRectangleAnimation(Rect to, TimeSpan duration, RectangleGeometry rectangle, bool enableDependentAnimation)
        {
            var animation = new ObjectAnimationUsingKeyFrames
            {
                Duration = duration,
                EnableDependentAnimation = enableDependentAnimation
            };

            var frames = GetRectKeyframes(rectangle.Rect, to, duration);

            foreach (var item in frames)
            {
                animation.KeyFrames.Add(item);
            }

            Storyboard.SetTarget(animation, rectangle);
            Storyboard.SetTargetProperty(animation, nameof(RectangleGeometry.Rect));

            return(animation);
        }