예제 #1
0
        /// <summary>
        /// Runs when the entire object graph has been deserialized.
        /// </summary>
        /// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
        public void OnDeserialization(object sender)
        {
            if (Tracing.BinaryDeserializationSwitch.Enabled)
            {
                Trace.WriteLine("IDeserializationCallback of 'Model' called.");
            }
            Init();
            #region Binding of connectors

            Dictionary <Guid, Anchor> .Enumerator enumer = Anchors.GetEnumerator();
            System.Collections.Generic.KeyValuePair <Guid, Anchor> pair;
            Anchor anchor;
            while (enumer.MoveNext())
            {
                pair   = enumer.Current;
                anchor = pair.Value;
                if (anchor.Parent != Guid.Empty) //there's a parent connector
                {
                    if (Anchors.ContainsKey(anchor.Parent))
                    {
                        Anchors.GetAnchor(anchor.Parent).Instance.AttachConnector(anchor.Instance);
                    }
                }
            }
            //clean up the anchoring matrix
            Anchors.Clear();
            #endregion
        }
예제 #2
0
        // ------------------------------------------------------------------
        /// <summary>
        /// Unwraps the specified collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        // ------------------------------------------------------------------
        public void Unwrap(CollectionBase <IDiagramEntity> collection)
        {
            if (collection == null)
            {
                return;
            }
            foreach (IDiagramEntity entity in collection)
            {
                Unwrap(entity);
            }
            //reconnect the connectors, just like the deserialization of a filed diagram
            Dictionary <Guid, Anchor> .Enumerator enumer = Anchors.GetEnumerator();
            System.Collections.Generic.KeyValuePair <Guid, Anchor> pair;
            Anchor anchor;

            while (enumer.MoveNext())
            {
                pair   = enumer.Current;
                anchor = pair.Value;
                if (anchor.Parent != Guid.Empty) //there's a parent connector
                {
                    if (Anchors.ContainsKey(anchor.Parent))
                    {
                        Anchors.GetAnchor(anchor.Parent).Instance.AttachConnector(anchor.Instance);
                    }
                }
            }
            //clean up the anchoring matrix
            Anchors.Clear();
        }