public static void BindShapeProperties(this IMountLocation self, object obj, Brush fill, Stroke stroke)
		{
			var control = obj as dynamic;

			control.Stroke = _reflection.Instantiate("Fuse.Drawing.Stroke") as dynamic;
			self.BindNativeProperty(fill, f => control.Color = new Float4(f.R, f.G, f.B, f.A));
			self.BindNativeProperty(stroke.Brush.CombineLatest(stroke.DashArray),
				t =>
				{
					var s = t.Item1;
					var dashArray = t.Item2;
					//Reflection.CallStatic("Fuse.Diagnostics","UserWarning", "Setting stroke of " + obj.GetHashCode() + " to " + s, obj, null, 0, null);
					if (dashArray == StrokeDashArray.Solid)
					{
						control.Stroke.Color = new Float4(s.R, s.G, s.B, s.A);
					}
					else
					{
						if (!_reflection.IsSubtype(control.Stroke.Brush, "DashedSolidColor"))
							control.Stroke.Brush = _reflection.Instantiate("DashedSolidColor", new Float4(s.R, s.G, s.B, s.A)) as dynamic;
						else
							control.Stroke.Brush.Color = new Float4(s.R, s.G, s.B, s.A);

						control.Stroke.Brush.DashSize = (float)dashArray.Data[0];
					}
				});
			self.BindNativeProperty(stroke.Thickness, s => control.Stroke.Width = (float)s);
		}
Exemple #2
0
        public static void BindShapeProperties(this IMountLocation self, System.Windows.Shapes.Shape control, Dispatcher dispatcher, Brush fill, Stroke stroke)
        {
            self.BindNativeProperty(dispatcher, "fill.Color", fill, f => control.Fill = new SolidColorBrush(f.ToColor()));

            self.BindNativeProperty(dispatcher, "stroke.Brush.Color", stroke.Brush, s => control.Stroke            = new SolidColorBrush(s.ToColor()));
            self.BindNativeProperty(dispatcher, "stroke.Thickness", stroke.Thickness, s => control.StrokeThickness = s);
            self.BindNativeProperty(dispatcher, "stroke.DashArray", stroke.DashArray, s => control.StrokeDashArray = s.ToDashArray());
        }
Exemple #3
0
        public static void BindShapeProperties(this IMountLocation self, NSShape control, IScheduler dispatcher, Brush fill, Stroke stroke)
        {
            self.BindNativeProperty(dispatcher, "fill.Color", fill, f => control.FillColor = f.ToNSColor());

            self.BindNativeProperty(dispatcher, "stroke.Brush.Color", stroke.Brush, s => control.StrokeColor     = s.ToNSColor());
            self.BindNativeProperty(dispatcher, "stroke.Thickness", stroke.Thickness, s => control.LineThickness = (float)s);
            self.BindNativeProperty(dispatcher, "stroke.DashArray", stroke.DashArray, s => control.LineDash      = s.ToLineDash());
        }
		public static void BindNativeDefaults(this IMountLocation self, object obj)
		{
			var element = obj as dynamic;

			var frame = self.NativeFrame;

			self.BindNativeProperty(frame.Left(), left =>
				element.X = _reflection.CallStatic("Uno.UX.Size", "Points", (float)left) as dynamic);
			self.BindNativeProperty(frame.Top(), top =>
				element.Y = _reflection.CallStatic("Uno.UX.Size", "Points", (float)top) as dynamic);
			self.BindNativeProperty(frame.Height, height =>
				element.Height = _reflection.CallStatic("Uno.UX.Size", "Points", (float)height) as dynamic);
			self.BindNativeProperty(frame.Width, width =>
				element.Width = _reflection.CallStatic("Uno.UX.Size", "Points", (float)width) as dynamic);
		}
Exemple #5
0
        public static void BindNativeDefaults(this IMountLocation self, NSView element, IScheduler dispatcher)
        {
            var frame = self.NativeFrame;

            self.BindNativeProperty(dispatcher, "position", frame.Position.Transpose(), position =>
            {
                element.SetFrameOrigin(position.ToPoint());
                element.NeedsDisplay = true;
            });

            self.BindNativeProperty(dispatcher, "size", frame.Size.Transpose(), size =>
            {
                element.SetFrameSize(size.Max(0, 0).ToSize());
                element.NeedsDisplay = true;
            });
        }
        static FrameworkElement Rectangle(
            IMountLocation model,
            IObservable <BitmapImage> imageStream,
            Optional <IObservable <Color> > overlayColor,
            Dispatcher dispatcher)
        {
            return(overlayColor.Select(
                       color =>
            {
                var rect = new System.Windows.Shapes.Rectangle();

                model.BindNativeProperty(dispatcher, "image", imageStream,
                                         bitmap =>
                {
                    var imgBrush = new ImageBrush(bitmap)
                    {
                        Stretch = Stretch.Uniform,
                        ImageSource = bitmap,
                    };
                    rect.OpacityMask = imgBrush;
                    rect.MaxWidth = imgBrush.ImageSource.Width;
                    rect.MaxHeight = imgBrush.ImageSource.Height;
                });

                model.BindNativeProperty(dispatcher, "overlayColor", color, c => rect.Fill = new SolidColorBrush(c.ToColor()));
                return (FrameworkElement)rect;
            }).Or(
                       () =>
            {
                var imageControl = new System.Windows.Controls.Image()
                {
                    StretchDirection = StretchDirection.DownOnly
                };
                model.BindNativeProperty(dispatcher, "image", imageStream,
                                         bitmap =>
                {
                    imageControl.Source = bitmap;
                });
                RenderOptions.SetBitmapScalingMode(imageControl, BitmapScalingMode.HighQuality);
                return (FrameworkElement)imageControl;
            }));
        }
Exemple #7
0
        public static void BindNativeDefaults(this IMountLocation self, FrameworkElement element, IScheduler dispatcher)
        {
            var frame = self.NativeFrame;

            self.BindNativeProperty(
                dispatcher, "left", frame.Left(),
                position =>
            {
                if (!double.IsInfinity(position))
                {
                    Canvas.SetLeft(element, position);
                }
            });
            self.BindNativeProperty(
                dispatcher, "top", frame.Top(),
                position =>
            {
                if (!double.IsInfinity(position))
                {
                    Canvas.SetTop(element, position);
                }
            });
            self.BindNativeProperty(
                dispatcher, "height", frame.Height,
                height =>
            {
                if (!double.IsInfinity(height))
                {
                    element.Height = Math.Max(0, (height));
                }
            });
            self.BindNativeProperty(
                dispatcher, "width", frame.Width,
                width =>
            {
                if (!double.IsInfinity(width))
                {
                    element.Width = Math.Max(0, (width));
                }
            });
        }