protected override void SetupHandler() { OptionGroup toplevelGroup = Handler.AddGroup(TOP_LEVEL); //the toplevel group will show neither in Table view nor in dialog view explicitely //it's children will be shown one level above ((IOptionItem)toplevelGroup).Attributes[TableEditorFactory.RenderingHintsAttribute] = TableEditorFactory.RenderingHints.Invisible; ((IOptionItem)toplevelGroup).Attributes[DefaultEditorFactory.RenderingHintsAttribute] = DefaultEditorFactory.RenderingHints.Invisible; OptionGroup spcg = toplevelGroup.AddGroup(SourcePortConstraints); spcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false; spcg.AddBool(StrongPortConstraint, false); OptionGroup tpcg = toplevelGroup.AddGroup(TargetPortConstraints); tpcg.Add(PortConstraintStr, PortConstraintType.Any).Attributes[OptionItem.SupportNullValueAttribute] = false; tpcg.AddBool(StrongPortConstraint, false); CollectionOptionItem <string> scopeItem = toplevelGroup.AddList(Scope, scopes, ScopeAllEdges); var clearItem = toplevelGroup.AddBool(ClearAllConstraints, false); ConstraintManager cm = new ConstraintManager(Handler); cm.SetEnabledOnValueEquals(clearItem, false, spcg); cm.SetEnabledOnValueEquals(clearItem, false, scopeItem); cm.SetEnabledOnValueEquals(clearItem, false, tpcg); }
public void ViewCreateWitness(int n) { var hearing = DB.Appeals.FirstOrDefault(x => x.Id == n); if (hearing == null) { RespondRaw("Unknown hearing", 404); return; } if (hearing.Holding != null) { RespondRaw("Petition has been concluded, no further witnesses may be called.", 400); return; } var existingWitnesses = new OptionGroup("Already called"); var notCalled = new OptionGroup("Available"); var players = new Select(id: "players") { Name = "id", Children = { notCalled, existingWitnesses } }; foreach (var player in DB.Players.AsQueryable().Where(x => !x.IsBuiltInAccount).OrderByDescending(x => x.Rating).ToList()) { if (hearing.Witnesses.Any(x => x.Witness.Id == player.Id)) { existingWitnesses.Children.Add(new Option(player.Name, "") { ReadOnly = true, }); } else { notCalled.Add(player.Name, player.Id.ToString()); } } ReplyFile("newwitness.html", 200, new Replacements(hearing) .Add("users", players)); }
public override ICrowdMember Clone() { CrowdMemberModel crowdMemberModel = new CrowdMemberModel() { Name = this.Name, RosterCrowd = null }; crowdMemberModel.InitializeCharacter(); foreach (AnimatedAbility ab in this.AnimatedAbilities) { AnimatedAbility clonedAbility = ab.Clone() as AnimatedAbility; clonedAbility.Owner = crowdMemberModel; if (clonedAbility.IsAttack) { if ((clonedAbility as Attack).OnHitAnimation != null) { (clonedAbility as Attack).OnHitAnimation.Owner = crowdMemberModel; } } crowdMemberModel.AnimatedAbilities.Add(clonedAbility); } foreach (Identity id in this.AvailableIdentities) { Identity clonedIdentity = id.Clone(); if (id.AnimationOnLoad != null) { AnimatedAbility animationOnLoad = crowdMemberModel.AnimatedAbilities.Where(aa => aa.Name == id.AnimationOnLoad.Name).FirstOrDefault(); clonedIdentity.AnimationOnLoad = animationOnLoad; } crowdMemberModel.AvailableIdentities.Add(clonedIdentity); } if (this.DefaultIdentity != null) { Identity defaultIdentity = crowdMemberModel.AvailableIdentities.Where(i => i.Name == this.DefaultIdentity.Name).FirstOrDefault(); crowdMemberModel.DefaultIdentity = defaultIdentity; } if (this.ActiveIdentity != null) { Identity activeIdentity = crowdMemberModel.AvailableIdentities.Where(i => i.Name == this.ActiveIdentity.Name).FirstOrDefault(); crowdMemberModel.ActiveIdentity = activeIdentity; } foreach (CharacterMovement characterMovement in this.Movements) { CharacterMovement clonedCharacterMovement = characterMovement.Clone(); clonedCharacterMovement.Character = crowdMemberModel; crowdMemberModel.Movements.Add(clonedCharacterMovement); } if (this.DefaultMovement != null) { CharacterMovement defaultCharacterMovement = crowdMemberModel.Movements.FirstOrDefault(cm => cm.Name == this.DefaultMovement.Name); crowdMemberModel.DefaultMovement = defaultCharacterMovement; } // Custom option groups foreach (var customGroup in this.OptionGroups.Where(og => og.Type == HeroVirtualTabletop.OptionGroups.OptionType.Mixed)) { OptionGroup <CharacterOption> optGroup = new OptionGroup <CharacterOption>(customGroup.Name); crowdMemberModel.AddOptionGroup(optGroup); foreach (var customOption in customGroup.Options) { if (customOption is Identity) { Identity id = customOption as Identity; Identity identityToRefer = crowdMemberModel.AvailableIdentities.FirstOrDefault(i => i.Name == id.Name); if (identityToRefer != null) { optGroup.Add(identityToRefer); } } else if (customOption is AnimatedAbility) { AnimatedAbility ab = customOption as AnimatedAbility; AnimatedAbility abilityToRefer = crowdMemberModel.AnimatedAbilities.FirstOrDefault(aa => aa.Name == ab.Name); if (abilityToRefer != null) { optGroup.Add(abilityToRefer); } } else if (customOption is CharacterMovement) { CharacterMovement mv = customOption as CharacterMovement; CharacterMovement characterMovementToRefer = crowdMemberModel.Movements.FirstOrDefault(m => m.Name == mv.Name); if (characterMovementToRefer != null) { optGroup.Add(characterMovementToRefer); } } } } return(crowdMemberModel); }