Example #1
0
        public void Opacity_Mask_Masks_Element()
        {
            var target = new Canvas
            {
                OpacityMask = new LinearGradientBrush
                {
                    StartPoint    = new RelativePoint(0, 0, RelativeUnit.Relative),
                    EndPoint      = new RelativePoint(1, 1, RelativeUnit.Relative),
                    GradientStops = new List <GradientStop>
                    {
                        new GradientStop(Color.FromUInt32(0xffffffff), 0),
                        new GradientStop(Color.FromUInt32(0x00ffffff), 1)
                    }
                },
                Width    = 76,
                Height   = 76,
                Children = new Avalonia.Controls.Controls
                {
                    new Path
                    {
                        Width  = 32,
                        Height = 40,
                        [Canvas.LeftProperty] = 23,
                        [Canvas.TopProperty]  = 18,
                        Stretch = Stretch.Fill,
                        Fill    = Brushes.Red,
                        Data    = StreamGeometry.Parse("F1 M 27,18L 23,26L 33,30L 24,38L 33,46L 23,50L 27,58L 45,58L 55,38L 45,18L 27,18 Z")
                    }
                }
            };

            RenderToFile(target);
            CompareImages();
        }
Example #2
0
        public async Task ImageDrawing_BottomRight()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Image
                {
                    Source = new DrawingImage
                    {
                        Drawing = new DrawingGroup
                        {
                            Children =
                            {
                                new GeometryDrawing
                                {
                                    Geometry = StreamGeometry.Parse("m0,0 l200,200"),
                                    Brush    = Brushes.Black,
                                },
                                new ImageDrawing
                                {
                                    ImageSource = new Bitmap(BitmapPath),
                                    Rect        = new Rect(100, 100, 100, 100),
                                }
                            }
                        }
                    }
                }
            };

            await RenderToFile(target);

            CompareImages();
        }
        public void GeometryClip_Should_Affect_Child_Layers()
        {
            using (TestApplication())
            {
                var       clip = StreamGeometry.Parse("M100,0 L0,100 100,100");
                Decorator decorator;
                Border    border;
                var       tree = new TestRoot
                {
                    Child = decorator = new Decorator
                    {
                        Clip   = clip,
                        Margin = new Thickness(12, 16),
                        Child  = border = new Border
                        {
                            Opacity = 0.5,
                        }
                    }
                };

                var layout = AvaloniaLocator.Current.GetService <ILayoutManager>();
                layout.ExecuteInitialLayoutPass(tree);

                var scene        = new Scene(tree);
                var sceneBuilder = new SceneBuilder();
                sceneBuilder.UpdateAll(scene);

                var borderLayer = scene.Layers[border];
                Assert.Equal(
                    Matrix.CreateTranslation(12, 16),
                    ((MockStreamGeometryImpl)borderLayer.GeometryClip).Transform);
            }
        }
Example #4
0
        private async void move_right()
        {
            var pm = FindResource("path") as PathGeometry;

            pm.Clear();
            string a = "M 850,333 A 250,250 0 1 1 850,332.99";

            pm.AddGeometry(StreamGeometry.Parse(a));
            var sb = FindResource("ellipseSB") as Storyboard;

            if (sb != null)
            {
                sb.Begin();
            }
            User user = new User();

            user.Orbit     = 1;
            user.PrivateId = 5201;
            string userdata_move = Newtonsoft.Json.JsonConvert.SerializeObject(user);

            try
            {
                await myhub.SendAsync("SendMessage", "exit", userdata_move);
            }
            //Exception message if something went wrong.
            catch (Exception ex)
            {
                kiirat.Text = (ex.Message);
            }
            move_energy();
        }
