private void CreatePlayersLayout(RadDiagram diagram, HudDragCanvas dgCanvas, ReplayerViewModel viewModel)
        {
            var seats = (int)CurrentCapacity;

            var positionProvider = ServiceLocator.Current.GetInstance <IPositionProvider>(ReplayerPokerSite.ToString());

            var labelPositions = positionProvider.Positions[seats];
            var hasHoleCards   = viewModel.CurrentGame.Players.Any(x => x.hasHoleCards);
            var cardsCount     = hasHoleCards ? viewModel.CurrentGame.Players.Where(x => x.hasHoleCards).Max(x => x.HoleCards.Count) : 2;

            for (var i = 0; i < seats; i++)
            {
                var player = viewModel.PlayersCollection[i];
                var label  = CreatePlayerLabel(player);

                label.X = labelPositions[i, 0];
                label.Y = labelPositions[i, 1];

                PlaceCardLabels(diagram, label, cardsCount);

                player.ChipsContainer.ChipsShape.X = predefinedChipsPositions[seats][i, 0];
                player.ChipsContainer.ChipsShape.Y = predefinedChipsPositions[seats][i, 1];

                AddPotPlayerLabel(diagram, viewModel.PlayersCollection[i], predefinedChipsPositions[seats][i, 0], predefinedChipsPositions[seats][i, 1]);

                diagram.AddShape(label);
                diagram.AddShape(player.ChipsContainer.ChipsShape);
            }
        }
