public async Task SaveAsync(RelativeType entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                using (var timeLineContext = _contextFactory.GetTimeLineContext())
                {
                    var entityModel = await timeLineContext
                                      .RelativeTypes
                                      .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id));

                    if (entityModel == null)
                    {
                        entityModel = new DA.RelativeType();
                        MapForUpdateentity(entity, entityModel);
                        await timeLineContext.RelativeTypes.AddAsync(entityModel);
                    }
                    else
                    {
                        MapForUpdateentity(entity, entityModel);
                    }


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public List <SourceReferencingFile> GetSourceReferencingReferencedFiles(RelativeType relativeType)
        {
            List <SourceReferencingFile> referencedFiles = new List <SourceReferencingFile>();

            if (relativeType == RelativeType.Absolute)
            {
                string directory = this.ScenePath;

                string oldRelativeDirectory = FileManager.RelativeDirectory;
                FileManager.RelativeDirectory = directory;

                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    referencedFiles[i].SourceFile =
                        FileManager.MakeAbsolute(referencedFiles[i].SourceFile);

                    referencedFiles[i].DestinationFile =
                        FileManager.MakeAbsolute(referencedFiles[i].DestinationFile);
                }

                FileManager.RelativeDirectory = oldRelativeDirectory;
            }

            return(referencedFiles);
        }
        private static EdgeDirection ConvertRelativeToDirection(RelativeType type)
        {
            switch (type)
            {
            case RelativeType.Postsynaptic:
                return(EdgeDirection.Outbound);

            case RelativeType.Presynaptic:
                return(EdgeDirection.Inbound);

            default:
                return(EdgeDirection.Any);
            }
        }
Exemple #4
0
 public void RelativeTypeTest()
 {
     // get test
     Assert.That(RelativeType.Sibling.ToString(), Is.EqualTo("sibling"));
     Assert.That(RelativeType.Parent.ToString(), Is.EqualTo("parent"));
     Assert.That(RelativeType.Child.ToString(), Is.EqualTo("child"));
     Assert.That(RelativeType.Grandparent.ToString(), Is.EqualTo("grandparent"));
     Assert.That(RelativeType.Grandchild.ToString(), Is.EqualTo("grandchild"));
     // parse test
     Assert.That(RelativeType.FromJsonString("sibling"), Is.EqualTo(RelativeType.Sibling));
     Assert.That(RelativeType.FromJsonString("parent"), Is.EqualTo(RelativeType.Parent));
     Assert.That(RelativeType.FromJsonString("child"), Is.EqualTo(RelativeType.Child));
     Assert.That(RelativeType.FromJsonString("grandparent"), Is.EqualTo(RelativeType.Grandparent));
     Assert.That(RelativeType.FromJsonString("grandchild"), Is.EqualTo(RelativeType.Grandchild));
 }
        public static string GetDirectory(string fileName, RelativeType relativeType)
        {
            int lastIndex = System.Math.Max(
                fileName.LastIndexOf('/'), fileName.LastIndexOf('\\'));

            if (lastIndex == fileName.Length - 1)
            {
                // If this happens then fileName is actually a directory.
                // So we should return the parent directory of the argument.



                lastIndex = System.Math.Max(
                    fileName.LastIndexOf('/', fileName.Length - 2),
                    fileName.LastIndexOf('\\', fileName.Length - 2));
            }

            if (lastIndex != -1)
            {
                //bool isFtp = false;


                return(fileName.Substring(0, lastIndex + 1));

                //if (FileManager.IsUrl(fileName) || isFtp)
                //{
                //    // don't standardize URLs - they're case sensitive!!!
                //    return fileName.Substring(0, lastIndex + 1);

                //}
                //else
                {
                    //if (relativeType == RelativeType.Absolute)
                    //{
                    //    return FileManager.Standardize(fileName.Substring(0, lastIndex + 1));
                    //}
                    //else
                    //{
                    //    return FileManager.Standardize(fileName.Substring(0, lastIndex + 1), "", false);
                    //}
                }
            }
            else
            {
                return(""); // there was no directory found.
            }
        }