Example #5
0
        public void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
        {
            using (AvaloniaLocator.EnterScope())
            {
                Direct2D1Platform.Initialize();

                var target = new Path
                {
                    Data                = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
                    Stroke              = Brushes.Black,
                    StrokeThickness     = 2,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    UseLayoutRounding   = false,
                };

                target.Measure(new Size(100, 100));
                target.Arrange(new Rect(0, 0, 100, 100));

                // Measured geometry with stroke of 2px is:
                //
                //     {-1, -0.414, 6.414, 12.828} (see GeometryTests)
                //
                // With origin at 0,0 the bounds should equal:
                //
                //     Assert.Equal(new Rect(0, 0, 5.414, 12.414), target.Bounds, compare);
                //
                // However Path.Measure doesn't correctly handle strokes currently, so testing for
                // the (incorrect) current output for now...
                Assert.Equal(new Rect(0, 0, 4, 10), target.Bounds, Compare);
            }
        }
        private async void btn_Validate_Click(object sender, RoutedEventArgs e)
        {
            setWorking(true);
            _user.User = await _app.Client.UserInfoAsync(tb_Email.Text);



            if (_user.User.Id < 1)
            {
                _user.User.Email = tb_Email.Text;
                await _app.GetUserDetail(_user.User);

                if (_user.User.EmployeeId > 0)
                {
                    _user.User.UserName = "";
                    await _app.Client.RegisterUserAsync(_user.User);

                    _user.User = await _app.Client.UserInfoAsync(_user.User.Email);
                }
            }
            if (_user.User.EmployeeId > 0)
            {
                btn_Icon.IconData   = StreamGeometry.Parse(_icon_Correct);
                btn_Icon.Foreground = new SolidColorBrush(Colors.Green);
                btn_OK.IsEnabled    = true;
            }
            else
            {
                btn_Icon.Foreground = new SolidColorBrush(Colors.Red);
                btn_Icon.IconData   = StreamGeometry.Parse(_icon_Wrong);
            }
            btn_Icon.Visibility = System.Windows.Visibility.Visible;
            setWorking(false);
        }
Example #7
0
        private void DrawSpiroShape(DrawingContext dc, SpiroShape shape, bool isSelected)
        {
            string data;
            var    result = SpiroEditor.Data.TryGetValue(shape, out data);

            if (result && !string.IsNullOrEmpty(data))
            {
                var geometry = StreamGeometry.Parse(data);
                if (isSelected)
                {
                    var cache = FromCache(_hitGeometryStyle);
                    dc.DrawGeometry(
                        shape.IsFilled ? cache.FillBrush : null,
                        shape.IsStroked ? cache.StrokePen : null,
                        geometry);
                }
                else
                {
                    var cache = FromCache(_geometryStyle);
                    dc.DrawGeometry(
                        shape.IsFilled ? cache.FillBrush : null,
                        shape.IsStroked ? cache.StrokePen : null,
                        geometry);
                }
            }
        }
Example #8
0
        public void HitTest_Should_Not_Find_Path_When_Outside_Fill()
        {
            using (TestApplication())
            {
                Path path;
                var  root = new TestRoot
                {
                    Width  = 200,
                    Height = 200,
                    Child  = path = new Path
                    {
                        Width  = 200,
                        Height = 200,
                        Fill   = Brushes.Red,
                        Data   = StreamGeometry.Parse("M100,0 L0,100 100,100")
                    }
                };

                root.Renderer = new DeferredRenderer(root, null);
                root.Measure(Size.Infinity);
                root.Arrange(new Rect(root.DesiredSize));

                var context = new DrawingContext(Mock.Of <IDrawingContextImpl>());

                var result = root.Renderer.HitTest(new Point(100, 100), root, null);
                Assert.Equal(new[] { path }, result);

                result = root.Renderer.HitTest(new Point(10, 10), root, null);
                Assert.Empty(result);
            }
        }
Example #9
0
        public async Task Geometry_Clip_Clips_Path()
        {
            var target = new Canvas
            {
                Background = Brushes.Yellow,
                Clip       = StreamGeometry.Parse("F1 M 0,0  H 76 V 76 Z"),
                Width      = 76,
                Height     = 76,
                Children   = new Avalonia.Controls.Controls
                {
                    new Path
                    {
                        Width  = 32,
                        Height = 40,
                        [Canvas.LeftProperty] = 23,
                        [Canvas.TopProperty]  = 18,
                        Stretch = Stretch.Fill,
                        Fill    = Brushes.Black,
                        Data    = StreamGeometry.Parse("F1 M 27,18L 23,26L 33,30L 24,38L 33,46L 23,50L 27,58L 45,58L 55,38L 45,18L 27,18 Z")
                    }
                }
            };

            await RenderToFile(target);

            CompareImages();
        }
