示例#1
0
 /// <summary>
 /// Check if any system of this canvas (exclude specified system) overlaps given rectangle.
 /// </summary>
 /// <param name="system">PPathwaySystem to be checked</param>
 /// <returns>True if there is a system which overlaps rectangle of argument, false otherwise</returns>
 public bool DoesSystemOverlaps(PPathwaySystem system)
 {
     bool isOverlaping = false;
     foreach (PPathwaySystem sys in m_systems.Values)
         if (system != sys && system.Overlaps(sys.Rect))
             return true;
     return isOverlaping;
 }
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="system"></param>
        private void DeleteSystemUnder(PPathwaySystem system)
        {
            CanvasControl canvas = system.Canvas;
            foreach (PPathwayObject obj in canvas.GetAllObjectUnder(system.EcellObject.Key))
                if (obj is PPathwaySystem)
                    DeleteSystemUnder((PPathwaySystem)obj);

            NotifyDataDelete(system, true);
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="system"></param>
        /// <param name="obj"></param>
        /// <param name="isDataChanged"></param>
        internal void MakeSpace(PPathwaySystem system, PPathwayObject obj, bool isDataChanged)
        {
            // Offset position of given object.
            PointF offset = PointF.Empty;
            //if (obj.X <= system.Left + PPathwaySystem.SYSTEM_MARGIN)
            //    obj.OffsetX = system.Left + PPathwaySystem.SYSTEM_MARGIN - obj.X;
            //if (obj.Y <= system.Top + PPathwaySystem.SYSTEM_MARGIN)
            //    obj.OffsetY = system.Top + PPathwaySystem.SYSTEM_MARGIN - obj.Y;
            // Enlarge this system
            //if (system.Right < obj.Right + PPathwaySystem.SYSTEM_MARGIN)
            //    system.Width = obj.Right + PPathwaySystem.SYSTEM_MARGIN - system.X;
            //if (system.Bottom < obj.Bottom + PPathwaySystem.SYSTEM_MARGIN)
            //    system.Height = obj.Bottom + PPathwaySystem.SYSTEM_MARGIN - system.Y;
            float margin = (isDataChanged) ? 10 : PPathwaySystem.SYSTEM_MARGIN;
            if (system.Right < obj.Right)
                system.Width = obj.Right - system.X + margin;
            if (system.Bottom < obj.Bottom)
                system.Height = obj.Bottom - system.Y + margin;

            // Check Intersecting objects.
            List<PPathwayObject> list = GetAllObjectUnder(system.EcellObject.Key);
            bool enlargeFlag = false;
            float offsetx = 0;
            RectangleF rect = obj.Rect;
            foreach (PPathwayObject child in list)
            {
                if (child is PPathwayText)
                    continue;
                if (child.EcellObject.Key.Equals(obj.EcellObject.Key))
                    continue;
                if (!child.EcellObject.ParentSystemID.Equals(system.EcellObject.Key))
                    continue;
                // move system
                if (obj is PPathwaySystem && ( rect.IntersectsWith(child.Rect) || rect.Contains(child.Rect) || child.Rect.Contains(rect) ) )
                {
                    enlargeFlag = true;
                    offsetx = obj.Right + PPathwaySystem.SYSTEM_MARGIN - child.X;
                    if (offsetx > offset.X)
                        offset.X = offsetx;
                }
                // Move entity.
                else if (obj is PPathwayEntity && ( rect.IntersectsWith(child.Rect) || rect.Contains(child.Rect) || child.Rect.Contains(rect) ) )
                {
                    enlargeFlag = true;
                    offsetx = obj.Right + PPathwaySystem.SYSTEM_MARGIN - child.X;
                    if (offsetx > offset.X)
                        offset.X = offsetx;
                }
                // move alias
                if (child is PPathwayVariable)
                {
                    foreach (PPathwayAlias alias in ((PPathwayVariable)child).Aliases)
                    {
                        if ( rect.IntersectsWith(alias.Rect) || rect.Contains(alias.Rect) || alias.Rect.Contains(rect) )
                        {
                            enlargeFlag = true;
                            offsetx = obj.Right + PPathwaySystem.SYSTEM_MARGIN - alias.X;
                            if (offsetx > offset.X)
                                offset.X = offsetx;
                        }
                    }
                }
            }
            if (enlargeFlag)
            {
                // Make new space.
                foreach (PPathwayObject child in list)
                {
                    if (child is PPathwayText)
                        continue;
                    if (child.EcellObject.Key.Equals(obj.EcellObject.Key))
                        continue;
                    if (!child.EcellObject.ParentSystemID.Equals(system.EcellObject.Key))
                        continue;

                    if (child.X >= obj.X || rect.IntersectsWith(child.Rect) || rect.Contains(child.Rect) || child.Rect.Contains(rect))
                        child.OffsetX = offset.X;

                    if (child is PPathwayVariable)
                    {
                        foreach (PPathwayAlias alias in ((PPathwayVariable)child).Aliases)
                            if (alias.X >= obj.X || rect.IntersectsWith(alias.Rect) || rect.Contains(alias.Rect) || alias.Rect.Contains(rect))
                                alias.OffsetX = offset.X;
                    }

                    if (child.OffsetX == 0 && child.OffsetY == 0)
                        continue;

                    offset = child.Offset;
                    m_con.NotifyDataChanged(child, false);

                    // Enlarge this system
                    //if (system.Right < child.Right + PPathwaySystem.SYSTEM_MARGIN)
                    //    system.Width = child.Right + PPathwaySystem.SYSTEM_MARGIN - system.X;
                    //if (system.Bottom < child.Bottom + PPathwaySystem.SYSTEM_MARGIN)
                    //    system.Height = child.Bottom + PPathwaySystem.SYSTEM_MARGIN - system.Y;
                    if (system.Right < child.Right)
                        system.Width = child.Right - system.X + 10;
                    if (system.Bottom < child.Bottom)
                        system.Height = child.Bottom - system.Y + 10;

                    // Move system's children.
                    if (!(child is PPathwaySystem))
                        continue;
                    foreach (PPathwayObject grandchild in GetAllObjectUnder(child.EcellObject.Key))
                    {
                        grandchild.Offset = offset;
                        if (grandchild is PPathwayVariable)
                        {
                            foreach (PPathwayAlias alias in ((PPathwayVariable)grandchild).Aliases)
                                alias.Offset = offset;
                        }
                        m_con.NotifyDataChanged(grandchild, false);
                    }
                }
            }

            m_con.NotifyDataChanged(system, false);

            // Make parent system create space for this system.
            if (system.ParentObject != null)
                MakeSpace(system.ParentObject, system, isDataChanged);
        }
示例#4
0
        /// <summary>
        /// Add a E-cell class of this ComponentSetting.
        /// </summary>
        /// <param name="type">a type of class</param>
        private void AddCreateMethod(string type)
        {
            PPathwayObject obj = null;
            switch (type)
            {
                case EcellObject.SYSTEM:
                    obj = new PPathwaySystem();
                    break;
                case EcellObject.PROCESS:
                    obj = new PPathwayProcess();
                    break;
                case EcellObject.VARIABLE:
                    obj = new PPathwayVariable();
                    break;
                case EcellObject.TEXT:
                    obj = new PPathwayText();
                    break;
                case EcellObject.STEPPER:
                    obj = new PPathwayStepper();
                    break;
                default:
                    throw new PathwayException(MessageResources.ErrUnknowType);
            }

            m_createMethod = obj.CreateNewObject;
        }