Exemple #6
0
        public static string GetDirectory(string fileName, RelativeType relativeType)
        {
            int lastIndex = System.Math.Max(
                fileName.LastIndexOf('/'), fileName.LastIndexOf('\\'));

            if (lastIndex == fileName.Length - 1)
            {
                // If this happens then fileName is actually a directory.
                // So we should return the parent directory of the argument.



                lastIndex = System.Math.Max(
                    fileName.LastIndexOf('/', fileName.Length - 2),
                    fileName.LastIndexOf('\\', fileName.Length - 2));
            }

            if (lastIndex != -1)
            {
                bool isFtp = false;

#if !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !MONOGAME
                isFtp = FtpManager.IsFtp(fileName);
#endif

                if (FileManager.IsUrl(fileName) || isFtp)
                {
                    // don't standardize URLs - they're case sensitive!!!
                    return(fileName.Substring(0, lastIndex + 1));
                }
                else
                {
                    if (relativeType == RelativeType.Absolute)
                    {
                        return(FileManager.Standardize(fileName.Substring(0, lastIndex + 1), null));
                    }
                    else
                    {
                        return(FileManager.Standardize(fileName.Substring(0, lastIndex + 1), ""));
                    }
                }
            }
            else
            {
                return("");                // there was no directory found.
            }
        }
        /// <summary>
        /// Returns a List of files referenced by this.
        /// </summary>
        /// <param name="relativeType">Whether the files should be absolute or relative.</param>
        /// <returns>The list of referenced files.</returns>
        public List <string> GetReferencedFiles(RelativeType relativeType)
        {
            if (string.IsNullOrEmpty(this.Name))
            {
                throw new InvalidOperationException("The EmitterSaveList's " +
                                                    "Name is null.  You must set this to the file associated with " +
                                                    "this instance.");
            }

            List <string> referencedFiles = new List <string>();

            for (int i = 0; i < this.emitters.Count; i++)
            {
                EmitterSave emitterSave = this.emitters[i];
                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.Texture))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.Texture);
                }

                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.AnimationChains))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.AnimationChains);
                }

                // Justin Johnson, 04/2015 - Retired particle blueprint system
                //if (emitterSave.ParticleBlueprint != null)
                //{
                //    emitterSave.ParticleBlueprint.GetReferencedFiles(referencedFiles);
                //}
            }

            string directory = FileManager.GetDirectory(this.Name);

            if (relativeType == RelativeType.Absolute)
            {
                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    if (FileManager.IsRelative(referencedFiles[i]))
                    {
                        referencedFiles[i] = directory + referencedFiles[i];
                    }
                }
            }

            return(referencedFiles);
        }
Exemple #8
0
        public List <string> GetReferencedFiles(RelativeType relativeType)
        {
            List <string> referencedFiles = new List <string>();

            foreach (AnimationChainSave acs in this.AnimationChains)
            {
                //if(acs.ParentFile
                if (acs.ParentFile != null && acs.ParentFile.EndsWith(".gif"))
                {
                    referencedFiles.Add(acs.ParentFile);
                }
                else
                {
                    foreach (AnimationFrameSave afs in acs.Frames)
                    {
                        string texture = FileManager.Standardize(afs.TextureName, null, false);

                        if (FileManager.GetExtension(texture).StartsWith("gif"))
                        {
                            texture = FileManager.RemoveExtension(texture) + ".gif";
                        }

                        if (!string.IsNullOrEmpty(texture) && !referencedFiles.Contains(texture))
                        {
                            referencedFiles.Add(texture);
                        }
                    }
                }
            }


            if (relativeType == RelativeType.Absolute)
            {
                string directory = FileManager.GetDirectory(FileName);

                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    referencedFiles[i] = directory + referencedFiles[i];
                }
            }

            return(referencedFiles);
        }
Exemple #9
0
        public void RelativeTypeTest()
        {
            // get test
            Assert.That(actual: RelativeType.Sibling.ToString(), expression: Is.EqualTo(expected: "sibling"));
            Assert.That(actual: RelativeType.Parent.ToString(), expression: Is.EqualTo(expected: "parent"));
            Assert.That(actual: RelativeType.Child.ToString(), expression: Is.EqualTo(expected: "child"));
            Assert.That(actual: RelativeType.Grandparent.ToString(), expression: Is.EqualTo(expected: "grandparent"));
            Assert.That(actual: RelativeType.Grandchild.ToString(), expression: Is.EqualTo(expected: "grandchild"));

            // parse test
            Assert.That(actual: RelativeType.FromJsonString(response: "sibling"), expression: Is.EqualTo(expected: RelativeType.Sibling));
            Assert.That(actual: RelativeType.FromJsonString(response: "parent"), expression: Is.EqualTo(expected: RelativeType.Parent));
            Assert.That(actual: RelativeType.FromJsonString(response: "child"), expression: Is.EqualTo(expected: RelativeType.Child));

            Assert.That(actual: RelativeType.FromJsonString(response: "grandparent")
                        , expression: Is.EqualTo(expected: RelativeType.Grandparent));

            Assert.That(actual: RelativeType.FromJsonString(response: "grandchild")
                        , expression: Is.EqualTo(expected: RelativeType.Grandchild));
        }
