Esempio n. 1
0
        private void CheckBox_Click(object sender, EventArgs e)
//событие клика по чек-боксу в созданной панели
//применяется, чтобы редактор открыл режим редакторивания для дневного палан
        {
            CheckBox cb = (CheckBox)sender;

            int columnNum = (int)workingTable.GetColumn(cb);

            if (columnNum == -1)
            {
                return;
            }
            ListView l = (ListView)workingTable.GetControlFromPosition(columnNum, workingTable.RowCount - 1);

            switch (cb.CheckState)
            {
            case CheckState.Checked:
                workingTable.GetControlFromPosition(columnNum, 1).Enabled = true;
                l.LargeImageList = Startup.myData.iconList;
                l.Enabled        = true;
                break;

            case CheckState.Unchecked:
                workingTable.GetControlFromPosition(columnNum, 1).Enabled = false;
                l.LargeImageList = Startup.myData.iconSmallList;
                l.Enabled        = false;
                break;
            }
            Startup.anyChanges           = true; //случились изменения!!!
            myOwner.saveMenuItem.Enabled = true;
        }
        /**
         * Event handler that toggles the buttons.
         */
        public void LightUp(object sender, EventArgs e)
        {
            LightButton b = (LightButton)sender;

            //Lights up the button clicked.
            b.changeLight();
            //Lights up the button on the left if there is one.
            if (b.TabIndex - 1 >= 0 && b.TabIndex - 5 != 0 && b.TabIndex - 5 != 5 && b.TabIndex - 5 != 10 && b.TabIndex - 5 != 15)
            {
                LightButton left = (LightButton)grid.GetControlFromPosition(grid.GetColumn(b) - 1, grid.GetRow(b));
                left.changeLight();
            }
            //Lights up the button on the right if there is one.
            if (b.TabIndex + 1 <= 24 && b.TabIndex + 1 != 5 && b.TabIndex + 1 != 10 && b.TabIndex + 1 != 15 && b.TabIndex + 1 != 20)
            {
                LightButton right = (LightButton)grid.GetControlFromPosition(grid.GetColumn(b) + 1, grid.GetRow(b));
                right.changeLight();
            }
            //Lights up the button on bottom if there is one
            if (b.TabIndex + 5 <= 24)
            {
                LightButton bottom = (LightButton)grid.GetControlFromPosition(grid.GetColumn(b), grid.GetRow(b) + 1);
                bottom.changeLight();
            }
            //Lights up the button on top if there is one.
            if (b.TabIndex - 5 >= 0)
            {
                LightButton top = (LightButton)grid.GetControlFromPosition(grid.GetColumn(b), grid.GetRow(b) - 1);
                top.changeLight();
            }
        }
Esempio n. 3
0
 public void clickOnSpace(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && isEditMode == true)
     {
         if (mode == 2)
         {
             if (panel.GetControlFromPosition(panel.GetColumn((PictureBox)sender), panel.GetRow((PictureBox)sender)).BackColor != Color.Maroon)
             {
                 panel.GetControlFromPosition(panel.GetColumn((PictureBox)sender), panel.GetRow((PictureBox)sender)).BackColor = Color.Maroon;
             }
         }
         else
         {
             if (panel.GetControlFromPosition(panel.GetColumn((PictureBox)sender), panel.GetRow((PictureBox)sender)).BackColor != Color.ForestGreen)
             {
                 panel.GetControlFromPosition(panel.GetColumn((PictureBox)sender), panel.GetRow((PictureBox)sender)).BackColor = Color.ForestGreen;
             }
         }
     }
     else if (isEditMode == true)
     {
         contextMenuStrip1.Show(panel.GetControlFromPosition(panel.GetColumn((PictureBox)sender), panel.GetRow((PictureBox)sender)), e.Location.X, e.Location.Y);
         np = (Point)GetRowColIndex(panel, panel.PointToClient(Cursor.Position));
     }
 }
Esempio n. 4
0
        public void TableLayoutPanel_SetColumn_MultipleTimes_GetReturnsExpected()
        {
            var control = new ScrollableControl();
            var panel   = new TableLayoutPanel();

            panel.SetColumn(control, 1);
            Assert.Equal(1, panel.GetColumn(control));

            panel.SetColumn(control, 2);
            Assert.Equal(2, panel.GetColumn(control));
        }
Esempio n. 5
0
        public void Verificar_CartaClicada(Form frm, TableLayoutPanel tlp, ref int r, ref int c, ref string nome_obj, PictureBox carta_clicada, ref bool aux)
        {
            if (carta_clicada != null)
            {
                r = tlp.GetRow(carta_clicada);
                c = tlp.GetColumn(carta_clicada);

                nome_obj = matObj[r, c].nome;

                if (carta_clicada.Image == carta_clicada.Tag)
                {
                    return;
                }

                if (clique1 == null)
                {
                    clique1       = carta_clicada;
                    clique1.Image = (Image)carta_clicada.Tag;

                    return;
                }
                if (clique2 == null)
                {
                    clique2       = carta_clicada;
                    clique2.Image = (Image)carta_clicada.Tag;

                    aux = true;
                    tentativas++;
                }

                /*if (Comparar_Imagens((Bitmap)clique1.Image, (Bitmap)clique2.Image))
                 * {
                 *  clique1 = null;
                 *  clique2 = null;
                 *
                 *  aux = false;
                 *
                 *  return;
                 * }*/

                if (matObj[tlp.GetRow(clique1), tlp.GetColumn(clique1)].ID == matObj[tlp.GetRow(clique2), tlp.GetColumn(clique2)].ID)
                {
                    clique1 = null;
                    clique2 = null;

                    aux = false;

                    return;
                }
            }
        }
Esempio n. 6
0
        } //Adds ComboBox to cell

        private void UpdateItems(Object sender, EventArgs e)
        {
            ComboBox cb = (ComboBox)sender; //Case object to ComboBox
            int      r  = p.GetRow(cb);
            int      c  = p.GetColumn(cb);

            try
            {
                puzzle[r, c] = (int)cb.SelectedIndex;//Places changed value into indexed array
            }catch (InvalidCastException ex)
            {
                Console.WriteLine(ex);
            }
        } //Updates array when ComboBox value is changed
