Example #1
0
 protected bool ContainsKey(INodeProxy node)
 {
     if (node.HasMetadata(Key) && node.GetNodeMetadata(Key) != null)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
 protected bool ContainsKey(INodeProxy node)
 {
     if (node.HasMetadata(Key) && node.GetNodeMetadata(Key) != null)
     {
         return true;
     }
     return false;
 }
Example #3
0
        /// <summary>
        /// Compares if the nodes metadata value is ==, !=, >, >=, <, <=, to the value passed as a parameter.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="value">The string representaion of a TimeSpan</param>
        /// <returns></returns>
        public override bool HasMatch(INodeProxy node)
        {
            bool result = false;
            if (!ContainsKey(node))
            {
                return false;
            }

            TimeSpan metaValue = TimeSpan.MinValue;
            TimeSpan compareValue = TimeSpan.MinValue;
            if (TimeSpan.TryParse(node.GetNodeMetadata(Key).MetadataValue, out metaValue) && TimeSpan.TryParse(Value, out compareValue))
            {
                switch (Operator)
                {
                    case MetadataFilterOperator.EQUAL:
                        if (metaValue.Equals(compareValue))
                        {
                            result = true;
                        }
                        break;
                    case MetadataFilterOperator.NOT_EQUAL:
                        if (!metaValue.Equals(compareValue))
                        {
                            result = true;
                        }
                        break;
                    case MetadataFilterOperator.GREATER_THAN:
                        if (metaValue > compareValue)
                        {
                            result = true;
                        }
                        break;
                    case MetadataFilterOperator.GREATER_THAN_OR_EQUAL:
                        if (metaValue >= compareValue)
                        {
                            result = true;
                        }
                        break;
                    case MetadataFilterOperator.LESS_THAN:
                        if (metaValue < compareValue)
                        {
                            result = true;
                        }
                        break;
                    case MetadataFilterOperator.LESS_THAN_OR_EQUAL:
                        if (metaValue <= compareValue)
                        {
                            result = true;
                        }
                        break;
                    default:
                        result = false;
                        break;
                }
            }
            return result;
        }
Example #4
0
 public VideoSizeHelper(INodeProxy nodeProxy)
 {
     MetadataContext videoSizeKey = new MetadataContext() { MetadataName = "Video.Size", NodeUid = nodeProxy.Id };
     string videoSize = null;
     if (nodeProxy.HasMetadata(videoSizeKey))
     {
         videoSize = nodeProxy.GetNodeMetadata(videoSizeKey).MetadataValue;
     }
     Size = ParseVideoSize(videoSize);
 }
Example #5
0
        public VideoSizeHelper(INodeProxy nodeProxy)
        {
            MetadataContext videoSizeKey = new MetadataContext()
            {
                MetadataName = "Video.Size", NodeUid = nodeProxy.Id
            };
            string videoSize = null;

            if (nodeProxy.HasMetadata(videoSizeKey))
            {
                videoSize = nodeProxy.GetNodeMetadata(videoSizeKey).MetadataValue;
            }
            Size = ParseVideoSize(videoSize);
        }
 public void ShowNodePropertiesDialog(INodeProxy node)
 {
     NodePropertiesDialog npd = new NodePropertiesDialog();
     npd.DataContext = node;
     MetadataContext noteKey = new MetadataContext()
     {
         NodeUid = node.Id,
         MetadataName = "Note"
     };
     if (node.HasMetadata(noteKey))
     {
         npd.Note = node.GetNodeMetadata(noteKey).MetadataValue;
     }
     npd.Closed += new EventHandler(NodePropertiesDialog_Close);
     npd.Show();
 }
        public void ShowNodePropertiesDialog(INodeProxy node)
        {
            NodePropertiesDialog npd = new NodePropertiesDialog();

            npd.DataContext = node;
            MetadataContext noteKey = new MetadataContext()
            {
                NodeUid      = node.Id,
                MetadataName = "Note"
            };

            if (node.HasMetadata(noteKey))
            {
                npd.Note = node.GetNodeMetadata(noteKey).MetadataValue;
            }
            npd.Closed += new EventHandler(NodePropertiesDialog_Close);
            npd.Show();
        }
Example #8
0
        public override bool HasMatch(INodeProxy node)
        {
            bool result = false;

            if (!ContainsKey(node))
            {
                return(false);
            }

            double metaValue    = double.NaN;
            double compareValue = double.NaN;

            if (Double.TryParse(node.GetNodeMetadata(Key).MetadataValue, out metaValue) && Double.TryParse(Value, out compareValue))
            {
                switch (Operator)
                {
                case MetadataFilterOperator.EQUAL:
                    if (metaValue.Equals(compareValue))
                    {
                        result = true;
                    }
                    break;

                case MetadataFilterOperator.NOT_EQUAL:
                    if (!metaValue.Equals(compareValue))
                    {
                        result = true;
                    }
                    break;

                case MetadataFilterOperator.GREATER_THAN:
                    if (metaValue > compareValue)
                    {
                        result = true;
                    }
                    break;

                case MetadataFilterOperator.GREATER_THAN_OR_EQUAL:
                    if (metaValue >= compareValue)
                    {
                        result = true;
                    }
                    break;

                case MetadataFilterOperator.LESS_THAN:
                    if (metaValue < compareValue)
                    {
                        result = true;
                    }
                    break;

                case MetadataFilterOperator.LESS_THAN_OR_EQUAL:
                    if (metaValue <= compareValue)
                    {
                        result = true;
                    }
                    break;

                default:
                    result = false;
                    break;
                }
            }
            return(result);
        }
        private void OnConnectNodesCompleted(object sender, ConnectNodesCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                List <INodeProxy> nodes = new List <INodeProxy>();

                ConnectedNodesResult connectResult = e.Result;

                foreach (SoapNode soapNode in connectResult.Nodes.Values)
                {
                    if (_cachedNodes.ContainsKey(soapNode.Id))
                    {
                        _cachedNodes.Remove(soapNode.Id);
                    }

                    NodeProxy node = new NodeProxy(soapNode);
                    _cachedNodes.Add(soapNode.Id, node);
                    nodes.Add(node);
                }

                foreach (INodeProxy nodeProxy in nodes)
                {
                    foreach (IDescriptorProxy descriptorProxy in nodeProxy.Descriptors)
                    {
                        CompleteRelationship(descriptorProxy.Relationship);
                    }
                }

                ConnectedNodesEventArgs connectedNodesEventArgs = new ConnectedNodesEventArgs();
                connectedNodesEventArgs.Nodes        = nodes.ToArray();
                connectedNodesEventArgs.Relationship = new RelationshipProxy(e.Result.Relationship);

                CompleteRelationship(connectedNodesEventArgs.Relationship);

                //When a node is connected via a MapContainerRelationship the UserState will be the location of the new node
                //on the map, it can't be stored in the db until the relationship exists since it's the contectual relationship
                //that determines where it is located in it's view in this map (it may be elsewhere in transclusions)
                if (e.UserState != null)
                {
                    INodeProxy nodeProxy = connectedNodesEventArgs.Nodes[1];
                    Point      location  = (Point)e.UserState;
                    if (location != null)
                    {
                        TypeManager          typeManager    = IoC.IoCContainer.GetInjectionInstance().GetInstance <TypeManager>();
                        IDescriptorTypeProxy descriptorType = null;
                        if (e.Result.Relationship.RelationshipType.Name == "TransclusionRelationship")
                        {
                            descriptorType = typeManager.GetDescriptorType("TransclusionMap");
                        }
                        else
                        {
                            descriptorType = typeManager.GetDescriptorType("From");
                        }

                        MetadataContext xPositionKey = new MetadataContext()
                        {
                            NodeUid           = nodeProxy.Id,
                            RelationshipUid   = e.Result.Relationship.Id,
                            DescriptorTypeUid = descriptorType.Id,
                            MetadataName      = "XPosition"
                        };
                        MetadataContext yPositionKey = new MetadataContext()
                        {
                            NodeUid           = nodeProxy.Id,
                            RelationshipUid   = e.Result.Relationship.Id,
                            DescriptorTypeUid = descriptorType.Id,
                            MetadataName      = "YPosition"
                        };

                        if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(xPositionKey) != null)
                        {
                            nodeProxy.GetNodeMetadata(xPositionKey).MetadataValue = location.X.ToString();
                        }
                        else
                        {
                            MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy;
                            if (metaDataTypeProxy != null)
                            {
                                SoapMetadata soapMetadata = new SoapMetadata();
                                soapMetadata.MetadataName  = "XPosition";
                                soapMetadata.MetadataType  = metaDataTypeProxy.BaseSoapNodeType;
                                soapMetadata.MetadataValue = location.X.ToString();
                                nodeProxy.Metadata.Add(xPositionKey, soapMetadata);
                            }
                        }

                        if (nodeProxy.Metadata != null && nodeProxy.GetNodeMetadata(yPositionKey) != null)
                        {
                            nodeProxy.GetNodeMetadata(yPositionKey).MetadataValue = location.Y.ToString();
                        }
                        else
                        {
                            MetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double") as MetadataTypeProxy;
                            if (metaDataTypeProxy != null)
                            {
                                SoapMetadata soapMetadata = new SoapMetadata();
                                soapMetadata.MetadataName  = "YPosition";
                                soapMetadata.MetadataType  = metaDataTypeProxy.BaseSoapNodeType;
                                soapMetadata.MetadataValue = location.Y.ToString();
                                nodeProxy.Metadata.Add(yPositionKey, soapMetadata);
                            }
                        }
                    }
                }

                if (ConnectNodesCompleted != null)
                {
                    ConnectNodesCompleted.Invoke(this, connectedNodesEventArgs);
                }
            }
        }