Exemple #10
0
 public Relative(RelativeType relativeType, NPC person)
 {
     RelativeType1 = relativeType;
     Person        = person;
 }
Exemple #11
0
        internal async static Task <bool> CreateRelative(Func <Task <string> > tagRetriever, Func <object, Task <string[]> > terminalParametersRetriever, object owner, IDialogService dialogService, INeuronQueryService neuronQueryService, INeuronApplicationService neuronApplicationService, ITerminalApplicationService terminalApplicationService, IStatusService statusService, string avatarUrl, string regionId, string targetNeuronId, RelativeType relativeType)
        {
            bool result = false;
            await Neurons.Helper.SetStatusOnComplete(async() =>
            {
                bool stat = false;
                var tag   = await tagRetriever();

                if (!string.IsNullOrEmpty(tag) &&
                    await Neurons.Helper.PromptSimilarExists(neuronQueryService, dialogService, avatarUrl, owner, tag))
                {
                    string[] tps             = await terminalParametersRetriever(owner);
                    var presynapticNeuronId  = string.Empty;
                    var postsynapticNeuronId = string.Empty;
                    var newNeuronId          = string.Empty;

                    if (relativeType == RelativeType.Presynaptic)
                    {
                        newNeuronId          = presynapticNeuronId = Guid.NewGuid().ToString();
                        postsynapticNeuronId = targetNeuronId;
                    }
                    else if (relativeType == RelativeType.Postsynaptic)
                    {
                        presynapticNeuronId = targetNeuronId;
                        newNeuronId         = postsynapticNeuronId = Guid.NewGuid().ToString();
                    }

                    await neuronApplicationService.CreateNeuron(
                        avatarUrl,
                        newNeuronId,
                        tag,
                        regionId
                        );
                    await terminalApplicationService.CreateTerminal(
                        avatarUrl,
                        Guid.NewGuid().ToString(),
                        presynapticNeuronId,
                        postsynapticNeuronId,
                        (neurUL.Cortex.Common.NeurotransmitterEffect) int.Parse(tps[0]),
                        float.Parse(tps[1])
                        );
                    result = true;
                    stat   = true;
                }
                return(stat);
            },
                                                     $"{relativeType.ToString()} created successfully.",
                                                     statusService,
                                                     $"{relativeType.ToString()} creation cancelled."
                                                     );

            return(result);
        }
        public async Task<IEnumerable<Neuron>> GetNeurons(string avatarUrl, string centralId = null, RelativeType type = RelativeType.NotSet, NeuronQuery neuronQuery = null, int? limit = 1000, CancellationToken token = default(CancellationToken))
        {
            var relatives = await this.neuronQueryClient.GetNeurons(avatarUrl, centralId, type, neuronQuery, limit, token);

            if (string.IsNullOrEmpty(centralId))
                relatives = relatives.OrderBy(n => n.Tag);
            else
            {
                var posts = relatives.Where(n => n.Type == RelativeType.Postsynaptic);
                var pres = relatives.Where(n => n.Type == RelativeType.Presynaptic);
                posts = posts.ToList().OrderBy(n => n.Tag);
                pres = pres.ToList().OrderBy(n => n.Tag);
                relatives = posts.Concat(pres);
            }

            return relatives;
        }
        public async Task <IEnumerable <NeuronResult> > GetAll(Guid?centralGuid = null, RelativeType type = RelativeType.NotSet, NeuronQuery neuronQuery = null, int?limit = 1000, CancellationToken token = default(CancellationToken))
        {
            IEnumerable <NeuronResult> result = null;

            result = this.GetNeuronResults(
                centralGuid,
                string.Empty,
                InMemoryNeuronRepository.ConvertRelativeToDirection(type),
                neuronQuery,
                limit);

            return(await Task.FromResult(result));
        }
