public void Display(AdminInGridClickableObject gameObject) { selectedObjectDetails.Children.Clear(); var image = gameObject.CreateOfButtons(gameObject.GameObject); image.Width = 99; image.Height = 99; Grid.SetRow(image, 0); Grid.SetColumnSpan(image, 2); var nameLabel = new TextBlock { Text = "Nazwa: " }; Grid.SetRow(nameLabel, 1); Grid.SetColumn(nameLabel, 0); var name = new TextBlock { Text = shorten(gameObject.GameObject.TileObject.Name, 20) }; Grid.SetRow(name, 1); Grid.SetColumn(name, 1); nameLabel.Padding = new Thickness(10, 0, 0, 5); name.Margin = new Thickness(-50, 0, 40, 3); var priceLabel = new TextBlock { Text = "Cena: " }; Grid.SetRow(priceLabel, 2); Grid.SetColumn(priceLabel, 0); var price = new System.Windows.Controls.TextBox { Text = gameObject.GameObject.Price.ToString() }; Grid.SetRow(price, 2); Grid.SetColumn(price, 1); price.PreviewTextInput += Int_PreviewTextInput; priceLabel.Padding = new Thickness(10, 0, 0, 5); price.Margin = new Thickness(0, 0, 40, 3); var ratioLabel = new TextBlock { Text = "Wpływ na temp: " }; Grid.SetRow(ratioLabel, 3); Grid.SetColumn(ratioLabel, 0); var ratio = new System.Windows.Controls.TextBox { Text = gameObject.GameObject.ChangeValue.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) }; Grid.SetRow(ratio, 3); Grid.SetColumn(ratio, 1); ratio.PreviewTextInput += Decimal_PreviewTextInput; ratioLabel.Padding = new Thickness(10, 0, 0, 5); ratio.Margin = new Thickness(0, 0, 40, 3); var save = new System.Windows.Controls.Button { Content = "Zapisz", Background = new SolidColorBrush(Color.FromRgb(0x00, 0x30, 0x49)), Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(-30, 0, 0, 0) }; save.Click += (sender, args) => SaveChanges( price, ratio, sender, args ); Grid.SetRow(save, 4); Grid.SetColumnSpan(save, 2); selectedObjectDetails.Children.Add(image); selectedObjectDetails.Children.Add(name); selectedObjectDetails.Children.Add(price); selectedObjectDetails.Children.Add(ratio); selectedObjectDetails.Children.Add(nameLabel); selectedObjectDetails.Children.Add(priceLabel); selectedObjectDetails.Children.Add(ratioLabel); selectedObjectDetails.Children.Add(save); }
public static void ShowMessageBox(this object obj, string title = null) { if (obj == null) { throw new ArgumentException("object null"); } List <DataShow> dataShows = new List <DataShow>(); Type type = obj.GetType(); PropertyInfo[] propertyInfos = type.GetProperties(); foreach (PropertyInfo propertyInfo in propertyInfos) { string name = propertyInfo.Name; object value = GetValue(propertyInfo, obj); dataShows.Add(new DataShow() { Name = name, Value = value.ToString() }); } List <DataShow> shows = dataShows.OrderBy(x => x.Name).ToList(); Window window = new Window(); window.Title = title == null?obj.GetType().FullName : title; window.Width = 400; window.Height = 600; window.SizeToContent = SizeToContent.Height; window.ResizeMode = ResizeMode.NoResize; Grid grid = new Grid(); RowDefinitionCollection rowDefinitions = grid.RowDefinitions; rowDefinitions.Add(new RowDefinition()); RowDefinition definition = new RowDefinition(); definition.Height = new GridLength(30); rowDefinitions.Add(definition); System.Windows.Controls.Button btnClose = new System.Windows.Controls.Button(); btnClose.IsCancel = true; btnClose.Content = "Close"; btnClose.Height = 29; btnClose.Click += new RoutedEventHandler((sender, args) => window.Close()); StackPanel stackPanel = new StackPanel(); Grid.SetRow(stackPanel, 1); stackPanel.Children.Add(btnClose); grid.Children.Add(stackPanel); System.Windows.Controls.ListView listView = new System.Windows.Controls.ListView(); GridViewColumn col1 = new GridViewColumn(); // col1.Width = ; col1.Header = "Name"; col1.DisplayMemberBinding = new System.Windows.Data.Binding("Name"); GridViewColumn col2 = new GridViewColumn(); //col2.Width = 100; col2.Header = "Value"; col2.DisplayMemberBinding = new System.Windows.Data.Binding("Value"); GridView gridView = new GridView(); gridView.Columns.Add(col1); gridView.Columns.Add(col2); listView.View = gridView; listView.ItemsSource = shows; grid.Children.Add(listView); window.Content = grid; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; window.ShowDialog(); }