Inheritance: DependencyObject, IGradientStop
        public GradientBrushCodePage() {
            this.InitializeComponent();

            // Create the foreground brush for the TextBlock
            LinearGradientBrush foregroundBrush = new LinearGradientBrush();
            foregroundBrush.StartPoint = new Point(0, 0);
            foregroundBrush.EndPoint = new Point(1, 0);

            GradientStop gradientStop = new GradientStop();
            gradientStop.Offset = 0;
            gradientStop.Color = Colors.Blue;
            foregroundBrush.GradientStops.Add(gradientStop);

            gradientStop = new GradientStop();
            gradientStop.Offset = 1;
            gradientStop.Color = Colors.Red;
            foregroundBrush.GradientStops.Add(gradientStop);

            txtblk.Foreground = foregroundBrush;

            // Create the background brush for the Grid
            LinearGradientBrush backgroundBrush = new LinearGradientBrush {StartPoint = new Point(0, 0), EndPoint = new Point(1, 0)};
            backgroundBrush.GradientStops.Add(new GradientStop { Offset = 0, Color = Colors.Red });
            backgroundBrush.GradientStops.Add(new GradientStop { Offset = 1, Color = Colors.Blue });
            contentGrid.Background = backgroundBrush;
        }
示例#2
0
 public static D2D.GradientStop ToSharpDX(
     this Jupiter.Media.GradientStop gradientStop)
 {
     return(new D2D.GradientStop
     {
         Color = gradientStop.Color.ToSharpDX(),
         Position = (float)gradientStop.Offset
     });
 }
