public void AddRow(Account account)
        {
            GridView.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(30)
            });

            var index = new TextBlock
            {
                Text                = NumberOfRows.ToString(),
                FontWeight          = FontWeights.Bold,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                Foreground          = Brushes.DarkSlateGray
            };
            var border1 = new Border
            {
                Child           = index,
                Background      = new SolidColorBrush(Colors.Wheat),
                BorderThickness = new Thickness(3)
            };

            GridView.Children.Add(border1);
            Grid.SetColumn(border1, 0);
            Grid.SetRow(border1, NumberOfRows);

            if (_detailed)
            {
                var username = new TextBlock
                {
                    Text                = account.Username,
                    FontWeight          = FontWeights.Bold,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    Foreground          = Brushes.DarkSlateGray
                };
                var border2 = new Border
                {
                    Child           = username,
                    Background      = new SolidColorBrush(Colors.Wheat),
                    BorderThickness = new Thickness(3)
                };

                var dugme = new Button {
                    Content = "---->"
                };

                UsernameButtonDictionary.Add(account.Username, dugme);

                GridView.Children.Add(border2);
                GridView.Children.Add(dugme);

                Grid.SetColumn(border2, 1);
                Grid.SetRow(border2, NumberOfRows);
                Grid.SetColumn(dugme, 2);
                Grid.SetRow(dugme, NumberOfRows);
            }
            NumberOfRows++;
        }
예제 #2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = offsetX.GetHashCode();
         hashCode = (hashCode * 397) ^ offsetY.GetHashCode();
         hashCode = (hashCode * 397) ^ Width.GetHashCode();
         hashCode = (hashCode * 397) ^ Height.GetHashCode();
         hashCode = (hashCode * 397) ^ NumberOfRows.GetHashCode();
         hashCode = (hashCode * 397) ^ newImageOffset;
         hashCode = (hashCode * 397) ^ EndOfHeader;
         return(hashCode);
     }
 }
예제 #3
0
        public override string ToString()
        {
            StringBuilder res = new StringBuilder();

            res.Append(NumberOfRows.ToString());

            res.Append(NumberOfRows.ToString());
            res.Append(",");
            res.AppendLine(NumberOfColumns.ToString());
            for (int y = 0; y < NumberOfRows; y++)
            {
                for (int x = 0; x < NumberOfColumns; x++)
                {
                    res.Append(Tiles[y, x].Resource.GetType().Name[0] + ",");
                }
                res = res.Remove(res.Length - 1, 1);
                res.AppendLine();
            }
            return(res.ToString());
        }
예제 #4
0
        public string ToString(int numberOfRows = 5, int colWidth = 10, int maxRows = 300, bool?printRowLabels = null, bool printDataTypes = false)
        {
            string output       = "";
            bool   printRowLabs = (printRowLabels == null)? false : true;

            printRowLabs = (printRowLabs | LabeledRows)? true:false;

            numberOfRows = (numberOfRows > maxRows)? maxRows : numberOfRows;
            var row1     = (NumberOfColumns * colWidth);
            var row2     = (Convert.ToInt32(printRowLabs) * colWidth);
            int rowWidth = (NumberOfColumns * colWidth) + (Convert.ToInt32(printRowLabs) * colWidth);

            output += (printRowLabs)? ColValue(NumberOfRows.ToString() + "x" + NumberOfColumns.ToString()) + '|' : "";


            foreach (string h in _headers)
            {
                output += ColValue(h) + '|';
            }
            output += Environment.NewLine;



            if (printDataTypes)
            {
                output += (printRowLabs)? ColValue("...") + '|' : "";
                foreach (Type t in _columnDataTypes)
                {
                    output += ColValue(t.Name, '-') + '|';
                }
                output += Environment.NewLine;
            }

            output += new String('-', rowWidth - (rowWidth / 10)).ToString();

            for (int r = 0; r < numberOfRows; r++)
            {
                output += Environment.NewLine;
                output += MakeRow(r);
            }

            string MakeRow(int row)
            {
                string outRow = "";

                if (printRowLabs)
                {
                    outRow += ColValue(_rowNames[row].ToString()) + '|';
                }

                for (int col = 0; col < NumberOfColumns; col++)
                {
                    outRow += ColValue(_data[row, col].ToString()) + '|';
                }
                return(outRow);
            }

            string ColValue(string value, char fill = ' ')
            {
                int    valLength    = value.Length;
                string valueToWrite = "";

                if (valLength > colWidth - 4)
                {
                    valueToWrite = value.Substring(0, colWidth - 4);
                }
                else
                {
                    if (valLength % 2 == 0)
                    {
                        int numspaces = ((colWidth - 4) - valLength) / 2;
                        valueToWrite = (new String(fill, numspaces)) + value + (new String(fill, numspaces));
                    }
                    else
                    {
                        int numspaces = ((colWidth - 4) - valLength - 1) / 2;
                        valueToWrite = (new String(' ', numspaces)) + value + (new String(' ', numspaces)) + " ";
                    }
                }
                return(" " + valueToWrite + " ");
            }

            return(output);
        }