/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="control">PathwayControl instance.</param>
 /// <param name="cs">ComponentSetting</param>
 public CreateNodeMouseHandler(PathwayControl control, ComponentSetting cs)
     : base(control)
 {
     this.m_cs = cs;
     this.m_template = m_cs.CreateTemplate();
     this.m_template.Pickable = false;
 }
示例#2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="obj"></param>
 public SystemResizeHandler(PPathwayObject obj)
     : base(obj)
 {
     m_minWidth = PPathwaySystem.MIN_WIDTH;
     m_minHeight = PPathwaySystem.MIN_HEIGHT;
 }
示例#3
0
        /// <summary>
        /// Add PPathwayObject to this canvas.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="hasCoords"></param>
        public void DataAdd(PPathwayObject obj, bool hasCoords)
        {
            // Set Layer
            obj.ShowingID = m_showingId;
            SetLayer(obj, obj.EcellObject.Layer);

            // Register
            RegisterObject(obj);
            if (obj is PPathwayEntity)
                ((PPathwayEntity)obj).ShowingID = this.m_showingId;

            // Set ParentObject.
            string sysKey = obj.EcellObject.ParentSystemID;
            PPathwaySystem system = null;
            if (!string.IsNullOrEmpty(sysKey))
            {
                system = m_systems[sysKey];
                obj.ParentObject = system;
            }

            // Set DragEvent
            if (obj is PPathwayObject && !(obj is PPathwayStepper))
                obj.AddInputEventListener(new NodeDragHandler(this));

            // Set Position.
            // If obj hasn't coordinate, it will be settled.
            if (obj is PPathwayEntity)
            {
                if (m_con.Window.IsLoading)
                {
                }
                else if (!hasCoords)
                {
                    obj.Center = GetVacantPoint(sysKey);
                }
                if (!DoesSystemContains(sysKey, obj.Center))
                {
                    if (!obj.EcellObject.IsLayouted)
                    {
                        MakeSpace(system, obj, false);
                    }
                    else
                    {
                        obj.Center = GetVacantPoint(sysKey, obj.Center);
                    }
                }
            }
            else if (obj is PPathwaySystem)
            {
                if (!hasCoords && !string.IsNullOrEmpty(sysKey))
                {
                    float maxX = system.X + system.OffsetX;
                    float x = 0f;
                    List<PPathwayObject> list = GetAllObjectUnder(system.EcellObject.Key);
                    foreach (PPathwayObject child in list)
                    {
                        if (child == obj)
                            continue;
                        x = child.X + child.Width;
                        if (maxX < x)
                            maxX = x;
                    }
                    // Set obj's coordinate
                    obj.X = maxX + PPathwaySystem.SYSTEM_MARGIN;
                    obj.Y = system.Y + PPathwaySystem.SYSTEM_MARGIN;
                    SetSystemSize(obj);
                }
                else if (!hasCoords)
                    SetSystemSize(obj);

                if (!obj.EcellObject.IsLayouted && system != null)
                    MakeSpace(system, obj, false);

            }
            // If this obj is root system, Refresh OverView.
            if (obj is PPathwayStepper || obj.EcellObject.Key.Equals(Constants.delimiterPath))
            {
                SetStepperPosition();
            }

            obj.Refresh();
            // Refresh OverView.
            RefreshOverView();
        }
示例#4
0
 /// <summary>
 /// event sequence of changing the information of object.
 /// </summary>
 /// <param name="obj"></param>
 public void AddSelect(PPathwayObject obj)
 {
     ResetSelectedLine();
     AddSelectedNode(obj);
 }
示例#5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 private void RemoveObject(PPathwayObject obj)
 {
     if (obj == null)
         return;
     obj.PText.RemoveFromParent();
     obj.RemoveFromParent();
     obj.Dispose();
 }
