Ejemplo n.º 1
0
        public ValueRangeControl(string name, DoubleRange range)
        {
            this._range = range;

            // Set up grid with four coulmns, one row
            ColumnDefinition col = new ColumnDefinition();
            col.Width = new GridLength(20, GridUnitType.Star);
            this.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = new GridLength(20, GridUnitType.Star);
            this.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = new GridLength(20, GridUnitType.Star);
            this.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = new GridLength(20, GridUnitType.Star);
            this.ColumnDefinitions.Add(col);

            RowDefinition row = new RowDefinition();
            row.Height = new GridLength(100, GridUnitType.Star);

            // TODO: remove the set row if it's not necessary
            TextBlock from = new TextBlock();
            from.Text = name + " from :";
            this.Children.Add(from);
            Grid.SetColumn(from,0);
            Grid.SetRow(from,0);

            TextBoxPlus low = new TextBoxPlus();
            low.Text = range.Low.ToString();
            this.Children.Add(low);
            Grid.SetColumn(low, 1);
            Grid.SetRow(low,0);

            TextBlock to = new TextBlock();
            to.Text = " to : ";
            this.Children.Add(to);
            Grid.SetColumn(to, 2);
            Grid.SetRow(to, 0);

            TextBoxPlus high = new TextBoxPlus();
            if (range.High < double.MaxValue)
            { high.Text = range.High.ToString(); }
            Grid.SetColumn(high, 3);
            Grid.SetRow(high, 0);
        }
Ejemplo n.º 2
0
        public SudokuSolverTextBoxManager Genera(int Dimensione)
        {
            SudokuSolverTextBoxManager sss = new SudokuSolverTextBoxManager();

            TextBoxPlus[] ArrTemp  = new TextBoxPlus[Dimensione * Dimensione];
            int           ArrTempI = 0;

            double ris = ((double)Dimensione).Sqrt();

            if (!ris.IsInteger())
            {
                throw new SudokuPanelException("Valore non accettato per la generazione dello schema");
            }

            Controls.Clear();
            NumRow = (int)ris;
            TextBoxPlus preV = null;
            TextBoxPlus preO = null;

            for (int i = 0; i < Dimensione; i++)
            {
                TextBoxPlus t = (TextBoxPlus) new TextBoxPlus().SetSize(_CellWidth, _CellHeight);
                if (preV == null)
                {
                    AddVerticalControl(t, null, 0, 0);
                }
                else
                {
                    AddVerticalControl(t, preV, 0, i % NumRow == 0 ? _PlusSpace : _NormalSpace);
                }

                preO = t;
                preV = t;
                ArrTemp[ArrTempI++] = t;

                for (int j = 1; j < Dimensione; j++)
                {
                    TextBoxPlus tt = (TextBoxPlus) new TextBoxPlus().SetSize(_CellWidth, _CellHeight);
                    AddOrizzontalControl(tt, preO, j % NumRow == 0 ? _PlusSpace : _NormalSpace, 0);
                    preO = tt;
                    ArrTemp[ArrTempI++] = tt;
                }
            }


            sss.SetArrayTextBox(ArrTemp);
            return(sss);
        }
        private Tuple <int, int> GetPos(TextBoxPlus t)
        {
            int x = -1;

            for (int i = 0; i < vett.Length; i++)
            {
                if (vett[i] == t)
                {
                    x = i;
                }
            }

            int y = x % _Dim;

            x = x / _Dim;
            return(new Tuple <int, int>(x, y));
        }