public static void ShowToast(Grid baseGrid, string message)
        {
            gridCount ++;

            StackPanel grid = new StackPanel();
            grid.Width = 200;
            grid.Height = 40;
            grid.Background = new System.Windows.Media.SolidColorBrush(Colors.Gray);
            grid.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            grid.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
            grid.Margin = new Thickness(0, 0, 0, 30);


            TextBlock text = new TextBlock();
            text.Text = message;
            text.VerticalAlignment = VerticalAlignment.Center;
            text.HorizontalAlignment = HorizontalAlignment.Center;
            text.FontSize = 22;

            grid.Children.Add(text);

            baseGrid.Children.Add(grid);

            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 3);
            timer.Tick += (sender, args) =>
            {
                var anim = new DoubleAnimation(0, (Duration) TimeSpan.FromSeconds(1));
                grid.BeginAnimation(UIElement.OpacityProperty, anim);
                anim.Completed += (s, _) => baseGrid.Children.Remove(grid);
                timer.Stop();
            };
            timer.Start();
        }
Beispiel #2
0
        public void Draw()
        {
            if (SelectedItem == null) return;
            if (gArcs == null) return;
            gArcs.Children.Clear();
            var a = 360.0/Segments;

            if (SelectedItem.Element != null)
            {
                ccCenter.Content = SelectedItem.Element;
                pBack.Visibility = Visibility.Collapsed;
                //ccCenter.Visibility = Visibility.Visible;
            }
            else if (SelectedItem.Icon != null && SelectedItem == RootItem)
            {
                iCenterIcon.Source = new BitmapImage(new Uri(SelectedItem.Icon, UriKind.RelativeOrAbsolute));
                iCenterIcon.Visibility = Visibility.Visible;
                pBack.Visibility = Visibility.Collapsed;
            }
            else
            {
                iCenterIcon.Visibility = Visibility.Collapsed;
                pBack.Visibility = Visibility.Visible;
                //ccCenter.Visibility = Visibility.Collapsed;
            }

            if (!Open)
            {
                BackgroundBrush = null;
                return;
            }
            BackgroundBrush = Brushes.White;

            for (var i = 0; i < Segments; i++)
            {
                var mi = SelectedItem.Items.FirstOrDefault(k => k.Position == i);

                var s = new Arc
                {
                    Width = Size,
                    Height = Size,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Stretch = Stretch.None,
                    StartAngle = i*a,
                    StrokeThickness = 0,
                    Stroke = null,
                    EndAngle = (i + 1)*a - 1
                };
                if (mi != null && mi.Items != null && mi.Items.Count > 0)
                {
                    s.Fill = AccentBrush;
                    s.MouseDown += (e, si) => SelectItem(mi);
                    s.TouchDown += (e, si) => SelectItem(mi);
                }
                else
                {
                    s.Fill = SecondAccentBrush;
                }
                s.ArcThickness = 0;
                s.ArcThicknessUnit = UnitType.Pixel;

                gArcs.Children.Add(s);
                s.BeginAnimation(Arc.ArcThicknessProperty,
                    new DoubleAnimation(ArrowArcSize, new Duration(new TimeSpan(0, 0, 0, 0, 200))));
                const double dDegToRad = Math.PI/180.0;

                if (mi == null) continue;
                var f = new Arc
                {
                    Width = Size - (ArrowArcSize*2) - 3,
                    Height = Size - (ArrowArcSize*2) - 3,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Stretch = Stretch.None,
                    StartAngle = i*a,
                    StrokeThickness = 0,
                    Stroke = null,
                    EndAngle = (i + 1)*a - 1,
                    Tag =  i
                };
                if (mi.Fill == null) mi.Fill = Brushes.Transparent;
                f.Fill = mi.Fill;
                f.ArcThickness = ItemSize;
                f.ArcThicknessUnit = UnitType.Pixel;
                f.MouseDown += (sender, e) => SelectItem(mi);

                //var eventAsObservable = Observable.FromEventPattern<TouchEventArgs>(f, "TouchDown");
                //eventAsObservable.Throttle(TimeSpan.FromMilliseconds(200)).Subscribe(k => Execute.OnUIThread(() => SelectItem(mi)));

                // Only subscribe to TouchDown on Windows 7: On Windows 8, it causes 
                var win8Version = new Version(6, 2, 9200, 0);
                if (Environment.OSVersion.Platform == PlatformID.Win32NT &&
                    Environment.OSVersion.Version < win8Version)
                {
                    f.TouchDown += (e, si) => SelectItem(mi);
                }
                //f.TouchDown += (sender, e) => SelectItem(mi);

                gArcs.Children.Add(f);
                f.UpdateLayout();


                var sp = new StackPanel {Opacity = 0, IsHitTestVisible = false};
                if (mi.Element != null)
                {
                    var vb = new Viewbox {Width = 20, Height = 20, Stretch = Stretch.Uniform};
                    var pa = new Path {Data = Geometry.Parse(mi.Element), Fill = Brushes.Black};
                    vb.Child = pa;

                    sp.Children.Add(vb);
                }
                else if (!string.IsNullOrEmpty(mi.Icon))
                {
                    var img = new Image {Width = 20, Height = 20, Stretch = Stretch.UniformToFill};
                    var binding = new Binding {Source = mi, Path = new PropertyPath("Icon"), Mode = BindingMode.OneWay};
                    //img.Source = new BitmapImage(new Uri(mi.Icon, UriKind.RelativeOrAbsolute));
                    img.SetBinding(Image.SourceProperty, binding);
                    sp.Children.Add(img);
                }
                else
                {
                    var b = new Border {Background = null, Width = 20, Height = 20};
                    sp.Children.Add(b);
                }
                var tb = new TextBlock {Text = mi.Title};
                var bind = new Binding {Source = mi, Path = new PropertyPath("Title"), Mode = BindingMode.OneWay};
                tb.SetBinding(TextBlock.TextProperty, bind);
                var r = MenuCenterSize/2 + ItemSize - 10;
                var dX = r*Math.Sin((i + 0.5)*a*dDegToRad);

                // We invert the Y coordinate, because the origin in controls 
                // is the upper left corner, rather than the lower left
                var dY = -r*Math.Cos((i + 0.5)*a*dDegToRad);
                tb.Foreground = Brushes.Black;
                tb.FontSize = 9;
                f.TranslatePoint(new Point(ItemSize/2, ItemSize/2), gArcs);
                tb.TextAlignment = TextAlignment.Center;
                tb.HorizontalAlignment = HorizontalAlignment.Center;
                sp.RenderTransform = new TranslateTransform(dX, dY + Size/2 - 15);
                sp.Tag = i;
                sp.Children.Add(tb);
                gArcs.Children.Add(sp);

                sp.BeginAnimation(OpacityProperty,
                    new DoubleAnimation(1.0, new Duration(new TimeSpan(0, 0, 0, 0, 200))));


                if (mi.Items == null || mi.Items.Count <= 0) continue;
                var rp = new RegularPolygon
                {
                    IsHitTestVisible = false,
                    PointCount = 3,
                    Width = 8,
                    Height = 8,
                    Fill = Brushes.White,
                    Margin = new Thickness(-4, 0, 0, 0)
                };
                var r2 = Size/2 - (ArrowArcSize/2) + (rp.Width/2);
                rp.RenderTransform = new TransformGroup
                {
                    Children = new TransformCollection
                    {
                        new RotateTransform((i + 0.5)*a),
                        new TranslateTransform(
                            r2*Math.Sin((i + 0.5)*a*dDegToRad) + 5,
                            -r2*Math.Cos((i + 0.5)*a*dDegToRad) + 5
                            )
                    }
                };
                gArcs.Children.Add(rp);
            }

            //if (SelectedItem.Items == null || SelectedItem.Items.Count <= 0) return;
            //foreach (var i in SelectedItem.Items)
            //    if (i.Fill != null)
            //    {
            //    }
        }
