public ViewMedicineControl()
		{
			this.InitializeComponent();

            _expiredMedicineColor = (GradientBrush)rcExpiredMedicineColor.Fill;
            _replacedMedicineColor = (GradientBrush)rcReplacedMedicineColor.Fill;
		}
        public ViewDotationControl()
		{
			this.InitializeComponent();

            _pendingDotationColor = (GradientBrush)rcPendingDotations.Fill;
            _signedDotationColor = (GradientBrush)rcSignedDotations.Fill;
        }
        public ViewReminderControl()
		{
			this.InitializeComponent();

            _reminderSeenColor = (GradientBrush)rcReminderSeenColor.Fill;
            _reminderPendingColor = (GradientBrush)rcPendingReminderColor.Fill;
		}
 /// <summary>
 ///     This method translates Avalon SD.Brushes into
 ///     WindowsForms color objects
 /// </summary>
 private static SD.Color TranslateSolidOrGradientBrush(SWM.Brush brush, out bool defined)
 {
     SWM.Color brushColor;
     SD.Color  wfColor = SD.Color.Empty;
     defined = false;
     SWM.SolidColorBrush solidColorBrush = brush as SWM.SolidColorBrush;
     if (solidColorBrush != null)
     {
         brushColor = solidColorBrush.Color;
         defined    = true;
         wfColor    = Convert.ToSystemDrawingColor(brushColor);
     }
     else
     {
         SWM.GradientBrush gradientBrush = brush as SWM.GradientBrush;
         if (gradientBrush != null)
         {
             SWM.GradientStopCollection grads = gradientBrush.GradientStops;
             if (grads != null)
             {
                 SWM.GradientStop firstStop = grads[0];
                 if (firstStop != null)
                 {
                     brushColor = firstStop.Color;
                     defined    = true;
                     wfColor    = Convert.ToSystemDrawingColor(brushColor);
                 }
             }
         }
     }
     return(wfColor);
 }
예제 #5
0
 private void CopyStops(System.Windows.Media.GradientBrush native, GradientStopCollection <Color> stops)
 {
     foreach (var stop in stops)
     {
         var Color = (System.Windows.Media.Color)stop.Color.ToNativeColor();
         native.GradientStops.Add(new GradientStop(Color, stop.Offset));
     }
 }
예제 #6
0
        public MainWindow(WindowActivity activity)
            : base(activity)
        {
            SolidColorBrush solidBrush = new SolidColorBrush();

            StackPanel stack = new StackPanel();

            Rectangle rect = new Rectangle();
            rect.Width = 100;
            rect.Height = 100;
            rect.HorizontalAlignment = HorizontalAlignment.Right;
            GradientBrush gradient = new GradientBrush();
            gradient.StartPoint = new Point(0, .5f);
            gradient.EndPoint = new Point(1, .5f);
            gradient.GradientStops.Add(new GradientStop(new Color(1f, 1f, 0f, 1f), 0));
            gradient.GradientStops.Add(new GradientStop(new Color(0, 0, 1f, 1f), 1));
            rect.Fill = gradient;
            stack.Children.Add(rect);

            BitmapSource src = BitmapSource.Create(WindowActivity, R.drawable.funny);

            WrapPanel wrap = new WrapPanel();
            //wrap.HorizontalAlignment = HorizontalAlignment.Center;
            wrap.Orientation = Orientation.Horizontal;

            for (int i = 0; i < 8; i++)
            {
                Image img = new Image();
                img.Margin = new Thickness(5,5,5,5);
                img.ImageSource = src;
                img.HorizontalAlignment = HorizontalAlignment.Center;
                wrap.Children.Add(img);
            }

            stack.HorizontalAlignment = HorizontalAlignment.Stretch;
            stack.Children.Add(wrap);

            Content = stack;

            FloatAnimation anim = new FloatAnimation();
            anim.From = 50;
            anim.To = 300;
            anim.Duration = new Duration(TimeSpan.FromMilliseconds(10000));
            anim.RepeatBehavior = RepeatBehavior.Forever;
            anim.AutoReverse = true;
            myClock = anim.CreateClock();
            myClock.Animate(rect, Rectangle.WidthProperty);

            //myTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(1000), (e, o) => Console.WriteLine("Foo"), Dispatcher.CurrentDispatcher);
            //myTimer.Start();

            //Content = img;
        }