示例#6
0
        /// <summary>
        /// NotifyMoveSystem
        /// </summary>
        /// <param name="system"></param>
        private void NotifyMoveSystem(PPathwayObject system)
        {
            string oldSysKey = system.EcellObject.Key;
            string parentSysKey = GetSurroundingSystemKey(system.PointF, oldSysKey);
            string newSysKey = null;
            if (parentSysKey == null)
                newSysKey = Constants.delimiterPath;
            else if (parentSysKey.Equals(Constants.delimiterPath))
                newSysKey = Constants.delimiterPath + system.EcellObject.LocalID;
            else
                newSysKey = parentSysKey + Constants.delimiterPath + system.EcellObject.LocalID;

            // Move system position.
            m_con.NotifyDataChanged(
                oldSysKey,
                oldSysKey,
                system,
                true,
                false);

            // Move objects under this system.
            // TODO: This process should be implemented in EcellLib.DataChanged().
            foreach (PPathwayObject obj in GetAllObjectUnder(oldSysKey))
            {
                m_con.NotifyDataChanged(
                    obj.EcellObject.Key,
                    obj.EcellObject.Key,
                    obj,
                    true,
                    false);
            }

            // Move system path.
            m_con.NotifyDataChanged(
                oldSysKey,
                newSysKey,
                system,
                true,
                false);

            // Import Systems and Nodes
            RectangleF rect = system.Rect;
            string parentSystemName = system.EcellObject.ParentSystemID;
            foreach (PPathwayObject obj in GetAllEntities())
            {
                if (obj == system)
                    continue;
                if (obj.EcellObject.ParentSystemID.StartsWith(newSysKey))
                    continue;
                if (obj is PPathwayText)
                    continue;
                if (obj is PPathwaySystem && !rect.Contains(obj.Rect))
                    continue;
                if (obj is PPathwayEntity && !rect.Contains(obj.Center))
                    continue;

                string newNodeKey = PathUtil.GetMovedKey(obj.EcellObject.Key, parentSystemName, newSysKey);
                m_con.NotifyDataChanged(
                    obj.EcellObject.Key,
                    newNodeKey,
                    obj,
                    true,
                    false);
            }

            // Refresh system.
            m_con.NotifyDataChanged(
                newSysKey,
                newSysKey,
                system,
                true,
                false);
        }
示例#7
0
        /// <summary>
        /// Check and Move Position.
        /// </summary>
        /// <param name="oldkey"></param>
        /// <param name="newkey"></param>
        /// <param name="obj"></param>
        private void MoveObject(string oldkey, string newkey, PPathwayObject obj)
        {
            if (obj is PPathwayStepper)
                return;

            PPathwaySystem system = m_systems[obj.EcellObject.ParentSystemID];
            string sysKey = system.EcellObject.Key;

            // Move Node.
            if (obj is PPathwayEntity)
            {
                if (DoesSystemContains(sysKey, obj.Center))
                    return;

                obj.Center = GetVacantPoint(sysKey, obj.Center);
                if (obj is PPathwayVariable)
                {
                    foreach (PPathwayAlias alias in ((PPathwayVariable)obj).Aliases)
                    {
                        alias.Center = GetVacantPoint(sysKey, alias.Center);
                    }
                }
                m_con.NotifyDataChanged(obj, false);
            }
            // Move System.
            else if( obj is PPathwaySystem && !m_isOwner)
            {
                // Set Object Position.
                if (!system.Rect.Contains(obj.Rect))
                {
                    // Set offset of this sistem.
                    obj.OffsetX = system.Left + PPathwaySystem.SYSTEM_MARGIN - obj.X;
                    obj.OffsetY = system.Top + PPathwaySystem.SYSTEM_MARGIN - obj.Y;
                    List<PPathwayObject> list = GetAllObjectUnder(newkey);
                    foreach (PPathwayObject child in list)
                    {
                        if (child is PPathwayText)
                            continue;
                        if (obj.X + obj.OffsetX < child.Right + PPathwaySystem.SYSTEM_MARGIN)
                            obj.OffsetX = child.Right + PPathwaySystem.SYSTEM_MARGIN - obj.X;
                    }

                    // move childs
                    foreach (PPathwayObject child in list)
                    {
                        child.OffsetX = obj.OffsetX;
                        child.OffsetY = obj.OffsetY;
                        if(child is PPathwayVariable)
                        {
                            foreach(PPathwayAlias alias in ((PPathwayVariable)child).Aliases)
                            {
                                alias.OffsetX = obj.OffsetX;
                                alias.OffsetY = obj.OffsetY;
                            }
                        }
                    }
                    // make space and move object.
                    MakeSpace(system, obj, true);
                    NotifyMoveSystem(obj);
                }
                else
                {
                    MakeSpace(system, obj, true);
                }
            }
        }
