Example #1
0
 public byte[] ExportMetadata(PostedDataDto postedData)
 {
     using (MetadataContext context = new MetadataContext(metadataConfiguration.GetAbsolutePath(postedData.guid), postedData.password))
     {
         return(context.ExportProperties());
     }
 }
        public MetadataContext BuildContext(MetadataGenerateRequest metadataGenerateContext)
        {
            var entityDescriptorConfiguration = MetadataHelper.BuildEntityDesriptorConfiguration(this._includeOrganisationPredicate(metadataGenerateContext));

            var keyDescriptorConfiguration = MetadataHelper.BuildKeyDescriptorConfiguration();

            RoleDescriptorConfiguration descriptorConfigurtion;

            switch (metadataGenerateContext.MetadataType)
            {
            case MetadataType.SP:
                descriptorConfigurtion = MetadataHelper.BuildSPSSODescriptorConfiguration();
                break;

            case MetadataType.Idp:
                descriptorConfigurtion = MetadataHelper.BuildIdPSSODescriptorConfiguration();
                break;

            default:
                throw new System.Exception(string.Format("Unkown metadata type: {0}.", metadataGenerateContext.MetadataType));
            }

            entityDescriptorConfiguration.RoleDescriptors.Add(descriptorConfigurtion);

            var context = new MetadataContext
            {
                EntityDesriptorConfiguration = entityDescriptorConfiguration,
                SignMetadata = true
            };

            context.MetadataSigningContext = new MetadataSigningContext(SecurityAlgorithms.RsaSha1Signature, SecurityAlgorithms.Sha1Digest);

            context.MetadataSigningContext.KeyDescriptors.Add(keyDescriptorConfiguration.First(x => x.IsDefault && x.Use == KeyUsage.Signing));
            return(context);
        }