예제 #7
0
        /// <summary>
        ///     PDF Shading function constructor
        /// </summary>
        /// <param name="Document">Document object parent of this function.</param>
        /// <param name="Brush">System.Windows.Media gradient brush</param>
        public PdfShadingFunction
        (
            PdfDocument Document,
            SysMedia.GradientBrush Brush
        ) : base(Document, ObjectType.Stream)
        {
            // build dictionary
            Constructorhelper(Brush.GradientStops.Count);

            // add color array to contents stream
            foreach (var Stop in Brush.GradientStops)
            {
                ObjectValueList.Add(Stop.Color.R); // red
                ObjectValueList.Add(Stop.Color.G); // green
                ObjectValueList.Add(Stop.Color.B); // blue
            }
        }
예제 #8
0
파일: XamlWindow.cs 프로젝트: koush/Xaml
        public XamlWindow()
        {
            Dispatcher d1 = Dispatcher.CurrentDispatcher;
            Dispatcher d2 = Dispatcher.CurrentDispatcher;

            SolidColorBrush solidBrush = new SolidColorBrush();

            StackPanel stack = new StackPanel();
            Label label = new Label();
            label.Content = "Hello world";
            label.Margin = new Thickness(20, 0, 0, 0);
            stack.Children.Add(label);
            label.ForeBrush = solidBrush;

            label = new Label();
            label.Content = "Hello world";
            label.HorizontalAlignment = HorizontalAlignment.Right;
            label.Margin = new Thickness(0, 0, 20, 0);
            stack.Children.Add(label);

            label = new Label();
            label.Content = "Hello world";
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.Margin = new Thickness(60, 0, 0, 0);
            Font font = new Font(FontFamily.GenericSerif, 24, FontStyle.Regular);
            label.Font = font;
            stack.Children.Add(label);

            Rectangle rect = new Rectangle();
            rect.Width = 100;
            rect.Height = 100;
            rect.HorizontalAlignment = HorizontalAlignment.Right;
            GradientBrush gradient = new GradientBrush();
            gradient.StartPoint = new Point(0, .5f);
            gradient.EndPoint = new Point(1, .5f);
            gradient.GradientStops.Add(new GradientStop(new Color(1f, 1f, 0f, 1f), 0));
            gradient.GradientStops.Add(new GradientStop(new Color(0, 0, 1f, 1f), 1));
            rect.Fill = gradient;
            stack.Children.Add(rect);

            BitmapSource bitmap;
            using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("XamlTest.Flames.bmp"))
            {
                bitmap = BitmapSource.Create(stream);
            }
            Image image = new Image();
            image.Stretch = Stretch.None;
            image.ImageSource = bitmap;
            stack.Children.Add(image);

            ImageBrush brush = new ImageBrush();
            brush.ImageSource = bitmap;
            brush.Stretch = Stretch.None;
            label.ForeBrush = brush;

            Content = stack;

            FloatAnimation anim = new FloatAnimation();
            anim.From = 50;
            anim.To = 300;
            anim.Duration = new Duration(TimeSpan.FromMilliseconds(10000));
            anim.RepeatBehavior = RepeatBehavior.Forever;
            anim.AutoReverse = true;
            myClock = anim.CreateClock();
            myClock.Animate(rect, Rectangle.WidthProperty);

            //new Thread(() =>
            //    {
            //        //Thread.Sleep(2000);
            //        Random rand = new Random();
            //        while (true)
            //        {
            //            Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new EmptyDelegate(() =>
            //                {
            //                    Color newColor = new Color((byte)(rand.Next() % 256), (byte)(rand.Next() % 256), (byte)(rand.Next() % 256), (byte)(rand.Next() % 256));
            //                    solidBrush.Color = newColor;
            //                    rect.Width += 5;
            //                    if (rect.Width > 300)
            //                        rect.Width = 200;
            //                }));
            //        }
            //    }
            //).Start();
        }