示例#8
0
 /// <summary>
 /// Set the system size.
 /// </summary>
 /// <param name="system">The system object.</param>
 private static void SetSystemSize(PPathwayObject system)
 {
     int length = 200 * (int)Math.Sqrt(system.EcellObject.Children.Count);
     if (length > PPathwaySystem.DEFAULT_WIDTH)
     {
         system.Width = length;
         system.Height = length;
     }
     else
     {
         system.Width = PPathwaySystem.DEFAULT_WIDTH;
         system.Height = PPathwaySystem.DEFAULT_HEIGHT;
     }
 }
示例#9
0
 /// <summary>
 /// Constructor
 /// </summary>
 public PPathwayProperties(PPathwayObject obj)
 {
     this.Pickable = false;
     this.Visible = false;
     SetObject(obj);
 }
示例#10
0
 /// <summary>
 /// Set Object
 /// </summary>
 /// <param name="obj"></param>
 private void SetObject(PPathwayObject obj)
 {
     // Reset
     this.RemoveAllChildren();
     this.m_properties.Clear();
     // Set Property
     if(obj is PPathwayProcess)
     {
         AddValue("Activity");
         AddValue("MolarActivity");
     }
     else if(obj is PPathwayVariable)
     {
         AddValue("Value");
         AddValue("MolarConc");
         AddValue("NumberConc");
     }
 }
示例#11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="obj"></param>
        public PathwayResizeHandler(PPathwayObject obj)
        {
            this.m_obj = obj;
            this.m_obj.VisibleChanged += new PPropertyEventHandler(Object_VisibleChanged);
            this.m_obj.HighLightChanged += new PPropertyEventHandler(Object_VisibleChanged);
            this.m_canvas = obj.Canvas;

            for (int i = 0; i < 8; i++)
            {
                ResizeHandle handle = new ResizeHandle();
                handle.MouseEnter += new PInputEventHandler(ResizeHandle_MouseEnter);
                handle.MouseLeave += new PInputEventHandler(ResizeHandle_MouseLeave);
                handle.MouseDown += new PInputEventHandler(ResizeHandle_MouseDown);
                handle.MouseDrag += new PInputEventHandler(ResizeHandle_MouseDrag);
                handle.MouseUp += new PInputEventHandler(ResizeHandle_MouseUp);
                handle.Cursor = GetCursor(i);
                handle.HandlePosition = i;
                m_resizeHandles.Add(handle);
            }
        }
示例#12
0
        /// <summary>
        /// 
        /// </summary>
        internal void RefreshStepperIcon()
        {
            if (m_canvas == null)
                return;

            // Create Stepper Icon
            if (_stepper == null)
            {
                _stepper = m_canvas.Control.ComponentManager.StepperSetting.CreateTemplate();
                _stepper.AddPath(_stepper.Figure.CreatePath(new RectangleF(0,0,10,10)), false);
                _stepper.Pickable = false;
            }
            EcellValue value = m_ecellObj.GetEcellValue(EcellProcess.STEPPERID);
            if(value == null)
                return;
            PPathwayStepper stepper = null;
            if(!m_canvas.Steppers.TryGetValue((string)value, out stepper))
                return;

            this.AddChild(_stepper);
            _stepper.Width = 10;
            _stepper.Height = 10;
            _stepper.X = this.Right - 10;
            _stepper.Y = this.Bottom - 10;
            _stepper.Setting = stepper.Setting;
            _stepper.MoveToFront();
        }