Exemple #14
0
        internal async static Task <bool> LinkRelative(Func <Task <IEnumerable <Neuron> > > linkCandidatesRetriever, Func <object, Task <string[]> > terminalParametersRetriever, object owner, ITerminalApplicationService terminalApplicationService, IStatusService statusService, string avatarUrl, string targetNeuronId, RelativeType relativeType)
        {
            bool result = false;
            await Neurons.Helper.SetStatusOnComplete(async() =>
            {
                bool stat      = false;
                var candidates = await linkCandidatesRetriever();

                if (candidates != null && candidates.Count() > 0)
                {
                    string[] tps = await terminalParametersRetriever(owner);

                    foreach (var n in candidates)
                    {
                        await terminalApplicationService.CreateTerminal(
                            avatarUrl,
                            Guid.NewGuid().ToString(),
                            relativeType == RelativeType.Presynaptic ? n.Id : targetNeuronId,
                            relativeType == RelativeType.Presynaptic ? targetNeuronId : n.Id,
                            (neurUL.Cortex.Common.NeurotransmitterEffect) int.Parse(tps[0]),
                            float.Parse(tps[1])
                            );
                    }
                    result = true;
                    stat   = true;
                }

                return(stat);
            },
                                                     $"{relativeType.ToString()} linked successfully.",
                                                     statusService,
                                                     $"{relativeType.ToString()} linking cancelled."
                                                     );

            return(result);
        }
        public async Task <IEnumerable <NeuronResult> > Get(Guid guid, Guid?centralGuid = null, RelativeType type = RelativeType.NotSet, bool shouldLoadTerminals = false, CancellationToken token = default(CancellationToken))
        {
            IEnumerable <NeuronResult> result = null;

            if (!centralGuid.HasValue)
            {
                result = new NeuronResult[] { new NeuronResult()
                                              {
                                                  Neuron = this.cache[guid]
                                              } }
            }
            ;
            else
            {
                var temp = this.GetNeuronResults(centralGuid.Value, string.Empty, InMemoryNeuronRepository.ConvertRelativeToDirection(type));
                // TODO: optimize by passing this into GetNeuronResults AQL
                result = temp.Where(nr =>
                                    (nr.Neuron != null && nr.Neuron.Id == guid.ToString()) ||
                                    (nr.Terminal != null && nr.Terminal.TargetId == guid.ToString())
                                    );
            }

            return(await Task.FromResult(result));
        }
Exemple #16
0
		public static string GetDirectory(string fileName, RelativeType relativeType)
		{
			int lastIndex = System.Math.Max(
				fileName.LastIndexOf('/'), fileName.LastIndexOf('\\'));
			
			if (lastIndex == fileName.Length - 1)
			{
				// If this happens then fileName is actually a directory.
				// So we should return the parent directory of the argument.
				
				
				
				lastIndex = System.Math.Max(
					fileName.LastIndexOf('/', fileName.Length - 2),
					fileName.LastIndexOf('\\', fileName.Length - 2));
			}
			
			if (lastIndex != -1)
			{
				bool isFtp = false;
				
#if !XBOX360 && !SILVERLIGHT && !WINDOWS_PHONE && !MONOGAME
				isFtp = FtpManager.IsFtp(fileName);
#endif
				
				if (FileManager.IsUrl(fileName) || isFtp)
				{
					// don't standardize URLs - they're case sensitive!!!
					return fileName.Substring(0, lastIndex + 1);
					
				}
				else
				{
					if (relativeType == RelativeType.Absolute)
					{
						return FileManager.Standardize(fileName.Substring(0, lastIndex + 1), null);
					}
					else
					{
						return FileManager.Standardize(fileName.Substring(0, lastIndex + 1), "");
					}
				}
			}
			else
				return ""; // there was no directory found.
			
		}
