internal void SetData(FieldData[,] tabelle)
        {
            Table = tabelle;
            UcTables = new UcTableField[tabelle.GetLength(0), tabelle.GetLength(1)];

            ClearElements();

            Grid.Rows = tabelle.GetLength(0);
            Grid.Columns = tabelle.GetLength(1);

            for (var i = 0; i < tabelle.GetLength(0); i++)
            {
                for (var j = 0; j < tabelle.GetLength(1); j++)
                {
                    var ucTableField = new UcTableField();
                    ucTableField.MouseEnter += ucTableField_MouseEnter;
                    ucTableField.MouseLeave += ucTableField_MouseLeave;
                    ucTableField.SetData(tabelle[i, j]);

                    Grid.Children.Add(ucTableField);

                    UcTables[i, j] = ucTableField;
                }
            }
        }
Exemplo n.º 2
0
        public FieldData[,] Calculate(string firstString, string secondString)
        {
            FirstString = firstString;
            SecondString = secondString;

            Table = new FieldData[FirstString.Length + 2, SecondString.Length + 2];

            Table[0, 0] = new FieldData(" ");
            Table[1, 0] = new FieldData(" ");
            Table[0, 1] = new FieldData(" ");

            for (var i = 2; i <= FirstString.Length + 1; i++)
            {
                Table[i, 0] = new FieldData(FirstString[i - 2].ToString(CultureInfo.InvariantCulture));
            }

            for (var j = 2; j <= SecondString.Length + 1; j++)
            {
                Table[0, j] = new FieldData(SecondString[j - 2].ToString(CultureInfo.InvariantCulture));
            }


            for (var i = 1; i <= FirstString.Length + 1; i++)
            {
                Table[i, 1] = new FieldData(i - 1);
            }

            for (var j = 1; j <= SecondString.Length + 1; j++)
            {
                Table[1, j] = new FieldData(j - 1);
            }

            for (var indexi = 2; indexi <= FirstString.Length + 1; indexi++)
            {
                for (var indexj = 2; indexj <= SecondString.Length + 1; indexj++)
                {
                    Table[indexi, indexj] = CalculateValue(indexi, indexj);
                }
            }

            Result = Table[FirstString.Length, SecondString.Length].CurrentData;

            return Table;
        }
        public void SetData(FieldData fieldData)
        {
            FieldData = fieldData;

            if (fieldData != null)
            {
                if (!String.IsNullOrEmpty(fieldData.Content))
                {
                    Data.Content = fieldData.Content;
                }
                else
                {
                    Data.Content = fieldData.CurrentData;
                }

                if (fieldData.Backtrace)
                {
                    Background = Brushes.Orange;
                }
            }
        }