Example #10
0
        public async Task Path_Expander_With_Border()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Border
                {
                    BorderBrush         = Brushes.Red,
                    BorderThickness     = new Thickness(1),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Child = new Path
                    {
                        Fill            = Brushes.Black,
                        Stroke          = Brushes.Black,
                        StrokeThickness = 1,
                        Stretch         = Stretch.Uniform,
                        Data            = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
                    }
                }
            };

            await RenderToFile(target);

            CompareImages();
        }
Example #11
0
    public void HitTest_Should_Respect_Geometry_Clip()
    {
        using (var s = new CompositorServices(new Size(400, 400)))
        {
            Canvas canvas;
            Border border = new Border
            {
                Background = Brushes.Red,
                Clip       = StreamGeometry.Parse("M100,0 L0,100 100,100"),
                Width      = 200,
                Height     = 200,
                Child      = canvas = new Canvas
                {
                    Background = Brushes.Yellow,
                    Margin     = new Thickness(10),
                }
            };
            s.TopLevel.Content = border;

            s.RunJobs();
            Assert.Equal(new Rect(100, 100, 200, 200), border.Bounds);

            s.AssertHitTest(new Point(200, 200), null, canvas, border);

            s.AssertHitTest(new Point(110, 110), null);
        }
    }
Example #12
0
        public async Task SVGPath()
        {
            var target = new Canvas
            {
                Background = Brushes.Yellow,
                Width      = 76,
                Height     = 76,
                Children   =
                {
                    new Path
                    {
                    Width  = 32,
                    Height = 40,
                    [Canvas.LeftProperty] = 23,
                    [Canvas.TopProperty]  = 18,
                    Stretch = Stretch.Fill,
                    Fill    = Brushes.Black,
                    //Coffee Maker by Becris from the Noun Project
                    Data = StreamGeometry.Parse("M5,51v4c0,1.654,1.346,3,3,3h7v3c0,0.552,0.447,1,1,1h8c0.553,0,1-0.448,1-1v-3h18v3c0,0.552,0.447,1,1,1h8  c0.553,0,1-0.448,1-1v-3c2.757,0,5-2.243,5-5V13V7c0-2.757-2.243-5-5-5H11C8.243,2,6,4.243,6,7v2c0,2.757,2.243,5,5,5h1.743  l-2.717,11.775c-0.068,0.297,0.002,0.609,0.192,0.848C10.407,26.861,10.695,27,11,27h4c0.431,0,0.812-0.275,0.948-0.684L18.721,18  h1.499l1.811,7.243C22.142,25.688,22.541,26,23,26h12c0.459,0,0.858-0.312,0.97-0.757L37.78,18h6.658l-3.235,29.11  C41.147,47.618,40.72,48,40.21,48h-4.167c0.873-1.159,1.203-2.622,0.897-4.047L35,34.895v-2.481l2.707-2.707  c0.286-0.286,0.372-0.716,0.217-1.09C37.77,28.244,37.404,28,37,28H22c-0.553,0-1,0.448-1,1v0.719l-2.758-0.689  c-0.443-0.111-0.906,0.094-1.123,0.496l-7,13l1.762,0.948l6.631-12.315L21,31.781v3.115l-1.94,9.057  c-0.306,1.426,0.025,2.889,0.897,4.048H8C6.346,48,5,49.346,5,51z M23,60h-6v-2h6V60z M51,60h-6v-2h6V60z M8,9V7  c0-1.654,1.346-3,3-3h42c1.654,0,3,1.346,3,3v5H46H14h-3C9.346,12,8,10.654,8,9z M34.219,24H23.781l-1.5-6h13.438L34.219,24z   M44.66,16H37H21h-3c-0.431,0-0.812,0.275-0.948,0.684L14.279,25h-2.022l2.539-11h30.087l-0.185,1.662L44.66,16z M43.191,47.331  L46.896,14H56v39c0,1.654-1.346,3-3,3h-1h-8H24h-8H8c-0.552,0-1-0.449-1-1v-4c0-0.551,0.448-1,1-1h15.948h8.104h8.158  C41.741,50,43.022,48.853,43.191,47.331z M23,30h11.586l-1.293,1.293C33.105,31.48,33,31.735,33,32v2H23V30z M21.614,46.886  c-0.571-0.708-0.79-1.624-0.6-2.514L22.809,36h10.383l1.794,8.372c0.19,0.89-0.028,1.806-0.6,2.514  C33.813,47.594,32.963,48,32.052,48h-8.104C23.037,48,22.187,47.594,21.614,46.886z")
                    }
                }
            };

            await RenderToFile(target);

            CompareImages();
        }