Example #3
0
 public bool ResetMediaIcon(TimeSpan newPosition)
 {
     if (_nodeControl.IsPlayingMedia)
     {
         string          endPosition;
         MetadataContext videoEndPosKey = new MetadataContext()
         {
             MetadataName = "Video.EndPosition", NodeUid = Node.Id
         };
         if (Node.HasMetadata(videoEndPosKey))
         {
             TimeSpan endPositionTs = TimeSpan.MinValue;
             endPosition = Node.GetNodeMetadata(videoEndPosKey).MetadataValue;
             if (TimeSpan.TryParse(endPosition, out endPositionTs))
             {
                 if (newPosition > endPositionTs)
                 {
                     _nodeControl.ResetMediaIcon();
                     _nodeControl.IsPlayingMedia = false;
                 }
             }
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 public MetadataViewModel(MetadataContext context, SoapMetadata metadata)
 {
     if (context == null)
     {
         throw new ArgumentException("The metadata context was null.", "context");
     }
     if (metadata == null)
     {
         throw new ArgumentException("The metadata was null.", "metadata");
     }
     if (context.MetadataName != metadata.MetadataName)
     {
         throw new ArgumentException("The MetadataContext.MetadataName did not match the SoapMetadata.MetadataName, the context was not for this metadata.");
     }
     this._metadataName = context.MetadataName;
     this._originalMetadataName = context.MetadataName;
     if (context.NodeUid.HasValue)
     {
         this._nodeUid = context.NodeUid.Value;
     }
     if (context.RelationshipUid.HasValue)
     {
         this._relationshipUid = context.RelationshipUid.Value;
     }
     if (context.DescriptorTypeUid.HasValue)
     {
         this._descriptorTypeUid = context.DescriptorTypeUid.Value;
     }
     this._metadataTypeUid = metadata.MetadataType.Id;
     this._metadataValue = metadata.MetadataValue;
 }
Example #5
0
        public void HelloWorld()
        {
            // declare
            // namespace MyApp.HelloWorld {
            var ns = NamespaceSignature.Parse("MyApp.HelloWorld");
            // public class Program {
            var programType = TypeSignature.Class("Program", ns, Accessibility.APublic);
            // public static int Main() {
            var mainMethod = MethodSignature.Static("Main", programType, Accessibility.APublic, returnType: TypeSignature.Int32);

            // get the Console.WriteLine reference
            var writeLineRef = MethodReference.FromLambda(() => Console.WriteLine(""));

            var body = new [] {
                Expression.StaticMethodCall(writeLineRef, Expression.Constant("Hello world!"))
            }.ToBlock(
                result: Expression.Constant(0)
                );

            var type = TypeDef.Empty(programType).AddMember(
                MethodDef.Create(mainMethod, body)
                );

            var cx = MetadataContext.Create();

            cx.AddType(type);
            var csharp = cx.EmitToString();

            check.CheckString(csharp, fileExtension: "cs");
        }
Example #6
0
        public static void Translate(
            CodeTextStorage storage,
            DispatchArgs dispatchArgs,
            string assemblyPath)
        {
            System.Console.WriteLine("AOTCompiler: Preparing assembly: \"{0}\" ...", Path.GetFullPath(assemblyPath));

            var metaContext                = new MetadataContext(assemblyPath, dispatchArgs.readSymbols);
            var translateContext           = new TranslateContext(assemblyPath, dispatchArgs.readSymbols, metaContext);
            CXXTranslateOptions cxxOptions = new CXXTranslateOptions();

            cxxOptions.StaticAssertOnUnimplementatedILs = dispatchArgs.cxxStaticAssertOnUnimplementatedILs;
            var cxxTranslator = new CXXTranslator(translateContext, cxxOptions);

            //using (var _ = storage.EnterScope("meta"))
            //{
            //    MetadataSerializer metaSerializer = new MetadataSerializer(translateContext);
            //    metaSerializer.WriteResult(storage);
            //}

            using (var _ = storage.EnterScope("include"))
            {
                cxxTranslator.WriteHeader(storage);
            }
            using (var _ = storage.EnterScope("src"))
            {
                cxxTranslator.WriteSource(storage);
            }

            System.Console.WriteLine(" done.");
        }
Example #7
0
 public MetadataViewModel(MetadataContext context, SoapMetadata metadata)
 {
     if (context == null)
     {
         throw new ArgumentException("The metadata context was null.", "context");
     }
     if (metadata == null)
     {
         throw new ArgumentException("The metadata was null.", "metadata");
     }
     if (context.MetadataName != metadata.MetadataName)
     {
         throw new ArgumentException("The MetadataContext.MetadataName did not match the SoapMetadata.MetadataName, the context was not for this metadata.");
     }
     this._metadataName         = context.MetadataName;
     this._originalMetadataName = context.MetadataName;
     if (context.NodeUid.HasValue)
     {
         this._nodeUid = context.NodeUid.Value;
     }
     if (context.RelationshipUid.HasValue)
     {
         this._relationshipUid = context.RelationshipUid.Value;
     }
     if (context.DescriptorTypeUid.HasValue)
     {
         this._descriptorTypeUid = context.DescriptorTypeUid.Value;
     }
     this._metadataTypeUid = metadata.MetadataType.Id;
     this._metadataValue   = metadata.MetadataValue;
 }
        private bool IsEqualToOriginal(MetadataViewModel metadata)
        {
            bool result = false;

            foreach (KeyValuePair <MetadataContext, MetadataViewModel> pair in _original)
            {
                MetadataContext   context = pair.Key;
                MetadataViewModel model   = pair.Value;
                if (context.NodeUid.Value == metadata.NodeUid && model.MetadataName == metadata.OriginalMetadataName)
                {
                    if (context.DescriptorTypeUid.HasValue && context.DescriptorTypeUid.Value != metadata.DescriptorTypeUid)
                    {
                        continue;
                    }
                    if (context.RelationshipUid.HasValue && context.RelationshipUid.Value != metadata.RelationshipUid)
                    {
                        continue;
                    }

                    //the context is the same so compare the items
                    if (model.Equals(metadata))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(result);
        }
        public TranslateContext(string assemblyPath, bool readSymbols)
        {
            var context = new MetadataContext(assemblyPath, readSymbols);

            this.FocusedAssembly = context.FocusedAssembly;
            this.MetadataContext = context;
        }
Example #10
0
        Task IMetadataGenerator.CreateMetadata(MetadataContext metadataContext)
        {
            try
            {
                var configuration = metadataContext.EntityDesriptorConfiguration;

                var descriptors = this.GetDescriptors(configuration.SPSSODescriptors);

                var entityDescriptor = BuildEntityDesciptor(configuration, descriptors);
                this.SignMetadata(metadataContext, entityDescriptor);
                var sb = new StringBuilder();

                using (var xmlWriter = XmlWriter.Create(sb))
                {
                    this._serialiser.Serialise(xmlWriter, entityDescriptor);
                }

                var metadata = new XmlDocument();
                metadata.LoadXml(sb.ToString());

                this._federationMetadataWriter.Write(metadata.DocumentElement);
                return(Task.CompletedTask);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #11
0
    public static FrameworkEntry Index(string frameworkName, IEnumerable <string> assemblyPaths)
    {
        var references = new List <MetadataReference>();

        foreach (var path in assemblyPaths)
        {
            var metadata = MetadataReference.CreateFromFile(path);
            references.Add(metadata);
        }

        var metadataContext = MetadataContext.Create(references);

        var assemblyEntries = new List <AssemblyEntry>();

        foreach (var assembly in metadataContext.Assemblies)
        {
            var entry = AssemblyEntry.Create(assembly);
            if (entry.Apis.Any())
            {
                assemblyEntries.Add(entry);
            }
        }

        return(FrameworkEntry.Create(frameworkName, assemblyEntries));
    }
Example #12
0
        private void _nodeControl_PlayMediaIconClicked(object sender, RoutedEventArgs e)
        {
            MetadataContext videoSourceKey = new MetadataContext()
            {
                MetadataName = "Video.Source", NodeUid = Node.Id
            };
            string source = Node.GetNodeMetadata(videoSourceKey).MetadataValue;

            VideoSizeHelper sizeHelper = new VideoSizeHelper(Node);

            RelatedContentPanelUtil.Instance.LoadRelatedVideoContent(source, sizeHelper.Size);

            string  startPosition = null;
            string  endPosition   = null;
            Command playCommand   = new Command();

            playCommand.Name   = "Play";
            playCommand.Params = new List <Param>();
            playCommand.Params.Add(new Param()
            {
                Name = "Source", Value = source
            });
            playCommand.Params.Add(new Param()
            {
                Name = "NodeId", Value = Node.Id.ToString()
            });
            playCommand.Params.Add(new Param()
            {
                Name = "AutoPlay", Value = "true"
            });
            MetadataContext videoStartPosKey = new MetadataContext()
            {
                MetadataName = "Video.StartPosition", NodeUid = Node.Id
            };

            if (Node.HasMetadata(videoStartPosKey))
            {
                startPosition = Node.GetNodeMetadata(videoStartPosKey).MetadataValue;
                playCommand.Params.Add(new Param()
                {
                    Name = "StartTimeCode", Value = startPosition
                });
            }
            MetadataContext videoEndPosKey = new MetadataContext()
            {
                MetadataName = "Video.EndPosition", NodeUid = Node.Id
            };

            if (Node.HasMetadata(videoEndPosKey))
            {
                endPosition = Node.GetNodeMetadata(videoEndPosKey).MetadataValue;
                playCommand.Params.Add(new Param()
                {
                    Name = "EndTimeCode", Value = endPosition
                });
            }
            LocalMessageSender msgSender = IoC.IoCContainer.GetInjectionInstance().GetInstance <LocalMessageSender>();
            //Utilities.SendMessage<Command>(msgSender, playCommand);
        }
Example #13
0
 public byte[] ExportMetadata(PostedDataDto postedData)
 {
     using (var inputStream = fileService.GetFileStream(postedData.guid))
         using (MetadataContext context = new MetadataContext(inputStream, postedData.password))
         {
             return(context.ExportProperties());
         }
 }
Example #14
0
        static Expression ExampleCondition(MetadataContext cx)
        {
            var thread        = TypeSignature.FromType(typeof(System.Threading.Thread)).NotGeneric();
            var currentThread = cx.GetMemberProperty(thread, "CurrentThread").Getter();
            var isBackground  = cx.GetMemberProperty(((TypeReference.SpecializedTypeCase)currentThread.ResultType()).Item, "IsBackground").Getter();
            var condition     = Expression.MethodCall(isBackground, ImmutableArray <Expression> .Empty, Expression.MethodCall(currentThread, ImmutableArray <Expression> .Empty, null));

            return(condition);
        }
Example #15
0
 private void UpdateMetadata(PostedDataDto postedData, Action <MetadataContext> updateMethod)
 {
     using (var inputStream = fileService.GetFileStream(postedData.guid, false))
         using (MetadataContext context = new MetadataContext(inputStream, postedData.password))
         {
             updateMethod(context);
             context.Save();
         }
 }
Example #16
0
        private void playVideoMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MetadataContext videoSourceKey = new MetadataContext()
            {
                MetadataName = "Video.Source",
                NodeUid      = NodeProxy.Id
            };
            string source = NodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue;

            VideoSizeHelper sizeHelper = new VideoSizeHelper(NodeProxy);

            RelatedContentPanelUtil.Instance.LoadRelatedVideoContent(source, sizeHelper.Size);

            string  startPosition = null;
            string  endPosition   = null;
            Command playCommand   = new Command();

            playCommand.Name   = "Play";
            playCommand.Params = new List <Param>();
            playCommand.Params.Add(new Param()
            {
                Name = "Source", Value = source
            });
            MetadataContext videoStartKey = new MetadataContext()
            {
                MetadataName = "Video.StartPosition",
                NodeUid      = NodeProxy.Id
            };

            if (NodeProxy.HasMetadata(videoStartKey))
            {
                startPosition = NodeProxy.GetNodeMetadata(videoStartKey).MetadataValue;
                playCommand.Params.Add(new Param()
                {
                    Name = "StartTimeCode", Value = startPosition
                });
            }
            MetadataContext videoEndKey = new MetadataContext()
            {
                MetadataName = "Video.EndPosition",
                NodeUid      = NodeProxy.Id
            };

            if (NodeProxy.HasMetadata(videoEndKey))
            {
                endPosition = NodeProxy.GetNodeMetadata(videoEndKey).MetadataValue;
                playCommand.Params.Add(new Param()
                {
                    Name = "EndTimeCode", Value = endPosition
                });
            }
            playCommand.Params.Add(new Param()
            {
                Name = "NodeId", Value = NodeProxy.Id.ToString()
            });
            //Utilities.SendMessage<Command>(MessageSender, playCommand);
        }
Example #17
0
        public void MetadataContext()
        {
            MetadataContext metadataContext = new MetadataContext();

            ExpectArgumentNull("type", delegate { metadataContext.FindMethod(null, NQuery.Identifier.CreateNonVerbatim("Test")); });
            ExpectArgumentNull("identifier", delegate { metadataContext.FindMethod(typeof(int), null); });
            ExpectArgumentNull("type", delegate { metadataContext.FindProperty((Type)null, NQuery.Identifier.CreateNonVerbatim("Test")); });
            ExpectArgumentNull("identifier", delegate { metadataContext.FindProperty(typeof(int), null); });
            ExpectArgumentNull("properties", delegate { metadataContext.FindProperty((PropertyBinding[])null, NQuery.Identifier.CreateNonVerbatim("Test")); });
        }
Example #18
0
        public void DeleteNodeMetadata(MetadataContext key)
        {
            if (HasMetadata(key))
            {
                INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance <INodeService>();
                nodeService.DeleteMetadata(key);

                RemoveMetadata(key); //assumes the service call works for speed of updating the data cached
            }
        }
Example #19
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 #20
0
		public static ResultIterator Convert(MetadataContext metadataContext, bool includeStatistics, ResultAlgebraNode resultAlgebraNode)
		{
			IteratorCreator iteratorCreator = new IteratorCreator(metadataContext, includeStatistics);
			Iterator iterator = iteratorCreator.ConvertAlgebraNode(resultAlgebraNode);

			ILEmitContext.CompleteILCompilation();

			if (includeStatistics)
				return (ResultIterator) ((StatisticsIterator) iterator).Input;

			return (ResultIterator) iterator;
		}
Example #21
0
        public void CleanMetadata(PostedDataDto postedData)
        {
            string filePath     = metadataConfiguration.GetAbsolutePath(postedData.guid);
            var    tempFilePath = GetTempPath(filePath);

            using (MetadataContext context = new MetadataContext(filePath, postedData.password))
            {
                context.Sanitize();
                context.Save(tempFilePath);
            }
            DirectoryUtils.MoveFile(tempFilePath, filePath);
        }
Example #22
0
    public ItemMetadata Get(int id)
    {
        if (Cache.TryGet(id, out ItemMetadata item))
        {
            return(item);
        }

        using var context = new MetadataContext(Options);
        item = context.ItemMetadata.Find(id);
        Cache.AddReplace(id, item);

        return(item);
    }
Example #23
0
        public void SetPlayingMediaIcon()
        {
            MetadataContext videoSourceKey = new MetadataContext()
            {
                MetadataName = "Video.Source",
                NodeUid      = nodeProxy.Id
            };

            if (nodeProxy.HasMetadata(videoSourceKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
            {
                GoToState(NodeControl.PlayingStateName, false);
            }
        }
Example #24
0
        public IEnumerable <ExtractedPackageDto> GetPackages(PostedDataDto postedData)
        {
            using (var inputStream = fileService.GetFileStream(postedData.guid))
                using (MetadataContext context = new MetadataContext(inputStream, postedData.password))
                {
                    var packages = new List <ExtractedPackageDto>();
                    foreach (var package in context.GetPackages())
                    {
                        List <PropertyDto>      properties  = new List <PropertyDto>();
                        List <KnownPropertyDto> descriptors = new List <KnownPropertyDto>();

                        foreach (var property in package.Properties)
                        {
                            properties.Add(new PropertyDto
                            {
                                name  = property.Name,
                                value = property.Value is Array ? ArrayUtil.AsString((Array)property.Value) : property.Value,
                                type  = (int)property.Type,
                            });
                        }

                        foreach (var descriptor in package.Descriptors)
                        {
                            var accessLevel = descriptor.AccessLevel;
                            if (arrayTypes.Contains(descriptor.Type))
                            {
                                accessLevel &= AccessLevels.Remove;
                            }

                            descriptors.Add(new KnownPropertyDto
                            {
                                name        = descriptor.Name,
                                type        = (int)descriptor.Type,
                                accessLevel = (int)accessLevel
                            });
                        }

                        packages.Add(new ExtractedPackageDto
                        {
                            id              = package.Id,
                            name            = package.Name,
                            index           = package.Index,
                            type            = (int)package.Type,
                            properties      = properties,
                            knownProperties = descriptors,
                        });
                    }
                    return(packages);
                }
        }
Example #25
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 #26
0
        public static ResultIterator Convert(MetadataContext metadataContext, bool includeStatistics, ResultAlgebraNode resultAlgebraNode)
        {
            IteratorCreator iteratorCreator = new IteratorCreator(metadataContext, includeStatistics);
            Iterator        iterator        = iteratorCreator.ConvertAlgebraNode(resultAlgebraNode);

            ILEmitContext.CompleteILCompilation();

            if (includeStatistics)
            {
                return((ResultIterator)((StatisticsIterator)iterator).Input);
            }

            return((ResultIterator)iterator);
        }
Example #27
0
        public static void AddTestExpr(this MetadataContext cx, Expression expr, params ParameterExpression[] parameters)
        {
            var typeCount = cx.DefinedTypes.Count;
            var name      = typeCount < 15 ? ((char)('C' + typeCount)).ToString() : "C" + typeCount;
            var ns        = ((TypeOrNamespace.NamespaceSignatureCase)cx.DefinedTypes.FirstOrDefault()?.Signature.Parent)?.Item ??
                            new NamespaceSignature("NS", NamespaceSignature.Global);
            var type      = TypeSignature.Class(name, ns, Accessibility.APublic);
            var method    = new MethodSignature(type, parameters.Select(p => new MethodParameter(p.Type, p.Name)).ToImmutableArray(), "M", expr.Type(), true, Accessibility.APublic, false, false, false, false, ImmutableArray <GenericParameter> .Empty);
            var methodDef = new MethodDef(method, parameters.ToImmutableArray(), expr);
            var typeDef   = TypeDef.Empty(type).With(members: ImmutableArray.Create <MemberDef>(methodDef));

            cx.AddType(typeDef);
            cx.CommitWaitingTypes();
        }
        private bool GetNodeLocation(MetadataContext xPosKey, MetadataContext yPosKey, out double x, out double y)
        {
            x = 0.0;
            y = 0.0;

            if (Node.Metadata != null && Node.HasMetadata(xPosKey) && Node.HasMetadata(yPosKey))
            {
                double.TryParse(Node.GetNodeMetadata(xPosKey).MetadataValue, out x);
                double.TryParse(Node.GetNodeMetadata(yPosKey).MetadataValue, out y);

                return true;
            }

            return false;
        }
Example #29
0
        public void RemoveProperties(PostedDataDto postedData)
        {
            string filePath     = metadataConfiguration.GetAbsolutePath(postedData.guid);
            var    tempFilePath = GetTempPath(filePath);

            using (MetadataContext context = new MetadataContext(filePath, postedData.password))
            {
                foreach (var packageInfo in postedData.packages)
                {
                    context.RemoveProperties(packageInfo.id, packageInfo.properties.Select(p => p.name));
                }
                context.Save(tempFilePath);
            }
            DirectoryUtils.MoveFile(tempFilePath, filePath);
        }
Example #30
0
        static Expression MakeExampleBreak(MetadataContext cx, LabelTarget label)
        {
            var call      = ExampleMethodCall(cx);
            var condition = ExampleCondition(cx);

            var ifBlock = Expression.IfThen(
                condition,
                Expression.Break(Expression.Nop, label));

            return(Expression.Block(ImmutableArray.Create <Expression>(
                                        call,
                                        ifBlock,
                                        call
                                        ), Expression.Nop));
        }
        private bool GetNodeLocation(MetadataContext xPosKey, MetadataContext yPosKey, out double x, out double y)
        {
            x = 0.0;
            y = 0.0;

            if (Node.Metadata != null && Node.HasMetadata(xPosKey) && Node.HasMetadata(yPosKey))
            {
                double.TryParse(Node.GetNodeMetadata(xPosKey).MetadataValue, out x);
                double.TryParse(Node.GetNodeMetadata(yPosKey).MetadataValue, out y);

                return(true);
            }

            return(false);
        }
 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 #33
0
        public MetadataContext GetContext()
        {
            MetadataContext context = new MetadataContext();

            context.NodeUid      = this.NodeUid;
            context.MetadataName = this.OriginalMetadataName;
            if (this.DescriptorTypeUid != Guid.Empty)
            {
                context.DescriptorTypeUid = this.DescriptorTypeUid;
            }
            if (this.RelationshipUid != Guid.Empty)
            {
                context.RelationshipUid = this.RelationshipUid;
            }
            return(context);
        }
        private bool ContainsOriginal(MetadataContext context)
        {
            bool result = false;

            foreach (KeyValuePair <MetadataContext, MetadataViewModel> pair in _original)
            {
                if (pair.Key.MetadataName == context.MetadataName &&
                    pair.Key.NodeUid == context.NodeUid &&
                    pair.Key.DescriptorTypeUid == context.DescriptorTypeUid &&
                    pair.Key.RelationshipUid == context.RelationshipUid)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
        private void RenderNodeAsChild(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y)
        {
            x = 0.0;
            y = 0.0;

            IRelationshipProxy mapRelationship = GetMapRelationship(Node);
            descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("From");
            xPosKey.DescriptorTypeUid = descriptorType.Id;
            yPosKey.DescriptorTypeUid = descriptorType.Id;

            if (mapRelationship != null)
            {
                xPosKey.RelationshipUid = mapRelationship.Id;
                yPosKey.RelationshipUid = mapRelationship.Id;
            }

            GetNodeLocation(xPosKey, yPosKey, out x, out y);
        }
        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();
        }
        private void RenderNodeAsTransclusion(MetadataContext xPosKey, MetadataContext yPosKey, out IDescriptorTypeProxy descriptorType, out double x, out double y)
        {
            x = 0.0;
            y = 0.0;

            descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("TransclusionMap");
            xPosKey.DescriptorTypeUid = descriptorType.Id;
            yPosKey.DescriptorTypeUid = descriptorType.Id;

            foreach (IRelationshipProxy relationship in GetTransclusionRelationship(Node))
            {
                xPosKey.RelationshipUid = relationship.Id;
                yPosKey.RelationshipUid = relationship.Id;

                if (GetNodeLocation(xPosKey, yPosKey, out x, out y))
                {
                    break;
                }
            }
        }
Example #38
0
        public void SetNodeMetadata(MetadataContext key, string metadataValue, IMetadataTypeProxy metadataType)
        {
            if (BaseSoapNode.Metadata != null)
            {
                if (HasMetadata(key))
                {
                    GetNodeMetadata(key).MetadataValue = metadataValue;
                }
                else
                {
                    BaseSoapNode.Metadata.Add(key, new SoapMetadata()
                    {
                        MetadataName = key.MetadataName,
                        MetadataType = new SoapMetadataType() { Id = metadataType.Id, Name = metadataType.Name },
                        MetadataValue = metadataValue
                    });
                }

                INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance<INodeService>();
                TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>();
                IDescriptorTypeProxy descriptorType = null;
                if (key.DescriptorTypeUid.HasValue)
                {
                    descriptorType = typeManager.GetDescriptorType(key.DescriptorTypeUid.Value);
                }
                Guid relationshipId = Guid.Empty;
                if (key.RelationshipUid.HasValue)
                {
                    relationshipId = key.RelationshipUid.Value;
                }
                
                nodeService.UpdateNodeMetadataAsync(Domain, this.Id, relationshipId, descriptorType, key.MetadataName, metadataValue, metadataType);
            }
        }
Example #39
0
        public void DeleteNodeMetadata(MetadataContext key)
        {
            if (HasMetadata(key))
            {
                INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance<INodeService>();
                nodeService.DeleteMetadata(key);

                RemoveMetadata(key); //assumes the service call works for speed of updating the data cached
            }
        }
Example #40
0
 private void propertiesMenuItem_Click(object sender, RoutedEventArgs e)
 {
     NodePropertiesDialog npd = new NodePropertiesDialog();
     npd.DataContext = NodeProxy;
     MetadataContext noteKey = new MetadataContext()
     {
         MetadataName = "Note",
         NodeUid = NodeProxy.Id
     };
     if (NodeProxy.HasMetadata(noteKey))
     {
         npd.Note = NodeProxy.GetNodeMetadata(noteKey).MetadataValue;
     }
     npd.Closed += new EventHandler(NodePropertiesDialog_Close);
     npd.Show();
 }
Example #41
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 #42
0
		private IteratorCreator(MetadataContext metadataContext, bool includeStatistics)
		{
			_metadataContext = metadataContext;
			_includeStatistics = includeStatistics;
		}
Example #43
0
 public Validator(IErrorReporter errorReporter, MetadataContext metadataContext)
 {
     _errorReporter = errorReporter;
     _metadataContext = metadataContext;
 }
Example #44
0
		public void MetadataContext()
		{
			MetadataContext metadataContext = new MetadataContext();
			ExpectArgumentNull("type", delegate { metadataContext.FindMethod(null, NQuery.Identifier.CreateNonVerbatim("Test")); });
			ExpectArgumentNull("identifier", delegate { metadataContext.FindMethod(typeof(int), null); });
			ExpectArgumentNull("type", delegate { metadataContext.FindProperty((Type) null, NQuery.Identifier.CreateNonVerbatim("Test")); });
			ExpectArgumentNull("identifier", delegate { metadataContext.FindProperty(typeof(int), null); });
			ExpectArgumentNull("properties", delegate { metadataContext.FindProperty((PropertyBinding[])null, NQuery.Identifier.CreateNonVerbatim("Test")); });
		}
Example #45
0
        public SoapMetadata GetNodeMetadata(MetadataContext key)
        {
            SoapMetadata metadata = null;
            if (HasMetadata(key))
            {
                foreach (MetadataContext contextKey in Metadata.Keys)
                {
                    if (contextKey.MetadataName == key.MetadataName)
                    {
                        if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                        {
                            metadata = Metadata[contextKey];
                            break;
                        }
                        if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.NodeUid.Value == key.NodeUid.Value && contextKey.RelationshipUid.Value == key.RelationshipUid.Value
                                && contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value &&
                                contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                                contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                                contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.NodeUid.Value == key.NodeUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                        else if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                        {
                            if (contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                            {
                                metadata = Metadata[contextKey];
                                break;
                            }
                        }
                    }
                }
            }

            return metadata;
        }
 public void DeleteMetadata(MetadataContext context)
 {
     Client.DeleteMetadataAsync(context);
 }
        public override NodeControl RenderChildren(RenderingContextInfo info)
        {
            if (_nodeControl == null)
            {
                double x = 0.0;
                double y = 0.0;

                MetadataContext xPosKey = new MetadataContext()
                {
                    MetadataName = "XPosition",
                    NodeUid = Node.Id
                };
                MetadataContext yPosKey = new MetadataContext()
                {
                    MetadataName = "YPosition",
                    NodeUid = Node.Id
                };

                IDescriptorTypeProxy descriptorType;

                //The is being drawn as a transclusion representation (i.e. not in it's original parent map)
                if (Node.ParentMapNodeUid != Guid.Empty && Node.ParentMapNodeUid != ParentNavigatorView.ContextNode.Id)
                {
                    RenderNodeAsTransclusion(xPosKey, yPosKey, out descriptorType, out x, out y);
                }

                //The node is being drawn in it's parent map (i.e. not a transclusion representation)
                else
                {
                    RenderNodeAsChild(xPosKey, yPosKey, out descriptorType, out x, out y);
                }

                Location = new Point(x, y);

                _nodeControl = Skin.RenderSkinElements(Node, SkinName, Skin.SkinProperties);
            }

            return _nodeControl;
        }
        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 #49
0
        private void NodeContextMenu_Loaded(object sender, RoutedEventArgs e)
        {
            Command getPlayingStateCommand = new Command();
            getPlayingStateCommand.Name = "GetPlayingState";
            getPlayingStateCommand.Params = new List<Param>();
            getPlayingStateCommand.Params.Add(new Param() { Name = "NodeId", Value = NodeProxy.Id.ToString() });
            //Utilities.SendMessage<Command>(MessageSender, getPlayingStateCommand);

            playVideoMenuItem = new MenuItem();
            playVideoMenuItem.Header = "Play Video Segment";
            MetadataContext videoSourceKey = new MetadataContext()
            {
                MetadataName = "Video.Source",
                NodeUid = NodeProxy.Id
            };
            playVideoMenuItem.Click += new RoutedEventHandler(playVideoMenuItem_Click);

            pauseVideoMenuItem = new MenuItem();
            pauseVideoMenuItem.Header = "Pause Video Segment";
            pauseVideoMenuItem.Click += delegate(object sender2, RoutedEventArgs e2)
            {
                Command pauseCommand = new Command();
                pauseCommand.Name = "Pause";
                //Utilities.SendMessage<Command>(MessageSender, pauseCommand);
            };
            if (!NodeProxy.HasMetadata(videoSourceKey))
            {
                playVideoMenuItem.IsEnabled = false;
                pauseVideoMenuItem.IsEnabled = false;
            }
            this.Items.Add(playVideoMenuItem);
            this.Items.Add(pauseVideoMenuItem);

            Separator videoOpSep = new Separator();
            this.Items.Add(videoOpSep);

            MenuItem recordStartPosition = new MenuItem();
            recordStartPosition.Header = "Record Start Position";
            recordStartPosition.Click += delegate(object sender2, RoutedEventArgs e2)
            {
                Command getStartPositionCommand = new Command();
                getStartPositionCommand.Name = "GetSourceAndPosition";
                getStartPositionCommand.Params = new List<Param>();
                getStartPositionCommand.Params.Add(new Param() { Name = "CallbackId", Value = "StartPosition" });
                getStartPositionCommand.Params.Add(new Param(){Name="NodeId", Value=NodeProxy.Id.ToString()});
                //Utilities.SendMessage<Command>(MessageSender, getStartPositionCommand);
            };
            this.Items.Add(recordStartPosition);

            MenuItem recordEndPosition = new MenuItem();
            recordEndPosition.Header = "Record End Position";
            recordEndPosition.Click += delegate(object sender2, RoutedEventArgs e2)
            {
                Command getEndPositionCommand = new Command();
                getEndPositionCommand.Name = "GetSourceAndPosition";
                getEndPositionCommand.Params = new List<Param>();
                getEndPositionCommand.Params.Add(new Param() { Name="CallbackId", Value="EndPosition"});
                getEndPositionCommand.Params.Add(new Param() { Name="NodeId", Value=NodeProxy.Id.ToString()});
                //Utilities.SendMessage<Command>(MessageSender, getEndPositionCommand);
            };
            this.Items.Add(recordEndPosition);

            MenuItem clearVideoData = new MenuItem();
            clearVideoData.Header = "Clear Node Video Markers";
            clearVideoData.Click += delegate(object sender2, RoutedEventArgs e2)
            {
                TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>();
                IMetadataTypeProxy stringMetadataTypeProxy = typeManager.GetMetadataType("string");
                Navigator.UpdateNodeMetadataAsync(NodeProxy, Guid.Empty, null, "Video.Source", "", stringMetadataTypeProxy);
            };
            clearVideoData.IsEnabled = false;
            if (NodeProxy.HasMetadata(videoSourceKey))
            {
                if (!string.IsNullOrEmpty(NodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
                {
                    clearVideoData.IsEnabled = true;
                }
            }
            this.Items.Add(clearVideoData);

            Separator videoOp2Sep = new Separator();
            this.Items.Add(videoOp2Sep);

            MenuItem deleteNodeMenuItem = new MenuItem();
            deleteNodeMenuItem.Header = "Delete Node";
            deleteNodeMenuItem.Click += new RoutedEventHandler(deleteNodeMenuItem_Click);
            this.Items.Add(deleteNodeMenuItem);

            Separator copyOpSep = new Separator();
            this.Items.Add(copyOpSep);

            MenuItem cloneMenuItem = new MenuItem();
            cloneMenuItem.Header = "Clone";
            cloneMenuItem.Click += new RoutedEventHandler(cloneMenuItem_Click);
            this.Items.Add(cloneMenuItem);

            MenuItem copyMenuItem = new MenuItem();
            copyMenuItem.Header = "Copy";
            copyMenuItem.Click += new RoutedEventHandler(copyMenuItem_Click);
            this.Items.Add(copyMenuItem);

            Separator propertiesSep = new Separator();
            this.Items.Add(propertiesSep);

            MenuItem propertiesMenuItem = new MenuItem();
            propertiesMenuItem.Header = "Properties...";
            propertiesMenuItem.Click += new RoutedEventHandler(propertiesMenuItem_Click);
            this.Items.Add(propertiesMenuItem);

            Separator sendSep = new Separator();
            this.Items.Add(sendSep);

            MenuItem sendMenuItem = new MenuItem();
            sendMenuItem.Header = "Send to Web Part Connection";
            sendMenuItem.Click += new RoutedEventHandler(sendMenuItem_Click);
            this.Items.Add(sendMenuItem);
        }
Example #50
0
        private void cloneMenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (MapControl.SelectedNodes != null && MapControl.SelectedNodes.Length <= 1)
            {
                Point cloneLocation = new Point(Location.X + 50, Location.Y + 50);
                Navigator.PasteNodeClone(NodeProxy.Id, cloneLocation);
            }
            else
            {
                //multi node cloning
                if (MapControl.SelectedNodes != null)
                {
                    foreach (INodeProxy nodeProxy in MapControl.SelectedNodes)
                    {
                        double x = 0.0;
                        double y = 0.0;

                        MetadataContext xPosKey = new MetadataContext()
                        {
                            MetadataName = "XPosition",
                            NodeUid = nodeProxy.Id
                        };
                        MetadataContext yPosKey = new MetadataContext()
                        {
                            MetadataName = "YPosition",
                            NodeUid = nodeProxy.Id
                        };

                        IDescriptorTypeProxy descriptorType;

                        //The is being drawn as a transclusion representation (i.e. not in it's original parent map)
                        if (nodeProxy.ParentMapNodeUid != Guid.Empty && nodeProxy.ParentMapNodeUid != Navigator.FocalNodeId)
                        {
                            descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("TransclusionMap");
                            xPosKey.DescriptorTypeUid = descriptorType.Id;
                            yPosKey.DescriptorTypeUid = descriptorType.Id;

                            foreach (IRelationshipProxy relationship in GetTransclusionRelationship(nodeProxy))
                            {
                                xPosKey.RelationshipUid = relationship.Id;
                                yPosKey.RelationshipUid = relationship.Id;

                                if (nodeProxy.Metadata != null && nodeProxy.HasMetadata(xPosKey) && nodeProxy.HasMetadata(yPosKey))
                                {
                                    double.TryParse(nodeProxy.GetNodeMetadata(xPosKey).MetadataValue, out x);
                                    double.TryParse(nodeProxy.GetNodeMetadata(yPosKey).MetadataValue, out y);
                                    break;
                                }
                            }
                        }

                        //The node is being drawn in it's parent map (i.e. not a transclusion representation)
                        else
                        {
                            IRelationshipProxy mapRelationship = GetMapRelationship(nodeProxy);
                            descriptorType = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>().GetDescriptorType("From");
                            xPosKey.DescriptorTypeUid = descriptorType.Id;
                            yPosKey.DescriptorTypeUid = descriptorType.Id;

                            if (mapRelationship != null)
                            {
                                xPosKey.RelationshipUid = mapRelationship.Id;
                                yPosKey.RelationshipUid = mapRelationship.Id;
                            }

                            if (nodeProxy.Metadata != null && nodeProxy.HasMetadata(xPosKey) && nodeProxy.HasMetadata(yPosKey))
                            {
                                double.TryParse(nodeProxy.GetNodeMetadata(xPosKey).MetadataValue, out x);
                                double.TryParse(nodeProxy.GetNodeMetadata(yPosKey).MetadataValue, out y);
                            }
                        }

                        Point cloneLocation = new Point(x + 50, y + 50);
                        Navigator.PasteNodeClone(nodeProxy.Id, cloneLocation);
                    }
                }
            }
        }
Example #51
0
 public void RenameNodeMetadata(MetadataContext key, string newName)
 {
     if (HasMetadata(key))
     {
         INodeService nodeService = IoC.IoCContainer.GetInjectionInstance().GetInstance<INodeService>();
         TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>();
         IDescriptorTypeProxy descriptorType = null;
         if (key.DescriptorTypeUid.HasValue)
         {
             descriptorType = typeManager.GetDescriptorType(key.DescriptorTypeUid.Value);
         }
         Guid relationshipId = Guid.Empty;
         if (key.RelationshipUid.HasValue)
         {
             relationshipId = key.RelationshipUid.Value;
         }
         nodeService.RenameNodeMetadataAsync(Domain, Id, relationshipId, descriptorType, key.MetadataName, newName);
     }
 }
 private bool ContainsOriginal(MetadataContext context)
 {
     bool result = false;
     foreach (KeyValuePair<MetadataContext, MetadataViewModel> pair in _original)
     {
         if (pair.Key.MetadataName == context.MetadataName &&
             pair.Key.NodeUid == context.NodeUid &&
             pair.Key.DescriptorTypeUid == context.DescriptorTypeUid &&
             pair.Key.RelationshipUid == context.RelationshipUid)
         {
             result = true;
             break;
         }
     }
     return result;
 }
Example #53
0
 private void RemoveMetadata(MetadataContext key)
 {
     if (HasMetadata(key))
     {
         MetadataContext actualKeyToRemove = null;
         foreach (MetadataContext contextKey in Metadata.Keys)
         {
             if (contextKey.MetadataName == key.MetadataName)
             {
                 if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     actualKeyToRemove = contextKey;
                     break;
                 }
                 if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value && contextKey.RelationshipUid.Value == key.RelationshipUid.Value
                         && contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value &&
                         contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                         contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                         contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         actualKeyToRemove = contextKey;
                         break;
                     }
                 }
             }
         }
         if (actualKeyToRemove != null)
         {
             Metadata.Remove(actualKeyToRemove);
         }
     }
 }
        private void AddMetadataDialog_Closed(object sender, EventArgs e)
        {
            EditMetadataDialog dialog = sender as EditMetadataDialog;
            if (dialog != null && dialog.DialogResult.Value == true)
            {
                //only allow a key to go into the properties once
                if (!_changes.ContainsKey(dialog.MetadataName.ToLower()))
                {
                    MetadataContext newContext = new MetadataContext();
                    newContext.MetadataName = dialog.MetadataName;
                    newContext.NodeUid = NodeProxy.Id;
                    SoapMetadata metadata = new SoapMetadata();
                    metadata.MetadataName = dialog.MetadataName;
                    TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>();
                    IMetadataTypeProxy[] metaDataTypes = typeManager.GetAllMetadataTypes();
                    foreach (IMetadataTypeProxy metadataType in metaDataTypes)
                    {
                        if (metadataType.Id == dialog.MetadataTypeUid)
                        {
                            SoapMetadataType soapMetadataType = new SoapMetadataType();
                            soapMetadataType.Id = metadataType.Id;
                            soapMetadataType.Name = metadataType.Name;
                            metadata.MetadataType = soapMetadataType;
                            break;
                        }
                    }
                    metadata.MetadataValue = dialog.Value;

                    MetadataViewModel newData = new MetadataViewModel(newContext, metadata);
                    _changes[newData.OriginalMetadataName.ToLower()] = true;
                    _metadata.Add(newData);
                    _metadataNames.Add(newData.MetadataName);
                    newData.PropertyChanged += new PropertyChangedEventHandler(model_PropertyChanged);
                }
                else
                {
                    MessageBox.Show("Metadata could not be added because the property name already existed", "Error Adding Metadata", MessageBoxButton.OK);
                }
            }
        }
Example #55
0
 public bool HasMetadata(MetadataContext key)
 {
     bool result = false;
     if (key != null)
     {
         foreach (MetadataContext contextKey in Metadata.Keys)
         {
             if (contextKey.MetadataName == key.MetadataName)
             {
                 if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     result = true;
                     break;
                 }
                 if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value && contextKey.RelationshipUid.Value == key.RelationshipUid.Value
                         && contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value &&
                         contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                         contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value &&
                         contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (key.NodeUid.HasValue && !key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.NodeUid.Value == key.NodeUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && key.RelationshipUid.HasValue && !key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.RelationshipUid.Value == key.RelationshipUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
                 else if (!key.NodeUid.HasValue && !key.RelationshipUid.HasValue && key.DescriptorTypeUid.HasValue)
                 {
                     if (contextKey.DescriptorTypeUid.Value == key.DescriptorTypeUid.Value)
                     {
                         result = true;
                         break;
                     }
                 }
             }
         }
     }
     return result;
 }
Example #56
0
 public void SetPlayingMediaIcon()
 {
     MetadataContext videoSourceKey = new MetadataContext()
     {
         MetadataName = "Video.Source",
         NodeUid = nodeProxy.Id
     };
     if (nodeProxy.HasMetadata(videoSourceKey) && !string.IsNullOrEmpty(nodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue))
     {
         GoToState(NodeControl.PlayingStateName, false);
     }
 }
Example #57
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 #58
0
 public MetadataContext GetContext()
 {
     MetadataContext context = new MetadataContext();
     context.NodeUid = this.NodeUid;
     context.MetadataName = this.OriginalMetadataName;
     if (this.DescriptorTypeUid != Guid.Empty)
     {
         context.DescriptorTypeUid = this.DescriptorTypeUid;
     }
     if (this.RelationshipUid != Guid.Empty)
     {
         context.RelationshipUid = this.RelationshipUid;
     }
     return context;
 }
Example #59
0
        private void OnConnectNodesCompletedNodeArgs(object sender, ConnectedNodesEventArgs e)
        {
            List<INodeProxy> nodes = new List<INodeProxy>();
            TypeManager typeManager = IoC.IoCContainer.GetInjectionInstance().GetInstance<TypeManager>();
            IMetadataTypeProxy metaDataTypeProxy = typeManager.GetMetadataType("double");

            if (e.Relationship.RelationshipType.Name == "TransclusionRelationship")
            {
                foreach (IDescriptorProxy descriptorProxy in e.Relationship.Descriptors.GetByDescriptorTypeName("To"))
                {
                    nodes.Add(descriptorProxy.Node);
                }

                if (e.Nodes.Length == 2) //TODO: Fix this, currently checking if it's just a transcluded node to map relationship
                {
                    IDescriptorTypeProxy transclusionMapDesc = typeManager.GetDescriptorType("TransclusionMap");

                    MetadataContext xPositionKey = new MetadataContext()
                    {
                        NodeUid = e.Nodes[1].Id,
                        MetadataName = "XPosition",
                        RelationshipUid = e.Relationship.Id,
                        DescriptorTypeUid = transclusionMapDesc.Id
                    };

                    MetadataContext yPositionKey = new MetadataContext()
                    {
                        NodeUid = e.Nodes[1].Id,
                        MetadataName = "YPosition",
                        RelationshipUid = e.Relationship.Id,
                        DescriptorTypeUid = transclusionMapDesc.Id
                    };

                    //it'll be the second node that is the added node, the first node is the map - this is unsafe to assume so needs to be fixed
                    UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, transclusionMapDesc, "XPosition", e.Nodes[1].GetNodeMetadata(xPositionKey).MetadataValue, metaDataTypeProxy);
                    UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, transclusionMapDesc, "YPosition", e.Nodes[1].GetNodeMetadata(yPositionKey).MetadataValue, metaDataTypeProxy);
                }
            }
            else if (e.Relationship.RelationshipType.Name == "MapContainerRelationship")
            {
                //if it's a MapContainerRelationship update the positioning based on the context of this map it's being added to

                IDescriptorTypeProxy fromDescriptorTypeProxy = null;
                if (e.Relationship != null)
                {
                    fromDescriptorTypeProxy = typeManager.GetDescriptorType("From");

                    MetadataContext xPositionKey = new MetadataContext()
                    {
                        NodeUid = e.Nodes[1].Id,
                        MetadataName = "XPosition",
                        RelationshipUid = e.Relationship.Id,
                        DescriptorTypeUid = fromDescriptorTypeProxy.Id
                    };

                    MetadataContext yPositionKey = new MetadataContext()
                    {
                        NodeUid = e.Nodes[1].Id,
                        MetadataName = "YPosition",
                        RelationshipUid = e.Relationship.Id,
                        DescriptorTypeUid = fromDescriptorTypeProxy.Id
                    };

                    //it'll be the second node that is the added node, the first node is the map - this is unsafe to assume so needs to be fixed
                    UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, fromDescriptorTypeProxy, "XPosition", e.Nodes[1].GetNodeMetadata(xPositionKey).MetadataValue, metaDataTypeProxy);
                    UpdateNodeMetadataAsync(e.Nodes[1], e.Relationship.Id, fromDescriptorTypeProxy, "YPosition", e.Nodes[1].GetNodeMetadata(yPositionKey).MetadataValue, metaDataTypeProxy);

                    nodes.Add(e.Nodes[1]);
                }
            }
            else
            {
                foreach (INodeProxy nodeProxy in e.Nodes)
                {
                    nodes.Add(nodeProxy);
                }
            }

            NodesEventArgs nodesEventArgs = new NodesEventArgs(null, null, nodes.ToArray());

            if (ConnectNodesCompleted != null)
            {
                ConnectNodesCompleted.Invoke(this, nodesEventArgs);
            }
        }
Example #60
0
        private void playVideoMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MetadataContext videoSourceKey = new MetadataContext()
            {
                MetadataName = "Video.Source",
                NodeUid = NodeProxy.Id
            };
            string source = NodeProxy.GetNodeMetadata(videoSourceKey).MetadataValue;

            VideoSizeHelper sizeHelper = new VideoSizeHelper(NodeProxy);
            RelatedContentPanelUtil.Instance.LoadRelatedVideoContent(source, sizeHelper.Size);

            string startPosition = null;
            string endPosition = null;
            Command playCommand = new Command();
            playCommand.Name = "Play";
            playCommand.Params = new List<Param>();
            playCommand.Params.Add(new Param() { Name = "Source", Value = source });
            MetadataContext videoStartKey = new MetadataContext()
            {
                MetadataName = "Video.StartPosition",
                NodeUid = NodeProxy.Id
            };
            if (NodeProxy.HasMetadata(videoStartKey))
            {
                startPosition = NodeProxy.GetNodeMetadata(videoStartKey).MetadataValue;
                playCommand.Params.Add(new Param() { Name="StartTimeCode", Value=startPosition});
            }
            MetadataContext videoEndKey = new MetadataContext()
            {
                MetadataName = "Video.EndPosition",
                NodeUid = NodeProxy.Id
            };
            if (NodeProxy.HasMetadata(videoEndKey))
            {
                endPosition = NodeProxy.GetNodeMetadata(videoEndKey).MetadataValue;
                playCommand.Params.Add(new Param() { Name="EndTimeCode", Value=endPosition});
            }
            playCommand.Params.Add(new Param() { Name="NodeId", Value=NodeProxy.Id.ToString()});
            //Utilities.SendMessage<Command>(MessageSender, playCommand);
        }