public NodeComponentRow(NodeComponent source, ObservableCollection <NodeComponent> sourceCollection) { Presenter = null; Layout = new VBoxLayout(); Nodes.Clear(); var container = new Widget { Anchors = Anchors.LeftRight, Layout = new VBoxLayout(), }; PostPresenter = new WidgetBoundsPresenter(ColorTheme.Current.Inspector.CategoryLabelBackground) { IgnorePadding = true }; var content = new InspectorContent(container) { History = history }; content.OnComponentRemove += c => { history.DoTransaction(() => Core.Operations.RemoveFromList.Perform(sourceCollection, sourceCollection.IndexOf(c))); }; Nodes.Add(container); content.BuildForObjects(new List <object> { source }); Padding = new Thickness { Bottom = 4f }; }
public Exception Open(string path) { file.Path = path; TitleChangedEvent?.Invoke(file.Name); TargaFile targaFile = TargaFile.Read(path); int width = targaFile.Header.Width; int height = targaFile.Header.Height; WriteableBitmap bitmap = new WriteableBitmap(width, height, 90, 90, PixelFormats.Bgra32, null); byte[] buffer = new byte[width * height * 4]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int pos = (x + y * width) * 4; var lookupX = width - x - 1; Color color = targaFile.Pixels[lookupX, y]; buffer[pos] = color.B; buffer[pos + 1] = color.G; buffer[pos + 2] = color.R; buffer[pos + 3] = color.A; } } Int32Rect rect = new Int32Rect(0, 0, width, height); bitmap.WritePixels(rect, buffer, width * 4, 0); OutputImage.Source = bitmap; FileInfo fileInfo = new FileInfo(file.Path); InspectorContent = new InspectorContent( file.Name, new InspectorTableEntry[] { new InspectorTableEntry("Path", file.Path, file.Path), new InspectorTableEntry("File Size", FileSizeFormatter.FormatSize(fileInfo.Length)), new InspectorTableEntry("Creation time", fileInfo.CreationTime.ToString(CultureInfo.InvariantCulture)), new InspectorTableEntry("Last change", fileInfo.LastWriteTime.ToString(CultureInfo.InvariantCulture)), new InspectorTableEntry("Dimensions", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions1", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions2", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions3", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions4", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions5", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions6", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions7", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions8", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions9", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions11", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions12", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions13", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions14", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions15", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions16", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions17", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions18", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions19", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions21", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions22", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions23", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), new InspectorTableEntry("Dimensions24", width + " x " + height, $"Height:\t{height}\nWidth:\t{width}"), }, new Image() { Source = new DrawingImage() { Drawing = (Drawing)FindResource("Image") } }); return(null); }
public static void Show(InspectorContent content) { Set(content); Show(); }
public static void Set(InspectorContent content) { try { if (content == null) { Clear(); return; } if (IsEmpty) { _groupBox.Content = ScrollViewer; IsEmpty = false; } // Add Image (and separator) if aviable if (!(content.Icon is null)) { _image = content.Icon; int size = 150; _image.Width = size; _image.Height = size; _image.VerticalAlignment = VerticalAlignment.Top; _image.HorizontalAlignment = HorizontalAlignment.Center; _image.Margin = IconMargin; Panel.Children.Add(_image); // TODO Fix wired bug Panel.Children.Add(Separator); } // Add Title if (content.Title is null) { _titleLabel = null; } else { _titleLabel = new Label() { Content = content.Title, FontSize = 22, FontFamily = FontFamily }; Panel.Children.Add(_titleLabel); } // Add Data Table.Clear(); _grid = new Grid() { ColumnDefinitions = { new ColumnDefinition() { Width = new GridLength(100) }, new ColumnDefinition() } }; foreach (InspectorTableEntry entry in content.TableEntries) { _grid.RowDefinitions.Add(new RowDefinition()); int id = Table.Count; Label keyLabel = new Label() { Content = entry.ID, FontWeight = FontWeights.Bold }; keyLabel.SetValue(Grid.RowProperty, id); keyLabel.SetValue(Grid.ColumnProperty, 0); Label valueLabel = new Label() { Content = entry.Value }; if (!(entry.ToolTip is null)) { valueLabel.ToolTip = entry.ToolTip; } valueLabel.SetValue(Grid.RowProperty, id); valueLabel.SetValue(Grid.ColumnProperty, 1); _grid.Children.Add(keyLabel); _grid.Children.Add(valueLabel); Table.Add(entry.ID, new[] { keyLabel, valueLabel }); } Panel.Children.Add(_grid); // TODO Fix custom control /*CustomControls.Clear(); * foreach (Control control in content.CustomControls) * { * control.Width = 276; * _panel.Children.Add(control); * CustomControls.Add(control); * }*/ } catch (Exception e) { Logger.DumpException(e); ShowFailedToBuild(); } }