protected override void UpdateElementsOrder() { var origOrders = Placemats.ToDictionary(pm => pm, pm => pm.ZOrder); base.UpdateElementsOrder(); var changed = Placemats.Where(pm => origOrders[pm] != pm.ZOrder).OfType <Placemat>().ToList(); m_Store.Dispatch( new ChangePlacematZOrdersAction( changed.Select(pm => pm.ZOrder).ToArray(), changed.Select(pm => pm.GraphElementModel).Cast <PlacematModel>().ToArray())); }
// If you need this, ask yourself if you should not use a UnityTest and CommandDispatcher.State.GraphViewState.RequestUIRebuild(); public void RebuildUI(IGraphModel graphModel, CommandDispatcher commandDispatcher) { var nodeList = Nodes.ToList(); foreach (var node in nodeList) { RemoveElement(node); } var edgeList = Edges.ToList(); foreach (var edge in edgeList) { RemoveElement(edge); } var stickyList = Stickies.ToList(); foreach (var sticky in stickyList) { RemoveElement(sticky); } var placematList = Placemats.ToList(); foreach (var placemat in placematList) { RemoveElement(placemat); } UIForModel.Reset(); foreach (var nodeModel in graphModel.NodeModels) { var element = GraphElementFactory.CreateUI <GraphElement>(this, commandDispatcher, nodeModel); AddElement(element); } foreach (var edgeModel in graphModel.EdgeModels) { var element = GraphElementFactory.CreateUI <GraphElement>(this, commandDispatcher, edgeModel); AddElement(element); } foreach (var stickyNoteModel in graphModel.StickyNoteModels) { var element = GraphElementFactory.CreateUI <GraphElement>(this, commandDispatcher, stickyNoteModel); AddElement(element); } List <IModelUI> placemats = new List <IModelUI>(); foreach (var placematModel in graphModel.PlacematModels) { var element = GraphElementFactory.CreateUI <GraphElement>(this, commandDispatcher, placematModel); AddElement(element); placemats.Add(element); } // Update placemats to make sure hidden elements are all hidden (since // a placemat can hide a placemat UI created after itself). foreach (var placemat in placemats) { placemat.UpdateFromModel(); } }