Exemple #17
0
        public List <string> GetReferencedFiles(RelativeType relativeType)
        {
            List <string> referencedFiles = new List <string>();

            foreach (SpriteSave spriteSave in SpriteList)
            {
                spriteSave.GetReferencedFiles(referencedFiles);
            }

            foreach (SpriteGridSave spriteGridSave in SpriteGridList)
            {
                if (!string.IsNullOrEmpty(spriteGridSave.BaseTexture) && !referencedFiles.Contains(spriteGridSave.BaseTexture))
                {
                    referencedFiles.Add(spriteGridSave.BaseTexture);
                }

                foreach (string[] stringArray in spriteGridSave.GridTexturesArray)
                {
                    foreach (string texture in stringArray)
                    {
                        if (!string.IsNullOrEmpty(texture) && !referencedFiles.Contains(texture))
                        {
                            referencedFiles.Add(texture);
                        }
                    }
                }
            }

            foreach (SpriteFrameSave spriteFrameSave in SpriteFrameSaveList)
            {
                if (!string.IsNullOrEmpty(spriteFrameSave.ParentSprite.Texture) &&
                    !referencedFiles.Contains(spriteFrameSave.ParentSprite.Texture))
                {
                    referencedFiles.Add(spriteFrameSave.ParentSprite.Texture);
                }

                if (!string.IsNullOrEmpty(spriteFrameSave.ParentSprite.AnimationChainsFile) &&
                    !referencedFiles.Contains(spriteFrameSave.ParentSprite.AnimationChainsFile))
                {
                    referencedFiles.Add(spriteFrameSave.ParentSprite.AnimationChainsFile);
                }
            }

            foreach (TextSave textSave in TextSaveList)
            {
                string fontFile         = textSave.FontFile;
                bool   isThereAFontFile = !string.IsNullOrEmpty(fontFile);
                if (isThereAFontFile &&
                    !referencedFiles.Contains(fontFile))
                {
                    referencedFiles.Add(fontFile);
                }


                string textureFile = textSave.FontTexture;
                if (!string.IsNullOrEmpty(textureFile))
                {
                    if (!referencedFiles.Contains(textureFile))
                    {
                        referencedFiles.Add(textureFile);
                    }
                }
                else if (isThereAFontFile)
                {
                    // This may be a multi-texture font, so let's check for that
                    string absoluteFontDirectory = this.mSceneDirectory + fontFile;

                    if (FileManager.FileExists(absoluteFontDirectory))
                    {
                        string fontDirectory = FileManager.GetDirectory(fontFile, FlatRedBall.IO.RelativeType.Relative);

                        string contents = FileManager.FromFileText(absoluteFontDirectory);

                        string[] textures = BitmapFont.GetSourceTextures(contents);

                        for (int i = 0; i < textures.Length; i++)
                        {
                            string textureWithFontFileDirectory = textures[i];

                            //make the texture hae the font file's directory
                            textureWithFontFileDirectory = fontDirectory + textureWithFontFileDirectory;


                            if (!referencedFiles.Contains(textureWithFontFileDirectory))
                            {
                                referencedFiles.Add(textureWithFontFileDirectory);
                            }
                        }
                    }
                }
            }

            if (relativeType == RelativeType.Absolute)
            {
                string directory = this.ScenePath;

                for (int i = 0; i < referencedFiles.Count; i++)
                {
                    if (FileManager.IsRelative(referencedFiles[i]))
                    {
                        referencedFiles[i] = directory + referencedFiles[i];
                    }
                }
            }

            return(referencedFiles);
        }