Example #13
0
        public Clock(Gates.IOGates.Clock gate)
            : base(gate, new TerminalID[] { new TerminalID(false, 0, Position.TOP) })
        {
            _clock = gate;



            Rectangle r = new Rectangle();

            r.Margin          = new System.Windows.Thickness(5, 17, 5, 17);
            r.Width           = this.Width - 10;
            r.Height          = this.Height - 34;
            r.Stroke          = Brushes.Black;
            r.StrokeThickness = 2;
            r.Fill            = Brushes.White;
            myCanvas.Children.Add(r);

            Path ph = new Path();

            ph.Data            = StreamGeometry.Parse("M 10,22 h 5 v 5 h -5 v 5 h 5 v 5 h -5 v 5 h 5");
            ph.Stroke          = Brushes.Black;
            ph.StrokeThickness = 2;
            ph.Fill            = Brushes.White;
            myCanvas.Children.Add(ph);

            nval = new TextBox();
            // green team :
            // set event handler to call GotFocus()
            nval.GotFocus     += new RoutedEventHandler(nval_GotFocus);
            nval.Margin        = new System.Windows.Thickness(20, 23, 10, 23);
            nval.FontFamily    = new FontFamily("Courier New");
            nval.FontSize      = 12;
            nval.TextAlignment = TextAlignment.Center;
            nval.Width         = 34;
            nval.Height        = 18;
            nval.Background    = Brushes.AntiqueWhite;


            Binding bind = new Binding("Milliseconds");

            bind.Source                = _clock;
            bind.FallbackValue         = "0";
            bind.Mode                  = BindingMode.TwoWay;
            bind.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
            bind.ValidatesOnExceptions = true;
            nval.SetBinding(TextBox.TextProperty, bind);


            Binding bindve = new Binding("(Validation.Errors)[0].Exception.InnerException.Message");

            bindve.Source        = nval;
            bindve.Mode          = BindingMode.OneWay;
            bindve.FallbackValue = "Clock period in milliseconds";
            nval.SetBinding(TextBox.ToolTipProperty, bindve);


            myCanvas.Children.Add(nval);
        }