Example #10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.isTemplateApplied) return;

            this.nodeProxy = DataContext as INodeProxy;
            if (nodeProxy == null) 
            {
                throw new Exception("The DataContext was not a valid NodeProxy");
            }

            this.imagePart = GetTemplateChild(NodeControl.ImagePartName) as Rectangle;
            if (this.imagePart != null)
            {
                this.imagePart.SetValue(Canvas.LeftProperty, 0.0);
                this.imagePart.SetValue(Canvas.TopProperty, 0.0);
                ImageBrush nodeImageBrush = this.imagePart.Fill as ImageBrush;
                if (nodeImageBrush != null)
                {
                    nodeImageBrush.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(nodeImageBrush_ImageFailed);
                }
            }

            this.playMediaImagePart = GetTemplateChild(NodeControl.PlayMediaImagePartName) as Rectangle;
            if (this.playMediaImagePart != null)
            {
                this.playMediaImagePart.MouseLeftButtonDown += new MouseButtonEventHandler(playMediaImagePart_MouseLeftButtonUp);
                MetadataContext videoSourceKey = new MetadataContext()
                {
                    MetadataName = "Video.Source",
                    NodeUid = nodeProxy.Id
                };
                if (nodeProxy.HasMetadata(videoSourceKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
                {
                    this.playMediaImagePart.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.playMediaImagePart.Visibility = System.Windows.Visibility.Collapsed;
                }
                ImageBrush brush = playMediaImagePart.Fill as ImageBrush;
                if (brush != null)
                {
                    brush.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(brush_ImageFailed);
                }
            }
            this.pauseMediaImagePart = GetTemplateChild(NodeControl.PauseMediaImagePartName) as Rectangle;
            if (this.pauseMediaImagePart != null)
            {
                this.pauseMediaImagePart.MouseLeftButtonDown += new MouseButtonEventHandler(pauseMediaImagePart_MouseLeftButtonUp);
                this.pauseMediaImagePart.Visibility = System.Windows.Visibility.Collapsed;
                ImageBrush brush = pauseMediaImagePart.Fill as ImageBrush;
                if (brush != null)
                {
                    brush.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(brush_ImageFailed);
                }
            }


            this.textBlockPart = GetTemplateChild(NodeControl.TextBlockPartName) as TextBlock;
            this.textBlockBorderPart = GetTemplateChild(NodeControl.TextBlockBorderName) as Border;
            this.textBoxPart = GetTemplateChild(NodeControl.TextBoxPartName) as TextBox;
            this.transCntTextBlockPart = GetTemplateChild(NodeControl.TranscludionsCountTextBlockPartName) as TextBlock;
            this.childCntTextBlockPart = GetTemplateChild(NodeControl.ChildCountTextBlockPartName) as TextBlock;
            this.noteTextBlockPart = GetTemplateChild(NodeControl.NoteTextBlockPartName) as TextBlock;

            Rect textLocation = GetTextLocation();
            if (this.textBlockBorderPart != null)
            {
                this.textBlockBorderPart.SetValue(Canvas.LeftProperty, textLocation.X);
                this.textBlockBorderPart.SetValue(Canvas.TopProperty, textLocation.Y);
                this.textBlockBorderPart.Width = textLocation.Width;
                this.textBlockBorderPart.Height = textLocation.Height;
            }
            if (this.textBlockPart != null)
            {
                this.textBlockPart.Width = textLocation.Width;
                this.textBlockPart.Height = textLocation.Height;
                if (this.textBlockBorderPart != null)
                {
                    if (textLocation.Height < this.textBlockPart.ActualHeight)
                    {
                        this.textBlockBorderPart.Height = this.textBlockPart.ActualHeight;
                        this.textBlockPart.Height = this.textBlockPart.ActualHeight;
                    }
                    else
                    {
                        if (this.textBlockPart.ActualHeight > 10)
                        {
                            this.textBlockBorderPart.Height = this.textBlockPart.ActualHeight;
                            this.textBlockPart.Height = this.textBlockPart.ActualHeight;
                        }
                    }
                }
                this.textBlockHeight = this.textBlockPart.ActualHeight;
                this.textBlockWidth = this.textBlockPart.ActualWidth;
                this.textBlockPart.MouseLeftButtonDown += new MouseButtonEventHandler(OnNodeTextBlockMouseLeftButtonDown);
            }

            if (this.textBoxPart != null)
            {
                this.textBoxPart.SetValue(Canvas.LeftProperty, textLocation.X);
                this.textBoxPart.SetValue(Canvas.TopProperty, textLocation.Y);
                this.textBoxPart.Width = textLocation.Width + 5;
                this.textBoxPart.Height = textLocation.Height + 5;
                this.textBoxPart.KeyDown += new KeyEventHandler(TextBoxPart_KeyDown);
            }

            if (this.transCntTextBlockPart != null)
            {
                if (this.transCntTextBlockPart.Text == "1")
                {
                    this.transCntTextBlockPart.Visibility = Visibility.Collapsed;
                }
                else
                {
                    this.transCntTextBlockPart.Visibility = Visibility.Visible;
                }
            }

            if (this.childCntTextBlockPart != null)
            {
                if (nodeProxy.NodeType.Name == "CompendiumMapNode")
                {
                    this.childCntTextBlockPart.Visibility = Visibility.Visible;
                    this.childCntTextBlockPart.Text = GetMapNodeChildCount(nodeProxy);
                }
                else
                {
                    this.childCntTextBlockPart.Visibility = Visibility.Collapsed;
                }
            }

            if (this.noteTextBlockPart != null)
            {
                MetadataContext noteKey = new MetadataContext() 
                {
                    MetadataName = "Note",
                    NodeUid = nodeProxy.Id
                };
                if (nodeProxy.HasMetadata(noteKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(noteKey).MetadataValue))
                {
                    this.noteTextBlockPart.Visibility = Visibility.Visible;
                    ToolTipService.SetToolTip(this.noteTextBlockPart, nodeProxy.GetNodeMetadata(noteKey).MetadataValue);
                }
                else
                {
                    this.noteTextBlockPart.Visibility = Visibility.Collapsed;
                }
            }

            BitmapImage nodeImg = new BitmapImage();
            //for optimal memory usage and speed only create as many ImageBrush objects as there are images.
            if (ImageUrl != null)
            {
                if (!nodeImageCache.ContainsKey(ImageUrl))
                {
                    nodeImg.UriSource = new Uri(ImageUrl);

                    ImageBrush imageBrush = new ImageBrush();
                    imageBrush.ImageSource = nodeImg;

                    NodeImage = imageBrush;
                    nodeImageCache.Add(ImageUrl, imageBrush);
                }
                else
                {
                    NodeImage = nodeImageCache[ImageUrl];
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(NodeImageName))
                {
                    
                    switch (NodeImageName)
                    {
                        case "Map":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/network.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Pro":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/plus.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Con":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/minus.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Decision":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Idea":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/exclamation.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        case "Question":
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/question.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                        default:
                            nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                            NodeImage = new ImageBrush() { ImageSource = nodeImg };
                            break;
                    }
                }
            }

            this.okButtonPart = GetTemplateChild(NodeControl.OkButtonPartName) as Button;
            this.cancelButtonPart = GetTemplateChild(NodeControl.CancelButtonPartName) as Button;

            if (this.textBlockBorderPart != null 
                && this.okButtonPart != null && this.cancelButtonPart != null)
            {
                double left = (double)textBlockBorderPart.GetValue(Canvas.LeftProperty);
                double top = (double)textBlockBorderPart.GetValue(Canvas.TopProperty);

                this.okButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 100);
                this.okButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.okButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxOkClick);

                this.cancelButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 50);
                this.cancelButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.cancelButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxCancelClick);
            }

            if (InEditState)
            {
                GoToState(NodeControl.EdittingStateName, false);
                if (this.textBoxPart != null)
                {
                    this.textBoxPart.Focus();
                }
            }
            else
            {
                this.GoToState(NodeControl.NormalStateName, false);
            }

            this.isTemplateApplied = true;
        }