Beispiel #2
0
        public Form1()
        {
            StyleManager.ApplicationTheme = new Office_SilverTheme();
            InitializeComponent();

            diagram = new RadDiagram()
            {
                Background = System.Windows.Media.Brushes.White, IsBackgroundSurfaceVisible = false
            };
            elementHost1.Child = diagram;
            var s1 = diagram.AddShape(new RadDiagramShape {
                Position = new System.Windows.Point(120, 50)
            });
            var s2 = diagram.AddShape(new RadDiagramShape {
                Position = new System.Windows.Point(320, 50)
            });
            var con = diagram.AddConnection(s1, s2) as RadDiagramConnection;

            con.Content = "Connected";
            con.Stroke  = System.Windows.Media.Brushes.OrangeRed;

            var info = diagram.AddShape(
                "This is not a XAML form, but a Windows Form hosting RadDiagram.",
                ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
                new System.Windows.Point(280, 150)) as RadDiagramShape;

            info.Background = System.Windows.Media.Brushes.Transparent;
            info.Stroke     = System.Windows.Media.Brushes.Silver;
        }
        private void CreatePlayerLabels(RadDiagram diagram, FilterStandardViewModel viewModel)
        {
            var positions = predefinedPlayerPositions[seats];

            IList <TableRingItem> collection;

            switch ((EnumTableType)seats)
            {
            case EnumTableType.Six:
                collection = viewModel.FilterModel.ActiveTable6MaxCollection;
                break;

            default:
                collection = viewModel.FilterModel.ActiveTableFullRingCollection;
                break;
            }

            for (int i = 0; i < seats && i < collection.Count; i++)
            {
                var tableItem = collection[i];

                RadDiagramShape player = new RadDiagramShape()
                {
                    DataContext                  = tableItem,
                    Background                   = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), BackgroundPlayerImage))),
                    Height                       = PLAYER_HEIGHT,
                    Width                        = PLAYER_WIDTH,
                    StrokeThickness              = 0,
                    BorderThickness              = new Thickness(0),
                    IsResizingEnabled            = false,
                    IsRotationEnabled            = false,
                    IsDraggingEnabled            = false,
                    IsManipulationEnabled        = false,
                    IsManipulationAdornerVisible = false,
                    IsHitTestVisible             = true,
                    FontSize                     = 13,
                };

                player.X = positions[tableItem.Seat - 1, 0];
                player.Y = positions[tableItem.Seat - 1, 1];

                var indicator = AddActiveIndicator(player, tableItem);

                player.MouseLeftButtonUp    += PlayerControl_MouseLeftButtonUp;
                indicator.MouseLeftButtonUp += PlayerControl_MouseLeftButtonUp;

                diagram.AddShape(player);
                diagram.AddShape(indicator);
            }
        }
        private void PlaceCardLabels(RadDiagram diagram, RadDiagramShape playerLabel, int cardsCount = 2)
        {
            var player = playerLabel.DataContext as ReplayerPlayerViewModel;

            if (player == null)
            {
                throw new ArgumentNullException("playerLabel", "Cannot place card labels for player because player is null");
            }

            Binding myBinding = new Binding(nameof(ReplayerPlayerViewModel.IsFinished))
            {
                Source = player, Mode = BindingMode.TwoWay, Converter = new BoolToVisibilityConverter(), ConverterParameter = "Inverse"
            };

            for (int i = 0; i < cardsCount; i++)
            {
                var card = CreateCardLabel(diagram, player.Cards[i]);
                card.SetBinding(UIElement.VisibilityProperty, myBinding);

                if (cardsCount == 4)
                {
                    double offset = card.Width / 4;
                    var    start  = playerLabel.X - offset + 2;
                    var    width  = playerLabel.Width + offset;
                    card.X = start + i * width / 5;
                }
                else if (cardsCount == 2)
                {
                    card.X = playerLabel.X + 5 + i * (playerLabel.Width - 10 - card.Width);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("cardsCount", "Supported cardsCount values are 2 and 4");
                }

                card.Y = playerLabel.Y - 60;

                diagram.AddShape(card);
            }

            if (player.IsDealer)
            {
                var button = CreateDealerLabel(diagram, player);
                button.X = playerLabel.X - BUTTON_WIDTH - 5;
                button.Y = playerLabel.Y + playerLabel.Height / 2 - BUTTON_HEIGHT / 2;

                diagram.AddShape(button);
            }
        }
        public static IContainerShape CreateContainerShape(this RadDiagram diagram, string title = null, string name = null)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "Container";
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "Container_" + Rand.Next(665686356);
            }
            var shape = new RadDiagramContainerShape
            {
                Width   = 250,
                Height  = 150,
                Name    = name,
                Content = title,
                //Stroke = Brushes.DimGray,
                IsCollapsible   = true,
                StrokeThickness = 1,

                CollapsedContent = null,
            };

            diagram.AddShape(shape);
            return(shape);
        }
        public static RadDiagramShape CreateShape(this RadDiagram diagram, string title = null, string name = null)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "Shape";
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "Shape_" + Rand.Next(665686356);
            }
            var shape = new RadDiagramShape
            {
                Width           = 80,
                Height          = 50,
                Name            = name,
                Geometry        = ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
                Background      = new SolidColorBrush(Windows8Palette.Palette.AccentColor),
                Content         = title,
                Stroke          = new SolidColorBrush(Colors.DarkGray),
                StrokeThickness = 0,
                Position        = new Point(50 + Rand.Next(800), 50 + Rand.Next(600))
            };

            diagram.AddShape(shape);
            return(shape);
        }
        private void CreateTotalPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel)
        {
            System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
            Binding myBinding = new Binding(nameof(ReplayerViewModel.TotalPotValue))
            {
                Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "{0:C2}"
            };

            lbl.SetBinding(ContentControl.ContentProperty, myBinding);
            lbl.Foreground = Brushes.White;
            lbl.Margin     = new Thickness(480, 100, 100, 100);
            diagram.AddShape(lbl);

            viewModel.TotalPotChipsContainer.ChipsShape.X = TotalPotChipsPosition.X;
            viewModel.TotalPotChipsContainer.ChipsShape.Y = TotalPotChipsPosition.Y;

            diagram.AddShape(viewModel.TotalPotChipsContainer.ChipsShape);
        }