Example #14
0
        public override void redessiner(string path)
        {
            Terminal terminal = new Terminal();

            if (_nbroutputs > OutputStack.Children.Count)
            {
                for (int i = OutputStack.Children.Count; i < _nbroutputs; i++)
                {
                    terminal = new Terminal();
                    terminal.terminal_grid.LayoutTransform = new RotateTransform(180);
                    terminal.IsOutpt = true;
                    OutputStack.Children.Add(terminal);
                    outputs_tab.Add(false);
                }
            }
            else if (_nbroutputs < OutputStack.Children.Count)
            {
                for (int i = OutputStack.Children.Count; i > _nbroutputs; i--)
                {
                    terminal = null;
                    Wireclass wire = null;

                    foreach (Terminal tmp in OutputStack.Children)
                    {
                        terminal = tmp;
                    }
                    foreach (Wireclass tmp in terminal.wires)
                    {
                        wire = tmp;
                    }
                    if (wire != null)
                    {
                        wire.Destroy();
                    }
                    OutputStack.Children.Remove(terminal);
                    outputs_tab.RemoveAt(1);
                }
            }


            grid.Height           = _nbroutputs * 22 + 25;
            typeComponenet.Height = terminal.Height * _nbroutputs;
            typeComponenet.Width  = terminal.Width * 4;

            typeComponenet.Data                = StreamGeometry.Parse(path);
            typeComponenet.Stretch             = Stretch.Fill;
            typeComponenet.StrokeThickness     = 0;
            typeComponenet.Fill                = Brushes.RoyalBlue;
            typeComponenet.Margin              = new Thickness(14, 25, 0, 0);
            typeComponenet.HorizontalAlignment = HorizontalAlignment.Left;
            typeComponenet.VerticalAlignment   = VerticalAlignment.Top;
            recalculer_pos();
            if (IsSelect)
            {
                selectElement(this);
            }
            canvas.UpdateLayout();
        }
 private void setCommonStatus()
 {
     _isEdit                   = !_isEdit;
     btn_Edit.IsEnabled        = _isEdit;
     btn_Refresh.IsEnabled     = !_isEdit;
     btn_Update.IsEnabled      = _isEdit;
     lv_Accounts.SelectedIndex = -1;
     btn_Edit.IconData         = StreamGeometry.Parse(_isEdit ? _endEdit : _edit);
 }
Example #16
0
        public void Should_Measure_Expander_Triangle_Correctly()
        {
            using (Locator.CurrentMutable.WithResolver())
            {
                Direct2D1Platform.Initialize();

                var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");

                Assert.Equal(new Rect(0, 2, 4, 8), target.Bounds, Compare);
            }
        }
Example #17
0
        public void Should_Measure_Expander_Triangle_Correctly()
        {
            using (AvaloniaLocator.EnterScope())
            {
                Direct2D1Platform.Initialize();

                var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");

                Assert.Equal(new Rect(0, 2, 4, 8), target.Bounds, Compare);
            }
        }
Example #18
0
        public void Should_Measure_Expander_Triangle_With_Stroke_Correctly()
        {
            using (AvaloniaLocator.EnterScope())
            {
                Direct2D1Platform.Initialize();

                var target = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z");

                Assert.Equal(new Rect(-1, -0.414, 6.414, 12.828), target.GetRenderBounds(2), Compare);
            }
        }
Example #19
0
        private void CreateAnimations()
        {
            const int Count = 100;
            var       panel = new WrapPanel();

            for (var i = 0; i < Count; ++i)
            {
                Ellipse ellipse;
                var     element = new Panel
                {
                    Children =
                    {
                        (ellipse                = new Ellipse
                        {
                            Name                = $"ellipse{i}",
                            Width               =                                        100,
                            Height              =                                        100,
                            Fill                = Brushes.Blue,
                        }),
                        new Path
                        {
                            Data                = StreamGeometry.Parse(
                                "F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z"),
                            Fill                = Brushes.Green,
                            HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center,
                            VerticalAlignment   = Avalonia.Layout.VerticalAlignment.Center,
                            RenderTransform     = new ScaleTransform(2, 2),
                        }
                    },
                    Margin          = new Thickness(4),
                    RenderTransform = new ScaleTransform(),
                };

                var start   = Animate.Stopwatch.Elapsed;
                var index   = i % (Count / 2);
                var degrees = Animate.Timer
                              .Select(x => (x - start).TotalSeconds)
                              .Where(x => (x % Count) >= index && (x % Count) < index + 1)
                              .Select(x => (x % 1) / 1);

                element.RenderTransform.Bind(
                    ScaleTransform.ScaleXProperty,
                    degrees,
                    BindingPriority.Animation);

                ellipse.PointerEnter += Ellipse_PointerEnter;
                ellipse.PointerLeave += Ellipse_PointerLeave;

                panel.Children.Add(element);
            }

            Content = panel;
        }