Beispiel #3
0
        private void option1_click(object sender, RoutedEventArgs e)
        {
            StackPanel sp = sender as StackPanel;
            StackPanel usedToBe = currentlyExpanded;

            if (currentlyExpanded != null)
            {
                double initialHeight = usedToBe.DesiredSize.Height;

                StackPanel sub = new StackPanel();

                shrink();
                this.UpdateLayout();
                double finalHeight = views[usedToBe].stub.DesiredSize.Height;
                sub.Height = initialHeight - finalHeight;
                usedToBe.Children.Add(sub);
                //views[sp].stub.Height = initialHeight;
                this.UpdateLayout();

                Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                doubleanimation.To = 0;

                doubleanimation.TargetElement = usedToBe;

                doubleanimation.Completed += new EventHandler(ShrinkAnimationCompleted);

                //views[sp].stub.BeginAnimation(HeightProperty, doubleanimation);
                sub.BeginAnimation(HeightProperty, doubleanimation);

            }
            if (usedToBe != sp)
            {
                double initialHeight = sp.DesiredSize.Height;

                expand(sp);
                this.UpdateLayout();
                double finalHeight = views[sp].DesiredSize.Height;
                //shrink();
                views[sp].Height = initialHeight;
                this.UpdateLayout();

                //StackPanel sub = new StackPanel();
                //sp.Children.Add(sub);

                //sub.Height = 0;

                Duration duration = new Duration(TimeSpan.FromSeconds(0.50));
                DoubleAnimationPlus doubleanimation = new DoubleAnimationPlus();
                doubleanimation.Duration = duration;
                //doubleanimation.To = finalHeight - initialHeight;
                doubleanimation.To = finalHeight;
                doubleanimation.From = initialHeight;

                doubleanimation.TargetElement = sp;

                doubleanimation.Completed += new EventHandler(AnimationCompleted);

                //sub.BeginAnimation(HeightProperty, doubleanimation);
                views[sp].BeginAnimation(HeightProperty, doubleanimation);
            }
        }