Beispiel #8
0
        public Form1()
        {
            StyleManager.ApplicationTheme = new Office_SilverTheme();
            InitializeComponent();

            diagram = new RadDiagram() { Background = System.Windows.Media.Brushes.White, IsBackgroundSurfaceVisible = false };
            elementHost1.Child = diagram;
            var s1 = diagram.AddShape(new RadDiagramShape { Position = new System.Windows.Point(120, 50) });
            var s2 = diagram.AddShape(new RadDiagramShape { Position = new System.Windows.Point(320, 50) });
            var con = diagram.AddConnection(s1, s2) as RadDiagramConnection;
            con.Content = "Connected";
            con.Stroke = System.Windows.Media.Brushes.OrangeRed;

            var info = diagram.AddShape(
                "This is not a XAML form, but a Windows Form hosting RadDiagram.",
                ShapeFactory.GetShapeGeometry(CommonShapeType.RectangleShape),
                new System.Windows.Point(280, 150)) as RadDiagramShape;
            info.Background = System.Windows.Media.Brushes.Transparent;
            info.Stroke = System.Windows.Media.Brushes.Silver;
        }
        private void CreatePlayerLabels(RadDiagram diagram, SettingsSiteViewModel viewModel, int seats)
        {
            var positions = PredefinedPlayerPositions[seats];

            for (int i = 0; i < seats; i++)
            {
                RadDiagramShape player = new RadDiagramShape()
                {
                    Background                   = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), BackgroundPlayerImage))),
                    Height                       = PLAYER_HEIGHT,
                    Width                        = PLAYER_WIDTH,
                    StrokeThickness              = 0,
                    BorderThickness              = new Thickness(0),
                    IsResizingEnabled            = false,
                    IsRotationEnabled            = false,
                    IsDraggingEnabled            = false,
                    IsManipulationEnabled        = false,
                    IsManipulationAdornerVisible = false,
                    IsHitTestVisible             = true,
                    FontSize                     = 13,
                    DataContext                  = viewModel.SelectedSiteViewModel,
                    Tag    = i + 1,
                    Cursor = Cursors.Hand
                };
                player.X = positions[i, 0];
                player.Y = positions[i, 1];

                var indicator = AddActiveIndicator(player, viewModel, i + 1);

                player.MouseLeftButtonUp    += PlayerControl_MouseLeftButtonUp;
                indicator.MouseLeftButtonUp += PlayerControl_MouseLeftButtonUp;

                diagram.AddShape(player);
                diagram.AddShape(indicator);
            }
        }
