public void SelectComponent(ParameterStructure.Component.Component _comp) { if (_comp == null) { return; } // deselect all this.DeselectAllNodes(); // starts w top-level parent and ends with _comp List <ParameterStructure.Component.Component> parent_chain = this.CompFactory.GetParentComponentChain(_comp); List <long> parent_id_chain = parent_chain.Select(x => x.ID).ToList(); if (parent_id_chain.Count < 1) { return; } foreach (object child in this.Children) { ComponentVisualization cv = child as ComponentVisualization; if (cv == null) { continue; } if (cv.VisID == parent_id_chain[0]) { cv.SelectChild(parent_id_chain); break; } } }
protected virtual string GetCrossSectionInfo(ParameterStructure.Component.Component _c) { if (_c == null) { return("[]"); } string cs = "["; ParameterStructure.Parameter.Parameter p_B = _c.GetFirstParamByName(Parameter.RP_WIDTH); ParameterStructure.Parameter.Parameter p_H = _c.GetFirstParamByName(Parameter.RP_HEIGHT); ParameterStructure.Parameter.Parameter p_D = _c.GetFirstParamByName(Parameter.RP_DIAMETER); if (p_B != null && p_H != null && p_B.ValueCurrent > 0 && p_H.ValueCurrent > 0) { cs += p_B.ValueCurrent.ToString("F0", FlNwElementVisualization.NR_FORMATTER) + " x " + p_H.ValueCurrent.ToString("F0", FlNwElementVisualization.NR_FORMATTER); } if (p_D != null && p_D.ValueCurrent > 0) { cs += "Ø " + p_D.ValueCurrent.ToString("F0", FlNwElementVisualization.NR_FORMATTER); } cs += "]"; return(cs); }
private void ComponentToDisplay_PropertyChanged(object sender, PropertyChangedEventArgs e) { ParameterStructure.Component.Component ctd = sender as ParameterStructure.Component.Component; if (ctd == null || e == null || string.IsNullOrEmpty(e.PropertyName)) { return; } if (e.PropertyName == "FitsInSlots" && !this.access_adapted_to_slot_once) { // display information this.AccessEditMode = (this.LoggedUser == ComponentManagerType.ADMINISTRATOR); this.Children.Clear(); this.PopulteGrid(); this.SetUserMark(); this.access_adapted_to_slot_once = true; } else if (e.PropertyName == "AccessLocal") { // update (added 01.09.2016) this.Children.Clear(); this.PopulteGrid(); this.SetUserMark(); } }
private void compFactory_PropertyChanged(object sender, PropertyChangedEventArgs e) { ComponentFactory cf = sender as ComponentFactory; if (cf == null || e == null) { return; } if (e.PropertyName == "MarkedId") { if (cf.MarkedId > 0) { if (!cf.MarkedTrue) { // remove node from the graph foreach (object child in this.Children) { ComponentVisualization cv = child as ComponentVisualization; if (cv == null) { continue; } if (cv.VisID == cf.MarkedId) { cv.RemoveAllGraphics(); this.Children.Remove(cv); break; } } } else { ParameterStructure.Component.Component c_to_add = this.CompFactory.ComponentRecord.Find(x => x.ID == cf.MarkedId); if (c_to_add != null) { // expand graph this.canvas_expand = new Vector(NodeVisualization.NODE_WIDTH_DEFAULT, NodeVisualization.NODE_COMP_HEIGHT * 1.5); this.AdaptSize2Content(); // add node to the graph ComponentVisualization cv = new ComponentVisualization(this, c_to_add, 3, this.Height - NodeVisualization.NODE_COMP_HEIGHT); } } } } }
protected void ExpandAll() { if (!this.IsUserManipulatable) { return; } if (!this.IsExpanded) { this.IsExpanded = true; } ParameterStructure.Component.Component comp = this.node_data as ParameterStructure.Component.Component; if (this.parent_canvas != null && comp != null) { // tell the parent canvas how many nodes need to be reordered if (this.parent_canvas.nodes_to_order_NR == 0) { this.parent_canvas.nodes_to_order_NR = comp.GetFlatSubCompList().Count + 1; // add to the nodes the parent canvas needs to reorder if (this.parent_canvas.nodes_to_order == null) { this.parent_canvas.nodes_to_order = new List <NodeVisualization>(); } this.parent_canvas.nodes_to_order.Add(this); } } foreach (NodeVisualization nv in this.node_children) { ComponentVisualization cv = nv as ComponentVisualization; if (cv == null) { continue; } cv.to_be_expanded = true; // the logic is completed and called recursively in the Loaded event handler // because expansion can only be completed after the respective node has been loaded } }
private void eh_MouseDoubleClick(object sender, MouseButtonEventArgs e) { TreeViewItemCompResult tvie = sender as TreeViewItemCompResult; if (tvie != null && tvie.Header is ParameterStructure.Component.Component) { ParameterStructure.Component.Component comp = tvie.Header as ParameterStructure.Component.Component; if (comp != null && this.ParentWindow != null) { if (this.OtherParentComp != null && this.ParentWindow.C1 != null && this.ParentWindow.C2 != null) { // choose this component for comparison... if (this.OtherParentComp.ID == this.ParentWindow.C1.ID) { this.ParentWindow.C2 = comp; } else { this.ParentWindow.C1 = comp; } } } } }
protected virtual string GetFlowInfo(ParameterStructure.Component.Component _c) { if (_c == null) { return("[...]"); } string flow = "["; ParameterStructure.Parameter.Parameter p_V = _c.GetFirstParamByName(Parameter.RP_FLOW); if (p_V != null) { flow += Parameter.ValueToString(p_V.ValueCurrent, "F3") + " " + p_V.Unit; } Parameter p_dP = _c.GetFirstParamByName(Parameter.RP_PRESS_IN); Parameter p_dP2 = _c.GetFirstParamByName(Parameter.RP_PRESS_IN_MAIN); Parameter p_dP3 = _c.GetFirstParamByName(Parameter.RP_PRESS_IN_BRANCH); if (p_dP != null) { flow += " " + Parameter.RP_PRESS_IN + ": " + Parameter.ValueToString(p_dP.ValueCurrent, "F2") + " " + p_dP.Unit; } if (p_dP2 != null) { flow += " " + Parameter.RP_PRESS_IN_MAIN + ": " + Parameter.ValueToString(p_dP2.ValueCurrent, "F2"); } if (p_dP3 != null) { flow += " " + Parameter.RP_PRESS_IN_BRANCH + ": " + Parameter.ValueToString(p_dP3.ValueCurrent, "F2"); } flow += "]"; return(flow); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (container == null) { return(null); } FrameworkElement element = container as FrameworkElement; if (element == null) { return(null); } if (item == null) { return(element.TryFindResource("DT_Empty") as DataTemplate); } ParameterStructure.Component.Component component = item as ParameterStructure.Component.Component; ParameterStructure.Component.EmptyComponentSlot compslot = new EmptyComponentSlot { SlotType = 0, SlotName = string.Empty, SlotDescr = string.Empty }; if (item is ParameterStructure.Component.EmptyComponentSlot) { compslot = (ParameterStructure.Component.EmptyComponentSlot)item; } ParameterStructure.Parameter.Parameter parameter = item as ParameterStructure.Parameter.Parameter; ParameterStructure.Parameter.Calculation calc = item as ParameterStructure.Parameter.Calculation; if (component != null) { if (component.IsHidden) { return(element.TryFindResource("ComponentInListHidden") as DataTemplate); } else { return(element.TryFindResource("ComponentInList") as DataTemplate); } } else if (!(string.IsNullOrEmpty(compslot.SlotName))) { if (compslot.IsLarge) { return(element.TryFindResource("ComponentSlotInParamList") as DataTemplate); } else { return(element.TryFindResource("ComponentSlotInList") as DataTemplate); } } else if (parameter != null) { return(element.TryFindResource("ParamOfCompInList") as DataTemplate); } else if (calc != null) { return(element.TryFindResource("CalcInList") as DataTemplate); } else { return(null); } }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (container == null) { return(null); } FrameworkElement element = container as FrameworkElement; if (element == null) { return(null); } if (item == null) { return(element.TryFindResource("DT_Empty") as DataTemplate); } ParameterStructure.Component.Component component = item as ParameterStructure.Component.Component; ParameterStructure.Component.EmptyComponentSlot compslot = new EmptyComponentSlot { SlotType = 0, SlotName = string.Empty, SlotDescr = string.Empty }; if (item is ParameterStructure.Component.EmptyComponentSlot) { compslot = (ParameterStructure.Component.EmptyComponentSlot)item; } ParameterStructure.Parameter.Parameter parameter = item as ParameterStructure.Parameter.Parameter; ParameterStructure.Parameter.Calculation calc = item as ParameterStructure.Parameter.Calculation; ParameterStructure.Geometry.GeometricRelationship geom_rel = item as ParameterStructure.Geometry.GeometricRelationship; ParameterStructure.Geometry.HierarchicalContainer hcontainer = item as ParameterStructure.Geometry.HierarchicalContainer; if (component != null) { if (component.IsHidden) { return(element.TryFindResource("ComponentInListHidden") as DataTemplate); } else { return(element.TryFindResource("ComponentWInstancesWoControlsInList") as DataTemplate); } } else if (!(string.IsNullOrEmpty(compslot.SlotName))) { if (compslot.IsLarge) { return(element.TryFindResource("ComponentSlotInParamList") as DataTemplate); } else { return(element.TryFindResource("ComponentSlotInList") as DataTemplate); } } else if (parameter != null) { return(element.TryFindResource("ParamInListMapping") as DataTemplate); } else if (calc != null) { return(element.TryFindResource("CalcInListMapping") as DataTemplate); } else if (geom_rel != null) { return(element.TryFindResource("GeomRelationshipInMappingTree") as DataTemplate); } else if (hcontainer != null) { return(element.TryFindResource("HierarchicalContainerInList") as DataTemplate); } else { return(null); } }
public static void TranslateIntoComponents(List <ComponentMessage> _messages, ComponentFactory _comp_factory, out List <ParameterStructure.Component.Component> new_comps_created) { new_comps_created = new List <ParameterStructure.Component.Component>(); if (_messages == null) { return; } if (_messages.Count == 0) { return; } if (_comp_factory == null) { return; } // 1. Modify the components Dictionary <Component, ComponentAction> updated = new Dictionary <Component, ComponentAction>(); foreach (ComponentMessage msg in _messages) { ParameterStructure.Component.Component comp = null; ComponentAction action_to_take = ComponentAction.NONE; if (msg.CompID > -1) { // handling of existing components comp = _comp_factory.GetByID(msg.CompID); action_to_take = (msg.ActionToTake == MessageAction.DELETE) ? ComponentAction.DELETE : ComponentAction.UPDATE; } else { Debug.WriteLine("CB: creating new component from {0}", msg.CompDescr); // create a new component (adds it to the top level of the component record of the Factory) // NOTE: should happen only for components describing a space comp = _comp_factory.CreateEmptyComponent(false); new_comps_created.Add(comp); ////comp.Name = GeometryUtils.Relationship2GeometryToCompNameDE(msg.GeomType); comp.Name = msg.CompDescr; comp.Description = "Representation"; action_to_take = ComponentAction.CREATE; } if (comp != null) { Debug.WriteLine("CB: calling 'UpdateComponentFromMessage' with {0} for {1}", action_to_take, msg.CompDescr); ComponentMessageTranslator.UpdateComponentFromMessage(comp, msg, _comp_factory.Caller, true); _comp_factory.UpdateConnectivity(comp); // for Relation2Geometry Type CONTAINED_IN -> propagates realization if (!(updated.ContainsKey(comp))) { updated.Add(comp, action_to_take); } } } // 2. Adjust the relationships btw the components // NOTE: includes deletion of all automatically generated sub-components and // replacing them with the new automatically created components List <long> parent_ids = new List <long>(); foreach (ComponentMessage msg in _messages) { if (msg.CompParentID < 0 && msg.CompRepParentID > -1) { // the parent was just generated... int index = _messages.FindIndex(x => x.CompRepID == msg.CompRepParentID); long new_parent_id = updated.ElementAt(index).Key.ID; parent_ids.Add(new_parent_id); } else { // the parent existed already before the call to this method OR // there is no parent parent_ids.Add(msg.CompParentID); } } List <List <long> > ref_comp_ids = _messages.Select(x => new List <long>(x.CompRefIds)).ToList(); // happens independent of the current user (references have a higher priority than writing access) _comp_factory.AdjustSubAndRefComponentDependenciesAfterAutomaticGeneration(updated, parent_ids, ref_comp_ids); }