示例#13
0
 private void SetTemplate(ComponentSetting setting)
 {
     if (setting == null)
         return;
     RectangleF bounds = base.Camera.ViewBounds;
     PointF center = new PointF(bounds.X + bounds.Width / 2f, bounds.Y + bounds.Height / 2f);
     if (m_object != null)
         m_object.RemoveFromParent();
     m_object = setting.CreateTemplate();
     m_object.Pickable = false;
     m_object.Center = center;
     m_object.RefreshView();
     base.Layer.AddChild(m_object);
 }
 /// <summary>
 /// Get line color
 /// </summary>
 /// <param name="activity"></param>
 /// <param name="process"></param>
 /// <returns></returns>
 private Brush GetEntityBrush(double activity, PPathwayObject process)
 {
     if (double.IsNaN(activity) || double.IsInfinity(activity))
         return _ngEdgeBrush;
     else if (activity <= _thresholdLow)
         return _lowEdgeBrush;
     else if (activity >= _thresholdHigh)
         return _highEdgeBrush;
     return process.Setting.CreateBrush(process.Path);
 }
示例#15
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);
        }
示例#16
0
        /// <summary>
        /// NotifySetPosition
        /// </summary>
        /// <param name="obj"></param>
        public void NotifySetPosition(PPathwayObject obj)
        {
            PointF offset = obj.Offset;
            EcellObject eo = obj.EcellObject;
            eo.Layer = obj.Layer.Name;
            eo.X = obj.X + offset.X;
            eo.Y = obj.Y + offset.Y;
            eo.Width = obj.Width;
            eo.Height = obj.Height;
            eo.OffsetX = 0f;
            eo.OffsetY = 0f;

            NotifySetPosition(eo);
        }
示例#17
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 private static bool CheckMoved(PPathwayObject obj)
 {
     if (obj.Offset != PointF.Empty || obj.Changed)
     {
         return true;
     }
     else if (obj is PPathwayVariable)
     {
         foreach (PPathwayAlias alias in ((PPathwayVariable)obj).Aliases)
         {
             if (alias.Offset != PointF.Empty)
                 return true;
         }
     }
     return  false;
 }
示例#18
0
 /// <summary>
 /// Notify DataChanged event to outside (PathwayControl -> PathwayWindow -> DataManager)
 /// To notify position or size change.
 /// </summary>
 /// <param name="obj">x coordinate of object.</param>
 /// <param name="isAnchor">Whether this action is an anchor or not.</param>
 public void NotifyDataChanged(PPathwayObject obj, bool isAnchor)
 {
     if (obj is PPathwayAlias)
         obj = ((PPathwayAlias)obj).Variable;
     EcellObject eo = obj.EcellObject;
     NotifyDataChanged(eo.Key, eo.Key, obj, true, isAnchor);
 }
示例#19
0
        /// <summary>
        /// This method check object for Offset and the change of surrounding system.
        /// Returns true if changed.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        private bool CheckMoveErrorAndKeyChange(PPathwayObject obj)
        {
            string newKey = null;
            string newSysKey;
            bool isMoved = false;

            if (obj is PPathwaySystem)
            {
                string oldSysKey = obj.EcellObject.Key;
                newSysKey = GetSurroundingSystemKey(obj.PointF, oldSysKey);
                if (newSysKey == null)
                    newKey = Constants.delimiterPath;
                else if (newSysKey.Equals(Constants.delimiterPath))
                    newKey = Constants.delimiterPath + obj.EcellObject.LocalID;
                else
                    newKey = newSysKey + Constants.delimiterPath + obj.EcellObject.LocalID;

                // Reset system movement when the system is overlapping other system or out of root.
                if (!IsInsideRoot(obj.Rect))
                {
                    throw new PathwayException(MessageResources.ErrOutRoot);
                }
                else if (DoesSystemOverlaps((PPathwaySystem)obj))
                {
                    throw new PathwayException(MessageResources.ErrOverSystem);
                }
                // Reset if system is duplicated.
                else if (!oldSysKey.Equals(newKey) && m_systems.ContainsKey(newKey))
                {
                    throw new PathwayException(string.Format(
                        MessageResources.ErrAlrExist,
                        new object[] { newKey }));
                }
                obj.Invalid = false;
            }
            else if (obj is PPathwayEntity)
            {
                newSysKey = GetSurroundingSystemKey(obj.Center);
                // When node is out of root.
                if (newSysKey == null)
                {
                    throw new PathwayException(obj.EcellObject.LocalID + ":" + MessageResources.ErrOutRoot);
                }

                // When node is duplicated.
                newKey = newSysKey + ":" + obj.EcellObject.LocalID;
                if (!newSysKey.Equals(obj.EcellObject.ParentSystemID)
                    && GetObject(newKey, obj.EcellObject.Type) != null)
                {
                    throw new PathwayException(string.Format(
                        MessageResources.ErrAlrExist,
                        new object[] { obj.EcellObject.LocalID }));
                }

                if (obj is PPathwayVariable)
                {
                    foreach (PPathwayAlias alias in ((PPathwayVariable)obj).Aliases)
                    {
                        if(!DoesSystemContains(newSysKey, alias.Center))
                            throw new PathwayException(MessageResources.ErrOutSystemAlias);
                    }
                }
            }
            else
            {
                return false;
            }
            isMoved = !obj.EcellObject.Key.Equals(newKey);
            return (isMoved);
        }
