Exemple #1
0
 /// <summary>
 /// Configures the excel cell for the property with index autodiscover. This method will try to autodiscover the column index by its <paramref name="title"/>
 /// </summary>
 /// <param name="title">The excel cell title (fist row).</param>
 /// <param name="formatter">The formatter will be used for formatting the value.</param>
 /// <param name="allowMerge">If set to <c>true</c> allow merge the same value cells.</param>
 /// <remarks>
 /// This method will try to autodiscover the column index by its <paramref name="title"/>
 /// </remarks>
 /// <param name="cellValueConverter">The value converter.</param>
 public void HasAutoIndexExcelCell(string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
 {
     Index              = -1;
     Title              = title;
     Formatter          = formatter;
     AutoIndex          = true;
     AllowMerge         = allowMerge;
     CellValueConverter = cellValueConverter;
 }
        private void InitGameGrid()
        {
            for (var i = 0; i < Constants.ORIG_SUDOKU_GRID_SIZE; i++)
            {
                GameGrid.RowDefinitions.Add(new RowDefinition());
                GameGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            var whiteStyle = (Style)FindResource("CellStyle");
            var blueStyle  = (Style)FindResource("CellBlueStyle");

            var converter = new CellValueConverter();

            var lastStyle = blueStyle;

            for (var i = 0; i < Constants.ORIG_SUDOKU_GRID_SIZE; i++)
            {
                var currentStyle = lastStyle;
                if (i % Constants.ORIG_SUDOKU_REGION_SIZE == 0)
                {
                    lastStyle = currentStyle = currentStyle == whiteStyle
                        ? blueStyle
                        : whiteStyle;
                }

                for (var j = 0; j < Constants.ORIG_SUDOKU_GRID_SIZE; j++)
                {
                    if (j % Constants.ORIG_SUDOKU_REGION_SIZE == 0)
                    {
                        currentStyle = currentStyle == whiteStyle
                            ? blueStyle
                            : whiteStyle;
                    }

                    var textBox = new TextBox
                    {
                        Style = currentStyle
                    };

                    textBox.SetBinding(TextBox.TextProperty, new Binding($"{MainViewModel.CellsPropertyName}[{i * Constants.ORIG_SUDOKU_GRID_SIZE + j}].{CellClass.ValuePropertyName}")
                    {
                        Converter = converter,
                    });

                    textBox.SetValue(Grid.RowProperty, i);
                    textBox.SetValue(Grid.ColumnProperty, j);

                    GameGrid.Children.Add(textBox);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Configures the excel cell for the property.
        /// </summary>
        /// <param name="index">The excel cell index.</param>
        /// <param name="title">The excel cell title (fist row).</param>
        /// <param name="formatter">The formatter will be used for formatting the value.</param>
        /// <param name="allowMerge">If set to <c>true</c> allow merge the same value cells.</param>
        /// <param name="cellValueConverter">The value converter.</param>
        public void HasExcelCell(int index, string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
        {
            if (index < 0)
            {
                throw new IndexOutOfRangeException("The index cannot be less then 0");
            }

            Index              = index;
            Title              = title;
            Formatter          = formatter;
            AutoIndex          = false;
            AllowMerge         = allowMerge;
            CellValueConverter = cellValueConverter;
        }
 public ExcelValueConverterTests()
 {
     _converterProvider = Substitute.For <IConverterProvider>();
     _sut = new CellValueConverter(_converterProvider);
 }
Exemple #5
0
 /// <summary>
 /// 值转换器
 /// </summary>
 /// <param name="cellValueConverter">值转换器</param>
 /// <returns></returns>
 public PropertyConfiguration HasValueConverter(CellValueConverter cellValueConverter)
 {
     CellValueConverter = cellValueConverter;
     return(this);
 }
Exemple #6
0
 public override string ToString()
 {
     return(IsNull
                         ? String.Empty
                         : $"{(IsBeforeCrist ? "BC " : null)}{CellValueConverter.FormatDateTime(Value)}");
 }