Ejemplo n.º 1
0
        /// <summary>
        /// delete lines which links this frame
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnEntityRefresh(object sender,dynamic e)
        {
            String e_name = e.ENTITYNAME;
            var    entity = (EntityFrame_Model)m_Elements.m_Frames[e_name];

            System.Numerics.Vector3 p = entity.UIEntity.Translation;
            var key_list = new System.Collections.ArrayList();

            foreach (String i in entity.m_Lines.Values)
            {
                key_list.Add(i);
            }

            foreach (String t_line_key in key_list)
            {
                EntityLine_Model line = (EntityLine_Model)m_Elements.m_Lines[t_line_key];
                if (line == null)
                {
                    continue;
                }
                DeleteLine(line.Name);
            }
            //this.C_MAINGRID.Children.Remove(entity.UIEntity);
            //m_Elements.m_Frames.Remove(entity.Name);
        }
Ejemplo n.º 2
0
 private void M_Timer_Tick(object sender, object e)
 {
     foreach (object t_line_key in m_Elements.m_Lines.Keys)
     {
         EntityLine_Model line = (EntityLine_Model)m_Elements.m_Lines[(String)t_line_key];
         line.UIPath.StrokeDashOffset -= 0.2;
         if (line.UIPath.StrokeDashOffset < 0)
         {
             line.UIPath.StrokeDashOffset = 6.0;
         }
     }
 }
Ejemplo n.º 3
0
        private void OnEntityFrameMove(object sender, dynamic e)
        {
            String e_name = e.ENTITYNAME;
            var    entity = (EntityFrame_Model)m_Elements.m_Frames[e_name];

            System.Numerics.Vector3 p = entity.UIEntity.Translation;
            foreach (object t_line_key in entity.m_Lines.Keys)
            {
                String           line_name = (String)entity.m_Lines[t_line_key];
                EntityLine_Model line      = (EntityLine_Model)m_Elements.m_Lines[line_name];
                if (line.from_Name.Equals(entity.Name))
                {
                    line.from_point.X  = (int)p.X;
                    line.from_point.Y  = (int)p.Y;
                    line.from_point.Y += EntityFrame_Model.SlotIndexToY(line.from_index);
                    line.from_point.X += 300 * 1 - 8;
                }
                if (line.to_Name.Equals(entity.Name))
                {
                    line.to_point.X  = (int)p.X;
                    line.to_point.Y  = (int)p.Y;
                    line.to_point.Y += EntityFrame_Model.SlotIndexToY(line.to_index);
                    line.to_point.X += 300 * 0 + 8;
                }



                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;


                line.UIPath.Data = pathGeometry1;
            }
        }
Ejemplo n.º 4
0
        public void DeleteFrame(String Name)
        {
            String e_name = Name;
            var    entity = (EntityFrame_Model)m_Elements.m_Frames[e_name];

            System.Numerics.Vector3 p = entity.UIEntity.Translation;
            var key_list = new System.Collections.ArrayList();

            foreach (String i in entity.m_Lines.Values)
            {
                key_list.Add(i);
            }

            foreach (String t_line_key in key_list)
            {
                EntityLine_Model line = (EntityLine_Model)m_Elements.m_Lines[t_line_key];
                DeleteLine(line.Name);
            }
            this.C_MAINGRID.Children.Remove(entity.UIEntity);
            m_Elements.m_Frames.Remove(entity.Name);
        }
Ejemplo n.º 5
0
        private void C_MAINGRID_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if (m_TempLine.to_Name == null && m_TempLine.from_Name == null)
            {
                m_TempLine.UIPath.Visibility = Visibility.Collapsed;
                return;
            }

            m_TempLine.UIPath.Visibility = Visibility.Visible;
            EntityLine_Model t_line = new EntityLine_Model();

            t_line.from_index = m_TempLine.from_index;
            t_line.to_index   = m_TempLine.to_index;



            if (m_TempLine.from_Name == null && m_TempLine.to_Name != null)
            {
                var frame_to = (EntityFrame_Model)m_Elements.m_Frames[m_TempLine.to_Name];
                t_line.from_point.X = (int)e.GetCurrentPoint(C_MAINGRID).Position.X;
                t_line.from_point.Y = (int)e.GetCurrentPoint(C_MAINGRID).Position.Y;
                t_line.to_point     = new System.Drawing.Point((int)frame_to.UIEntity.Translation.X, (int)frame_to.UIEntity.Translation.Y);

                t_line.to_point.Y += EntityFrame_Model.SlotIndexToY(t_line.to_index);
                t_line.to_point.X += 300 * 0 + 8;
            }
            if (m_TempLine.to_Name == null && m_TempLine.from_Name != null)
            {
                var frame_from = (EntityFrame_Model)m_Elements.m_Frames[m_TempLine.from_Name];
                t_line.to_point.X = (int)e.GetCurrentPoint(C_MAINGRID).Position.X;
                t_line.to_point.Y = (int)e.GetCurrentPoint(C_MAINGRID).Position.Y;
                t_line.from_point = new System.Drawing.Point((int)frame_from.UIEntity.Translation.X, (int)frame_from.UIEntity.Translation.Y);

                t_line.from_point.Y += EntityFrame_Model.SlotIndexToY(t_line.from_index);
                t_line.from_point.X += 300 * 1 - 8;
            }



            //create new path
            /////////////////////////////////////////////////////////////////
            var pathGeometry1         = new PathGeometry();
            var pathFigureCollection1 = new PathFigureCollection();
            var pathFigure1           = new PathFigure();

            pathFigure1.IsClosed   = false;
            pathFigure1.StartPoint = new Windows.Foundation.Point(t_line.from_point.X, t_line.from_point.Y);
            pathFigureCollection1.Add(pathFigure1);
            pathGeometry1.Figures = pathFigureCollection1;

            var pathSegmentCollection1 = new PathSegmentCollection();
            var pathSegment1           = new BezierSegment();

            pathSegment1.Point1 = new Point(t_line.from_point.X + 100, t_line.from_point.Y);
            pathSegment1.Point2 = new Point(t_line.to_point.X - 100, t_line.to_point.Y);
            pathSegment1.Point3 = new Point(t_line.to_point.X, t_line.to_point.Y);
            pathSegmentCollection1.Add(pathSegment1);

            pathFigure1.Segments = pathSegmentCollection1;
            ///////////////////////////////////////////////////////////////////

            m_TempLine.UIPath.Data = pathGeometry1;
        }
Ejemplo n.º 6
0
        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);
        }