示例#20
0
        /// <summary>
        /// Notify DataChanged event to outside (PathwayControl -> PathwayWindow -> DataManager)
        /// To notify position or size change.
        /// </summary>
        /// <param name="oldKey">the key before adding.</param>
        /// <param name="newKey">the key after adding.</param>
        /// <param name="obj">x coordinate of object.</param>
        /// <param name="isRecorded">Whether to record this change.</param>
        /// <param name="isAnchor">Whether this action is an anchor or not.</param>
        public void NotifyDataChanged(
            string oldKey,
            string newKey,
            PPathwayObject obj,
            bool isRecorded,
            bool isAnchor)
        {
            try
            {
                EcellObject eo = m_window.GetEcellObject(obj.EcellObject);
                eo.Key = newKey;

                PathUtil.SetLayout(eo, obj);
                Debug.WriteLine("Key:" + oldKey + ", x:" + obj.X.ToString() + ", y:" + obj.Y.ToString() + ", OffsetX:" + obj.OffsetX.ToString() + ", OffsetY:" + obj.OffsetY.ToString());
                Debug.WriteLine("Key:" + oldKey + ", x:" + eo.X.ToString() + ", y:" + eo.Y.ToString());

                if (eo is EcellVariable)
                    ResetAlias((EcellVariable)eo, (PPathwayVariable)obj);

                NotifyDataChanged(oldKey, eo, isRecorded, isAnchor);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                if (m_isAnimation)
                    m_animCon.SetAnimation();
                throw new PathwayException("Error DataChange: " + oldKey, e);
            }
        }
示例#21
0
        /// <summary>
        /// NotyfyMoveNode
        /// </summary>
        /// <param name="node"></param>
        private void NotifyMoveNode(PPathwayObject node)
        {
            string oldKey = node.EcellObject.Key;
            string newKey;
            //
            if (node is PPathwayText)
                newKey = node.EcellObject.Key;
            else
                newKey = GetSurroundingSystemKey(node.Center) + ":" + node.EcellObject.LocalID;

            //if (oldKey == newKey && node.OffsetX == 0.0 && node.OffsetY == 0.0)
            //    return;

            m_con.NotifyDataChanged(
                oldKey,
                newKey,
                node,
                true,
                false);
        }