Esempio n. 7
0
        public void TableLayoutPanel_GetColumn_NoSuchControl_ReturnsExpected()
        {
            var control = new ScrollableControl();
            var panel   = new TableLayoutPanel();

            Assert.Equal(-1, panel.GetColumn(control));
        }
Esempio n. 8
0
        public void TableLayoutPanel_SetColumn_ValidControl_GetReturnsExpected(int value)
        {
            var control = new ScrollableControl();
            var panel   = new TableLayoutPanel();

            panel.SetColumn(control, value);
            Assert.Equal(value, panel.GetColumn(control));
        }
Esempio n. 9
0
        /// <summary>
        /// TableLayoutPanel において、実際に利用されている列数を取得します。
        /// デフォルトの ColumnCount 及び ColumnStyles.Count は実際と異なる値を返すことがあるためです。
        /// </summary>
        public static int GetActualColumnCount(TableLayoutPanel panel)
        {
            int count = panel.ColumnCount;

            foreach (System.Windows.Forms.Control c in panel.Controls)
            {
                count = Math.Max(panel.GetColumn(c) + 1, count);
            }
            return(count);
        }
        public void TableLayoutControlCollection_Add_ValidControl_Success(int column, int row)
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);
            var control    = new Control();

            collection.Add(control, column, row);
            Assert.Equal(control, Assert.Single(collection));
            Assert.Equal(column, container.GetColumn(control));
            Assert.Equal(row, container.GetRow(control));
        }
        public void TableLayoutControlCollection_Add_NegativeRow_ThrowsArgumentOutOfRangeException()
        {
            var container  = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);
            var control    = new Control();

            Assert.Throws <ArgumentOutOfRangeException>("row", () => collection.Add(control, 1, -2));
            Assert.Equal(control, Assert.Single(collection));
            Assert.Equal(1, container.GetColumn(control));
            Assert.Equal(-1, container.GetRow(control));
        }
Esempio n. 12
0
        public void TableLayoutControlCollection_Add_NegativeColumn_ThrowsArgumentOutOfRangeException()
        {
            using var container = new TableLayoutPanel();
            var collection = new TableLayoutControlCollection(container);

            using var child = new Control();
            Assert.Throws <ArgumentOutOfRangeException>("column", () => collection.Add(child, -2, 2));
            Assert.Equal(child, Assert.Single(collection));
            Assert.Equal(-1, container.GetColumn(child));
            Assert.Equal(-1, container.GetRow(child));
        }
Esempio n. 13
0
        public static IEnumerable <Control> GetControlsFromColumn(this TableLayoutPanel panel, int column)
        {
            var retVal = new List <Control>();

            foreach (Control item in panel.Controls)
            {
                if (panel.GetColumn(item) == column)
                {
                    retVal.Add(item);
                }
            }
            return(retVal);
        }
Esempio n. 14
0
        private int GetIndexFromTextBox(TextBox tBox)
        {
            int row = 0;
            int num = 0;

            foreach (Control control in (ArrangedElementCollection)panel.Controls)
            {
                if (control is TextBox && control == tBox)
                {
                    num = panel.GetColumn(control);
                    row = panel.GetRow(control);
                    break;
                }
            }
            return(registers.IndexOf(registers[panel.GetControlFromPosition(num - 2, row).Text]));
        }
Esempio n. 15
0
            //public class Border
            //{
            //    public TableLayoutPanelCellBorderStyle style = TableLayoutPanelCellBorderStyle.Single;
            //}

            public void apply(TableLayoutPanel table)
            {
                //int rowsCount = table.RowCount;
                //int ColumnCount = table.ColumnCount;
                foreach (Control control in table.Controls)
                {
                    if (table.GetRow(control) == 0)
                    {
                        RowHeader.apply(control);
                    }
                    else if (table.GetColumn(control) == 0)
                    {
                        ColumnHeader.apply(control);
                    }
                }
            }
Esempio n. 16
0
        private int GetIndexFromTextBox(TextBox tBox)
        {
            int row    = 0;
            int column = 0;

            foreach (Control control in panel.Controls)
            {
                if ((control is TextBox) && (control == tBox))
                {
                    column = panel.GetColumn(control);
                    row    = panel.GetRow(control);
                    break;
                }
            }
            Label controlFromPosition = (Label)panel.GetControlFromPosition(column - 2, row);

            return(registers.IndexOf(registers[controlFromPosition.Text]));
        }
        private AlignUnitsCollection(TableLayoutPanel panel)
        {
            IDictionary <int, int> rowsMapping = this.GetRowsMapping(panel);

            this.unitsCollection = new AlignUnit[rowsMapping.Count, panel.ColumnCount];
            this.RowDeltaValue   = new int[rowsMapping.Count];
            foreach (object obj in panel.Controls)
            {
                Control control = (Control)obj;
                int     row     = panel.GetRow(control);
                int     column  = panel.GetColumn(control);
                if (this.GetControlVisible(control) && row >= 0 && column >= 0)
                {
                    int       num       = rowsMapping[row];
                    int       num2      = column;
                    AlignUnit alignUnit = new AlignUnit(control, panel.GetRowSpan(control), panel.GetColumnSpan(control), num, num2);
                    for (int i = 0; i < alignUnit.ColumnSpan; i++)
                    {
                        this.unitsCollection[num, num2 + i] = alignUnit;
                    }
                    this.unitsList.Add(alignUnit);
                    if (!this.rowUnitsDictionary.ContainsKey(num))
                    {
                        this.rowUnitsDictionary[num] = new List <AlignUnit>();
                    }
                    this.rowUnitsDictionary[num].Add(alignUnit);
                }
            }
            for (int j = 0; j < this.RowCount; j++)
            {
                if (!this.rowUnitsDictionary.ContainsKey(j))
                {
                    this.rowUnitsDictionary[j] = new List <AlignUnit>();
                }
                else
                {
                    this.rowUnitsDictionary[j].Sort();
                }
                this.RowDeltaValue[j] = AlignSettings.DefaultVertical;
            }
            this.UpdateCompareMargin();
        }