Beispiel #10
0
 public static void CreateGraph(this RadDiagram diagram, GraphGenerationSpecifications specs, CreateShapeDelegate createShape)
 {
     diagram.Clear();
     if (specs.Connections)
     {
         var g = specs.Connected ? GraphExtensions.CreateRandomConnectedGraph(specs.NodeCount, 4, specs.TreeGraph) : GraphExtensions.CreateRandomGraph(specs.NodeCount, 4, specs.TreeGraph);
         diagram.CreateDiagram(g, GraphExtensions.CreateShape, specs.RandomShapeSize);
     }
     else
     {
         for (var i = 0; i < specs.NodeCount; i++)
         {
             var shape = createShape(new Node(i, false), specs.RandomShapeSize);
             diagram.AddShape(shape);
         }
     }
 }
        private void CreateCurrentPotValueLabel(RadDiagram diagram, ReplayerViewModel viewModel)
        {
            System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
            Binding myBinding = new Binding(nameof(ReplayerViewModel.CurrentPotValue))
            {
                Source = viewModel, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "Pot {0:C2}"
            };

            lbl.SetBinding(ContentControl.ContentProperty, myBinding);
            lbl.Background      = Brushes.LightGray;
            lbl.Foreground      = Brushes.Black;
            lbl.BorderBrush     = Brushes.Black;
            lbl.BorderThickness = new Thickness(1);
            lbl.Padding         = new Thickness(3, 3, 3, 3);
            lbl.Margin          = new Thickness(480, 315, 100, 100);
            diagram.AddShape(lbl);
        }
        public void ConfigureTable(RadDiagram diagram, FilterStandardViewModel viewModel)
        {
            diagram.Clear();

            var table = new RadDiagramShape()
            {
                Background      = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), string.Format(BackgroundImage, seats)))),
                StrokeThickness = 0,
                IsEnabled       = false,
                Height          = TABLE_HEIGHT,
                Width           = TABLE_WIDTH,
                X = tablePosition.X,
                Y = tablePosition.Y
            };

            diagram.AddShape(table);

            CreatePlayerLabels(diagram, viewModel);
        }
        public void ConfigureTable(RadDiagram diagram, SettingsSiteViewModel viewModel, EnumTableType tableType)
        {
            diagram.Clear();

            var table = new RadDiagramShape()
            {
                Background      = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), GetBackgroundImage(tableType)))),
                StrokeThickness = 0,
                IsEnabled       = false,
                Height          = TABLE_HEIGHT,
                Width           = TABLE_WIDTH,
                X = tablePosition.X,
                Y = tablePosition.Y,
            };

            diagram.AddShape(table);

            CreatePlayerLabels(diagram, viewModel, (int)tableType);
        }
        private void AddPotPlayerLabel(RadDiagram diagram, ReplayerPlayerViewModel player, double x, double y)
        {
            try
            {
                System.Windows.Controls.Label lbl = new System.Windows.Controls.Label();
                Binding myBinding = new Binding(ReflectionHelper.GetPath <ReplayerPlayerViewModel>(o => o.ActiveAmount))
                {
                    Source = player, Mode = BindingMode.TwoWay, Converter = new DecimalToPotConverter(), ConverterParameter = "{0:C2}"
                };
                lbl.SetBinding(ContentControl.ContentProperty, myBinding);
                lbl.Foreground = Brushes.White;

                lbl.Margin = new Thickness(x - 15, y + 20, 100, 100);

                diagram.AddShape(lbl);
            }
            catch (Exception e)
            {
                LogProvider.Log.Error(this, e);
            }
        }
        private void CreateTable(RadDiagram diagram)
        {
            diagram.Clear();

            var seats = (int)CurrentCapacity;

            table = new RadDiagramShape()
            {
                Name            = "Table",
                Background      = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(diagram), BackgroundImage))),
                Height          = predefinedTableSizes[seats].Item1,
                Width           = predefinedTableSizes[seats].Item2,
                StrokeThickness = 0,
                IsEnabled       = false
            };

            table.X = DefaultTablePosition.X;
            table.Y = DefaultTablePosition.Y;

            diagram.AddShape(table);
        }
        private void PlaceTableCardPanels(RadDiagram diagram, ReplayerViewModel viewModel)
        {
            double y = table.Y + table.Height / 2 - CARD_HEIGHT / 2.0 - 20;
            double x = table.X + table.Width / 2 - CARD_WIDTH / 2.0 - 2 * CARD_WIDTH - 10;

            for (int i = 0; i < viewModel.CommunityCards.Count; i++)
            {
                var card = CreateCardLabel(diagram, viewModel.CommunityCards[i]);

                Street  cardStreet = i < 3 ? Street.Flop : i < 4 ? Street.Turn : Street.River;
                Binding myBinding  = new Binding(ReflectionHelper.GetPath <ViewModels.Replayer.ReplayerViewModel>(o => o.CurrentStreet))
                {
                    Source = viewModel, Mode = BindingMode.TwoWay, Converter = new StreetToVisibilityConverter(), ConverterParameter = cardStreet
                };
                card.SetBinding(UIElement.VisibilityProperty, myBinding);

                card.X = x;
                card.Y = y;

                diagram.AddShape(card);

                x = card.X + CARD_WIDTH + 5;
            }
        }