示例#22
0
 /// <summary>
 /// Notify DataDelete event to outsite.
 /// </summary>
 /// <param name="obj">the deleted object.</param>
 /// <param name="isAnchor">the type of deleted object.</param>
 public void NotifyDataDelete(PPathwayObject obj, bool isAnchor)
 {
     try
     {
         if (obj is PPathwayAlias)
         {
             PPathwayAlias alias = (PPathwayAlias)obj;
             alias.Variable.Aliases.Remove(alias);
             alias.RemoveFromParent();
             foreach (PPathwayEdge edge in alias.Variable.Edges)
             {
                 edge.VIndex = -1;
             }
             NotifyDataChanged(alias.Variable, isAnchor);
         }
         else
         {
             NotifyDataDelete(obj.EcellObject, isAnchor);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
示例#23
0
 /// <summary>
 /// register the object to this set.
 /// </summary>
 /// <param name="obj">the registered object.</param>
 private void RegisterObject(PPathwayObject obj)
 {
     string key = obj.EcellObject.Key;
     PathwayException ex = new PathwayException(
         string.Format(MessageResources.ErrAlrExist, key));
     if (obj is PPathwaySystem)
     {
         if (m_systems.ContainsKey(key))
             throw ex;
         m_systems.Add(key, (PPathwaySystem)obj);
     }
     else if (obj is PPathwayVariable)
     {
         if (m_variables.ContainsKey(key))
             throw ex;
         m_variables.Add(key, (PPathwayVariable)obj);
     }
     else if (obj is PPathwayProcess)
     {
         if (m_processes.ContainsKey(key))
             throw ex;
         m_processes.Add(key, (PPathwayProcess)obj);
     }
     else if (obj is PPathwayText)
     {
         if (m_processes.ContainsKey(key))
             throw ex;
         m_texts.Add(key, (PPathwayText)obj);
     }
     else if (obj is PPathwayStepper)
     {
         if (m_steppers.ContainsKey(key))
             throw ex;
         m_steppers.Add(key, (PPathwayStepper)obj);
     }
 }
示例#24
0
 /// <summary>
 /// Notify SelectChanged event to outside.
 /// <param name="obj">the selected object.</param>
 /// </summary>
 public void NotifyRemoveSelect(PPathwayObject obj)
 {
     if (obj is PPathwayAlias)
     {
         m_selectedNodes.Remove(obj);
         obj.Selected = false;
     }
     if (obj.EcellObject == null)
         return;
     m_con.Window.NotifyRemoveSelect(
         this.m_modelId,
         obj.EcellObject.Key,
         obj.EcellObject.Type);
 }
示例#25
0
 /// <summary>
 /// Transfer the EcellObject from the old key to the new key.
 /// </summary>
 /// <param name="oldkey">The old key.</param>
 /// <param name="newkey">The new key.</param>
 /// <param name="obj">The transfered EcellObject.</param>
 private void UpdateDictionaryKey(string oldkey, string newkey, PPathwayObject obj)
 {
     // Change Path
     if (!(obj is PPathwayStepper))
     {
         PPathwaySystem system = m_systems[obj.EcellObject.ParentSystemID];
         obj.ParentObject = system;
     }
     if (obj is PPathwaySystem)
     {
         if (!m_systems.ContainsKey(oldkey))
             throw new PathwayException(string.Format(MessageResources.ErrNotFound, oldkey));
         m_systems.Remove(oldkey);
         m_systems.Add(newkey, (PPathwaySystem)obj);
         foreach (PPathwayObject child in GetAllObjectUnder(oldkey))
         {
             if (child.EcellObject.ParentSystemID != oldkey)
                 continue;
             string oldChildKey = child.EcellObject.Key;
             child.EcellObject.Key = Util.GetMovedKey(oldChildKey, oldkey, newkey);
             UpdateDictionaryKey(oldChildKey, child.EcellObject.Key, child);
         }
     }
     else if (obj is PPathwayVariable)
     {
         if (!m_variables.ContainsKey(oldkey))
             throw new PathwayException(string.Format(MessageResources.ErrNotFound, oldkey));
         m_variables.Remove(oldkey);
         m_variables.Add(newkey, (PPathwayVariable)obj);
     }
     else if (obj is PPathwayProcess)
     {
         if (!m_processes.ContainsKey(oldkey))
             throw new PathwayException(string.Format(MessageResources.ErrNotFound, oldkey));
         m_processes.Remove(oldkey);
         m_processes.Add(newkey, (PPathwayProcess)obj);
     }
     else if (obj is PPathwayText)
     {
         if (!m_texts.ContainsKey(oldkey))
             throw new PathwayException(string.Format(MessageResources.ErrNotFound, oldkey));
         m_texts.Remove(oldkey);
         m_texts.Add(newkey, (PPathwayText)obj);
     }
     else if (obj is PPathwayStepper)
     {
         if (!m_steppers.ContainsKey(oldkey))
             throw new PathwayException(string.Format(MessageResources.ErrNotFound, oldkey));
         m_steppers.Remove(oldkey);
         m_steppers.Add(newkey, (PPathwayStepper)obj);
     }
 }
示例#26
0
        /// <summary>
        /// Notify SelectChanged event to outside.
        /// <param name="obj">the selected object.</param>
        /// </summary>
        public void NotifySelectChanged(PPathwayObject obj)
        {
            if (obj is PPathwayAlias)
            {
                PPathwayAlias alias = (PPathwayAlias)obj;
                EcellAlias ea = new EcellAlias(m_modelId, alias.Variable.EcellObject.Key, "", "", new List<EcellData>());
                m_con.Window.NotifySelectChanged(
                    ea.ModelID,
                    ea.Key,
                    ea.Type);
                alias.Selected = true;
                m_selectedNodes.Add(alias);
                return;
            }

            if (obj.EcellObject == null)
                return;
            m_isOwner = true;
            m_con.Window.NotifySelectChanged(
                this.m_modelId,
                obj.EcellObject.Key,
                obj.EcellObject.Type);
        }
示例#27
0
 /// <summary>
 /// AddSelect PPathwayNode
 /// </summary>
 /// <param name="obj">Newly selected object</param>
 public void AddSelectedNode(PPathwayObject obj)
 {
     if (!m_selectedNodes.Contains(obj))
         m_selectedNodes.Add(obj);
     obj.Selected = true;
 }
示例#28
0
        /// <summary>
        /// Set Layer.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="layerID"></param>
        public void SetLayer(PPathwayObject obj, string layerID)
        {
            // if obj is root system or layerID is null.
            PPathwayLayer layer = m_defaultLayer;
            if (obj.Layer != null && obj.Layer.Name == layerID)
                return;

            if ( (obj.EcellObject != null && obj.EcellObject.Key.Equals(Constants.delimiterPath))
                 || string.IsNullOrEmpty(layerID) )
            {
                // Set default layer.
                obj.Layer = layer;
                return;
            }
            else if (m_layers.ContainsKey(layerID))
            {
                // Set new layer.
                layer = m_layers[layerID];
            }
            obj.Layer = layer;
        }
示例#29
0
        /// <summary>
        /// The event sequence on changing value of data at other plugin.
        /// </summary>
        /// <param name="oldKey">The ID before value change.</param>
        /// <param name="newKey">The data type before value change.</param>
        /// <param name="obj">Changed value of object.</param>
        public void DataChanged(string oldKey, string newKey, PPathwayObject obj)
        {
            if (!oldKey.Equals(newKey))
            {
                UpdateDictionaryKey(oldKey, newKey, obj);
                if( !m_con.Window.IsLoading)
                    MoveObject(oldKey, newKey, obj);
                RefreshEdges();
            }
            // Set Layer
            SetLayer(obj, obj.EcellObject.Layer);
            // Set visibility
            obj.RefreshView();

            // If this obj is root system, Refresh OverView.
            if (newKey.Equals(Constants.delimiterPath))
            {
                RefreshOverView();
                SetStepperPosition();
            }
            if (obj is PPathwayStepper)
                SetStepperPosition();
        }
示例#30
0
 /// <summary>
 /// Set PathwayLayout to EcellObject. 
 /// </summary>
 /// <param name="eo"></param>
 /// <param name="obj"></param>
 public static void SetLayout(EcellObject eo, PPathwayObject obj)
 {
     if (obj is PPathwayEntity)
     {
         eo.CenterPointF = obj.Center;
     }
     else
     {
         eo.X = obj.X + obj.OffsetX;
         eo.Y = obj.Y + obj.OffsetY;
         eo.Width = obj.Width;
         eo.Height = obj.Height;
     }
     eo.Layer = obj.Layer.Name;
     eo.OffsetX = 0f;
     eo.OffsetY = 0f;
     eo.IsLayouted = false;
     eo.Layout.Figure = obj.Setting.Name;
 }