Пример #1
0
        public VoteBall(Vector p, CanvasController CC, Color c, int R, bool yn, bool vB, string text)
        {
            fill = new SolidColorBrush()
            {
                Color = c
            };

            Title = new TextBlock()
            {
                Text          = text,
                FontFamily    = new FontFamily("Segoe UI"),
                FontSize      = 20,
                TextAlignment = System.Windows.TextAlignment.Center,
                Foreground    = Brushes.Black
            };

            this.position         = p;
            this.CanvasCtrl       = CC;
            this._radius          = R;
            this.yes              = yn;
            this.voteBool         = vB;
            this.selectedBall     = null;
            this.ballClicked      = false;
            this.safeZoneT        = 0;
            this.Title.Visibility = Visibility.Hidden;

            Ellipse = new Ellipse()
            {
                Fill = fill,
            };

            Ellipse.AddHandler(TouchExtensions.TapGestureEvent, new RoutedEventHandler(Ellipse_TapGestureEvent));
        }
Пример #2
0
        /**
         * Erstellt alle Felder im Grid (müssen Studis selbst machen aber mit Hilfestellung)
         */
        public void createFields()
        {
            // Hinweis: Die Anzahl der Reihen und Spalten im Grid können mittels Field.RowDefinitions.Count bzw. FieldColumnDefinitions.Count abgeholt werden

            for (int row = 0; row < Field.RowDefinitions.Count; row++)
            {
                for (int column = 0; column < Field.ColumnDefinitions.Count; column++)
                {
                    // [3] Neues Münzfeld erstellen (Klasse Ellipse verwenden)
                    Ellipse current = new Ellipse();

                    // [4] Hintergrundfarbe des Münzfeldes auf neutrale Farbe (z.B. Weiß) setzen (Achtung. Bei Ellipse ist die Eigenschaft der Hintergrundfarbe "Fill")
                    current.Fill = System.Windows.Media.Brushes.White;

                    // [5] Münzfeld in der entsprechenden Zeile und Spalte platzieren sowie Rahmenstärke vorgeben (Vorgegeben)
                    current.SetValue(Grid.RowProperty, row);
                    current.SetValue(Grid.ColumnProperty, column);
                    current.Margin = new Thickness(5);

                    // [6] Klick Methode hinzufügen
                    current.AddHandler(MouseLeftButtonDownEvent, new RoutedEventHandler(SlotClicked));

                    // [7] Münzfelder dem Spielfeld (Grid) hinzufügen
                    Field.Children.Add(current);
                }
            }
        }
Пример #3
0
        public IdeaBall(Vector Position, Vector Velocity, Canvas mainCanvas, int rad, Color c, CanvasController CC, String text)
        {
            random = new Random();
            fill   = new SolidColorBrush()
            {
                Color = c
            };

            this.Velocity          = Velocity;
            this.Position          = Position;
            this.mainCanvas        = mainCanvas;
            this.IsTouched         = false;
            this.timerReset        = 0;
            this.affectedByGravity = true;
            this.CanvasCtrl        = CC;
            this.runHandler        = true;
            this.text           = text;
            this.transformGroup = new TransformGroup();
            this.rotation       = new RotateTransform(0);
            this.transformGroup.Children.Add(this.rotation);


            Ellipse = new Ellipse()
            {
                Fill = fill,
            };


            Title = new TextBlock()
            {
                Text             = text,
                FontFamily       = new FontFamily("Segoe UI"),
                FontSize         = 20,
                IsHitTestVisible = false,
                TextAlignment    = System.Windows.TextAlignment.Center
            };

            Radius = rad;

            timer.Elapsed += new ElapsedEventHandler(Ellipse_HoldGestureEvent);
            timer.Interval = 1000;

            pulseTimer.Elapsed += new ElapsedEventHandler(Ellipse_ClickedFeedbackEvent);
            pulseTimer.Interval = 125;

            Ellipse.IsManipulationEnabled = true;
            this.Ellipse.RenderTransform  = this.transformGroup;

            Ellipse.TouchDown  += new System.EventHandler <System.Windows.Input.TouchEventArgs>(Ellipse_TouchDown);
            Ellipse.TouchMove  += new System.EventHandler <System.Windows.Input.TouchEventArgs>(Ellipse_TouchMove);
            Ellipse.TouchLeave += new System.EventHandler <System.Windows.Input.TouchEventArgs>(Ellipse_TouchLeave);
            Ellipse.AddHandler(TouchExtensions.TapGestureEvent, new RoutedEventHandler(Ellipse_TapGestureEvent));
            Ellipse.ManipulationStarting        += this.TouchableThing_ManipulationStarting;
            Ellipse.ManipulationDelta           += this.TouchableThing_ManipulationDelta;
            Ellipse.ManipulationInertiaStarting += this.TouchableThing_ManipulationInertiaStarting;
        }
