/// <summary> /// Selects the default or first webcam as the active webcam. /// </summary> private void SelectDefaultWebcam( ) { string path = AppDomain.CurrentDomain.BaseDirectory + "default_webcam.txt"; string webcamMoniker; if (File.Exists(path)) { webcamMoniker = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "default_webcam.txt"); } else { ReadOnlyDictionary <string, string> webcamDictionary = WebcamManager.GetWebcamList( ); webcamMoniker = webcamDictionary.Any( ) ? WebcamManager.GetWebcamList( ).First( ).Key : null; } WebcamManager.RefreshWebcamList( ); WebcamManager.SelectWebcam(webcamMoniker); }
public static bool IsOperator(string value) { return(OperatorTexts.Any(x => x.Value == value)); }
public static bool IsTrigonometricFunction(string value) { return(TrigonometricFunctionTexts.Any(x => x.Value == value)); }
public static bool IsFunction(string value) { return(FunctionTexts.Any(x => x.Value == value)); }
/// <summary> /// P system constructor used during simulation. /// </summary> /// <param name="mSystemObjects">Deserialized M System objects.</param> /// <exception cref="ArgumentException"> /// If M System objects objecst list is null. /// </exception> public MSystem(DeserializedObjects mSystemObjects) { if (mSystemObjects == null) { throw new ArgumentException("M System objects can't be null."); } // New copies of seed tiles must be created here! SeedTiles = mSystemObjects.SeedTiles.Select(tile => new TileInSpace((Tile)tile, tile.Position, tile.Quaternion)).ToList(); GlueRadius = mSystemObjects.GlueRadius; TilingRandomMovement = mSystemObjects.TilingRandomMovement; Tau = mSystemObjects.Tau; Nu0 = mSystemObjects.Nu0; PushingCoef = mSystemObjects.PushingCoef; RandomizeConnectors = mSystemObjects.RandomizeConnectors; FloatingObjects = new ReadOnlyDictionary <string, FloatingObject>(mSystemObjects.FloatingObjects); if (FloatingObjects.Any()) { Mobility = FloatingObjects.Values.Max(obj => obj.Mobility); } RefillEnvironment = mSystemObjects.RefillEnvironment; v_Proteins = new ReadOnlyDictionary <string, Protein>(mSystemObjects.Proteins); Tiles = new ReadOnlyDictionary <string, Tile>(mSystemObjects.Tiles); GlueRelation = mSystemObjects.GluePRelation; v_EvolutionRules = mSystemObjects.EvolutionRules; //====================================================================== MetabolicRules = new Dictionary <string, IReadOnlyList <EvoMetabolicRule> >(); foreach (string proteinName in v_Proteins.Keys) { MetabolicRules[proteinName] = v_EvolutionRules.OfType <EvoMetabolicRule>().Where(rule => proteinName == rule.RProtein.Name).ToList(); } //====================================================================== CreationRules = new Dictionary <Glue, IReadOnlyList <EvoNonMetabolicRule> >(); foreach (Glue glue in mSystemObjects.Glues.Values) { var creationRules = v_EvolutionRules.OfType <EvoNonMetabolicRule>().Where(rule => rule.Type == EvolutionRule.RuleType.Create).ToList(); CreationRulesPriorities = new SortedSet <int>(creationRules.Select(rule => rule.Priority)); CreationRules[glue] = creationRules.Where(rule => rule.RightSideObjects.OfType <Tile>().Single() .Connectors.Any(connector => GlueRelation.ContainsKey(Tuple.Create(glue, connector.Glue)))) .ToList(); } //====================================================================== InsertionRules = new Dictionary <Glue, Dictionary <Glue, IReadOnlyList <EvoNonMetabolicRule> > >(); foreach (Glue glue1 in mSystemObjects.Glues.Values) { foreach (Glue glue2 in mSystemObjects.Glues.Values) { var insRules = v_EvolutionRules.OfType <EvoNonMetabolicRule>() .Where(rule => (rule.Type == EvolutionRule.RuleType.Insert) && IsInsertable(rule.RightSideObjects.OfType <Tile>().Single(), glue1, glue2)) .ToList(); if (insRules.Any()) { AddRulesToDictionary(InsertionRules, glue1, glue2, insRules); AddRulesToDictionary(InsertionRules, glue2, glue1, insRules); } } } //====================================================================== DestructionRules = new Dictionary <string, IReadOnlyList <EvoNonMetabolicRule> >(); foreach (string tileName in Tiles.Keys) { DestructionRules[tileName] = v_EvolutionRules.OfType <EvoNonMetabolicRule>().Where(rule => (rule.Type == EvolutionRule.RuleType.Destroy) && rule.LeftSideObjects.OfType <Tile>().Single().Name == tileName).ToList(); } //====================================================================== DivisionRules = new Dictionary <Glue, Dictionary <Glue, IReadOnlyList <EvoNonMetabolicRule> > >(); foreach (Glue glue1 in mSystemObjects.Glues.Values) { foreach (Glue glue2 in mSystemObjects.Glues.Values) { var divRules = v_EvolutionRules.OfType <EvoNonMetabolicRule>() .Where(rule => (rule.Type == EvolutionRule.RuleType.Divide) && glue1 == (Glue)rule.RightSideObjects[0] && glue2 == (Glue)rule.RightSideObjects[1]) .ToList(); if (divRules.Any()) { AddRulesToDictionary(DivisionRules, glue1, glue2, divRules); AddRulesToDictionary(DivisionRules, glue2, glue1, divRules); } } } }