Пример #1
0
        private void pos_click(object sender, RoutedEventArgs e)
        {
            Button b   = (Button)sender;
            pawn   pwn = (pawn)b.DataContext;

            if (select.player1 == true)
            {
                if (select.highlighted == false)
                {
                    select.pwn   = pwn;
                    selectedpawn = b;
                    select.highlight(placeholders);
                    // highlight = true;
                }
                else
                {
                    select.move(b, selectedpawn);
                    clearhighlight(placeholders);
                }
            }
            else if (select.player1 == false)
            {
                if (select.highlighted == false)
                {
                    select.pwn   = pwn;
                    selectedpawn = b;
                    select.highlight(placeholders);
                }
                else
                {
                    select.move(b, selectedpawn);
                    clearhighlight(placeholders);
                }
            }
        }
Пример #2
0
        public static void Getmoves(Card crd, pawn pwn, List <List <Button> > placeholders /*, RoutedEventHandler v*/)
        {
            //pawn.Findindex(pwn, placeholders);
            //pwn.positions.Clear();
            //foreach (List<int> c in crd.vector)
            //{
            //    int x = pwn.index[0];
            //    int y = pwn.index[1];
            //    int x2 = c[0];
            //    int y2 = c[1];

            //    try
            //    {
            //        pwn.positions.Add(placeholders[x + x2][y + y2]);
            //        Canvas.SetZIndex(placeholders[x + x2][y + y2], 2);
            //        //    placeholders[x + x2][y + y2].Click += v;
            //        // placeholders[x + x2][y + y2].set
            //    }
            //    catch { }
            //}
        }
Пример #3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            select.possible = possiblemoves;
            crdplaceholer.Add(crd1); crdplaceholer.Add(crd2); crdplaceholer.Add(crd3); crdplaceholer.Add(crd4); crdplaceholer.Add(crd5);
            placeholders.Add(new List <Button> {
                p1, p2, p3, p4, p5
            });
            placeholders.Add(new List <Button> {
                p6, p7, p8, p9, p10
            });
            placeholders.Add(new List <Button> {
                p11, p12, p13, p14, p15
            });
            placeholders.Add(new List <Button> {
                p16, p17, p18, p19, p20
            });
            placeholders.Add(new List <Button> {
                p21, p22, p23, p24, p25
            });

            int u = 0;

            Gen(crdplaceholer, crds);
            foreach (Button i in placeholders[0])
            {
                if (i == placeholders[0][2])
                {
                    i.DataContext = new pawn(new List <int>()
                    {
                        0, u
                    }, "wking.png", "wk");
                }
                else
                {
                    i.DataContext = new pawn(new List <int>()
                    {
                        0, u
                    }, "wpawn.png", "wp");
                }
                u++;
            }
            u = 0;
            foreach (Button i in placeholders[4])
            {
                if (i == placeholders[4][2])
                {
                    i.DataContext = new pawn(new List <int>()
                    {
                        4, u
                    }, "bking.png", "bk");
                }
                else
                {
                    i.DataContext = new pawn(new List <int>()
                    {
                        4, u
                    }, "bpawn.png", "bp");
                }
                u++;
            }
            foreach (Button i in placeholders[4])
            {
                dynamic z   = i.DataContext;
                pawn    r   = z;
                string  img = r.Imgref;
                i.Content = new Image
                {
                    Source = new BitmapImage(new Uri(img, UriKind.RelativeOrAbsolute))
                };
            }
            foreach (Button i in placeholders[0])
            {
                dynamic z   = i.DataContext;
                pawn    r   = z;
                string  img = r.Imgref;
                i.Content = new Image
                {
                    Source = new BitmapImage(new Uri(img, UriKind.RelativeOrAbsolute))
                };
            }
        }