public void InitComponent(IAttributeTable attributeTable) { Crouching = false; ScaleFactorMoving = DefaultScaleFactorMoving; ScaleFactorStationary = DefaultScaleFactorStationary; Speed = DefaultSpeed; }
public static void BlueprintComponentsField( Blueprint blueprint, IAttributeTable configuration, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { // Compute maximum label width. float maxLabelWidth = 0; foreach (var componentType in blueprint.GetAllComponentTypes()) { var inspectorType = inspectorTypeTable[componentType]; foreach (var componentProperty in inspectorType.Properties) { var textDimensions = GUI.skin.label.CalcSize(new GUIContent(componentProperty.Name)); maxLabelWidth = MathUtils.Max(textDimensions.x, maxLabelWidth); } } EditorGUIUtility.labelWidth = maxLabelWidth; foreach (var componentType in blueprint.GetAllComponentTypes()) { var inspectorType = inspectorTypeTable[componentType]; // Draw inspector. AttributeTableField(inspectorType, configuration, inspectorTypeTable, blueprintManager); } }
/// <summary> /// Adds all content of the passed attribute table to this one. /// </summary> /// <param name="attributeTable"> Table to add the content of. </param> public void AddRange(IAttributeTable attributeTable) { foreach (KeyValuePair <object, object> keyValuePair in attributeTable) { this.SetValue(keyValuePair.Key, keyValuePair.Value); } }
public static void RelateTableLayer(ILayer ilayer_0, string string_0, ITable itable_0, string string_1) { try { IAttributeTable table = ilayer_0 as IAttributeTable; if (table != null) { ITable attributeTable = table.AttributeTable; if (itable_0 is IStandaloneTable) { itable_0 = (itable_0 as IStandaloneTable).Table; } IMemoryRelationshipClassFactory factory = new MemoryRelationshipClassFactoryClass(); IRelationshipClass relationshipClass = factory.Open("TabletoLayer", (IObjectClass)itable_0, string_1, (IObjectClass)attributeTable, string_0, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany); ((IRelationshipClassCollectionEdit)ilayer_0).AddRelationshipClass(relationshipClass); } } catch (COMException exception) { MessageBox.Show(exception.Message, "COM Error: " + exception.ErrorCode.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception exception2) { MessageBox.Show(exception2.Message, ".NET Error: ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Creates a new entity, adding components matching the passed /// blueprint and initializing these with the data stored in the /// blueprint and the specified configuration. Configuration data /// is preferred over blueprint data. /// </summary> /// <param name="blueprint"> Blueprint describing the entity to create. </param> /// <param name="configuration"> Data for initializing the entity. </param> /// <param name="additionalComponents">Components to add to the entity, in addition to the ones specified by the blueprint.</param> /// <returns> Unique id of the new entity. </returns> public int CreateEntity(Blueprint blueprint, IAttributeTable configuration, List <Type> additionalComponents) { int id = this.CreateEntity(); this.InitEntity(id, blueprint, configuration, additionalComponents); return(id); }
public void SetTableSource(IFeatureSet fs, int layerHandle, bool ogr) { if (fs == null) { RowCount = 0; return; } _layerHandle = layerHandle; _shapefile = fs; _table = fs.Table; _ogr = ogr; InitColumns(_table); RowManager.Reset(_shapefile); RowCount = 0; // this will clear all rows at once or else it will try to remove them one by one (veeeery slow) RowCount = _table.NumRows; bool editing = _shapefile.CanEditTable(); ReadOnly = !editing; }
public static void RelateTableLayer(ILayer pSrcLayer, string pSrcFieldName, ITable pToTable, string pToFieldName) { try { IAttributeTable table = pSrcLayer as IAttributeTable; if (table != null) { ITable attributeTable = table.AttributeTable; if (pToTable is IStandaloneTable) { pToTable = (pToTable as IStandaloneTable).Table; } IMemoryRelationshipClassFactory factory = new MemoryRelationshipClassFactoryClass(); IRelationshipClass relationshipClass = factory.Open("TabletoLayer", (IObjectClass)pToTable, pToFieldName, (IObjectClass)attributeTable, pSrcFieldName, "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany); ((IRelationshipClassCollectionEdit)pSrcLayer).AddRelationshipClass(relationshipClass); } } catch (COMException exception) { MessageBox.Show(exception.Message, "COM Error: " + exception.ErrorCode.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception exception2) { MessageBox.Show(exception2.Message, ".NET Error: ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Draws the game configuration inspector. /// </summary> public override void OnInspectorGUI() { this.DrawDefaultInspector(); // Collect system types. if (this.inspectorSystemTypes == null) { this.inspectorSystemTypes = InspectorTypeTable.FindInspectorTypes(typeof(ISystem)); } IAttributeTable configuration = this.gameConfiguration.Configuration; foreach (var inspectorType in this.inspectorSystemTypes) { // Draw inspector type. this.DrawInspector(inspectorType, configuration, this.inspectorSystemTypes, null); } if (GUILayout.Button("Reload")) { // Reload configuration. this.gameConfiguration.Load(); } if (GUILayout.Button("Save")) { // Save configuration. // TODO(co): Save automatically if changed. this.Save(); // Refresh assets. AssetDatabase.Refresh(); } }
public void GetUniqueValues(ILayer ilayer_1, string string_2, IList ilist_1) { try { IAttributeTable table = ilayer_1 as IAttributeTable; if (table != null) { ITable attributeTable = table.AttributeTable; IQueryFilter queryFilter = new QueryFilterClass { WhereClause = "1=1" }; (queryFilter as IQueryFilterDefinition).PostfixClause = "Order by " + string_2; ICursor cursor = attributeTable.Search(queryFilter, false); IDataStatistics statistics = new DataStatisticsClass { Field = string_2, Cursor = cursor }; IEnumerator uniqueValues = statistics.UniqueValues; uniqueValues.Reset(); while (uniqueValues.MoveNext()) { this.arrayList_0.Add(uniqueValues.Current); } this.arrayList_0.Sort(); } } catch (Exception exception) { Logger.Current.Error("", exception, ""); } }
/// <summary> /// Tries to get the value of the attribute with the specified key. If not found, /// the specified default value is returned. /// </summary> /// <typeparam name="T">Expected type of attribute. Only classes are allowed as the method wouldn't be AOT compatible otherwise.</typeparam> /// <param name="attributeTable">Attribute table to work on.</param> /// <param name="key"> Key to retrieve the value of. </param> /// <param name="defaultValue">Default value to use if attribute wasn't found.</param> /// <returns>Value of attribute with specified key, if found. Specified default value otherwise.</returns> public static T GetValueOrDefault <T>(this IAttributeTable attributeTable, object key, T defaultValue) where T : class { T value; return(TryGetValue(attributeTable, key, out value) ? value : defaultValue); }
private static void CopyFields(DataTable dt, IAttributeTable tableToFill) { for (var i = 0; i < dt.Columns.Count; i++) { var type = AttributeType.String; switch (dt.Columns[i].DataType.ToString()) { case "System.String": type = AttributeType.String; break; case "System.Double": type = AttributeType.Double; break; case "System.Int32": type = AttributeType.Integer; break; } var fld = new AttributeField { Name = dt.Columns[i].ColumnName, Type = type, Precision = 6, }; if (dt.Columns[i].MaxLength != -1) { fld.Width = dt.Columns[i].MaxLength; } tableToFill.Fields.Add(fld); } }
/// <summary> /// Draws an inspector for the passed attribute table. /// </summary> /// <param name="inspectorType">Type to draw inspector controls for.</param> /// <param name="attributeTable">Attribute to draw inspector for.</param> /// <param name="inspectorTypeTable"></param> /// <param name="blueprintManager"></param> public static void AttributeTableField( InspectorType inspectorType, IAttributeTable attributeTable, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { foreach (var inspectorProperty in inspectorType.Properties) { // Get current value. object currentValue = attributeTable.GetValueOrDefault( inspectorProperty.Name, inspectorProperty.Default); // Draw inspector property. object newValue = LogicInspectorPropertyField( inspectorProperty, currentValue, inspectorTypeTable, blueprintManager); // Set new value if changed. if (!Equals(newValue, currentValue)) { attributeTable.SetValue(inspectorProperty.Name, newValue); } } }
/// <summary> /// Stops currently selected join. /// </summary> public static bool StopJoin(IAttributeTable table, FieldJoin join) { if (table == null) { throw new ArgumentNullException("table"); } if (join == null) { MessageService.Current.Info("No join is selected."); return(false); } string filename = join.Filename; if (!MessageService.Current.Ask("Do you want to stop the join: " + filename + "?")) { return(false); } if (table.StopJoin(join.JoinIndex)) { filename = Path.GetFileName(filename); MessageService.Current.Info("Join was stopped: " + filename); return(true); } return(false); }
public static void CreateSystem <T>(out EventManager eventManager, IAttributeTable configuration) where T : ISystem, new() { EntityManager tmp; CreateSystem <T>(out eventManager, out tmp, configuration); }
public override void Init(IAttributeTable configuration) { this.EventManager.RegisterListener(RPGGameEvent.PickedLock, OnPickedLock); this.EventManager.RegisterListener(RPGGameEvent.TrapDetection, OnTrapDetection); this.EventManager.RegisterListener(RPGGameEvent.TrapDetonated, OnTrapDetonated); this.EventManager.RegisterListener(RPGGameEvent.TrapDisarmAttempt, OnTrapDisarmAttempt); }
public override void Init(IAttributeTable configuration) { base.Init(configuration); this.EventManager.RegisterListener(SerializationAction.Save, this.OnSave); this.EventManager.RegisterListener(SerializationAction.Load, this.OnLoad); }
public UpdateJoinEventArgs(string filename, string fieldList, string options, IAttributeTable tableToFill) { Filename = filename; FieldList = fieldList; Options = options; TableToFill = tableToFill; }
public bool ReloadExternal(IAttributeTable table, string joinOptions) { External = table; RestoreSelectedOption(joinOptions); return(ReloadExternal(table)); }
/// <summary> /// Fills table with data obtained by ADO.NET provider /// </summary> /// <param name="dt"> Data table to make the data from </param> /// <param name="tableToFill"> MapWinGIS table to copy the data to </param> public static void FillMapWinGisTable(DataTable dt, IAttributeTable tableToFill) { tableToFill.CreateNew(string.Empty); CopyFields(dt, tableToFill); CopyValues(dt, tableToFill); }
/// <summary> /// Inserts the passed attribute table as parent to be consulted with /// the specified priority if a key can't be found in this one. /// </summary> /// <param name="priority">Priority of the new parent.</param> /// <param name="parent">Parent to add.</param> public void InsertParent(int priority, IAttributeTable parent) { if (parent == null) { throw new ArgumentNullException("parent", "Parent is null."); } this.parents.Insert(priority, parent); }
public static void CreateSystem <T>( out EventManager eventManager, out EntityManager entityManager, IAttributeTable configuration) where T : ISystem, new() { var game = CreateGameWithSystem <T>(configuration); eventManager = game.EventManager; entityManager = game.EntityManager; }
public override void Init(IAttributeTable configuration) { base.Init(configuration); this.EventManager.RegisterListener(WeaponAction.Fire, this.OnFire); this.EventManager.RegisterListener(WeaponAction.Reload, this.OnReload); this.weaponEntities = new CompoundEntities<WeaponEntity>(this.EntityManager); }
public JoinViewModel(IAttributeTable table) { if (table == null) { throw new ArgumentNullException("table"); } Table = table; }
/// <summary> /// Adds the passed attribute table as parent to this one. /// </summary> /// <param name="parent">Parent to add.</param> public void AddParent(IAttributeTable parent) { if (parent == null) { throw new ArgumentNullException("parent", "Parent is null."); } this.parents.Add(parent); }
public static IEnumerable <ValueCountItem> GetUniqueValues(this IAttributeTable table, int fieldIndex) { var hashTable = new SortedDictionary <object, int>(); var type = table.Fields[fieldIndex].Type; for (int i = 0; i < table.NumRows; i++) { var obj = table.CellValue(fieldIndex, i); switch (type) { case AttributeType.String: string s = obj != null?obj.ToString() : string.Empty; s = "\"" + s + "\""; obj = s; break; case AttributeType.Integer: obj = obj ?? 0; break; case AttributeType.Double: obj = obj ?? 0.0; break; case AttributeType.Boolean: obj = obj ?? false; break; } if (hashTable.ContainsKey(obj)) { hashTable[obj] += 1; } else { hashTable.Add(obj, 1); } } switch (type) { case AttributeType.String: return(hashTable.Select(item => new ValueCountItem(item.Key.ToString(), item.Value))); case AttributeType.Integer: return(hashTable.Select(item => new ValueCountItem((int)item.Key, item.Value))); case AttributeType.Double: return(hashTable.Select(item => new ValueCountItem((double)item.Key, item.Value))); } return(new List <ValueCountItem>()); }
public FieldStatsModel(IAttributeTable table, int fieldIndex) { if (table == null) { throw new ArgumentNullException("table"); } Table = table; FieldIndex = fieldIndex; }
/// <summary> /// Called before view is shown. Allows to initialize UI from this.Model property. /// </summary> public void Initialize() { _table = Model.FeatureSet.Table; InitFieldGrid(); InitValuesGrid(); ShowValues(); }
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext; InspectorDataAttribute inspectorDataAttribute = (InspectorDataAttribute)dataContext.InspectorProperty; this.value = (IAttributeTable)dataContext.Value; this.inspectorFactory = new InspectorFactory(dataContext.EditorContext, null); InspectorType typeInfo = InspectorType.GetInspectorType(inspectorDataAttribute.PropertyType); this.inspectorFactory.AddInspectorControls(typeInfo, this.Controls, this.GetPropertyValue, this.OnPropertyValueChanged, false); }
public bool GetUniqueValues(ILayer ilayer_1, string string_0, IList ilist_1) { try { ITable displayTable = null; if (ilayer_1 is IDisplayTable) { displayTable = (ilayer_1 as IDisplayTable).DisplayTable; } else { IAttributeTable table2 = ilayer_1 as IAttributeTable; if (table2 != null) { displayTable = table2.AttributeTable; } else { displayTable = ilayer_1 as ITable; } } if (displayTable == null) { return(false); } ICursor o = displayTable.Search(null, false); IDataStatistics statistics = new DataStatisticsClass { Field = string_0, Cursor = o }; if ((statistics.UniqueValueCount > 500) && (MessageBox.Show("唯一值数大于500,是否继续", "提示", MessageBoxButtons.YesNo) == DialogResult.No)) { Marshal.ReleaseComObject(o); o = null; return(false); } this.bool_1 = true; IEnumerator uniqueValues = statistics.UniqueValues; uniqueValues.Reset(); while (uniqueValues.MoveNext()) { this.ilist_0.Add(uniqueValues.Current); } (this.ilist_0 as ArrayList).Sort(); return(true); } catch (Exception exception) { Logger.Current.Error("", exception, ""); } return(false); }
public void InitComponent(IAttributeTable attributeTable) { PickLockAttempts_Failed = 0; PickLockAttempts_Success = 0; PickLockLevel = 1; TrapDetectionLevel = 10; TrapDetections_Failed = 0; TrapDetections_Success = 0; TrapDetonations = 0; TrapDisarmLevel = 10; }
/// <summary> /// Initializes the specified object via reflection with the specified property value. /// </summary> /// <param name="entityManager">Entity manager.</param> /// <param name="obj">Object to set property value for.</param> /// <param name="propertyValue">Property value to set.</param> public override void SetPropertyValue(EntityManager entityManager, object obj, object propertyValue) { IAttributeTable propertyAttributeTable = (IAttributeTable)propertyValue; propertyValue = Activator.CreateInstance(this.PropertyType); InspectorType propertyInspectorType = InspectorType.GetInspectorType(this.PropertyType); InspectorUtils.InitFromAttributeTable(entityManager, propertyInspectorType, propertyValue, propertyAttributeTable); base.SetPropertyValue(entityManager, obj, propertyValue); }
public override void Init(IAttributeTable configuration) { EventManager.RegisterListener(RPGGameEvent.FallLanded, OnFallLanded); EventManager.RegisterListener(RPGGameEvent.FallStarted, OnFallStarted); EventManager.RegisterListener(RPGGameEvent.JumpStarted, OnJumpStarted); EventManager.RegisterListener(RPGGameEvent.Menu_Close, OnMenuClose); EventManager.RegisterListener(RPGGameEvent.Menu_DisarmTrap, OnMenuDisarmTrap); EventManager.RegisterListener(RPGGameEvent.Menu_Open, OnMenuOpen); EventManager.RegisterListener(RPGGameEvent.Menu_PickLock, OnMenuPickLock); EventManager.RegisterListener(RPGGameEvent.Menu_UseKey, OnMenuUseKey); }
private void OnPropertyValueChanged(InspectorPropertyAttribute inspectorProperty, object newValue) { if (this.value == null) { this.value = new AttributeTable(); } this.value.SetValue(inspectorProperty.Name, newValue); InspectorPropertyData dataContext = (InspectorPropertyData)this.DataContext; dataContext.Value = this.value; }
private void DrawInspector(InspectorType inspectorType, IAttributeTable configuration, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager) { foreach (var inspectorProperty in inspectorType.Properties) { // Get current value. object currentValue = configuration.GetValueOrDefault(inspectorProperty.Name, inspectorProperty.Default); object newValue = EditorGUIUtils.LogicInspectorPropertyField(inspectorProperty, currentValue, inspectorTypeTable, blueprintManager); // Set new value if changed. if (!Equals(newValue, currentValue)) { configuration.SetValue(inspectorProperty.Name, newValue); } } }
/// <summary> /// Loads the current game configuration from the resource at <see cref="ConfigurationFilePath" />. /// </summary> public void Load() { Debug.Log("Loading game configuration from resources at " + this.ConfigurationFilePath); this.configurationFile = (TextAsset)Resources.Load(this.ConfigurationFilePath); if (this.configurationFile == null) { Debug.LogWarning("No configuration file at " + this.ConfigurationFilePath); this.Configuration = new AttributeTable(); return; } XmlSerializer xmlSerializer = new XmlSerializer(typeof(AttributeTable)); this.Configuration = (IAttributeTable)xmlSerializer.Deserialize(new StringReader(this.configurationFile.text)); }
/// <summary> /// Initializes this component with the data stored in the specified /// attribute table. /// </summary> /// <param name="attributeTable">Component data.</param> public void InitComponent(IAttributeTable attributeTable) { this.value = (TestEnum)attributeTable.GetEnumOrDefault(AttributeValue, DefaultValue); }
public override void Init(IAttributeTable configuration) { base.Init(configuration); this.movementEntities = new CompoundEntities<MovementEntity>(this.EntityManager); }
public CreateEntityProcess(string blueprintId, IAttributeTable attributeTable) { this.blueprintId = blueprintId; this.attributeTable = attributeTable; }
/// <summary> /// Initializes this system with the data stored in the specified /// attribute table. /// </summary> /// <param name="configuration">System configuration data.</param> public virtual void Init(IAttributeTable configuration) { // Initialize from configuration. InspectorUtils.InitFromAttributeTable(this.EntityManager, this, configuration); }
/// <summary> /// Initializes this component with the data stored in the specified /// attribute table. /// </summary> /// <param name="attributeTable">Component data.</param> public void InitComponent(IAttributeTable attributeTable) { this.ListInt = attributeTable.GetValueOrDefault(AttributeListInt, DefaultListInt); }
/// <summary> /// Removes the passed parent from this attribute table. /// </summary> /// <param name="parent">Parent to remove.</param> public void RemoveParent(IAttributeTable parent) { this.parents.Remove(parent); }
/// <summary> /// Checks whether the passed attribute table is a parent of this one. /// </summary> /// <param name="parent">Table to check.</param> /// <returns>true, if the passed table is a parent of this one, and false otherwise.</returns> public bool HasParent(IAttributeTable parent) { return this.parents.Contains(parent); }
/// <summary> /// Initializes this component with the data stored in the specified /// attribute table. /// </summary> /// <param name="attributeTable">Component data.</param> public void InitComponent(IAttributeTable attributeTable) { attributeTable.TryGetInt(AttributeInteger, out this.integer); }
/// <summary> /// Initializes this component with the data stored in the specified /// attribute table. /// </summary> /// <param name="attributeTable">Component data.</param> public void InitComponent(IAttributeTable attributeTable) { attributeTable.TryGetFloat(AttributeValue, out this.value); }
public void InitComponent(IAttributeTable attributeTable) { }
/// <summary> /// Initializes this component with the data stored in the specified /// attribute table. /// </summary> /// <param name="attributeTable">Component data.</param> public void InitComponent(IAttributeTable attributeTable) { this.String = (string)attributeTable.GetValue(AttributeString); }
/// <summary> /// Adds all content of the passed attribute table to this one. /// </summary> /// <param name="other"> Table to add the content of. </param> public void AddRange(IAttributeTable other) { this.attributeTable.AddRange(other); }
public override void Init(IAttributeTable configuration) { base.Init(configuration); this.EventManager.RegisterListener(FrameworkEvent.GameStarted, this.OnGameStarted); }