Exemple #18
0
        public static IUIAutomationElement xtGetRelative(this IUIAutomationElement element, RelativeType RelativeType)
        {
            IUIAutomationElement relative = null;

            IUIAutomationTreeWalker walker = new CUIAutomationClass().RawViewWalker;

            switch (RelativeType)
            {
            case RelativeType.Parent:
                try { relative = walker.GetParentElement(element); }
                catch (COMException e) { }
                break;

            case RelativeType.FirstChild:
                try { relative = walker.GetFirstChildElement(element); }
                catch (COMException e) { }
                break;

            default: throw new Exception("Given enum was not present in the switch!!!");
            }

            return(relative as IUIAutomationElement);
        }
        /// <summary>
        /// Returns a List of files referenced by this.
        /// </summary>
        /// <param name="relativeType">Whether the files should be absolute or relative.</param>
        /// <returns>The list of referenced files.</returns>
		public List<string> GetReferencedFiles(RelativeType relativeType)
		{
            if (string.IsNullOrEmpty(this.Name))
            {
                throw new InvalidOperationException("The EmitterSaveList's " +
                    "Name is null.  You must set this to the file associated with " +
                    "this instance.");
            }

			List<string> referencedFiles = new List<string>();

			for (int i = 0; i < this.emitters.Count; i++)
			{
				EmitterSave emitterSave = this.emitters[i];
                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.Texture))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.Texture);
                }

                if (!string.IsNullOrEmpty(emitterSave.EmissionSettings.AnimationChains))
                {
                    referencedFiles.Add(emitterSave.EmissionSettings.AnimationChains);
                }

                // Justin Johnson, 04/2015 - Retired particle blueprint system
                //if (emitterSave.ParticleBlueprint != null)
                //{
                //    emitterSave.ParticleBlueprint.GetReferencedFiles(referencedFiles);
                //}
			}

			string directory = FileManager.GetDirectory(this.Name);

			if (relativeType == RelativeType.Absolute)
			{
				for (int i = 0; i < referencedFiles.Count; i++)
				{
                    if (FileManager.IsRelative(referencedFiles[i]))
                    {
                        referencedFiles[i] = directory + referencedFiles[i];
                    }
				}
			}

			return referencedFiles;
		}
 public async Task<IEnumerable<Neuron>> GetNeuronById(string avatarUrl, string id, string centralId = null, RelativeType type = RelativeType.NotSet, CancellationToken token = default(CancellationToken))
 {
     return await this.neuronQueryClient.GetNeuronById(avatarUrl, id, centralId, type, token);
 }
        public void AddRelative(RelativeType relation, IndividualClass person = null)
        {
            trace.TraceInformation("TreeViewPanel2::AddRelative " + relation);
            if (familyTree != null)
            {
                if (selectedIndividual != null)
                {
                    IndividualClass newPerson;
                    if (person != null)
                    {
                        newPerson = person;
                    }
                    else
                    {
                        newPerson = new IndividualClass();
                    }
                    newPerson.SetXrefName(familyTree.CreateNewXref(XrefType.Individual));

                    if (relation == RelativeType.Parent)
                    {
                        FamilyXrefClass         parentFamilyXref = null;
                        FamilyClass             parentFamily     = null;
                        IList <FamilyXrefClass> parents          = selectedIndividual.GetFamilyChildList();
                        if (parents != null)
                        {
                            if (parents.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                parentFamilyXref = parents[0];
                                parentFamily     = familyTree.GetFamily(parentFamilyXref.GetXrefName());
                            }
                        }
                        if (parentFamilyXref == null)
                        {
                            parentFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            parentFamily = new FamilyClass();
                            parentFamily.SetXrefName(parentFamilyXref.GetXrefName());
                            parentFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Child);
                            selectedIndividual.AddRelation(parentFamilyXref, IndividualClass.RelationType.Child);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.ChildFamily);
                        }
                        parentFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Parent);
                        newPerson.AddRelation(parentFamilyXref, IndividualClass.RelationType.Spouse);
                        familyTree.AddFamily(parentFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else if (relation == RelativeType.Child)
                    {
                        FamilyXrefClass         childFamilyXref = null;
                        FamilyClass             childFamily     = null;
                        IList <FamilyXrefClass> children        = selectedIndividual.GetFamilySpouseList();
                        if (children != null)
                        {
                            if (children.Count > 0)
                            {
                                // ToDo: Full support for multiple families..
                                childFamilyXref = children[0];
                                childFamily     = familyTree.GetFamily(childFamilyXref.GetXrefName());
                            }
                        }
                        if (childFamilyXref == null)
                        {
                            childFamilyXref = new FamilyXrefClass(familyTree.CreateNewXref(XrefType.Family));
                            //parentFamily.SetXrefName();
                            childFamily = new FamilyClass();
                            childFamily.SetXrefName(childFamilyXref.GetXrefName());
                            childFamily.AddRelation(new IndividualXrefClass(selectedIndividual.GetXrefName()), FamilyClass.RelationType.Parent);
                            selectedIndividual.AddRelation(childFamilyXref, IndividualClass.RelationType.Spouse);
                            familyTree.UpdateIndividual(selectedIndividual, PersonUpdateType.SpouseFamily);
                        }
                        childFamily.AddRelation(new IndividualXrefClass(newPerson.GetXrefName()), FamilyClass.RelationType.Child);
                        newPerson.AddRelation(childFamilyXref, IndividualClass.RelationType.Child);
                        familyTree.AddFamily(childFamily);

                        familyTree.AddIndividual(newPerson);
                    }
                    else // if (relation == RelativeType.Unrelated)
                    {
                        familyTree.AddIndividual(newPerson);
                    }
                    //familyTree.AddIndividual(newPerson);
                }
                ShowActiveFamily();
            }
        }
Exemple #22
0
 public RelativeToken(RelativeType type)
 {
     RelativeType = type;
 }
Exemple #23
0
 internal static Graph.Common.RelativeType ToExternalType(this RelativeType value)
 {
     return((Graph.Common.RelativeType)Enum.Parse(typeof(Graph.Common.RelativeType), ((int)value).ToString()));
 }
 private void MapForUpdateentity(RelativeType entity, DA.RelativeType daEntity)
 {
     daEntity.Id = entity.Id;
 }
Exemple #25
0
 public RelativeToPlayerHorizontally(PlacedPlayer playerRelative, int distance, RelativeType relativeType)
 {
     _playerRelative = playerRelative;
     _distance       = distance;
     _relativeType   = relativeType;
 }