示例#3
0
        public GradientButton() {
            gradientStop1 = new GradientStop { Offset = 0, Color = this.Color1 };
            gradientStop2 = new GradientStop { Offset = 1, Color = this.Color2 };

            LinearGradientBrush brush = new LinearGradientBrush();
            brush.GradientStops.Add(gradientStop1);
            brush.GradientStops.Add(gradientStop2);

            this.Foreground = brush;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public LightOverviewControl()
        {
            this.InitializeComponent();

            var stops = 7;
            var step = Light.MaxHue / stops;
            for(int i = 0; i < stops; i++)
            {
                var gs = new GradientStop();
                gs.Offset = (float)i / stops;
                gs.Color = HSBColor.FromHSB(i * step, 100, 255);
                HueGradient.GradientStops.Add(gs);
            }
        }
        public static Brush DrawField(bool white)
        {
            LinearGradientBrush brush = new LinearGradientBrush();

            brush.StartPoint = white ? new Point(0, 0) : new Point(0, 1);
            brush.EndPoint = white ? new Point(1, 1) : new Point(1, 0);
            GradientStop stop1 = new GradientStop();
            stop1.Color = white ? Color.FromArgb(255, 239, 231, 186) : Color.FromArgb(255, 254, 0, 0);
            stop1.Offset = 0.5;
            brush.GradientStops.Add(stop1);
            GradientStop stop2 = new GradientStop();
            stop2.Color = white ? Color.FromArgb(255, 191, 167, 127) : Color.FromArgb(255, 169, 0, 0);
            stop2.Offset = 1;
            brush.GradientStops.Add(stop2);
            return brush;
        }
示例#6
0
        protected override void UpdateBackgroundColor()
        {
            // background color change must be handled separately
            // because the background would protrude through the border if the corners are rounded
            // as the background would be applied to the renderer's FrameworkElement
            var pancake = (PancakeView)Element;

            if (Control != null)
            {
                if ((pancake.BackgroundGradientStartColor != default(Color) && pancake.BackgroundGradientEndColor != default(Color)) || (pancake.BackgroundGradientStops != null && pancake.BackgroundGradientStops.Any()))
                {
                    // Create a gradient layer that draws our background.
                    if (pancake.BackgroundGradientStops != null && pancake.BackgroundGradientStops.Count > 0)
                    {
                        // A range of colors is given. Let's add them.
                        var orderedStops = pancake.BackgroundGradientStops.OrderBy(x => x.Offset).ToList();
                        var gc           = new Windows.UI.Xaml.Media.GradientStopCollection();

                        foreach (var item in orderedStops)
                        {
                            gc.Add(new Windows.UI.Xaml.Media.GradientStop {
                                Offset = item.Offset, Color = item.Color.ToWindowsColor()
                            });
                        }

                        this.Control.Background = new LinearGradientBrush(gc, pancake.BackgroundGradientAngle);
                    }
                    else
                    {
                        var gs1 = new Windows.UI.Xaml.Media.GradientStop {
                            Offset = 0, Color = pancake.BackgroundGradientStartColor.ToWindowsColor()
                        };
                        var gs2 = new Windows.UI.Xaml.Media.GradientStop {
                            Offset = 1, Color = pancake.BackgroundGradientEndColor.ToWindowsColor()
                        };
                        var gc = new Windows.UI.Xaml.Media.GradientStopCollection {
                            gs1, gs2
                        };
                        this.Control.Background = new LinearGradientBrush(gc, pancake.BackgroundGradientAngle);
                    }
                }
                else
                {
                    Control.Background = Element.BackgroundColor.IsDefault ? null : Element.BackgroundColor.ToBrush();
                }
            }
        }
示例#7
0
        private void UpdateBorder(PancakeView pancake)
        {
            //// Create the border layer
            if (Control != null)
            {
                this.Control.BorderThickness = new Windows.UI.Xaml.Thickness(pancake.BorderThickness);

                if ((pancake.BorderGradientStartColor != default(Color) && pancake.BorderGradientEndColor != default(Color)) || (pancake.BorderGradientStops != null && pancake.BorderGradientStops.Any()))
                {
                    // Create a gradient layer that draws our background.
                    if (pancake.BorderGradientStops != null && pancake.BorderGradientStops.Count > 0)
                    {
                        // A range of colors is given. Let's add them.
                        var orderedStops = pancake.BorderGradientStops.OrderBy(x => x.Offset).ToList();
                        var gc           = new Windows.UI.Xaml.Media.GradientStopCollection();

                        foreach (var item in orderedStops)
                        {
                            gc.Add(new Windows.UI.Xaml.Media.GradientStop {
                                Offset = item.Offset, Color = item.Color.ToWindowsColor()
                            });
                        }

                        this.Control.BorderBrush = new LinearGradientBrush(gc, pancake.BorderGradientAngle);
                    }
                    else
                    {
                        var gs1 = new Windows.UI.Xaml.Media.GradientStop {
                            Offset = 0, Color = pancake.BorderGradientStartColor.ToWindowsColor()
                        };
                        var gs2 = new Windows.UI.Xaml.Media.GradientStop {
                            Offset = 1, Color = pancake.BorderGradientEndColor.ToWindowsColor()
                        };
                        var gc = new Windows.UI.Xaml.Media.GradientStopCollection {
                            gs1, gs2
                        };
                        this.Control.BorderBrush = new LinearGradientBrush(gc, pancake.BorderGradientAngle);
                    }
                }
                else
                {
                    this.Control.BorderBrush = pancake.BorderColor.IsDefault ? null : pancake.BorderColor.ToBrush();
                }
            }
        }
        void FlatNavigationPage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            Current = this;

            AppBar appBar = new AppBar();
            appBar.Content = new FlatNavigationControl();
            this.TopAppBar = appBar;

            LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush();
            myLinearGradientBrush.StartPoint = new Point(0, 0);
            myLinearGradientBrush.EndPoint = new Point(1, 1);
            GradientStop gradientStop = new GradientStop();

            myLinearGradientBrush.GradientStops.Add(new GradientStop() { Color = Colors.AliceBlue, Offset = 0 });
            myLinearGradientBrush.GradientStops.Add(new GradientStop() { Color = Colors.Magenta, Offset = 1 });

            this.Background = myLinearGradientBrush;
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Loaded += Clr_Pckr_Loaded;

            clrViewbox = GetTemplateChild("clrViewbox") as Viewbox;
            pointer = GetTemplateChild("pointer") as Grid;
            reference = GetTemplateChild("reference") as Border;
            rtrnsfrm = GetTemplateChild("rtrnsfrm") as CompositeTransform;
            innerCanvas = GetTemplateChild("innerCanvas") as Canvas;
            innerEll = GetTemplateChild("innerEll") as Grid;
            ColorImg = GetTemplateChild("ColorImg") as Image;
           
            thumbInnerEll = GetTemplateChild("thumbInnerEll") as Thumb;
            rectColor = GetTemplateChild("rectColor") as Rectangle;
            gdStop = GetTemplateChild("gdStop") as GradientStop;
            FinalColor = GetTemplateChild("FinalColor") as Ellipse;
            testblock = GetTemplateChild("test") as TextBlock;


            ColorImg.Tapped += ColorImg_Tapped_1;
          
            rectColor.PointerPressed += Rectangle_PointerPressed_1;
            thumbInnerEll.DragDelta += Thumb_DragDelta_1;

            ColorImg.PointerReleased += ColorImg_PointerReleased_1;
            ColorImg.PointerPressed += ColorImg_PointerPressed_1;
            ColorImg.PointerMoved += ColorImg_PointerMoved_1;

            gdStop.Color = SelectedColor;
            FinalColor.Fill = new SolidColorBrush(SelectedColor);



            GeneralTransform gt = pointer.TransformToVisual(reference);

            Point p = new Point();

            p = gt.TransformPoint(p);
            px = p.X;
            py = p.Y;
            loadnew();
        }
        protected override void OnHSBColorSourceChanged()
        {
            if (HSBColorSource == null)
            {
                return;
            }

            int stops = 7;
            HueGradient.GradientStops.Clear();
            for (int i = 0; i <= stops; i++)
            {
                GradientStop gs = new GradientStop();
                gs.Offset = (float)i / stops;

                int hue = (int)Math.Floor(Light.MaxHue * gs.Offset);
                gs.Color = HSBColor.FromHSB(hue, (int)HSBColorSource.S / 2, (int)HSBColorSource.B);
                HueGradient.GradientStops.Add(gs);
            }

            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(HSBColorSource);

            // Set slider thumb positions
            if (HueSlider.Value != HSBColorSource.H)
            {
                HueSlider.Value = HSBColorSource.H;
            }

            if (SaturationSlider.Value != HSBColorSource.S)
            {
                SaturationSlider.Value = HSBColorSource.S;
            }

            if (BrightnessSlider.Value != HSBColorSource.B)
            {
                BrightnessSlider.Value = HSBColorSource.B;
            }
        }
