Inheritance: CircularMenuItem
Beispiel #1
0
        public static ColorCircularMenuItem CreateColorMenu(string title, int pos)
        {

            CircularMenuItem opacity = new CircularMenuItem()
                                           {
                                               Title = "Opacity",
                                               Position = 7,
                                               Items = new List<CircularMenuItem>()
                                                           {
                                                               new CircularMenuItem() {Title = "20%", Position = 1},
                                                               new CircularMenuItem() {Title = "40%", Position = 2},
                                                               new CircularMenuItem() {Title = "60%", Position = 3},
                                                               new CircularMenuItem() {Title = "80%", Position = 4},
                                                               new CircularMenuItem() {Title = "100%", Position = 5},
                                                           }
                                           };
            

            ColorCircularMenuItem result = new ColorCircularMenuItem()
                                               {
                                                   Title = title,
                                                   Position = pos,
                                                   Items = new List<CircularMenuItem>()
                                                               {
                                                                   new CircularMenuItem() {Title = "Purple",Fill = Brushes.Purple,Position = 0},
                                                                   new CircularMenuItem() {Title = "Red",Fill = Brushes.Red,Position = 1},
                                                                   new CircularMenuItem() {Title = "Blue",Fill = Brushes.Blue, Position = 2},
                                                                   new CircularMenuItem() {Title = "Black",Fill = Brushes.Black, Position = 3},
                                                                   new CircularMenuItem() {Title = "Orange",Fill = Brushes.Orange,Position = 4},
                                                                   new CircularMenuItem() {Title = "Green",Fill = Brushes.Green, Position = 5},
                                                                   
                                                                 
                                                                   new CircularMenuItem() {Title = "None",Position = 6},
                                                                   opacity
                                                               }
                                               };

            opacity.ItemSelected += (e, f) =>
            {
                var i =
                    double.Parse(f.SelectedItem.Title.Remove(f.SelectedItem.Title.Length - 1, 1)) / 100.0;
                result.UpdateOpacity(i);
                opacity.Menu.Back();
            };

            result.Opacity = 1;

            result.ItemSelected += (e, s) =>
                                       {
                                           result.UpdateColor(((SolidColorBrush)s.SelectedItem.Fill).Color);
                                           if (result.Menu != null) result.Menu.Back();
                                       };

            return result;
        }
Beispiel #2
0
        private void UpdateMenu()
        {
            circularMenuItem.Items.Clear();
            lineColor = ColorCircularMenuItem.CreateColorMenu("Line", 5);
            lineColor.Color = Colors.Black;
            circularMenuItem.Items.Add(lineColor);

            fillColor = ColorCircularMenuItem.CreateColorMenu("Fill", 6);
            fillColor.Color = Colors.Transparent;
            //circularMenuItem.Items.Add(fillColor);

            sketchMenuItem = new CircularMenuItem
            {
                Title = "Draw",
                Id = "Draw",
                CanCheck = true,
                Fill = Brushes.White,
                Icon = "pack://application:,,,/csCommon;component/Resources/Icons/freehand.png"
            };

            Draw = new Draw(AppState.ViewDef.MapControl)
            {
                DrawMode = DrawMode.Freehand,
                LineSymbol = new SimpleLineSymbol {Color = Brushes.Black, Width = 3}
            };
            Draw.DrawBegin += MyDrawObject_DrawBegin;
            Draw.DrawComplete += MyDrawObjectDrawComplete;
            sketchMenuItem.Selected += (s, f) =>
            {
                selectedPoiType = new PoI
                {
                    Service = SketchService,
                    DrawingMode = DrawingModes.Polyline,
                    StrokeColor = lineColor.Color,
                    FillColor = Colors.Transparent,
                    StrokeWidth = 3,
                    
                };
                Draw.LineSymbol = new SimpleLineSymbol {Color = new SolidColorBrush(lineColor.Color), Width = 3};
                //sketchMenuItem.Fill = AppState.AccentBrush;
                Draw.IsEnabled = true;
                drawingNotification = new NotificationEventArgs
                {
                    Id = Guid.NewGuid(),
                    Style = NotificationStyle.Popup,
                    Duration = TimeSpan.FromHours(1),
                    Header = "Drawing activated",
                    Foreground = Brushes.White,
                    Background = AppState.AccentBrush,
                    Image = new BitmapImage(new Uri("pack://application:,,,/csCommon;component/Resources/Icons/Pen.png"))
                };

                AppState.TriggerNotification(drawingNotification);
            };

            var clear = new CircularMenuItem
            {
                Title = "Clear",
                Id = "Clear",
                CanCheck = true,
                Position = 3,
                Icon = "pack://application:,,,/csCommon;component/Resources/Icons/appbar.delete.png"
            };
            clear.Selected += (s, f) => { while (SketchService.PoIs.Any()) SketchService.PoIs.RemoveAt(0); };

            circularMenuItem.Items.Add(sketchMenuItem);
            circularMenuItem.Items.Add(clear);
        }