Example #20
0
        public And(Gates.BasicGates.And mand) : base(mand,
                                                     new TerminalID[] { new TerminalID(true, 0, Position.LEFT),
                                                                        new TerminalID(true, 1, Position.LEFT),
                                                                        new TerminalID(false, 0, Position.RIGHT) })
        {
            Path ph = new Path();

            ph.Data            = StreamGeometry.Parse("M 15,12 v 40 h 15 a 2,2 1 0 0 0,-40 h -15");
            ph.Stroke          = Brushes.Black;
            ph.StrokeThickness = 2;
            ph.Fill            = Brushes.White;
            myCanvas.Children.Add(ph);
        }
Example #21
0
 /// <summary>
 /// Create a shape gate from a given gate and visual path.
 /// The visual path is based on the StreamGeometry.
 /// See http://msdn.microsoft.com/en-us/library/ms752293.aspx for details
 /// of the path syntax.
 /// </summary>
 /// <param name="abgate"></param>
 /// <param name="path"></param>
 public ShapeGate(Gates.AbstractGate abgate, string path)
     : base(abgate,
            CreateTerminals(abgate.NumberOfInputs))
 {
     ph = new Path();
     ph.StrokeEndLineCap   = PenLineCap.Square;
     ph.StrokeStartLineCap = PenLineCap.Triangle;
     ph.Data            = StreamGeometry.Parse(path);
     ph.Stroke          = Brushes.Black;
     ph.StrokeThickness = 2;
     ph.Fill            = Brushes.White;
     myCanvas.Children.Add(ph);
 }
Example #22
0
        /// <summary>
        /// The default template for a <see cref="CheckBox"/> control.
        /// </summary>
        /// <param name="control">The control being styled.</param>
        /// <returns>The root of the instantiated template.</returns>
        public static Control Template(CheckBox control)
        {
            Border result = new Border
            {
                [~Border.BackgroundProperty] = control[~TemplatedControl.BackgroundProperty],
                Child = new Grid
                {
                    ColumnDefinitions = new ColumnDefinitions
                    {
                        new ColumnDefinition(GridLength.Auto),
                        new ColumnDefinition(new GridLength(1, GridUnitType.Star)),
                    },
                    Children = new Controls
                    {
                        new Border
                        {
                            Name                  = "checkBorder",
                            BorderBrush           = Brushes.Black,
                            BorderThickness       = 2,
                            Width                 = 18,
                            Height                = 18,
                            VerticalAlignment     = VerticalAlignment.Center,
                            [Grid.ColumnProperty] = 0,
                        },
                        new Path
                        {
                            Name                  = "checkMark",
                            Fill                  = Brushes.Black,
                            Width                 = 11,
                            Height                = 10,
                            Stretch               = Stretch.Uniform,
                            HorizontalAlignment   = HorizontalAlignment.Center,
                            VerticalAlignment     = VerticalAlignment.Center,
                            Data                  = StreamGeometry.Parse("M 1145.607177734375,430 C1145.607177734375,430 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1141.449951171875,435.0772705078125 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1139.232177734375,433.0999755859375 1138,434.5538330078125 1138,434.5538330078125 1138,434.5538330078125 1141.482177734375,438 1141.482177734375,438 1141.482177734375,438 1141.96875,437.9375 1141.96875,437.9375 1141.96875,437.9375 1147,431.34619140625 1147,431.34619140625 1147,431.34619140625 1145.607177734375,430 1145.607177734375,430 z"),
                            [Grid.ColumnProperty] = 0,
                        },
                        new ContentPresenter
                        {
                            Name              = "contentPresenter",
                            Margin            = new Thickness(4, 0, 0, 0),
                            VerticalAlignment = VerticalAlignment.Center,
                            [~ContentPresenter.ContentProperty] = control[~ContentControl.ContentProperty],
                            [Grid.ColumnProperty] = 1,
                        },
                    },
                },
            };

            return(result);
        }
 private Control ToggleButtonTemplate(ToggleButton control)
 {
     return(new Border
     {
         Content = new Path
         {
             Fill = Brushes.Black,
             Stroke = Brushes.Black,
             StrokeThickness = 1,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center,
             Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
         }
     });
 }
