private EntityFrame_Model AddFrame(String EntityFrameName = null) { var entity = new EntityFrame_Model(); entity.Name = "ENTITY_" + EntityElements.RandToken(); if (EntityFrameName != null) { if (m_Elements.m_Frames.ContainsKey(EntityFrameName)) { DeleteFrame(EntityFrameName); } entity.Name = EntityFrameName; } entity.UIEntity = new EntityFrame(); entity.UIEntity.Width = 300; entity.UIEntity.Height = 400; entity.UIEntity.Translation = new System.Numerics.Vector3(0,0,0); entity.UIEntity.m_Name = entity.Name; entity.UIEntity.e_SlotClicked += this.OnEntitySlotClicked; entity.UIEntity.e_EntityMoved += this.OnEntityFrameMove; entity.UIEntity.e_Deletelicked += this.OnEntityDeleteClicked; entity.UIEntity.e_RefreshFrame += this.OnEntityRefresh; //entity.UIEntity.e_PointerExit += this.OnEntityPointerExit; //entity.UIEntity.e_PointerEnter += this.OnEntityPointerEnter; //entity.UIEntity.Shadow = new ThemeShadow(); //entity.UIEntity. this.C_MAINGRID.Children.Add(entity.UIEntity); m_Elements.m_Frames[entity.Name] = entity; return(entity); }
private EntityLine_Model AddLine(EntityLine_Model EntityLine,String LineName = null) { var frame_from = (EntityFrame_Model)m_Elements.m_Frames[EntityLine.from_Name]; var frame_to = (EntityFrame_Model)m_Elements.m_Frames[EntityLine.to_Name]; string from_slot_name = frame_from.UIEntity.m_OutputSlot[EntityLine.from_index]; string to_slot_name = frame_to.UIEntity.m_InputSlot[EntityLine.to_index]; //TODO:/// DELETE Existing Line if (frame_from.m_Lines.Contains(from_slot_name)) { var from_line_name = (String)frame_from.m_Lines[from_slot_name]; DeleteLine(from_line_name); } if (frame_to.m_Lines.Contains(to_slot_name)) { var to_line_name = (String)frame_to.m_Lines[to_slot_name]; DeleteLine(to_line_name); } ////// Refresh Frame frame_from = (EntityFrame_Model)m_Elements.m_Frames[EntityLine.from_Name]; frame_to = (EntityFrame_Model)m_Elements.m_Frames[EntityLine.to_Name]; ///// Fill Line Params var line = new EntityLine_Model(); line.Name = "LINE" + EntityElements.RandToken(); if (LineName != null) { line.Name = LineName; } line.from_Name = EntityLine.from_Name; line.to_Name = EntityLine.to_Name; line.from_SlotName = from_slot_name; line.to_SlotName = to_slot_name; line.from_point = new System.Drawing.Point((int)frame_from.UIEntity.Translation.X,(int)frame_from.UIEntity.Translation.Y); line.to_point = new System.Drawing.Point((int)frame_to.UIEntity.Translation.X,(int)frame_to.UIEntity.Translation.Y); line.from_index = EntityLine.from_index; line.to_index = EntityLine.to_index; line.from_point.Y += EntityFrame_Model.SlotIndexToY(line.from_index); line.to_point.Y += EntityFrame_Model.SlotIndexToY(line.to_index); line.from_point.X += 300 * 1 - 8; line.to_point.X += 300 * 0 + 8; Windows.UI.Xaml.Shapes.Path t_path = new Windows.UI.Xaml.Shapes.Path(); var pathGeometry1 = new PathGeometry(); var pathFigureCollection1 = new PathFigureCollection(); var pathFigure1 = new PathFigure(); pathFigure1.IsClosed = false; pathFigure1.StartPoint = new Windows.Foundation.Point(line.from_point.X,line.from_point.Y); pathFigureCollection1.Add(pathFigure1); pathGeometry1.Figures = pathFigureCollection1; var pathSegmentCollection1 = new PathSegmentCollection(); var pathSegment1 = new BezierSegment(); pathSegment1.Point1 = new Point(line.from_point.X + 100,line.from_point.Y); pathSegment1.Point2 = new Point(line.to_point.X - 100,line.to_point.Y); pathSegment1.Point3 = new Point(line.to_point.X,line.to_point.Y); pathSegmentCollection1.Add(pathSegment1); pathFigure1.Segments = pathSegmentCollection1; DoubleCollection t_path_dash = new DoubleCollection(); t_path_dash.Add(4); t_path_dash.Add(2); t_path.Name = line.Name; t_path.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(0,204,204,255)); t_path.Stroke = new SolidColorBrush(Windows.UI.Colors.Black); t_path.StrokeStartLineCap = PenLineCap.Round; t_path.StrokeDashOffset = 40; t_path.StrokeDashArray = t_path_dash; t_path.StrokeDashCap = PenLineCap.Round; t_path.StrokeThickness = 4; t_path.Opacity = 0.5; t_path.Data = pathGeometry1; line.UIPath = t_path; Canvas.SetZIndex(line.UIPath,5); m_Elements.m_Lines[line.Name] = line; frame_from.m_Lines[from_slot_name] = line.Name; frame_to.m_Lines[to_slot_name] = line.Name; m_Elements.m_Frames[EntityLine.from_Name] = frame_from; m_Elements.m_Frames[EntityLine.to_Name] = frame_to; this.C_MAINGRID.Children.Add(t_path); return(line); }