Пример #4
0
        private void randomCircle()
        {
            Random r  = new Random();
            int    cx = r.Next() % x;
            int    cy = r.Next() % y;
            int    cr = r.Next() % 500 + 50;

            baseCanvas.Children.Clear();
            Ellipse e = new Ellipse();

            e.Height = cr;
            e.Width  = cr;
            e.Stroke = new SolidColorBrush(Color.FromArgb((byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200)));
            e.Fill   = new SolidColorBrush(Color.FromArgb((byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200), (byte)(r.Next() % 200)));
            e.SetValue(Canvas.LeftProperty, (double)cx);
            e.SetValue(Canvas.TopProperty, (double)cy);

            e.AddHandler(Button.MouseLeftButtonDownEvent, new MouseButtonEventHandler(e_MouseLeftButtonDown), true);

            baseCanvas.Children.Add(e);
        }
Пример #5
0
        void OnLoad(object sender, RoutedEventArgs e)
        {
            //<SnippetToolTipCode>
            //Create an ellipse that will have a
            //ToolTip control.
            Ellipse ellipse1 = new Ellipse();

            ellipse1.Height = 25;
            ellipse1.Width  = 50;
            ellipse1.Fill   = Brushes.Gray;
            ellipse1.HorizontalAlignment = HorizontalAlignment.Left;

            //Create a tooltip and set its position.
            //<SnippetToolTipControlPlacement>
            ToolTip tooltip = new ToolTip();

            tooltip.Placement          = PlacementMode.Right;
            tooltip.PlacementRectangle = new Rect(50, 0, 0, 0);
            tooltip.HorizontalOffset   = 10;
            tooltip.VerticalOffset     = 20;
            //</SnippetToolTipControlPlacement>

            //Create BulletDecorator and set it
            //as the tooltip content.
            BulletDecorator bdec          = new BulletDecorator();
            Ellipse         littleEllipse = new Ellipse();

            littleEllipse.Height = 10;
            littleEllipse.Width  = 20;
            littleEllipse.Fill   = Brushes.Blue;
            bdec.Bullet          = littleEllipse;
            TextBlock tipText = new TextBlock();

            tipText.Text    = "Uses the ToolTip class";
            bdec.Child      = tipText;
            tooltip.Content = bdec;

            //set tooltip on ellipse
            ellipse1.ToolTip = tooltip;
            //</SnippetToolTipCode>

            stackPanel_1_1.Children.Add(ellipse1);

            //set event handlers for the Opened and Closed events
            //<SnippetToolTipEventHandlers>
            tooltip.Opened +=
                new RoutedEventHandler(whenToolTipOpens);
            tooltip.Closed +=
                new RoutedEventHandler(whenToolTipCloses);
            //</SnippetToolTipEventHandlers>

            //set drop shadow effect
            //<SnippetToolTipHasDropShadow>
            tooltip.HasDropShadow = false;
            //</SnippetToolTipHasDropShadow>

            ///////////////////////////////////////////////////////////////////////
            //<SnippetNoToolTipCode>
            //Create and Ellipse with the BulletDecorator as
            //the tooltip
            Ellipse ellipse2 = new Ellipse();

            ellipse2.Name = "ellipse2";
            this.RegisterName(ellipse2.Name, ellipse2);
            ellipse2.Height = 25;
            ellipse2.Width  = 50;
            ellipse2.Fill   = Brushes.Gray;
            ellipse2.HorizontalAlignment = HorizontalAlignment.Left;

            //set tooltip timing
            ToolTipService.SetInitialShowDelay(ellipse2, 1000);
            ToolTipService.SetBetweenShowDelay(ellipse2, 2000);
            ToolTipService.SetShowDuration(ellipse2, 7000);

            //set tooltip placement
            //<SnippetNonToolTipControlPlacement>

            //<SnippetSetPlacement>
            ToolTipService.SetPlacement(ellipse2, PlacementMode.Right);
            //</SnippetSetPlacement>

            //<SnippetSetPlacementRectangle>
            ToolTipService.SetPlacementRectangle(ellipse2,
                                                 new Rect(50, 0, 0, 0));
            //</SnippetSetPlacementRectangle>

            //<SnippetSetHorizontalOffset>
            ToolTipService.SetHorizontalOffset(ellipse2, 10.0);
            //</SnippetSetHorizontalOffset>

            //<SnippetSetVerticalOffset>
            ToolTipService.SetVerticalOffset(ellipse2, 20.0);
            //</SnippetSetVerticalOffset>

            //</SnippetNonToolTipControlPlacement>

            //<SnippetSetHasDropShadow>
            ToolTipService.SetHasDropShadow(ellipse2, false);
            //</SnippetSetHasDropShadow>

            //<SnippetSetIsEnabled>
            ToolTipService.SetIsEnabled(ellipse2, true);
            //</SnippetSetIsEnabled>

            //<SnippetSetShowOnDisabled>
            ToolTipService.SetShowOnDisabled(ellipse2, true);
            //</SnippetSetShowOnDisabled>

            //<SnippetToolTipServiceEventHandlers>
            ellipse2.AddHandler(ToolTipService.ToolTipOpeningEvent,
                                new RoutedEventHandler(whenToolTipOpens));
            ellipse2.AddHandler(ToolTipService.ToolTipClosingEvent,
                                new RoutedEventHandler(whenToolTipCloses));
            //</SnippetToolTipServiceEventHandlers>

            //define tooltip content
            //<SnippetSetToolTip>
            BulletDecorator bdec2          = new BulletDecorator();
            Ellipse         littleEllipse2 = new Ellipse();

            littleEllipse2.Height = 10;
            littleEllipse2.Width  = 20;
            littleEllipse2.Fill   = Brushes.Blue;
            bdec2.Bullet          = littleEllipse2;
            TextBlock tipText2 = new TextBlock();

            tipText2.Text = "Uses the ToolTipService class";
            bdec2.Child   = tipText2;
            //<SnippetSetToolTip2>
            ToolTipService.SetToolTip(ellipse2, bdec2);
            //</SnippetSetToolTip2>
            stackPanel_1_2.Children.Add(ellipse2);
            //</SnippetSetToolTip>

            //</SnippetNoToolTipCode>
        }
