public static void BrowseObjectProperties(object obj) { var grd = new DataGrid() { SelectionMode = DataGridSelectionMode.Single }; PropertyHelper.Populate(grd, obj); if (obj is IEnumerable) { grd.ItemsSource = obj as IEnumerable; } else { grd.ItemsSource = new[] { obj } }; var wnd = new Window(); wnd.Content = grd; wnd.Title = obj.GetType().FullName; wnd.ShowDialog(); } }
private void BindMouseEvents(ModelUIElement3D model, Node elm) { var tagGuid = @"35DA1A20-AA6D-4436-890E-CBFA341F9E51"; Material oldfrontm = null; Material oldbackm = null; #region MouseEnter model.MouseEnter += (sender, e) => { var tb = MainCanvas.Children .Cast <UIElement>() .Where(i => i is Border) .Cast <Border>() .FirstOrDefault(i => tagGuid.Equals(i.Tag)); if (tb == null) { MainCanvas.Children.Add(tb = new Border() { Tag = tagGuid }); tb.Child = new TextBlock(); tb.MouseMove += (o, args) => { args.Handled = false; }; tb.PreviewMouseMove += (o, args) => { args.Handled = false; }; StyleTexblock(tb); } var tx = tb.Child as TextBlock; if (tx != null) { tx.Text = "NODE: " + elm.Label; } var geo = model.Model as GeometryModel3D; if (geo != null) { oldfrontm = geo.Material; oldbackm = geo.BackMaterial; geo.Material = geo.BackMaterial = MaterialHelper.CreateMaterial(Brushes.Aqua); } }; #endregion #region MouseMove model.MouseMove += (sender, e) => { Border tb = null; foreach (var child in MainCanvas.Children) { if (child is Border) { if (tagGuid.Equals((child as Border).Tag)) { tb = child as Border; break; } } } if (tb == null) { return; } tb.Visibility = Visibility.Visible; var mousePos = e.GetPosition(MainCanvas); Canvas.SetLeft(tb, mousePos.X - tb.ActualWidth - 10); Canvas.SetTop(tb, mousePos.Y - tb.ActualHeight - 10); }; #endregion #region MouseLeave model.MouseLeave += (sender, args) => { Border tb = null; foreach (var child in MainCanvas.Children) { if (child is Border) { if (tagGuid.Equals((child as Border).Tag)) { tb = child as Border; break; } } } if (tb == null) { return; } tb.Visibility = Visibility.Collapsed; var geo = model.Model as GeometryModel3D; if (geo != null) { geo.Material = oldfrontm; geo.BackMaterial = oldbackm; } }; #endregion model.MouseDown += (sender, args) => { var grd = new DataGrid(); PropertyHelper.Populate(grd, elm); grd.ItemsSource = new[] { elm }; if (DisableEditingProperties) { grd.IsReadOnly = true; } var wnd = new Window(); wnd.Content = grd; wnd.ShowDialog(); args.Handled = true; }; }