Example #24
0
 private Control ToggleButtonTemplate(ToggleButton control)
 {
     return(new Border
     {
         Width = 12,
         Height = 14,
         HorizontalAlignment = HorizontalAlignment.Center,
         VerticalAlignment = VerticalAlignment.Center,
         Child = new Path
         {
             Fill = Brushes.Black,
             HorizontalAlignment = HorizontalAlignment.Center,
             VerticalAlignment = VerticalAlignment.Center,
             Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
         }
     });
 }
Example #25
0
    public void HitTest_Should_Not_Find_Path_When_Outside_Fill()
    {
        using (var s = new CompositorServices(new Size(200, 200)))
        {
            Path path = new Path
            {
                Width  = 200,
                Height = 200,
                Fill   = Brushes.Red,
                Data   = StreamGeometry.Parse("M100,0 L0,100 100,100")
            };
            s.TopLevel.Content = path;

            s.AssertHitTest(new Point(100, 100), null, path);
            s.AssertHitTest(new Point(10, 10), null);
        }
    }
Example #26
0
        private void ResizeDueToName()
        {
            Gates.IOGates.Comment cmt = _gate as Gates.IOGates.Comment;

            FormattedText ft = new FormattedText(cmt.Value, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight,
                                                 new Typeface(nm.FontFamily, nm.FontStyle, nm.FontWeight, nm.FontStretch),
                                                 nm.FontSize, nm.Foreground);

            // I would assume 40 b/c that is the total below
            // for diff between label width and gate width
            // but it is not enough
            // hacking it
            this.Width = Math.Max(64, ft.Width + 50);

            string path = "M0,0 ";

            for (int i = 20; i < this.Width - 20; i += 9)
            {
                path += "a 5,5 45 1 1 9,0 ";
            }
            path += "a 5,5 45 1 1 9,0 ";

            for (int i = 20; i < this.Height - 20; i += 9)
            {
                path += "a 5,5 45 1 1 0,9 ";
            }
            path += "a 5,5 45 1 1 0,9 ";

            for (int i = 20; i < this.Width - 20; i += 9)
            {
                path += "a 5,5 45 1 1 -9,0 ";
            }
            path += "a 5,5 45 1 1 -9,0 ";

            for (int i = 20; i < this.Height - 20; i += 9)
            {
                path += "a 5,5 45 1 1 0,-9 ";
            }
            path += "a 5,5 45 1 1 0,-9 ";

            ph.Data = StreamGeometry.Parse(path);

            nm.Text   = cmt.Value;
            nm.Width  = this.Width - 40;
            nm.Height = this.Height - 40;
        }
Example #27
0
        public void HorizontalLine_Absolute()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Path
                {
                    Stroke              = Brushes.Red,
                    StrokeThickness     = 1,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Data = StreamGeometry.Parse("M190,100 H10 M0,0M200,200"),
                }
            };

            RenderToFile(target);
            CompareImages();
        }
Example #28
0
        public async Task Line_Relative()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Path
                {
                    Stroke              = Brushes.Red,
                    StrokeThickness     = 1,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Data = StreamGeometry.Parse("M10,190 l190,-190 M0,0M200,200"),
                }
            };

            await RenderToFile(target);

            CompareImages();
        }
Example #29
0
        public void Arc_Relative()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Path
                {
                    Fill                = Brushes.Gray,
                    Stroke              = Brushes.Red,
                    StrokeThickness     = 1,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Data                = StreamGeometry.Parse("M190,100 a90,90 0 1,0 -180,0  M0,0M200,200"),
                }
            };

            RenderToFile(target);
            CompareImages();
        }
Example #30
0
        public void Path_100px_Triangle_Centered()
        {
            Decorator target = new Decorator
            {
                Width  = 200,
                Height = 200,
                Child  = new Path
                {
                    Fill                = Brushes.Gray,
                    Stroke              = Brushes.Red,
                    StrokeThickness     = 2,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Data                = StreamGeometry.Parse("M 0,100 L 100,100 50,0 Z"),
                }
            };

            RenderToFile(target);
            CompareImages();
        }