Пример #6
0
        private void DrawCircels()
        {
            gameGrid1.Children.Clear();
            gameGrid2.Children.Clear();
            blackDeadArea.Children.Clear();
            whiteDeadArea.Children.Clear();
            {
                int k = 0;
                for (int i = 0; i < _board.GameBoard.Count(); i++)
                {
                    if (i > 11)
                    {
                        k++;
                    }
                    if (_board.GameBoard[i].Count > 0)
                    {
                        if (i <= 11)
                        {
                            int n = 0;
                            foreach (var item in _board.GameBoard[i])
                            {
                                Ellipse el = new Ellipse();
                                if (item.Color == "Black")
                                {
                                    el.Fill = new SolidColorBrush(Colors.Black);
                                }
                                else
                                {
                                    el.Fill = new SolidColorBrush(Colors.White);
                                }

                                if (item.IsSelected == true)
                                {
                                    el.Stroke          = new SolidColorBrush(Colors.Yellow);
                                    el.StrokeThickness = 3;
                                }
                                else
                                {
                                    el.Stroke = null;
                                }
                                el.Height = 45;
                                el.Width  = 45;
                                el.HorizontalAlignment = HorizontalAlignment.Center;
                                el.Name = $"{i}_{n}";
                                el.AddHandler(TappedEvent, new TappedEventHandler(Ellipse_Tapped), true);
                                _circels.Add(el);
                                if (i == 6)
                                {
                                    el.HorizontalAlignment = HorizontalAlignment.Left;
                                }
                                Grid.SetColumn(el, 11 - i);
                                Grid.SetRow(el, n);
                                gameGrid1.Children.Add(el);

                                n++;
                            }
                        }

                        if (i > 11)
                        {
                            if (_board.GameBoard[i].Count > 0)
                            {
                                int n = 6;

                                foreach (var item in _board.GameBoard[i])
                                {
                                    Ellipse el = new Ellipse();
                                    if (item.Color == "Black")
                                    {
                                        el.Fill = new SolidColorBrush(Colors.Black);
                                    }
                                    else
                                    {
                                        el.Fill = new SolidColorBrush(Colors.White);
                                    }

                                    if (item.IsSelected == true)
                                    {
                                        el.Stroke          = new SolidColorBrush(Colors.Yellow);
                                        el.StrokeThickness = 3;
                                    }
                                    else
                                    {
                                        el.Stroke = null;
                                    }
                                    el.Height = 45;
                                    el.Width  = 45;
                                    el.HorizontalAlignment = HorizontalAlignment.Center;
                                    el.Name = $"{i}_{n}";
                                    el.AddHandler(TappedEvent, new TappedEventHandler(Ellipse_Tapped), true);
                                    _circels.Add(el);
                                    if (i == 17)
                                    {
                                        el.HorizontalAlignment = HorizontalAlignment.Left;
                                    }
                                    Grid.SetColumn(el, k - 1);
                                    Grid.SetRow(el, n);
                                    gameGrid2.Children.Add(el);

                                    n--;
                                }
                            }
                        }
                    }
                }
                int index = 0;
                foreach (var item in _currnetPlayer.NumOfDeadCircels)
                {
                    Ellipse el = new Ellipse();
                    if (item.Color == "Black")
                    {
                        el.Fill = new SolidColorBrush(Colors.Black);
                    }
                    else
                    {
                        el.Fill = new SolidColorBrush(Colors.White);
                    }
                    if (item.IsSelected == true)
                    {
                        el.Stroke          = new SolidColorBrush(Colors.Yellow);
                        el.StrokeThickness = 3;
                    }
                    else
                    {
                        el.Stroke = null;
                    }
                    el.Height = 45;
                    el.Width  = 45;
                    el.HorizontalAlignment = HorizontalAlignment.Center;
                    el.Name = $"dead{index}";
                    _circels.Add(el);
                    el.AddHandler(TappedEvent, new TappedEventHandler(Ellipse_Tapped), true);
                    Grid.SetColumn(el, index);
                    Grid.SetRow(el, index);
                    if (_currnetPlayer.Color == "Black")
                    {
                        blackDeadArea.Children.Add(el);
                    }
                    else
                    {
                        whiteDeadArea.Children.Add(el);
                    }
                    index++;
                }

                foreach (var item in _secondPlayer.NumOfDeadCircels)
                {
                    Ellipse el = new Ellipse();
                    if (item.Color == "Black")
                    {
                        el.Fill = new SolidColorBrush(Colors.Black);
                    }
                    else
                    {
                        el.Fill = new SolidColorBrush(Colors.White);
                    }
                    if (item.IsSelected == true)
                    {
                        el.Stroke          = new SolidColorBrush(Colors.Yellow);
                        el.StrokeThickness = 3;
                    }
                    else
                    {
                        el.Stroke = null;
                    }
                    el.Height = 45;
                    el.Width  = 45;
                    el.HorizontalAlignment = HorizontalAlignment.Center;
                    el.Name = $"dead{index}";
                    _circels.Add(el);
                    el.AddHandler(TappedEvent, new TappedEventHandler(Ellipse_Tapped), true);
                    Grid.SetColumn(el, index);
                    Grid.SetRow(el, index);
                    if (_secondPlayer.Color == "Black")
                    {
                        blackDeadArea.Children.Add(el);
                    }
                    else
                    {
                        whiteDeadArea.Children.Add(el);
                    }
                    index++;
                }
            }
        }