예제 #9
0
 //==========================================================================
 protected override GradientBrush SetBrush(GradientBrush brush)
 {
     LinearGradientBrush linear_gradient_brush = base.SetBrush(brush) as LinearGradientBrush;
       if(linear_gradient_brush != null)
       {
     linear_gradient_brush.StartPoint = new Point(X1.ToDouble(), Y1.ToDouble());
     linear_gradient_brush.EndPoint = new Point(X2.ToDouble(), Y2.ToDouble());
       }
       return brush;
 }
        //==========================================================================
        protected virtual GradientBrush SetBrush(GradientBrush brush)
        {
            switch(SpreadMethod)
              {
            case SvgSpreadMethod.Pad:
              brush.SpreadMethod = GradientSpreadMethod.Pad;
              break;

            case SvgSpreadMethod.Reflect:
              brush.SpreadMethod = GradientSpreadMethod.Reflect;
              break;

            case SvgSpreadMethod.Repeat:
              brush.SpreadMethod = GradientSpreadMethod.Repeat;
              break;
              }

              switch(GradientUnits)
              {
            case SvgGradientUnits.ObjectBoundingBox:
              brush.MappingMode = BrushMappingMode.RelativeToBoundingBox;
              break;

            case SvgGradientUnits.UserSpaceOnUse:
              brush.MappingMode = BrushMappingMode.Absolute;
              break;
              }

              if(Transform != null)
            brush.Transform = Transform.ToTransform();

              foreach(SvgStopElement stop in Stops)
            brush.GradientStops.Add(stop.ToGradientStop());

              return brush;
        }
        //==========================================================================
        protected override GradientBrush SetBrush(GradientBrush brush)
        {
            RadialGradientBrush radial_gradient_brush = base.SetBrush(brush) as RadialGradientBrush;
              if(radial_gradient_brush != null)
              {
            double cx = CX.ToDouble();
            double cy = CY.ToDouble();
            double fx = (FX != null) ? FX.ToDouble() : cx;
            double fy = (FY != null) ? FY.ToDouble() : cy;

            radial_gradient_brush.GradientOrigin = new Point(fx, fy);
            radial_gradient_brush.RadiusX = R.ToDouble();
            radial_gradient_brush.RadiusY = R.ToDouble();
            radial_gradient_brush.Center = new Point(cx, cy);
              }
              return brush;
        }
 private void UpdateBrushes()
 {
     this.SelectedBrush = this.GetNewBrush();
     this.Mediator.Notify(ViewModelMessages.TileColorsChanged, this.GetNewBrush());
 }
예제 #13
0
		static d2.ColorBlend ConvertGradient(GradientBrush brush) {
			var g = new List<GradientStop>(brush.GradientStops);
			g.Sort((a, b) => a.Offset.CompareTo(b.Offset));

			if (g[0].Offset > 0) g.Insert(0, new GradientStop(g[0].Color, 0));
			if (g[g.Count - 1].Offset < 1) g.Add(new GradientStop(g[g.Count - 1].Color, 1));

			var offset = g[0].Offset;
			if (offset < 0) foreach(var s in g) s.Offset -= offset;
			var scale = g[g.Count - 1].Offset;
			if (scale > 1) foreach(var s in g) s.Offset /= scale;

			var cb = new d2.ColorBlend(g.Count);
			var invert = brush is RadialGradientBrush;
			for(int i = 0; i < g.Count; ++i) {
				cb.Positions[i] = (float)(invert ? (1 - g[i].Offset) : g[i].Offset);
				cb.Colors[i] = g[i].Color.ToGdiPlus(brush.Opacity);
			}
			if (invert) {
				Array.Reverse(cb.Positions);
				Array.Reverse(cb.Colors);
			}
			return cb;
		}
예제 #14
0
		static d.Brush CheckDegenerate(GradientBrush brush) {
			switch (brush.GradientStops.Count) {
			case 0: return new d.SolidBrush(d.Color.FromArgb(0 ,255 ,255 ,255));
			case 1: return new d.SolidBrush(brush.GradientStops[0].Color.ToGdiPlus(brush.Opacity));
			}
			return null;
		}