示例#11
0
        public object ConvertToNative(Brush brush, object context)
        {
            winMedia.Brush winBrush = null;

            // SolidColorBrush
            if (brush is SolidColorBrush)
            {
                SolidColorBrush xamBrush = brush as SolidColorBrush;

                winBrush = new winMedia.SolidColorBrush
                {
                    Color = ConvertColor(xamBrush.Color)
                };
            }

            // LinearGradientBrush
            else if (brush is LinearGradientBrush)
            {
                LinearGradientBrush xamBrush = brush as LinearGradientBrush;

                winBrush = new winMedia.LinearGradientBrush
                {
                    StartPoint   = ConvertPoint(xamBrush.StartPoint),
                    EndPoint     = ConvertPoint(xamBrush.EndPoint),
                    SpreadMethod = ConvertGradientSpread(xamBrush.SpreadMethod)
                };

                foreach (GradientStop xamGradientStop in xamBrush.GradientStops)
                {
                    winMedia.GradientStop winGradientStop = new winMedia.GradientStop
                    {
                        Color  = ConvertColor(xamGradientStop.Color),
                        Offset = xamGradientStop.Offset
                    };

                    (winBrush as winMedia.LinearGradientBrush).GradientStops.Add(winGradientStop);
                }
            }

            else if (brush is ImageBrush)
            {
                ImageBrush xamBrush = brush as ImageBrush;

                winBrush = new winMedia.ImageBrush
                {
                    Stretch    = (winMedia.Stretch)(int) xamBrush.Stretch,
                    AlignmentX = (winMedia.AlignmentX)(int) xamBrush.AlignmentX,
                    AlignmentY = (winMedia.AlignmentY)(int) xamBrush.AlignmentY,
                };

                ImageSource xamImageSource = (brush as ImageBrush).ImageSource;

                if (xamImageSource != null)
                {
                    IImageSourceHandler handler = null;

                    if (xamImageSource.GetType() == typeof(FileImageSource))
                    {
                        handler = new FileImageSourceHandler();
                    }
                    else if (xamImageSource.GetType() == typeof(StreamImageSource))
                    {
                        handler = new StreamImageSourceHandler();
                    }
                    else if (xamImageSource.GetType() == typeof(UriImageSource))
                    {
                        handler = new UriImageSourceHandler();
                    }

                    if (handler != null)
                    {
                        Task <winMedia.ImageSource> winImageSourceTask = handler.LoadImageAsync(xamImageSource);

                        winImageSourceTask.ContinueWith((task) =>
                        {
                            winFound.IAsyncAction asyncAction = winBrush.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                            {
                                (winBrush as winMedia.ImageBrush).ImageSource = task.Result;
                            });
                        });
                    }
                }
            }

            if (winBrush != null)
            {
                winBrush.Transform = brush.Transform?.GetNativeObject() as winMedia.MatrixTransform;

                // TODO: RelativeTransform and Opacity
            }

            return(winBrush);
        }
        /// <summary>
        /// Populates list from response of web service
        /// </summary>
        /// <param name="ReportsList"></param>
        private async void PopulateQueue(ObservableCollection<ReportObject> QueuedList, IReadOnlyList<StorageFile> pf)
        {
            //if (refreshMap)
            //{
            //    ClearMap();
            //}

            queuedObjectList.Clear();

            int count = 0;
            foreach (var Que in QueuedList)
            {
                Image image = new Image();
                count++;
                var file = await pictureFolder.GetFileAsync(count + "_" + Que.ReportType.ToString() + ".png");

                var fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
                var img = new BitmapImage();
                img.SetSource(fileStream);

                image.Source = img;

                GridViewItem ReportView = new GridViewItem();
                GridViewItem ImageView = new GridViewItem();

                StackPanel listSP = new StackPanel();

                LinearGradientBrush lgb = new LinearGradientBrush();

                lgb.StartPoint = new Point(.5, 0);
                lgb.EndPoint = new Point(.5, 1);

                GradientStop lggs = new GradientStop();
                lggs.Color = Color.FromArgb(255, 217, 214, 203);
                lggs.Offset = 0.0;
                lgb.GradientStops.Add(lggs);

                GradientStop ggs = new GradientStop();
                ggs.Color = Color.FromArgb(255, 108, 108, 108);
                ggs.Offset = 1.25;
                lgb.GradientStops.Add(ggs);

                listSP.Background = lgb;

                listSP.Orientation = Orientation.Horizontal;

                StackPanel reportSP = new StackPanel();

                queuedListIndex.Add(Que.ReportId);

                TextBlock ridTB = new TextBlock() { Text = Que.ReportId.ToString() };
                ridTB.Foreground = new SolidColorBrush(Colors.Black);
                reportSP.Children.Add(ridTB);

                TextBlock rtypeTB = new TextBlock() { Text = Que.ReportType };
                rtypeTB.Foreground = new SolidColorBrush(Colors.Black);
                reportSP.Children.Add(rtypeTB);

                TextBlock rtimeTB = new TextBlock() { Text = Que.ReportTime.ToString() };
                rtimeTB.Foreground = new SolidColorBrush(Colors.Black);
                reportSP.Children.Add(rtimeTB);

                ReportObject queuedReportObject = new ReportObject(Que.ReportId,
                                                                   Que.ReportType,
                                                                   Que.ReportAuthor,
                                                                   Que.ReportDescription,
                                                                   Que.ReportLocation,
                                                                   Que.ReportTime,
                                                                   Que.ReportLatitude,
                                                                   Que.ReportLongitude,
                                                                   Que.ReportAccuracy,
                                                                   Que.ReportDirection);

                queuedObjectList.Add(queuedReportObject);

                if (!(queuedReportObject.ReportLatitude == "NA" || queuedReportObject.ReportLongitude == "NA"))
                {
                    try
                    {
                        AddToMap(queuedReportObject);
                    }
                    catch (Exception) { }
                }

                image.Height = 110;
                image.Width = 175;

                ImageView.Content = image;
                ReportView.Content = reportSP;
                ImageView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(QImageSelected), true);
                ReportView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(QReportSelected), true);

                listSP.Children.Add(ReportView);
                listSP.Children.Add(ImageView);
                QueuedListView.Items.Add(listSP);
            }
            if (count > 0)
            {
                if (SIUC311.SettingsView.GetAutoSubmitSetting())
                {
                    await WaitablePromptMessage("You have " + count + " reports queued\n\nQueued reports will be automatically submitted.");
                }
                else
                {
                    await WaitablePromptMessage("You have " + count + " reports queued.");
                }
                if (haveInternetAccess)
                {
                    //NotifyUser("Processing queue . . . ", NotifyType.ReportMessage);
                    try
                    {
                        inSession = await SIU311Service.IsSessionAliveAsync(sessionId); // SLOW TAKES TIME 
                    }
                    catch (Exception)
                    {
                        inSession = false;
                    }
                    //NotifyUser("Session checked at " + string.Format("{0:M/d/yyyy H:mm:ss tt}", DateTime.Now), NotifyType.ReportMessage);
                    if (inSession)
                    {
                        if (SIUC311.SettingsView.GetAutoSubmitSetting())
                        {
                            await SubmitQueue();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Populates list from response of web service
        /// </summary>
        /// <param name="ReportsList"></param>
        private async void PopulateList(ObservableCollection<SIUC311ServiceRef.ReportObject> ReportsList, bool byOwner)
        {
            // add condition from checkbox
            if (refreshMap)
            {
                ClearMap();
                reportObjectList.Clear();
            }            

            foreach (var Rep in ReportsList)
            {
                Image image = new Image();

                var photoObject = await SIU311Service.GetPhotoAsync(Rep.ReportId);

                BitmapImage bimage;

                if (photoObject != null && photoObject.ReportPhoto != null)
                {
                    bimage = await ByteToImage(photoObject.ReportPhoto);
                }
                else
                {
                    bimage = new BitmapImage(new Uri("ms-appx:///Assets/ImagePlaceHolder.png"));
                }

                string status = await SIU311Service.GetStatusAsync(Rep.ReportId);

                image.Source = bimage;

                GridViewItem ReportView = new GridViewItem();
                GridViewItem ImageView = new GridViewItem();

                StackPanel listSP = new StackPanel();

                LinearGradientBrush lgb = new LinearGradientBrush();

                lgb.StartPoint = new Point(.5, 0);
                lgb.EndPoint = new Point(.5, 1);

                GradientStop lggs = new GradientStop();
                lggs.Color = Color.FromArgb(255, 217, 214, 203);
                lggs.Offset = 0.0;
                lgb.GradientStops.Add(lggs);

                GradientStop ggs = new GradientStop();
                ggs.Color = Color.FromArgb(255, 108, 108, 108);
                ggs.Offset = 1.25;
                lgb.GradientStops.Add(ggs);

                listSP.Background = lgb;

                listSP.Orientation = Orientation.Horizontal;

                StackPanel reportSP = new StackPanel();

                reportListIndex.Add(Rep.ReportId);

                StackPanel idStatusSP = new StackPanel();
                idStatusSP.Orientation = Orientation.Horizontal;

                TextBlock ridTB = new TextBlock() { Text = Rep.ReportId.ToString() };
                ridTB.Foreground = new SolidColorBrush(Colors.Black);

                TextBlock statusTB = new TextBlock() { Text = " : " + status };
                statusTB.Foreground = new SolidColorBrush(Colors.Black);

                idStatusSP.Children.Add(ridTB);
                idStatusSP.Children.Add(statusTB);

                reportSP.Children.Add(idStatusSP);

                TextBlock rtypeTB = new TextBlock() { Text = Rep.ReportType };
                rtypeTB.Foreground = new SolidColorBrush(Colors.Black);
                reportSP.Children.Add(rtypeTB);

                if (!byOwner)
                {
                    TextBlock rownTB = new TextBlock() { Text = Rep.ReportAuthor };
                    rownTB.Foreground = new SolidColorBrush(Colors.Black);
                    reportSP.Children.Add(rownTB);
                }

                TextBlock rtimeTB = new TextBlock() { Text = Rep.ReportTime.ToString() };
                rtimeTB.Foreground = new SolidColorBrush(Colors.Black);
                reportSP.Children.Add(rtimeTB);

                ReportObject reportObject = new ReportObject(Rep.ReportId,
                                                             Rep.ReportType,
                                                             Rep.ReportAuthor,
                                                             Rep.ReportDescription,
                                                             Rep.ReportLocation,
                                                             Rep.ReportTime,
                                                             Rep.ReportLatitude,
                                                             Rep.ReportLongitude,
                                                             Rep.ReportAccuracy,
                                                             Rep.ReportDirection);

                reportObjectList.Add(reportObject);

                if (!(reportObject.ReportLatitude == "NA" || reportObject.ReportLatitude == "NA"))
                {
                    try
                    {
                        AddToMap(reportObject);
                    }
                    catch (Exception) { }
                }

                image.Height = 110;
                image.Width = 175;
                ImageView.Content = image;

                ReportView.Content = reportSP;

                ImageView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(ImageSelected), true);
                ReportView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(ReportSelected), true);

                listSP.Children.Add(ReportView);
                listSP.Children.Add(ImageView);

                ReportsListView.Items.Add(listSP);
            }
            UnLockControls();
        }
示例#14
0
		private static void OnRateChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
		{
			var uc = obj as StarRating;
			if (uc != null && e.NewValue != e.OldValue)
			{
				double value = Convert.ToDouble(e.NewValue);

				uc.star_1.Fill = new SolidColorBrush(Colors.Gray);
				uc.star_2.Fill = new SolidColorBrush(Colors.Gray);
				uc.star_3.Fill = new SolidColorBrush(Colors.Gray);
				uc.star_4.Fill = new SolidColorBrush(Colors.Gray);
				uc.star_5.Fill = new SolidColorBrush(Colors.Gray);

				if (value == 0) return;

				double floorValue = Math.Floor(value);
				double realPart = value - floorValue;

				LinearGradientBrush gradient = new LinearGradientBrush();
				gradient.StartPoint = new Point(0.5, 0);
				gradient.EndPoint = new Point(1, 0);

				GradientStop first = new GradientStop();
				first.Color = Colors.Yellow;
				first.Offset = realPart;

				GradientStop second = new GradientStop();
				second.Color = Colors.Gray;
				second.Offset = realPart;

				gradient.GradientStops.Add(first);
				gradient.GradientStops.Add(second);

				if (value > 0 && value < 1)
				{
					uc.star_1.Fill = gradient;
					return;
				}

				if (value > 1 && value < 2)
				{
					uc.star_1.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_2.Fill = gradient;
					return;
				}

				if (value > 2 && value < 3)
				{
					uc.star_1.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_2.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_3.Fill = gradient;
					return;
				}

				if (value > 3 && value < 4)
				{
					uc.star_1.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_2.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_3.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_4.Fill = gradient;
					return;
				}

				if (value > 4 && value < 5)
				{
					uc.star_1.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_2.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_3.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_4.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_5.Fill = gradient;
					return;
				}
				else {
					uc.star_1.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_2.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_3.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_4.Fill = new SolidColorBrush(Colors.Yellow);
					uc.star_5.Fill = new SolidColorBrush(Colors.Yellow);
				}
			}
		}
示例#15
0
文件: HexagonGrid.cs 项目: djpark/Hex
        public void UpdateHex(Hexagon hUI, Hex h)
        {
            if (h.HexColor == Color.Null)
            {
                hUI.Color = new SolidColorBrush(Colors.Gray);
                hUI.IsVisible = false;
            }
            else
            {
                GradientStopCollection gsc = new GradientStopCollection();
                GradientStop white = new GradientStop();
                GradientStop primary = new GradientStop();
                primary.Offset = -0.25;
                white.Offset = 1.5;
                white.Color = Colors.White;

                switch (h.HexColor)
                {
                    case Color.Blue:
                        primary.Color = Colors.Blue;
                        break;

                    case Color.Green:
                        primary.Color = Colors.Green;
                        break;

                    case Color.Orange:
                        primary.Color = Colors.Orange;
                        break;

                    case Color.White:
                        primary.Color = Colors.White;
                        break;

                    case Color.Purple:
                        primary.Color = Colors.Purple;
                        break;

                    case Color.Red:
                        primary.Color = Colors.Red;
                        break;

                    case Color.Yellow:
                        primary.Color = Colors.Yellow;
                        break;
                }

                gsc.Add(primary);
                gsc.Add(white);

                // Update UIElement
                hUI.IsVisible = true;
                hUI.Color = new LinearGradientBrush(gsc, 0.0f); ;
            }
        }