Exemplo n.º 1
0
        private static EdgeMapData GetEdge(EdgeViewModelBase uiEdge)
        {
            EdgeMapData objEdge = new EdgeMapData(uiEdge.ParentEdge.Source.ID, uiEdge.ParentEdge.Target.ID);

            // Properties
            objEdge.Type = uiEdge.ParentEdge.Type;
            objEdge.IsLabelTextUnderlined = uiEdge.EdgeLine.LabelTextUnderline;
            objEdge.Thickness             = uiEdge.Thickness;
            objEdge.Color = ((SolidColorBrush)uiEdge.Color).Color;
            objEdge.LabelBackgroundColor = ((SolidColorBrush)uiEdge.LabelBackgroundColor).Color;
            objEdge.LabelForegroundColor = ((SolidColorBrush)uiEdge.LabelForegroundColor).Color;
            objEdge.LabelFontStyle       = uiEdge.LabelFontStyle;
            objEdge.LabelFontWeight      = uiEdge.LabelFontWeight;
            objEdge.LabelFont            = uiEdge.LabelFont;

            if (uiEdge.ParentEdge.GetType().Equals(typeof(DataEdge)))
            {
                DataEdge dataEdge = (DataEdge)uiEdge.ParentEdge;
                objEdge.Label = dataEdge.DisplayValue;

                // Attributes
                foreach (KeyValuePair <string, AttributeValue> uiDataEdgeAttrKVP in dataEdge.Attributes)
                {
                    //Attributes.Attribute uiEdgeAttribute = GlobalAttributeCollection.GetInstance(scope).GetAttribute(uiDataEdgeAttrKVP.Key);

                    AttributeMapData objEdgeAttribute = new AttributeMapData(uiDataEdgeAttrKVP.Key, uiDataEdgeAttrKVP.Value.Value);
                    objEdge.Attributes.Add(objEdgeAttribute.Name, objEdgeAttribute);

                    //objEdgeAttribute.SemanticType = uiEdgeAttribute.SemanticType;
                    //objEdgeAttribute.SimilarityMeasure = uiEdgeAttribute.PreferredSimilarityMeasure;
                    //objEdgeAttribute.IsHidden = !uiEdgeAttribute.Visible;
                }
            }

            return(objEdge);
        }
