Example #1
0
        public void CopyIdAndStatus(GraphicMetaBase source)
        {
            if (this == source)
            {
                return;
            }
            base.CloneFrom(source);
            foreach (LineMeta line in Lines)
            {
                LineMeta lineMeta = null;
                try
                {
                    lineMeta          = source.Lines.First <LineMeta>(c => c.FromId == line.FromId && c.FromType == line.FromType && c.ToId == line.ToId && c.ToType == line.ToType);
                    line.Associate_ID = lineMeta.Associate_ID;
                    line.State        = lineMeta.State;
                }
                catch
                { }
            }

            foreach (NodeMeta node in Nodes)
            {
                NodeMeta nodemeta = null;
                try
                {
                    nodemeta   = source.Nodes.First <NodeMeta>(c => c.SId == node.SId && c.DataType == node.DataType);
                    node.State = nodemeta.State;
                }
                catch
                { }
            }
        }
Example #2
0
        public LineMeta AddLine(int fromID, ObjectType fromType, int toID, ObjectType toType, string assoc)
        {
            LineMeta line = new LineMeta()
            {
                LineMode      = LineMode.Antrorse,
                LineColor     = Color.FromArgb(255, 0, 0, 0),
                StrokePattern = StrokePattern.Solid,
                ReadOnly      = true
            };
            // GetNoteMeta(LinkData) to initial
            NodeMeta node = GetNoteMetaByInnerId(fromID, fromType);

            if (node != null)
            {
                line.FromId   = node.SId;
                line.FromType = node.DataType;
                line.From     = node;
            }

            //
            // GetNodeMeta(LinkData) to end
            node = GetNoteMetaByInnerId(toID, toType);
            if (node != null)
            {
                line.ToType = node.DataType;
                line.ToId   = node.SId;
                line.To     = node;
            }

            //
            // Appoint the associate for the new Line(Mete)
            line.Association = assoc;
            //
            // Push the new Line(Meta) into the Line collection Lines
            Lines.Add(line);
            return(line);
        }
Example #3
0
        //Properties
        //public List<NodeMeta> Data { get; set; }

        //protected NodeMeta GetMetaData(NodeMeta nm)
        //{
        //    return Data.FirstOrDefault((c) => { return c.DataType == nm.DataType && c.SId == nm.SId; });
        //}

        //public override bool AddObject(NodeMeta data)
        //{
        //    if (null == data) return false;
        //    _BindTag = false;
        //    bool result = false;
        //    result = Data.IndexOf(data) < 0;
        //    if (result)
        //        Data.Add(data);
        //    return result;
        //}

        //public List<NodeMeta> GetAllMetaData()
        //{
        //    return new List<NodeMeta>(Data);
        //}
        /// <summary>
        /// ?need some desirable detail for the method
        /// </summary>
        /// <param name="meta"></param>
        public void MegerGraphic(GraphicMeta meta)
        {
            if (subject_id == 0)
            {
                subject_id   = meta.subject_id;
                subject_type = meta.subject_type;
                title        = meta.title;
                Version      = meta.Version;
                base.note    = meta.note;
            }

            //foreach (NodeMeta node in meta.Nodes)
            for (int index = meta.Nodes.Count - 1; index >= 0; index--)
            {
                NodeMeta node      = meta.Nodes[index];
                NodeMeta existNode = GetNoteMetaByInnerId(node.SId, node.DataType);
                if (existNode == null)
                {
                    node.State = MetaState.New;
                    Nodes.Add(node);
                    //AddObject(meta.GetMetaData(node));
                }
                else
                {
                    node.Left = existNode.Left;
                    node.Top  = existNode.Top;
                    meta.Nodes.RemoveAt(index);
                }
            }

            //
            //The line collection whose elements are copied to the new list named copyLines.
            //
            List <LineMeta> copyLines = new List <LineMeta>(Lines);

            //foreach (LineMeta line in meta.Lines)
            for (int index = meta.Lines.Count - 1; index >= 0; index--)
            {
                LineMeta line       = meta.Lines[index];
                bool     lineExists = false;
                foreach (LineMeta l in copyLines)
                {
                    if ((l.FromId == line.FromId && l.FromType == line.FromType &&
                         l.ToId == line.ToId && l.ToType == line.ToType) ||
                        (l.FromId == line.ToId && l.FromType == line.ToType &&
                         l.ToId == line.FromId && l.ToType == line.FromType)
                        )
                    {
                        lineExists = true;
                        break;
                    }
                }
                if (!lineExists)
                {
                    line.State = MetaState.New;
                    Lines.Add(line);
                }
                else
                {
                    meta.Lines.RemoveAt(index);
                }
            }
        }