Exemple #1
0
 public void GenerateValue(int Min, int Max)
 {
     rad = new Rad(Min, Max + 1);
     foreach (Position a in Positions)
     {
         Debug.WriteLine(Position.ToString(a) + "From Generate");
         dataGridView.CurrentCell       = dataGridView[a.Column, a.Row];
         dataGridView.CurrentCell.Value = rad.RadInt();
     }
 }
Exemple #2
0
        /// <summary>
        /// 愿Num1和Num2终成眷属
        /// </summary>
        /// <param name="Min"></param>
        /// <param name="Max"></param>
        /// <param name="Num1">The Girl</param>
        /// <param name="Num2">The infatuated Boy</param>
        public void GenerateValue(int Min, int Max, int Num1, int Num2)
        {
            ArrayList b = new ArrayList(2);
            Position  j, k;
            object    d;

            rad = new Rad(Min, Max + 1);
            foreach (Position a in Positions)
            {
                dataGridView.CurrentCell       = dataGridView[a.Column, a.Row];
                dataGridView.CurrentCell.Value = rad.RadInt();
                if ((int)dataGridView.CurrentCell.Value == Num1 || (int)dataGridView.CurrentCell.Value == Num2)
                {
                    b.Add(a);
                }
            }
            if (b.Count > 1 && b.Count < 3 && Num1 <= Max && Num1 >= Min && Num2 <= Max && Num2 >= Min && Num1 != Num2)
            {
                j = (Position)b[0]; k = (Position)b[1];
                if (j.Column - 1 >= 0 && dataGridView[j.Column - 1, j.Row].Value != null)
                {
                    d = dataGridView[j.Column - 1, j.Row].Value;
                    dataGridView[j.Column - 1, j.Row].Value = dataGridView[k.Column, k.Row].Value;
                    dataGridView[k.Column, k.Row].Value     = d;
                    return;
                }
                else if (j.Column + 1 >= 1 && j.Column + 1 < dataGridView.Columns.Count && dataGridView[j.Column + 1, j.Row].Value != null)
                {
                    d = dataGridView[j.Column + 1, j.Row].Value;
                    dataGridView[j.Column + 1, j.Row].Value = dataGridView[k.Column, k.Row].Value;
                    dataGridView[k.Column, k.Row].Value     = d;
                    return;
                }
                if (k.Column - 1 >= 0 && dataGridView[k.Column - 1, k.Row].Value != null)
                {
                    d = dataGridView[k.Column - 1, k.Row].Value;
                    dataGridView[k.Column - 1, k.Row].Value = dataGridView[j.Column, j.Row].Value;
                    dataGridView[j.Column, j.Row].Value     = d;
                    return;
                }
                else if (k.Column + 1 >= 1 && k.Column + 1 < dataGridView.Columns.Count && dataGridView[k.Column + 1, k.Row].Value != null)
                {
                    d = dataGridView[k.Column + 1, k.Row].Value;
                    dataGridView[k.Column + 1, k.Row].Value = dataGridView[j.Column, j.Row].Value;
                    dataGridView[j.Column, j.Row].Value     = d;
                    return;
                }
            }
        }