private DiagramDrawer DiagramDrawer(GraphNode node)
{
var window = InvertGraphEditor.DesignerWindow as ElementsDesigner;
var diagramViewModel = new DiagramViewModel(node.Graph);
diagramViewModel.NavigateTo(node.Identifier);
var drawer = new DiagramDrawer(diagramViewModel);
drawer.Refresh(InvertGraphEditor.PlatformDrawer);
var screenshotVM = diagramViewModel.AllViewModels.OfType<DiagramNodeViewModel>().FirstOrDefault(p => p.GraphItemObject.Identifier == node.Identifier);
if (screenshotVM == null)
return null;
this.position = new Rect(this.position.x, this.position.y, screenshotVM.Bounds.width + 20f, screenshotVM.Bounds.height + 20f);
var position = screenshotVM.Position - new Vector2(10f,10f);
Debug.Log(diagramViewModel.GraphData.CurrentFilter.Name + " " + position.x + ": " + position.y);
foreach (var item in drawer.Children.OrderBy(p => p.ZOrder))
{
//item.Refresh(InvertGraphEditor.PlatformDrawer, new Vector2(item.Bounds.x - screenshotVM.Bounds.x, item.Bounds.y - screenshotVM.Bounds.y));
if (item == null) continue;
if (item.ViewModelObject != null)
{
item.IsSelected = false;
item.ViewModelObject.ShowHelp = true;
}
item.Bounds = new Rect(item.Bounds.x - position.x, item.Bounds.y - position.y,
item.Bounds.width, item.Bounds.height);
foreach (var child in item.Children)
{
if (child == null) continue;
child.Bounds = new Rect(child.Bounds.x - position.x, child.Bounds.y - position.y,
child.Bounds.width, child.Bounds.height);
if (child.ViewModelObject != null)
{
var cb = child.ViewModelObject.ConnectorBounds;
child.ViewModelObject.ConnectorBounds = new Rect(cb.x - position.x, cb.y - position.y,
cb.width, cb.height);
}
//child.Refresh(InvertGraphEditor.PlatformDrawer, new Vector2(item.Bounds.x - screenshotVM.Bounds.x, item.Bounds.y - screenshotVM.Bounds.y));
}
}
return drawer;
}