Esempio n. 18
0
        private bool SetLabelBlank(TableLayoutPanel tlp, Label lbl, bool captureUndo, bool hasChanged)
        {
            if (lbl.BackColor == Color.Transparent)
            {
                return(hasChanged);
            }
            if (!hasChanged && lbl.BackColor != Color.Transparent)
            {
                hasChanged = true;
            }
            if (captureUndo && hasChanged)
            {
                var row = tlp.GetRow(lbl);
                var col = tlp.GetColumn(lbl);

                var ci = GetChangeItem(tlp, lbl, Color.Transparent, col, row);
                _undoStack.Push(ci);
            }
            lbl.BackColor = Color.Transparent;
            lbl.Image     = Resources.BlankImage;
            return(hasChanged);
        }
Esempio n. 19
0
        /// <summary>
        /// xét label dược click thuộc tableLP nào, row index nào
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void lb_MouseClick(object sender, MouseEventArgs e)
        {
            Label            lb   = ((Label)(sender));
            TableLayoutPanel TLP  = ((TableLayoutPanel)(lb.Parent));
            string           name = lb.Name;
            int TLPRows           = TLP.RowCount;
            int lbRow             = TLP.GetRow(lb);
            int lbCol             = TLP.GetColumn(lb);

            if (name.Contains("Xoa"))
            {
                if (TLPRows > 1)   // khong duoc xoa dong cuoi cung
                {
                    // dòng bị xoá là dòng cuối
                    //thì unhide "Thêm" ở dòng kế cuối
                    if ((lbRow + 1) == TLPRows)
                    {
                        Control c = TLP.Controls[lbCol - 1 + TLP.ColumnCount * (lbRow - 1)];    // trừ 1 để chuyển sang lb Thêm
                        c.Visible = true;
                    }
                    AddRemoveRow(TLP, "Remove", lbRow);
                    MoveUp(TLP, lbRow);
                }
            }
            else if (name.Contains("Them"))
            {
                if (TLPRows < 4)                                                     // gioi han 4 dong
                {
                    TLP.Controls[lbCol + TLP.ColumnCount * (lbRow)].Visible = false; // hide chữ "thêm" trước khi thêm mới
                    AddRemoveRow(TLP, "Add", ++lbRow);
                }
                else
                {
                    MessageBox.Show("Số lượng dòng vượt quá giới hạn.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 20
0
        public void enKarliAltin(TableLayoutPanel tableLayoutPanel1, List <Altin> altinliste, List <Altin> gizlialtinliste, int dPuan, int adimSayisi, AOyuncusu aOyuncusu, BOyuncusu bOyuncusu, COyuncusu cOyuncusu)
        {
            Control    dControl = tableLayoutPanel1.Controls.Find("dOyuncusu", true).FirstOrDefault();
            PictureBox dPCBox   = dControl as PictureBox;


            int dOyuncusuX = tableLayoutPanel1.GetRow(dControl);
            int dOyuncusuY = tableLayoutPanel1.GetColumn(dControl);


            var enYakinAltin = altinliste.OrderByDescending(x => x.altinMiktar - (Math.Abs(x.altinKonumSatir - dOyuncusuX) + Math.Abs(+x.altinKonumSutun - dOyuncusuY)) * hamleMaliyet - hedefBelirlemeMaliyet).FirstOrDefault();


            Control    c1 = tableLayoutPanel1.GetControlFromPosition(enYakinAltin.altinKonumSutun, enYakinAltin.altinKonumSatir);
            PictureBox pc = c1 as PictureBox;

            hedefAltin.altinKonumSatir = tableLayoutPanel1.GetRow(c1);
            hedefAltin.altinKonumSutun = tableLayoutPanel1.GetColumn(c1);


            #region Önceden Sezme için a,b ve c oyuncularıyla kontrol gerçekleştirme

            Control aControl = tableLayoutPanel1.Controls.Find("aOyuncusu", true).FirstOrDefault();
            Control bControl = tableLayoutPanel1.Controls.Find("bOyuncusu", true).FirstOrDefault();
            Control cControl = tableLayoutPanel1.Controls.Find("cOyuncusu", true).FirstOrDefault();

            int ayakinlik = Math.Abs(tableLayoutPanel1.GetRow(aControl) - hedefAltin.altinKonumSatir) + Math.Abs(tableLayoutPanel1.GetColumn(aControl) - hedefAltin.altinKonumSutun);
            int byakinlik = Math.Abs(tableLayoutPanel1.GetRow(bControl) - hedefAltin.altinKonumSatir) + Math.Abs(tableLayoutPanel1.GetColumn(bControl) - hedefAltin.altinKonumSutun);
            int cyakinlik = Math.Abs(tableLayoutPanel1.GetRow(cControl) - hedefAltin.altinKonumSatir) + Math.Abs(tableLayoutPanel1.GetColumn(cControl) - hedefAltin.altinKonumSutun);
            int dyakinlik = Math.Abs(tableLayoutPanel1.GetRow(dControl) - hedefAltin.altinKonumSatir) + Math.Abs(tableLayoutPanel1.GetColumn(dControl) - hedefAltin.altinKonumSutun);

            bool aHedefAltinaMiGidiyor = aOyuncusu.hedefAltin.altinKonumSatir == hedefAltin.altinKonumSatir && aOyuncusu.hedefAltin.altinKonumSutun == hedefAltin.altinKonumSutun ? true : false;
            bool bHedefAltinaMiGidiyor = bOyuncusu.hedefAltin.altinKonumSatir == hedefAltin.altinKonumSatir && bOyuncusu.hedefAltin.altinKonumSutun == hedefAltin.altinKonumSutun ? true : false;
            bool cHedefAltinaMiGidiyor = cOyuncusu.hedefAltin.altinKonumSatir == hedefAltin.altinKonumSatir && cOyuncusu.hedefAltin.altinKonumSutun == hedefAltin.altinKonumSutun ? true : false;


            if ((aHedefAltinaMiGidiyor.Equals(true) && ayakinlik < dyakinlik) || (bHedefAltinaMiGidiyor.Equals(true) && byakinlik < dyakinlik) || (cHedefAltinaMiGidiyor.Equals(true) && cyakinlik < dyakinlik))
            {
                enYakinAltin = altinliste.OrderByDescending(x => x.altinMiktar - (Math.Abs(x.altinKonumSatir - dOyuncusuX) + Math.Abs(+x.altinKonumSutun - dOyuncusuY)) * hamleMaliyet - hedefBelirlemeMaliyet).ElementAt(1);


                c1 = tableLayoutPanel1.GetControlFromPosition(enYakinAltin.altinKonumSutun, enYakinAltin.altinKonumSatir);
                pc = c1 as PictureBox;

                hedefAltin.altinKonumSatir = tableLayoutPanel1.GetRow(c1);
                hedefAltin.altinKonumSutun = tableLayoutPanel1.GetColumn(c1);
            }


            #endregion


            //oyuncu hedef belirlediğinde altın kaybeder
            if (hedefAltin.hedefAltinVarMi == false)
            {
                dPuan = dPuan - hedefBelirlemeMaliyet;
                hedefAltin.hedefAltinVarMi = true;
                harcananAltinMiktari      += hedefBelirlemeMaliyet;
            }



            int i  = 1;
            int dX = 1; //b oyuncusunun x yönündeki (row) hareketi
            int dY = 1; //b oyuncusunun y yönündeki (column) hareketi


            while (tableLayoutPanel1.GetRow(dControl) != hedefAltin.altinKonumSatir && i <= adimSayisi && dPuan > 0)
            {
                if (tableLayoutPanel1.GetRow(dControl) <= hedefAltin.altinKonumSatir)
                {
                    if (dOyuncusuX + dX == hedefAltin.altinKonumSatir && dOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        dPuan = dPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (dOyuncusuX + dX == item.altinKonumSatir && dOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (dPuan > hamleMaliyet)
                    {
                        dPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(dControl, dOyuncusuX + dX);
                        adimlar.Add((dOyuncusuX + dX) + " " + dOyuncusuY);
                    }
                }

                else
                {
                    if (dOyuncusuX - dX == hedefAltin.altinKonumSatir && dOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        dPuan = dPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (dOyuncusuX - dX == item.altinKonumSatir && dOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (dPuan > hamleMaliyet)
                    {
                        dPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(dControl, dOyuncusuX - dX);
                        adimlar.Add((dOyuncusuX - dX) + " " + dOyuncusuY);
                    }
                }
                toplamAdim++;
                dX++;
                i++;
            }

            while (tableLayoutPanel1.GetRow(dControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(dControl) != hedefAltin.altinKonumSutun && i <= adimSayisi && dPuan > 0)
            {
                if (dOyuncusuY <= hedefAltin.altinKonumSutun)
                {
                    if (dOyuncusuY + dY == hedefAltin.altinKonumSutun)
                    {
                        dPuan = dPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (dOyuncusuX == item.altinKonumSatir && dOyuncusuY + dY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (dPuan > hamleMaliyet)
                    {
                        dPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(dControl, dOyuncusuY + dY);
                        adimlar.Add(dOyuncusuX + " " + (dOyuncusuY + dY));
                    }
                }

                else
                {
                    if (dOyuncusuY - dY == hedefAltin.altinKonumSutun)
                    {
                        dPuan = dPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (dOyuncusuX == item.altinKonumSatir && dOyuncusuY - dY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (dPuan > hamleMaliyet)
                    {
                        dPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(dControl, dOyuncusuY - dY);
                        adimlar.Add(dOyuncusuX + " " + (dOyuncusuY - dY));
                    }
                }
                toplamAdim++;
                i++;
                dY++;
            }
            if (tableLayoutPanel1.GetRow(dControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(dControl) == hedefAltin.altinKonumSutun && dPuan > 0)
            {
                altinliste.Remove(enYakinAltin);
            }

            kasadakiAltinMiktari = dPuan;
        }
Esempio n. 21
0
    void enter_cick(object sender, KeyEventArgs e)
    {
        for (int l = 0; l < ctil_kartu.Count; l++)
        {
            ctil_kartu[l].img.BorderStyle = BorderStyle.None;
        }


        if (can_go && ctil_kartu.Count > 0)
        {
            List <int> del  = new List <int>();
            bool       next = true;

            if (e.KeyCode == Keys.Enter)
            {
                int ctil_kol = ctil_kartu.Count;
                for (int ctil = 0; ctil < ctil_kol && next; ctil++)
                {
                    bool clon    = false;
                    int  min     = 99;
                    int  id      = 0;
                    int  min_koz = 99;

                    for (int w = 0; w < my_kart_only.Count; w++)
                    {
                        if (my_kart_only[w].ToString() == ctil_kartu[ctil].img.Name)
                        {
                            clon = true;
                        }
                    }
                    if (clon && my_kart_only.Count > 0)
                    {
                        for (int ryki = 0; ryki < voroga_kartu.Count; ryki++)
                        {
                            if (voroga_kartu[ryki].vaga < min_koz && voroga_kartu[ryki].kozur && min == 99 && !ctil_kartu[ctil].kozur)
                            {
                                min_koz = voroga_kartu[ryki].vaga;
                                id      = ryki;
                            }

                            if (ctil_kartu[ctil].vaga < voroga_kartu[ryki].vaga && voroga_kartu[ryki].vaga < min && voroga_kartu[ryki].mast == ctil_kartu[ctil].mast)
                            {
                                min = voroga_kartu[ryki].vaga;
                                id  = ryki;
                            }
                        }


                        if (min == 99)
                        {
                            min = min_koz;
                        }


                        if (min != 99)
                        {
                            my_kart_only.RemoveAt(0);
                            her.Controls.Remove(voroga_kartu[id].face);
                            ctol.Controls.Add(voroga_kartu[id].img, ctol.GetColumn(ctil_kartu[ctil].img), 1);
                            voroga_kartu[id].img.Top  = top_center - 60;
                            voroga_kartu[id].img.Left = ctil_kartu[ctil].img.Left;
                            ctil_kartu.Add(voroga_kartu[id]);
                            voroga_kartu.RemoveAt(id);

                            can_go1 = true;

                            end = true;
                        }
                        else
                        {
                            can_go1 = true;
                            next    = false;

                            for (int ex = 0; ex < ctil_kartu.Count; ex++)
                            {
                                her.Controls.Add(ctil_kartu[ex].face);
                                ctil_kartu[ex].face.Top  = 0;
                                ctil_kartu[ex].face.Left = (600 + (ex * 50) + 50);
                                voroga_kartu.Add(ctil_kartu[ex]);
                            }

                            ctol.Controls.Clear();
                            up.Visible = true;
                            System.Windows.Forms.Timer clock = new System.Windows.Forms.Timer();

                            clock.Interval = 3000;
                            clock.Start();
                            clock.Tick += new EventHandler(clock_Tick);
                            ctil_kartu.Clear();
                            end = false;
                            gra();
                        }
                    }
                }
            }
        }
        else if (can_go2)
        {
            if (ctil_kartu.Count % 2 == 0 && e.KeyCode == Keys.Enter && moe.Count == ctil_kartu.Count)
            {
                bool doc = vrag_docidoc();

                if (!doc)
                {
                    for (int n = 0; n < ctil_kartu.Count; n++)
                    {
                        ctil_kartu[n].vigre = false;
                    }
                    for (int h = 0; h < moi_kartu.Count; h++)
                    {
                        moi_kartu[h].img.BorderStyle = BorderStyle.None;
                    }
                    ctol.Controls.Clear();
                    ctil_kartu.Clear();
                    can_go  = true;
                    vidbuv  = false;
                    can_go1 = true;
                    can_go2 = false;
                    moe.Clear();
                    gra();
                }
                else
                {
                    List <int> num = new List <int>();
                    for (int n = 0; n < moe.Count; n++)
                    {
                        for (int id = 0; id < voroga_kartu.Count; id++)
                        {
                            if (voroga_kartu[id].vaga == koloda[moe[n]].vaga && num.Count <= moi_kartu.Count)
                            {
                                num.Add(id);
                                ctol.Controls.Add(voroga_kartu[id].img, ctol.Controls.Count, 0);
                                her.Controls.Remove(voroga_kartu[id].face);
                                ctil_kartu.Add(voroga_kartu[id]);
                            }
                        }
                    }


                    can_go2 = true;
                    num.Sort();
                    int ccol = 0;
                    for (int end = 1; ccol < num.Count; end++)
                    {
                        ccol++;
                        voroga_kartu.RemoveAt(num[num.Count - end]);
                    }
                }
            }
            else if (e.KeyCode == Keys.Space)
            {
                for (int h = 0; h < moi_kartu.Count; h++)
                {
                    moi_kartu[h].img.BorderStyle = BorderStyle.None;
                }

                for (int re = 0; re < ctil_kartu.Count; re++)
                {
                    my.Controls.Add(ctil_kartu[re].img);
                    ctil_kartu[re].img.Top = SystemInformation.PrimaryMonitorSize.Height - ctil_kartu[re].img.Height;
                    moi_kartu.Add(ctil_kartu[re]);
                }
                ctol.Controls.Clear();
                ctil_kartu.Clear();
                can_go  = false;
                vidbuv  = true;
                can_go1 = false;
                moe.Clear();
                gra();
            }
        }
    }
Esempio n. 22
0
        private VisualWrapper(Control control)
        {
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);

            Control          parent      = control.Parent;
            TableLayoutPanel layoutPanel = parent as TableLayoutPanel;

            _control = control;

            this.Size     = control.Size;
            this.Location = control.Location;
            this.Padding  = control.Padding;
            this.Margin   = control.Margin;
            this.Anchor   = control.Anchor;
            this.Dock     = control.Dock;
            this.TabIndex = control.TabIndex;

            int index   = parent.Controls.IndexOf(control);
            int row     = layoutPanel?.GetRow(control) ?? 0;
            int col     = layoutPanel?.GetColumn(control) ?? 0;
            int rowSpan = layoutPanel?.GetRowSpan(control) ?? 0;
            int colSpan = layoutPanel?.GetColumnSpan(control) ?? 0;

            parent.Controls.Remove(control);

            if (layoutPanel != null)
            {
                layoutPanel.Controls.Add(this, col, row);
                layoutPanel.SetRowSpan(this, rowSpan);
                layoutPanel.SetColumnSpan(this, colSpan);
            }
            else
            {
                parent.Controls.Add(this);
                parent.Controls.SetChildIndex(this, index);
            }

            control.Padding      = new Padding();
            control.Margin       = new Padding();
            control.Dock         = DockStyle.None;
            control.Anchor       = AnchorStyles.None;
            control.GotFocus    += ControlFocusChanged;
            control.LostFocus   += ControlFocusChanged;
            control.TextChanged += ControlTextChanged;

            if (control is TextBoxBase)
            {
                this.SetStyle(ControlStyles.Selectable, false);
                ((TextBoxBase)control).BorderStyle = BorderStyle.None;
            }
            else if (control is ComboBox)
            {
                control.Visible = false;

                if (((ComboBox)control).DropDownStyle == ComboBoxStyle.DropDown)
                {
                    _comboTextBox                 = new TextBox();
                    _comboTextBox.Text            = control.Text;
                    _comboTextBox.BorderStyle     = BorderStyle.None;
                    _comboTextBox.KeyDown        += ComboTextBoxKeyDown;
                    _comboTextBox.PreviewKeyDown += ComboTextBoxPreviewKeyDown;
                    _comboTextBox.TextChanged    += ComboTextBoxTextChanged;
                    this.Controls.Add(_comboTextBox);
                    this.SetStyle(ControlStyles.Selectable, false);
                }

                ((ComboBox)control).ItemHeight            = control.Height;
                ((ComboBox)control).SelectedIndexChanged += ComboSelectedIndexChanged;
                ((ComboBox)control).DropDown             += ComboDropDownChanged;
                ((ComboBox)control).DropDownClosed       += ComboDropDownChanged;
            }

            this.Controls.Add(control);
            this.BackColor = control.BackColor;

            OnSizeChanged(new EventArgs());
        }
Esempio n. 23
0
        public void TableLayoutPanel_GetColumn_NullControl_ThrowsArgumentNullException()
        {
            var panel = new TableLayoutPanel();

            Assert.Throws <ArgumentNullException>("control", () => panel.GetColumn(null));
        }
Esempio n. 24
0
        public void enYakinAltin(TableLayoutPanel tableLayoutPanel1, List <Altin> altinliste, List <Altin> gizlialtinliste, int aPuan, int adimSayisi)
        {
            Control    aControl = tableLayoutPanel1.Controls.Find("aOyuncusu", true).FirstOrDefault();
            PictureBox aPCBox   = aControl as PictureBox;

            int aOyuncusuX = tableLayoutPanel1.GetRow(aControl);
            int aOyuncusuY = tableLayoutPanel1.GetColumn(aControl);

            var enYakinAltin = altinliste.OrderBy(x => Math.Abs(x.altinKonumSatir - aOyuncusuX) + Math.Abs(+x.altinKonumSutun - aOyuncusuY)).FirstOrDefault();

            Control    c1 = tableLayoutPanel1.GetControlFromPosition(enYakinAltin.altinKonumSutun, enYakinAltin.altinKonumSatir);
            PictureBox pc = c1 as PictureBox;

            hedefAltin.altinKonumSatir = tableLayoutPanel1.GetRow(c1);
            hedefAltin.altinKonumSutun = tableLayoutPanel1.GetColumn(c1);

            //oyuncu hedef belirlediğinde altın kaybeder
            if (hedefAltin.hedefAltinVarMi)
            {
                aPuan = aPuan - hedefBelirlemeMaliyet;
                hedefAltin.hedefAltinVarMi = true;
                harcananAltinMiktari      += hedefBelirlemeMaliyet;
            }



            int i  = 1;
            int aX = 1; //a oyuncusunun x yönündeki (row) hareketi
            int aY = 1; //a oyuncusunun y yönündeki (column) hareketi


            while (tableLayoutPanel1.GetRow(aControl) != hedefAltin.altinKonumSatir && i <= adimSayisi && aPuan > 0)
            {
                if (tableLayoutPanel1.GetRow(aControl) <= hedefAltin.altinKonumSatir)
                {
                    if (aOyuncusuX + aX == hedefAltin.altinKonumSatir && aOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        aPuan = aPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (aOyuncusuX + aX == item.altinKonumSatir && aOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }

                    if (aPuan > hamleMaliyet)
                    {
                        aPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(aControl, aOyuncusuX + aX);
                        adimlar.Add((aOyuncusuX + aX) + " " + aOyuncusuY);
                    }
                }

                else
                {
                    if (aOyuncusuX - aX == hedefAltin.altinKonumSatir && aOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        aPuan = aPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (aOyuncusuX - aX == item.altinKonumSatir && aOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }



                    if (aPuan > hamleMaliyet)
                    {
                        aPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(aControl, aOyuncusuX - aX);
                        adimlar.Add((aOyuncusuX - aX) + " " + aOyuncusuY);
                    }
                }
                toplamAdim++;
                aX++;
                i++;
            }

            while (tableLayoutPanel1.GetRow(aControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(aControl) != hedefAltin.altinKonumSutun && i <= adimSayisi && aPuan > 0)
            {
                if (aOyuncusuY <= hedefAltin.altinKonumSutun)
                {
                    if (aOyuncusuY + aY == hedefAltin.altinKonumSutun)
                    {
                        aPuan = aPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (aOyuncusuX == item.altinKonumSatir && aOyuncusuY + aY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }

                    if (aPuan > hamleMaliyet)
                    {
                        aPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(aControl, aOyuncusuY + aY);
                        adimlar.Add(aOyuncusuX + " " + (aOyuncusuY + aY));
                    }
                }

                else
                {
                    if (aOyuncusuY - aY == hedefAltin.altinKonumSutun)
                    {
                        aPuan = aPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (aOyuncusuX == item.altinKonumSatir && aOyuncusuY - aY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (aPuan > hamleMaliyet)
                    {
                        aPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(aControl, aOyuncusuY - aY);
                        adimlar.Add(aOyuncusuX + " " + (aOyuncusuY - aY));
                    }
                }
                toplamAdim++;
                i++;
                aY++;
            }
            if (tableLayoutPanel1.GetRow(aControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(aControl) == hedefAltin.altinKonumSutun && aPuan > 0)
            {
                altinliste.Remove(enYakinAltin);
            }

            kasadakiAltinMiktari = aPuan;
        }
Esempio n. 25
0
        private void Form1_Load(object sender, EventArgs e)
        {
            const int cols = 5;
            const int rows = 6;

            // setup layout
            var tlp = new TableLayoutPanel
            {
                ColumnCount = cols,
                RowCount    = rows,
                Dock        = DockStyle.Fill,
                GrowStyle   = TableLayoutPanelGrowStyle.FixedSize
            };

            for (var i = 0; i < cols; i++)
            {
                tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f / cols));
            }

            // add header
            var label = new Label
            {
                Text      = @"My Header",
                BackColor = Color.Red,
                Dock      = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleCenter
            };

            tlp.Controls.Add(label);
            tlp.SetColumn(label, 0);
            tlp.SetRow(label, 0);
            tlp.SetColumnSpan(label, cols);

            // add some cells
            var yMin = 1;
            var yMax = 5;
            var xMin = 0;
            var xMax = cols;

            for (var y = yMin; y < yMax; y++)
            {
                for (var x = xMin; x < xMax; x++)
                {
                    var color = Color.FromArgb(
                        255 / (xMax - xMin) * (x - xMin),
                        128,
                        255 / (yMax - yMin) * (y - yMin)
                        );
                    var label1 = new Label
                    {
                        Text      = $@"X = {x}, Y = {y}",
                        BackColor = color,
                        ForeColor = Color.White,
                        Dock      = DockStyle.Fill,
                        TextAlign = ContentAlignment.MiddleCenter,
                        Margin    = DefaultMargin
                    };
                    tlp.Controls.Add(label1, x, y);
                }
            }

            // add swapper
            var button = new Button
            {
                Text = @"Clicky !",
                Dock = DockStyle.Fill
            };

            button.Click += (o, args) =>
            {
                var srcRow   = 2;
                var tgtRow   = 3;
                var controls = tlp.Controls.Cast <Control>().ToArray();
                var array1   = controls.Where(s => tlp.GetRow(s) == srcRow).ToArray();
                var array2   = controls.Where(s => tlp.GetRow(s) == tgtRow).ToArray();

                foreach (var control in array1)
                {
                    tlp.SetCellPosition(control, new TableLayoutPanelCellPosition(tlp.GetColumn(control), tgtRow));
                }

                foreach (var control in array2)
                {
                    tlp.SetCellPosition(control, new TableLayoutPanelCellPosition(tlp.GetColumn(control), srcRow));
                }
            };

            // pack things up
            var sc = new SplitContainer
            {
                Orientation = Orientation.Horizontal,
                BorderStyle = BorderStyle.Fixed3D,
                Dock        = DockStyle.Fill
            };

            sc.Panel1.Controls.Add(tlp);
            sc.Panel2.Controls.Add(button);
            Controls.Add(sc);
        }
Esempio n. 26
0
        //Нажимаем на карточку и отправляем координаты выбранной карточки
        private void cardButton_Click(object sender, EventArgs e)
        {
            TableLayoutPanel t = getCurentTableForCards();

            Controller.pushThisCard(t.GetRow((Control)sender), t.GetColumn((Control)sender));
        }
Esempio n. 27
0
        private void settingscrap(TableLayoutPanel tablelayoutpanel, List <KeyValuePair <string, int> > settings, byte[] file)
        {
            tablelayoutpanel.SuspendLayout();

            if (tablelayoutpanel.RowCount == settings.Count + 2)
            {
                foreach (Control control in tablelayoutpanel.Controls)
                {
                    if (!(control is Button))
                    {
                        continue;
                    }

                    Button buton = (Button)control;

                    int index = (int)buton.Tag;
                    if (index < 1)
                    {
                        continue;
                    }

                    if (tablelayoutpanel.GetColumn(buton) < 3)
                    {
                        if (file != null)
                        {
                            string test = ((char)MapVirtualKey((uint)MapVirtualKey(file[index], MAPVK_VSC_TO_VK), MAPVK_VK_TO_CHAR)).ToString().Trim();
                            if (!string.IsNullOrEmpty(test) && test != "\0")
                            {
                                buton.Text = test;
                            }
                            else
                            {
                                buton.Text = ((Keys)MapVirtualKey(file[index], MAPVK_VSC_TO_VK)).ToString();
                            }
                        }
                        else
                        {
                            buton.Text = null;
                        }
                    }
                    else
                    {
                        if (file != null)
                        {
                            byte setting = file[index];
                            if (setting > 0)
                            {
                                setting = file[index + 1];
                                switch (setting)
                                {
                                case 0:
                                    buton.Text = "LEFT BUTON";
                                    break;

                                case 1:
                                    buton.Text = "RIGHT BUTON";
                                    break;

                                case 2:
                                    buton.Text = "MIDDLE BUTON";
                                    break;

                                case 255:
                                    buton.Text = "<none>";
                                    break;

                                default:
                                    buton.Text = "BUTON #" + setting;
                                    break;
                                }
                                buton.Enabled = true;
                            }
                            else
                            {
                                buton.Text    = "NO.";
                                buton.Enabled = false;
                            }
                        }
                        else
                        {
                            buton.Text = null;
                        }
                    }
                }
            }
            else
            {
                tablelayoutpanel.RowCount = settings.Count + 2;

                for (int n = 0; n < settings.Count; n++)
                {
                    int row = tablelayoutpanel.RowStyles.Count;

                    Label label = new Label();
                    label.Margin    = new Padding(0);
                    label.Dock      = DockStyle.Fill;
                    label.TextAlign = ContentAlignment.MiddleLeft;
                    label.Text      = settings[n].Key;

                    tablelayoutpanel.Controls.Add(label, 0, row);

                    int settingspos = settings[n].Value;

                    Button firsty = new Button();
                    firsty.Margin = new Padding(0);
                    firsty.Dock   = DockStyle.Fill;
                    firsty.Tag    = settingspos;

                    if (settingspos > 0)
                    {
                        firsty.Click += new EventHandler(firsty_Click);
                    }
                    else
                    {
                        firsty.Tag     = 0;
                        firsty.Text    = "NO.";
                        firsty.Enabled = false;
                    }

                    tablelayoutpanel.Controls.Add(firsty, 1, row);

                    Button secondy = new Button();
                    secondy.Margin = new Padding(0);
                    secondy.Dock   = DockStyle.Fill;
                    secondy.Tag    = settingspos + 1;

                    if (settingspos > 0)
                    {
                        secondy.Click += new EventHandler(firsty_Click);
                    }
                    else
                    {
                        secondy.Tag     = 0;
                        secondy.Text    = "NO.";
                        secondy.Enabled = false;
                    }

                    tablelayoutpanel.Controls.Add(secondy, 2, row);


                    Button mousey = new Button();
                    mousey.Margin = new Padding(0);
                    mousey.Dock   = DockStyle.Fill;
                    mousey.Tag    = settingspos + 8;

                    if (settingspos > 0)
                    {
                        mousey.Click += new EventHandler(mousey_Click);
                    }
                    else
                    {
                        mousey.Tag     = 0;
                        mousey.Text    = "NO.";
                        mousey.Enabled = false;
                    }

                    tablelayoutpanel.Controls.Add(mousey, 3, row);

                    tablelayoutpanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                }
            }

            tablelayoutpanel.ResumeLayout();
        }
Esempio n. 28
0
        public void enKarliAltin(TableLayoutPanel tableLayoutPanel1, List <Altin> altinliste, List <Altin> gizlialtinliste, int cPuan, int adimSayisi)
        {
            Control    cControl = tableLayoutPanel1.Controls.Find("cOyuncusu", true).FirstOrDefault();
            PictureBox cPCBox   = cControl as PictureBox;

            int cOyuncusuX = tableLayoutPanel1.GetRow(cControl);
            int cOyuncusuY = tableLayoutPanel1.GetColumn(cControl);

            if (gizlialtinliste.Any())
            {
                var        enYakinGizliAltin = gizlialtinliste.OrderBy(x => (Math.Abs(x.altinKonumSatir - cOyuncusuX) + Math.Abs(+x.altinKonumSutun - cOyuncusuY))).FirstOrDefault();
                Control    ccitem            = tableLayoutPanel1.GetControlFromPosition(enYakinGizliAltin.altinKonumSutun, enYakinGizliAltin.altinKonumSatir);
                PictureBox pccitem           = ccitem as PictureBox;
                pccitem.Visible = true;
                altinliste.Add(enYakinGizliAltin);
                gizlialtinliste.Remove(enYakinGizliAltin);
            }


            var enYakinAltin = altinliste.OrderByDescending(x => x.altinMiktar - (Math.Abs(x.altinKonumSatir - cOyuncusuX) + Math.Abs(+x.altinKonumSutun - cOyuncusuY)) * hamleMaliyet - hedefBelirlemeMaliyet).FirstOrDefault();


            Control    c1 = tableLayoutPanel1.GetControlFromPosition(enYakinAltin.altinKonumSutun, enYakinAltin.altinKonumSatir);
            PictureBox pc = c1 as PictureBox;

            hedefAltin.altinKonumSatir = tableLayoutPanel1.GetRow(c1);
            hedefAltin.altinKonumSutun = tableLayoutPanel1.GetColumn(c1);

            //oyuncu hedef belirlediğinde altın kaybeder
            if (hedefAltin.hedefAltinVarMi == false)
            {
                cPuan = cPuan - hedefBelirlemeMaliyet;
                hedefAltin.hedefAltinVarMi = true;
                harcananAltinMiktari      += hedefBelirlemeMaliyet;
            }



            int i  = 1;
            int cX = 1; //b oyuncusunun x yönündeki (row) hareketi
            int cY = 1; //b oyuncusunun y yönündeki (column) hareketi



            while (tableLayoutPanel1.GetRow(cControl) != hedefAltin.altinKonumSatir && i <= adimSayisi && cPuan > 0)
            {
                if (tableLayoutPanel1.GetRow(cControl) <= hedefAltin.altinKonumSatir)
                {
                    if (cOyuncusuX + cX == hedefAltin.altinKonumSatir && cOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        cPuan = cPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (cOyuncusuX + cX == item.altinKonumSatir && cOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (cPuan > hamleMaliyet)
                    {
                        cPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(cControl, cOyuncusuX + cX);
                        adimlar.Add((cOyuncusuX + cX) + " " + cOyuncusuY);
                    }
                }

                else
                {
                    if (cOyuncusuX - cX == hedefAltin.altinKonumSatir && cOyuncusuY == hedefAltin.altinKonumSutun)
                    {
                        cPuan = cPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (cOyuncusuX - cX == item.altinKonumSatir && cOyuncusuY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (cPuan > hamleMaliyet)
                    {
                        cPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetRow(cControl, cOyuncusuX - cX);
                        adimlar.Add((cOyuncusuX - cX) + " " + cOyuncusuY);
                    }
                }
                toplamAdim++;
                cX++;
                i++;
            }

            while (tableLayoutPanel1.GetRow(cControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(cControl) != hedefAltin.altinKonumSutun && i <= adimSayisi && cPuan > 0)
            {
                if (cOyuncusuY <= hedefAltin.altinKonumSutun)
                {
                    if (cOyuncusuY + cY == hedefAltin.altinKonumSutun)
                    {
                        cPuan = cPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (cOyuncusuX == item.altinKonumSatir && cOyuncusuY + cY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (cPuan > hamleMaliyet)
                    {
                        cPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(cControl, cOyuncusuY + cY);
                        adimlar.Add(cOyuncusuX + " " + (cOyuncusuY + cY));
                    }
                }

                else
                {
                    if (cOyuncusuY - cY == hedefAltin.altinKonumSutun)
                    {
                        cPuan = cPuan + enYakinAltin.altinMiktar;
                        tableLayoutPanel1.Controls.Remove(pc);
                        altinliste.Remove(enYakinAltin);
                        hedefAltin.hedefAltinVarMi = false;
                        toplananAltin++;
                    }
                    foreach (Altin item in gizlialtinliste)
                    {
                        Control    citem  = tableLayoutPanel1.GetControlFromPosition(item.altinKonumSutun, item.altinKonumSatir);
                        PictureBox pcitem = citem as PictureBox;

                        if (cOyuncusuX == item.altinKonumSatir && cOyuncusuY - cY == item.altinKonumSutun)
                        {
                            pcitem.Visible = true;
                            altinliste.Add(item);
                            gizlialtinliste.Remove(item);
                            break;
                        }
                    }
                    if (cPuan > hamleMaliyet)
                    {
                        cPuan -= hamleMaliyet;
                        harcananAltinMiktari += hamleMaliyet;
                        tableLayoutPanel1.SetColumn(cControl, cOyuncusuY - cY);
                        adimlar.Add(cOyuncusuX + " " + (cOyuncusuY + cY));
                    }
                }
                toplamAdim++;
                i++;
                cY++;
            }
            if (tableLayoutPanel1.GetRow(cControl) == hedefAltin.altinKonumSatir && tableLayoutPanel1.GetColumn(cControl) == hedefAltin.altinKonumSutun && cPuan > 0)
            {
                altinliste.Remove(enYakinAltin);
            }

            kasadakiAltinMiktari = cPuan;
        }