Example #11
0
        public void RefreshMetadata(INodeProxy node)
        {
            nodeProxy.Metadata = node.Metadata;
            DataContext        = nodeProxy;

            if (nodeProxy != null && isTemplateApplied)
            {
                if (transCntTextBlockPart != null)
                {
                    if (this.transCntTextBlockPart.Text == "1")
                    {
                        this.transCntTextBlockPart.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        this.transCntTextBlockPart.Visibility = Visibility.Visible;
                    }
                }
                if (this.childCntTextBlockPart != null)
                {
                    if (nodeProxy.NodeType.Name == "CompendiumMapNode")
                    {
                        this.childCntTextBlockPart.Visibility = Visibility.Visible;
                        this.childCntTextBlockPart.Text       = GetMapNodeChildCount(nodeProxy);
                    }
                    else
                    {
                        this.childCntTextBlockPart.Visibility = Visibility.Collapsed;
                    }
                }
                if (noteTextBlockPart != null)
                {
                    MetadataContext noteKey = new MetadataContext()
                    {
                        MetadataName = "Note",
                        NodeUid      = nodeProxy.Id
                    };
                    if (nodeProxy.HasMetadata(noteKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(noteKey).MetadataValue))
                    {
                        string note = nodeProxy.GetNodeMetadata(noteKey).MetadataValue;
                        if (!string.IsNullOrEmpty(note))
                        {
                            this.noteTextBlockPart.Visibility = Visibility.Visible;
                            ToolTipService.SetToolTip(this.noteTextBlockPart, note);
                        }
                        else
                        {
                            this.noteTextBlockPart.Visibility = Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        this.noteTextBlockPart.Visibility = Visibility.Collapsed;
                    }
                }

                if (playMediaImagePart != null && pauseMediaImagePart != null)
                {
                    MetadataContext videoSourceKey = new MetadataContext()
                    {
                        MetadataName = "Video.Source",
                        NodeUid      = nodeProxy.Id
                    };
                    if (nodeProxy.HasMetadata(videoSourceKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
                    {
                        this.playMediaImagePart.Visibility = System.Windows.Visibility.Visible;
                    }
                    else
                    {
                        this.playMediaImagePart.Visibility  = System.Windows.Visibility.Collapsed;
                        this.pauseMediaImagePart.Visibility = System.Windows.Visibility.Collapsed;
                    }
                }
            }
        }
Example #12
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (this.isTemplateApplied)
            {
                return;
            }

            this.nodeProxy = DataContext as INodeProxy;
            if (nodeProxy == null)
            {
                throw new Exception("The DataContext was not a valid NodeProxy");
            }

            this.imagePart = GetTemplateChild(NodeControl.ImagePartName) as Rectangle;
            if (this.imagePart != null)
            {
                this.imagePart.SetValue(Canvas.LeftProperty, 0.0);
                this.imagePart.SetValue(Canvas.TopProperty, 0.0);
                ImageBrush nodeImageBrush = this.imagePart.Fill as ImageBrush;
                if (nodeImageBrush != null)
                {
                    nodeImageBrush.ImageFailed += new EventHandler <ExceptionRoutedEventArgs>(nodeImageBrush_ImageFailed);
                }
            }

            this.playMediaImagePart = GetTemplateChild(NodeControl.PlayMediaImagePartName) as Rectangle;
            if (this.playMediaImagePart != null)
            {
                this.playMediaImagePart.MouseLeftButtonDown += new MouseButtonEventHandler(playMediaImagePart_MouseLeftButtonUp);
                MetadataContext videoSourceKey = new MetadataContext()
                {
                    MetadataName = "Video.Source",
                    NodeUid      = nodeProxy.Id
                };
                if (nodeProxy.HasMetadata(videoSourceKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
                {
                    this.playMediaImagePart.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.playMediaImagePart.Visibility = System.Windows.Visibility.Collapsed;
                }
                ImageBrush brush = playMediaImagePart.Fill as ImageBrush;
                if (brush != null)
                {
                    brush.ImageFailed += new EventHandler <ExceptionRoutedEventArgs>(brush_ImageFailed);
                }
            }
            this.pauseMediaImagePart = GetTemplateChild(NodeControl.PauseMediaImagePartName) as Rectangle;
            if (this.pauseMediaImagePart != null)
            {
                this.pauseMediaImagePart.MouseLeftButtonDown += new MouseButtonEventHandler(pauseMediaImagePart_MouseLeftButtonUp);
                this.pauseMediaImagePart.Visibility           = System.Windows.Visibility.Collapsed;
                ImageBrush brush = pauseMediaImagePart.Fill as ImageBrush;
                if (brush != null)
                {
                    brush.ImageFailed += new EventHandler <ExceptionRoutedEventArgs>(brush_ImageFailed);
                }
            }


            this.textBlockPart         = GetTemplateChild(NodeControl.TextBlockPartName) as TextBlock;
            this.textBlockBorderPart   = GetTemplateChild(NodeControl.TextBlockBorderName) as Border;
            this.textBoxPart           = GetTemplateChild(NodeControl.TextBoxPartName) as TextBox;
            this.transCntTextBlockPart = GetTemplateChild(NodeControl.TranscludionsCountTextBlockPartName) as TextBlock;
            this.childCntTextBlockPart = GetTemplateChild(NodeControl.ChildCountTextBlockPartName) as TextBlock;
            this.noteTextBlockPart     = GetTemplateChild(NodeControl.NoteTextBlockPartName) as TextBlock;

            Rect textLocation = GetTextLocation();

            if (this.textBlockBorderPart != null)
            {
                this.textBlockBorderPart.SetValue(Canvas.LeftProperty, textLocation.X);
                this.textBlockBorderPart.SetValue(Canvas.TopProperty, textLocation.Y);
                this.textBlockBorderPart.Width  = textLocation.Width;
                this.textBlockBorderPart.Height = textLocation.Height;
            }
            if (this.textBlockPart != null)
            {
                this.textBlockPart.Width  = textLocation.Width;
                this.textBlockPart.Height = textLocation.Height;
                if (this.textBlockBorderPart != null)
                {
                    if (textLocation.Height < this.textBlockPart.ActualHeight)
                    {
                        this.textBlockBorderPart.Height = this.textBlockPart.ActualHeight;
                        this.textBlockPart.Height       = this.textBlockPart.ActualHeight;
                    }
                    else
                    {
                        if (this.textBlockPart.ActualHeight > 10)
                        {
                            this.textBlockBorderPart.Height = this.textBlockPart.ActualHeight;
                            this.textBlockPart.Height       = this.textBlockPart.ActualHeight;
                        }
                    }
                }
                this.textBlockHeight = this.textBlockPart.ActualHeight;
                this.textBlockWidth  = this.textBlockPart.ActualWidth;
                this.textBlockPart.MouseLeftButtonDown += new MouseButtonEventHandler(OnNodeTextBlockMouseLeftButtonDown);
            }

            if (this.textBoxPart != null)
            {
                this.textBoxPart.SetValue(Canvas.LeftProperty, textLocation.X);
                this.textBoxPart.SetValue(Canvas.TopProperty, textLocation.Y);
                this.textBoxPart.Width    = textLocation.Width + 5;
                this.textBoxPart.Height   = textLocation.Height + 5;
                this.textBoxPart.KeyDown += new KeyEventHandler(TextBoxPart_KeyDown);
            }

            if (this.transCntTextBlockPart != null)
            {
                if (this.transCntTextBlockPart.Text == "1")
                {
                    this.transCntTextBlockPart.Visibility = Visibility.Collapsed;
                }
                else
                {
                    this.transCntTextBlockPart.Visibility = Visibility.Visible;
                }
            }

            if (this.childCntTextBlockPart != null)
            {
                if (nodeProxy.NodeType.Name == "CompendiumMapNode")
                {
                    this.childCntTextBlockPart.Visibility = Visibility.Visible;
                    this.childCntTextBlockPart.Text       = GetMapNodeChildCount(nodeProxy);
                }
                else
                {
                    this.childCntTextBlockPart.Visibility = Visibility.Collapsed;
                }
            }

            if (this.noteTextBlockPart != null)
            {
                MetadataContext noteKey = new MetadataContext()
                {
                    MetadataName = "Note",
                    NodeUid      = nodeProxy.Id
                };
                if (nodeProxy.HasMetadata(noteKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(noteKey).MetadataValue))
                {
                    this.noteTextBlockPart.Visibility = Visibility.Visible;
                    ToolTipService.SetToolTip(this.noteTextBlockPart, nodeProxy.GetNodeMetadata(noteKey).MetadataValue);
                }
                else
                {
                    this.noteTextBlockPart.Visibility = Visibility.Collapsed;
                }
            }

            BitmapImage nodeImg = new BitmapImage();

            //for optimal memory usage and speed only create as many ImageBrush objects as there are images.
            if (ImageUrl != null)
            {
                if (!nodeImageCache.ContainsKey(ImageUrl))
                {
                    nodeImg.UriSource = new Uri(ImageUrl);

                    ImageBrush imageBrush = new ImageBrush();
                    imageBrush.ImageSource = nodeImg;

                    NodeImage = imageBrush;
                    nodeImageCache.Add(ImageUrl, imageBrush);
                }
                else
                {
                    NodeImage = nodeImageCache[ImageUrl];
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(NodeImageName))
                {
                    switch (NodeImageName)
                    {
                    case "Map":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/network.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    case "Pro":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/plus.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    case "Con":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/minus.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    case "Decision":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    case "Idea":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/exclamation.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    case "Question":
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/question.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;

                    default:
                        nodeImg.UriSource = new Uri("/SilverlightMappingToolBasic;component/Images/generic.png", UriKind.Relative);
                        NodeImage         = new ImageBrush()
                        {
                            ImageSource = nodeImg
                        };
                        break;
                    }
                }
            }

            this.okButtonPart     = GetTemplateChild(NodeControl.OkButtonPartName) as Button;
            this.cancelButtonPart = GetTemplateChild(NodeControl.CancelButtonPartName) as Button;

            if (this.textBlockBorderPart != null &&
                this.okButtonPart != null && this.cancelButtonPart != null)
            {
                double left = (double)textBlockBorderPart.GetValue(Canvas.LeftProperty);
                double top  = (double)textBlockBorderPart.GetValue(Canvas.TopProperty);

                this.okButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 100);
                this.okButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.okButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxOkClick);

                this.cancelButtonPart.SetValue(Canvas.LeftProperty, left + this.textBoxPart.Width - 50);
                this.cancelButtonPart.SetValue(Canvas.TopProperty, top + this.textBoxPart.Height);
                this.cancelButtonPart.Click += new RoutedEventHandler(OnNodeTextBoxCancelClick);
            }

            if (InEditState)
            {
                GoToState(NodeControl.EdittingStateName, false);
                if (this.textBoxPart != null)
                {
                    this.textBoxPart.Focus();
                }
            }
            else
            {
                this.GoToState(NodeControl.NormalStateName, false);
            }

            this.isTemplateApplied = true;
        }
Example #13
0
        public override bool HasMatch(INodeProxy node)
        {
            bool result = false;
            string metaValue;
            if (!ContainsKey(node))
            {
                if (string.IsNullOrEmpty(Value))
                {
                    //if the metadata doesn't exist and the compare value is null or string.Empty
                    //set the values to both be string.Empty and allow the operator to work it out
                    metaValue = string.Empty;
                    Value = string.Empty;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                metaValue = node.GetNodeMetadata(Key).MetadataValue;
            }

            switch (Operator)
            {
                case MetadataFilterOperator.EQUAL:
                    if (metaValue == Value)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.NOT_EQUAL:
                    if (metaValue != Value)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.GREATER_THAN:
                    if (metaValue.CompareTo(Value) > 0)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.GREATER_THAN_OR_EQUAL:
                    if (metaValue.CompareTo(Value) == 0)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.LESS_THAN:
                    if (metaValue.CompareTo(Value) < 0)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.LESS_THAN_OR_EQUAL:
                    if (metaValue.CompareTo(Value) == 0)
                    {
                        result = true;
                    }
                    break;
                case MetadataFilterOperator.CONTAINS:
                    if (metaValue.IndexOf(Value, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        result = true;
                    }
                    break;
                default:
                    result = false;
                    break;
            }
            return result;
        }
Example #14
0
        public override bool HasMatch(INodeProxy node)
        {
            bool   result = false;
            string metaValue;

            if (!ContainsKey(node))
            {
                if (string.IsNullOrEmpty(Value))
                {
                    //if the metadata doesn't exist and the compare value is null or string.Empty
                    //set the values to both be string.Empty and allow the operator to work it out
                    metaValue = string.Empty;
                    Value     = string.Empty;
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                metaValue = node.GetNodeMetadata(Key).MetadataValue;
            }

            switch (Operator)
            {
            case MetadataFilterOperator.EQUAL:
                if (metaValue == Value)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.NOT_EQUAL:
                if (metaValue != Value)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.GREATER_THAN:
                if (metaValue.CompareTo(Value) > 0)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.GREATER_THAN_OR_EQUAL:
                if (metaValue.CompareTo(Value) == 0)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.LESS_THAN:
                if (metaValue.CompareTo(Value) < 0)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.LESS_THAN_OR_EQUAL:
                if (metaValue.CompareTo(Value) == 0)
                {
                    result = true;
                }
                break;

            case MetadataFilterOperator.CONTAINS:
                if (metaValue.IndexOf(Value, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    result = true;
                }
                break;

            default:
                result = false;
                break;
            }
            return(result);
        }