Beispiel #4
0
 private void CloseStackPanel(StackPanel stackPanel)
 {
     if (stackPanel.Height > 0)
     {
         DoubleAnimation animation = new DoubleAnimation() { From = stackPanel.Height, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
         stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
     }
 }
Beispiel #5
0
        private void FoldAfterAnotherSingleMode(StackPanel openedStackPanel, StackPanel closedStackPanel)
        {
            double openedStackPanelHeight = GetStackPanelHeight(openedStackPanel);
            double closedStackPanelHeight = GetStackPanelHeight(closedStackPanel);

            DoubleAnimation closingAnimation = new DoubleAnimation() { From = openedStackPanelHeight, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
            DoubleAnimation openingAnimation = new DoubleAnimation() { From = 0, To = closedStackPanelHeight, Duration = TimeSpan.Parse("0:0:0.35") };
            closingAnimation.Completed += (s, e) => closedStackPanel.BeginAnimation(StackPanel.HeightProperty, openingAnimation);
            openedStackPanel.BeginAnimation(StackPanel.HeightProperty, closingAnimation);
        }
Beispiel #6
0
 private void FoldStackPanelUpwardButton(StackPanel stackPanel)
 {
     double stackPanelHeight = GetStackPanelHeightButton(stackPanel);
     if (stackPanel.Height > 0)
     {
         DoubleAnimation animation = new DoubleAnimation() { From = stackPanelHeight, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
         stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
     }
     else
     {
         DoubleAnimation animation = new DoubleAnimation() { From = 0, To = stackPanelHeight, Duration = TimeSpan.Parse("0:0:0.35") };
         stackPanel.BeginAnimation(StackPanel.HeightProperty, animation);
     }
 }
Beispiel #7
0
 private void FoldStackPanelSideward(StackPanel stackPanel)
 {
     double stackPanelWidth = GetStackPanelWidth(stackPanel);
     if (stackPanel.Width > 0)
     {
         DoubleAnimation animation = new DoubleAnimation() { From = stackPanelWidth, To = 0, Duration = TimeSpan.Parse("0:0:0.35") };
         stackPanel.BeginAnimation(StackPanel.WidthProperty, animation);
     }
     else
     {
         DoubleAnimation animation = new DoubleAnimation() { From = 0, To = stackPanelWidth, Duration = TimeSpan.Parse("0:0:0.35") };
         stackPanel.BeginAnimation(StackPanel.WidthProperty, animation);
     }
 }