Exemplo n.º 2
0
        private static EdgeMapData GetEdge(EdgeViewModelBase uiEdge)
        {
            EdgeMapData objEdge = new EdgeMapData(uiEdge.ParentEdge.Source.ID, uiEdge.ParentEdge.Target.ID);

            // Properties
            objEdge.Type = uiEdge.ParentEdge.Type;
            objEdge.IsLabelTextUnderlined = uiEdge.EdgeLine.LabelTextUnderline;
            objEdge.Thickness = uiEdge.Thickness;
            objEdge.Color = ((SolidColorBrush)uiEdge.Color).Color;
            objEdge.LabelBackgroundColor = ((SolidColorBrush)uiEdge.LabelBackgroundColor).Color;
            objEdge.LabelForegroundColor = ((SolidColorBrush)uiEdge.LabelForegroundColor).Color;
            objEdge.LabelFontStyle = uiEdge.LabelFontStyle;
            objEdge.LabelFontWeight = uiEdge.LabelFontWeight;
            objEdge.LabelFont = uiEdge.LabelFont;

            if (uiEdge.ParentEdge.GetType().Equals(typeof(DataEdge)))
            {
                DataEdge dataEdge = (DataEdge)uiEdge.ParentEdge;
                objEdge.Label = dataEdge.DisplayValue;

                // Attributes
                foreach (KeyValuePair<string, AttributeValue> uiDataEdgeAttrKVP in dataEdge.Attributes)
                {
                    //Attributes.Attribute uiEdgeAttribute = GlobalAttributeCollection.GetInstance(scope).GetAttribute(uiDataEdgeAttrKVP.Key);

                    AttributeMapData objEdgeAttribute = new AttributeMapData(uiDataEdgeAttrKVP.Key, uiDataEdgeAttrKVP.Value.Value);
                    objEdge.Attributes.Add(objEdgeAttribute.Name, objEdgeAttribute);

                    //objEdgeAttribute.SemanticType = uiEdgeAttribute.SemanticType;
                    //objEdgeAttribute.SimilarityMeasure = uiEdgeAttribute.PreferredSimilarityMeasure;
                    //objEdgeAttribute.IsHidden = !uiEdgeAttribute.Visible;
                }
            }

            return objEdge;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the specificed edge
        /// </summary>
        /// <param name="graphComponents">The Graph that data is being imported into</param>
        /// <param name="creationType">The specified CreationType</param>
        /// <param name="objEdge">Edge to be added</param>
        public static void AddEdge(GraphComponents graphComponents, CreationType creationType, EdgeMapData objEdge)
        {
            INode uiSourceNode = graphComponents.Data.GetNode(objEdge.Source);

            if (uiSourceNode == null && creationType == CreationType.Imported)
            {
                throw new Exception("Missing Source Node");
            }
            else if (uiSourceNode == null)// && creationType == CreationType.Live
            {
                uiSourceNode = new GhostNode(objEdge.Source);
            }

            INode uiTargetNode = graphComponents.Data.GetNode(objEdge.Target);

            if (uiTargetNode == null && creationType == CreationType.Imported)
            {
                throw new Exception("Missing Target Node");
            }
            else if (uiTargetNode == null)// && creationType == CreationType.Live
            {
                uiTargetNode = new GhostNode(objEdge.Target);
            }

            if (string.IsNullOrEmpty(objEdge.Label) && objEdge.Attributes.Count == 0)
            {
                Berico.SnagL.Model.Edge uiEdge = new Berico.SnagL.Model.Edge(uiSourceNode, uiTargetNode);
                uiEdge.SourceMechanism = creationType;

                // Properties
                uiEdge.Type = objEdge.Type;

                // the EdgeViewModel must be created after uiEdge has had a Type specified
                IEdgeViewModel uiEdgeVM = EdgeViewModelBase.GetEdgeViewModel(uiEdge, graphComponents.Scope);
                graphComponents.AddEdgeViewModel(uiEdgeVM);
            }
            else
            {
                DataEdge uiEdge = new DataEdge(uiSourceNode, uiTargetNode);
                uiEdge.SourceMechanism = creationType;

                // Properties
                uiEdge.Type         = objEdge.Type;
                uiEdge.DisplayValue = objEdge.Label;

                // the EdgeViewModel must be created after uiEdge has had a Type specified
                IEdgeViewModel uiEdgeVM = EdgeViewModelBase.GetEdgeViewModel(uiEdge, graphComponents.Scope);
                graphComponents.AddEdgeViewModel(uiEdgeVM);

                uiEdgeVM.Thickness     = objEdge.Thickness;
                uiEdgeVM.Color         = new SolidColorBrush(objEdge.Color);
                uiEdgeVM.EdgeLine.Text = objEdge.Label;
                uiEdgeVM.EdgeLine.LabelTextUnderline   = objEdge.IsLabelTextUnderlined;
                uiEdgeVM.EdgeLine.LabelBackgroundColor = new SolidColorBrush(objEdge.LabelBackgroundColor);
                uiEdgeVM.EdgeLine.LabelForegroundColor = new SolidColorBrush(objEdge.LabelForegroundColor);
                uiEdgeVM.EdgeLine.LabelFontStyle       = objEdge.LabelFontStyle;
                uiEdgeVM.EdgeLine.LabelFontWeight      = objEdge.LabelFontWeight;
                if (objEdge.LabelFont != null)
                {
                    uiEdgeVM.EdgeLine.LabelFont = objEdge.LabelFont;
                }

                // Attributes
                foreach (KeyValuePair <string, AttributeMapData> objEdgeAttrKVP in objEdge.Attributes)
                {
                    Attributes.Attribute uiEdgeAttribute      = new Attributes.Attribute(objEdgeAttrKVP.Value.Name);
                    AttributeValue       uiEdgeAttributeValue = new AttributeValue(objEdgeAttrKVP.Value.Value);

                    uiEdge.Attributes.Add(uiEdgeAttribute.Name, uiEdgeAttributeValue);
                    //GlobalAttributeCollection.GetInstance(graphComponents.Scope).Add(uiEdgeAttribute, uiEdgeAttributeValue);

                    uiEdgeAttribute.SemanticType = objEdgeAttrKVP.Value.SemanticType;
                    uiEdgeAttribute.PreferredSimilarityMeasure = objEdgeAttrKVP.Value.SimilarityMeasure;
                    uiEdgeAttribute.Visible = !objEdgeAttrKVP.Value.IsHidden;
                }
            }
        }