public static ITable RandomSample(this ITableCollection tables) { return(tables.Random(item => { if (item.IsPrivate == true) { return false; } if (item.IsLocked == true) { return false; } if (item.Childs.Any() == false) { return false; } if (item.TemplatedParent != null) { return false; } if (item.Category.Parent == null) { return false; } return true; })); }
private void CopyMap(IMap fromCopyMap, IMap toCopyMap) { int num; toCopyMap.ClearLayers(); toCopyMap.DistanceUnits = fromCopyMap.DistanceUnits; toCopyMap.MapUnits = fromCopyMap.MapUnits; toCopyMap.SpatialReferenceLocked = false; toCopyMap.SpatialReference = fromCopyMap.SpatialReference; toCopyMap.Name = fromCopyMap.Name; for (num = fromCopyMap.LayerCount - 1; num >= 0; num--) { ILayer layer = fromCopyMap.get_Layer(num); toCopyMap.AddLayer(layer); } IGraphicsContainer container = fromCopyMap as IGraphicsContainer; container.Reset(); IElement element = container.Next(); int zorder = 0; while (element != null) { (toCopyMap as IGraphicsContainer).AddElement(element, zorder); zorder++; element = container.Next(); } ITableCollection tables = fromCopyMap as ITableCollection; for (num = 0; num < tables.TableCount; num++) { (toCopyMap as ITableCollection).AddTable(tables.get_Table(num)); } (toCopyMap as IActiveView).Extent = (fromCopyMap as IActiveView).Extent; }
private void method_1(IMap imap_0, IMap imap_1) { int num; imap_1.ClearLayers(); imap_1.DistanceUnits = imap_0.DistanceUnits; imap_1.MapUnits = imap_0.MapUnits; imap_1.SpatialReferenceLocked = false; imap_1.SpatialReference = imap_0.SpatialReference; imap_1.Name = imap_0.Name; for (num = imap_0.LayerCount - 1; num >= 0; num--) { ILayer layer = imap_0.get_Layer(num); imap_1.AddLayer(layer); } IGraphicsContainer container = imap_0 as IGraphicsContainer; container.Reset(); IElement element = container.Next(); int zorder = 0; while (element != null) { (imap_1 as IGraphicsContainer).AddElement(element, zorder); zorder++; element = container.Next(); } ITableCollection tables = imap_0 as ITableCollection; for (num = 0; num < tables.TableCount; num++) { (imap_1 as ITableCollection).AddTable(tables.get_Table(num)); } (imap_1 as IActiveView).Extent = (imap_0 as IActiveView).Extent; }
private ITable[] GetFilterTables(ITableCollection tables, string tableNames) { var query = from item in tables where item.Name.GlobMany(tableNames) || item.Path.GlobMany(tableNames) select item.Parent ?? item; return(query.Distinct().ToArray()); }
public NewTableViewModel(Authentication authentication, ITableCategory category, ITableTemplate template) : base(authentication, template, true) { this.category = category; this.category.Dispatcher.VerifyAccess(); this.tableCollection = category.GetService(typeof(ITableCollection)) as ITableCollection; this.DisplayName = Resources.Title_NewTable; }
public static async Task <ITable> GenerateTableAsync(this ITableCollection tableCollection, Authentication authentication) { if (tableCollection.GetService(typeof(ITableCategoryCollection)) is ITableCategoryCollection tableCategoryCollection) { var category = await tableCategoryCollection.GetRandomTableCategoryAsync(); return(await category.GenerateTableAsync(authentication)); } throw new NotImplementedException(); }
/// <summary> /// 得到地图上的所有表 /// </summary> /// <param name="tableCollection">表集合(map as ITableCollection)</param> /// <returns></returns> public static ITable[] GetTables(this ITableCollection tableCollection) { List <ITable> tableList = new List <ITable>(); for (int i = 0; i < tableCollection.TableCount; i++) { tableList.Add(tableCollection.get_Table(i)); } return(tableList.ToArray()); }
public static async Task <ITable[]> GenerateTablesAsync(this ITableCollection tableCollection, Authentication authentication, int count) { var itemList = new List <ITable>(count); for (var i = 0; i < count; i++) { var item = await tableCollection.GenerateTableAsync(authentication); itemList.Add(item); } return(itemList.ToArray()); }
public static Task <ITable[]> GetRandomTablesAsync(this ITableCollection tableCollection, TableFlags tableFlags, Func <ITable, bool> predicate) { return(tableCollection.Dispatcher.InvokeAsync(() => { var query = from item in tableCollection where TableFlagsUtility.Test(item, tableFlags) == true && predicate(item) == true let i = RandomUtility.Next <int>() orderby i select item; return query.ToArray(); })); }
private CopyTableViewModel(Authentication authentication, ITable table, bool useTemplate) { this.authentication = authentication; this.table = table; this.table.Dispatcher.VerifyAccess(); this.useTemplate = useTemplate; this.tables = table.GetService(typeof(ITableCollection)) as ITableCollection; this.categories = table.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; this.categoryPath = this.table.Category.Path; this.categoryPaths = this.categories.Select(item => item.Path).OrderBy(item => item).ToArray(); this.tableName = table.Name; this.newName = table.Name; this.DisplayName = Resources.Title_CopyTable; }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITableCollection_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.Initialize(authentication); tables = dataBase.TableContext.Tables; }); }
/// <summary> /// 根据表名,在表集合上查找对应表,找不到则返回Null /// </summary> /// <param name="tableCollection">表集合(map as ITableCollection)</param> /// <param name="name">表名</param> /// <returns></returns> public static ITable GetTable(this ITableCollection tableCollection, string name) { ITable table = null; for (int i = 0; i < tableCollection.TableCount; i++) { ITable tmpTable = tableCollection.get_Table(i); if ((tmpTable as IDataset).Name == name) { table = tmpTable; break; } } return(table); }
private void axPageLayoutControl_OnPageLayoutReplaced(object sender, IPageLayoutControlEvents_OnPageLayoutReplacedEvent e) { int num; IMap focusMap = this.axPageLayoutControl.ActiveView.FocusMap; this.axMapControl.Map.ClearLayers(); (this.axMapControl.Map as IGraphicsContainer).DeleteAllElements(); (this.axMapControl.Map as ITableCollection).RemoveAllTables(); this.axMapControl.Map.ClearLayers(); (this.axMapControl.Map as IActiveView).ContentsChanged(); this.axMapControl.Map.MapUnits = focusMap.MapUnits; this.axMapControl.Map.SpatialReferenceLocked = false; this.axMapControl.Map.SpatialReference = focusMap.SpatialReference; this.axMapControl.Map.Name = focusMap.Name; for (num = 0; num < focusMap.LayerCount; num++) { ILayer layer = focusMap.get_Layer(num); this.axMapControl.AddLayer(layer, num); } IGraphicsContainer container = focusMap as IGraphicsContainer; container.Reset(); IElement element = container.Next(); int zorder = 0; while (element != null) { (this.axMapControl.Map as IGraphicsContainer).AddElement(element, zorder); zorder++; element = container.Next(); } ITableCollection tables = focusMap as ITableCollection; for (num = 0; num < tables.TableCount; num++) { (this.axMapControl.Map as ITableCollection).AddTable(tables.get_Table(num)); } this.axMapControl.ActiveView.Extent = (focusMap as IActiveView).Extent; this.axMapControl.ActiveView.Refresh(); }
/// <summary> /// Cleans a featureclass or table according to the selected options. /// </summary> /// <param name="sSuffix"></param> /// <returns></returns> public bool CleanLayer(string sSuffix) { bool bResult = false; if (ItemsChecked()) { ITableCollection pTableCollection = (ITableCollection)ArcMap.Document.FocusMap; if (m_sLayertype == "FeatureClass") { IFeatureLayer pFL = clsStatic.GetFeatureLayer(m_sWorkspace, m_sLayername + "_" + sSuffix); if (pFL != null) { MessageBox.Show("The output featureclass already exists. Choose another output suffix", clsStatic.g_cProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(bResult); } IFeatureLayer pResult = CleanFeatureClass(sSuffix); if (pResult != null) { ArcMap.Document.AddLayer((ILayer)pResult); } } if (m_sLayertype == "Table") { ITable pTable = clsStatic.GetTable(m_sWorkspace, m_sLayername + "_" + sSuffix); if (pTable != null) { MessageBox.Show("The output table already exists. Choose another output suffix.", clsStatic.g_cProjectName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(bResult); } ITable pResultTable = CleanTable(sSuffix); if (pResultTable != null) { pTableCollection.AddTable(pResultTable); } } bResult = true; } m_sNewLayername = m_sLayername + "_" + sSuffix; return(bResult); }
public static void CopyMap(IMap pMap, IMap targetMap, bool bCopyTable, bool bSetExtent) { int i; targetMap.ClearLayers(); targetMap.SpatialReferenceLocked = false; targetMap.DistanceUnits = pMap.DistanceUnits; targetMap.MapUnits = pMap.MapUnits; targetMap.SpatialReference = pMap.SpatialReference; targetMap.Name = pMap.Name; for (i = pMap.LayerCount - 1; i >= 0; i--) { targetMap.AddLayer(pMap.Layer[i]); } IGraphicsContainer graphicsContainer = pMap as IGraphicsContainer; graphicsContainer.Reset(); IElement element = graphicsContainer.Next(); int num = 0; while (element != null) { (targetMap as IGraphicsContainer).AddElement(element, num); num++; element = graphicsContainer.Next(); } if (bCopyTable) { ITableCollection tableCollection = pMap as ITableCollection; for (i = 0; i < tableCollection.TableCount; i++) { (targetMap as ITableCollection).AddTable(tableCollection.Table[i]); } } if (bSetExtent) { (targetMap as IActiveView).Extent = (pMap as IActiveView).Extent; } }
/// <summary> /// adds a layer to the active view /// </summary> /// <param name="path">full path name</param> /// <returns>Ilayer</returns> public ILayer addLayer(string path) { IMap map = (IMap)acView; geoDatabaseUtility geoUtil = new geoDatabaseUtility(); esriDatasetType dType = geoUtil.getDataType(path); ILayer lyr = null; switch (dType) { case esriDatasetType.esriDTFeatureClass: IFeatureLayer ftrLayer = new FeatureLayerClass(); ftrLayer.FeatureClass = geoUtil.getFeatureClass(path); lyr = (ILayer)ftrLayer; lyr.Name = ftrLayer.FeatureClass.AliasName; map.AddLayer(lyr); break; case esriDatasetType.esriDTRasterBand: case esriDatasetType.esriDTRasterCatalog: case esriDatasetType.esriDTRasterDataset: IRasterLayer rasterLayer = new RasterLayerClass(); rasterLayer.CreateFromDataset(geoUtil.getRasterDataset(path)); rasterLayer.Name = rasterLayer.Name; map.AddLayer((ILayer)rasterLayer); break; case esriDatasetType.esriDTTable: ITable tbl = geoUtil.getTable(path); ITableCollection tableCollection = (ITableCollection)map; tableCollection.AddTable(tbl); break; default: break; } acView.Refresh(); return(lyr); }
public void CreateNewTable() { IMxDocument pMxDoc; pMxDoc = (IMxDocument)ArcMap.Application.Document; IMap pMap; pMap = pMxDoc.FocusMap; IWorkspaceFactory pWSFactory; pWSFactory = new ShapefileWorkspaceFactory(); IFeatureWorkspace pFWorkspace; pFWorkspace = (IFeatureWorkspace)pWSFactory.OpenFromFile("c:/temp", ArcMap.Application.hWnd); IFieldsEdit pFieldsEdit; pFieldsEdit = (IFieldsEdit) new Fields(); IFieldEdit pIDField; pIDField = (IFieldEdit) new Field(); pIDField.Name_2 = "OID"; pIDField.Type_2 = esriFieldType.esriFieldTypeOID; pIDField.Length_2 = 8; IFieldEdit pNameField; pNameField = (IFieldEdit) new Field(); pNameField.Name_2 = "Site_Name"; pNameField.Type_2 = esriFieldType.esriFieldTypeString; pNameField.Length_2 = 20; IFieldEdit pReadingField; pReadingField = (IFieldEdit) new Field(); pReadingField.Name_2 = "Reading"; pReadingField.Type_2 = esriFieldType.esriFieldTypeInteger; pReadingField.Length_2 = 8; IFieldEdit pDateField; pDateField = (IFieldEdit) new Field(); pDateField.Name_2 = "Visit_Date"; pDateField.Type_2 = esriFieldType.esriFieldTypeDate; pFieldsEdit.AddField(pIDField); pFieldsEdit.AddField(pNameField); pFieldsEdit.AddField(pReadingField); pFieldsEdit.AddField(pDateField); ITable pTable = default(ITable); pTable = pFWorkspace.CreateTable("measurements.dbf", pFieldsEdit, null, null, ""); ITableCollection pTableCollection = default(ITableCollection); pTableCollection = (ITableCollection)pMap; pTableCollection.AddTable(pTable); pMxDoc.UpdateContents(); }
private void method_6() { int i; if (this.bool_1) { try { if (this.iactiveViewEvents_Event_0 != null) { this.iactiveViewEvents_Event_0.ItemAdded -= new IActiveViewEvents_ItemAddedEventHandler(this.method_8); this.iactiveViewEvents_Event_0.ItemReordered -= new IActiveViewEvents_ItemReorderedEventHandler(this.method_0); this.iactiveViewEvents_Event_0.ItemDeleted -= new IActiveViewEvents_ItemDeletedEventHandler(this.method_7); } } catch { } IMap focusMap = this.ipageLayoutControl2_0.ActiveView.FocusMap; this.iactiveViewEvents_Event_0 = focusMap as IActiveViewEvents_Event; try { if (this.iactiveViewEvents_Event_0 != null) { this.iactiveViewEvents_Event_0.ItemAdded += new IActiveViewEvents_ItemAddedEventHandler(this.method_8); this.iactiveViewEvents_Event_0.ItemReordered += new IActiveViewEvents_ItemReorderedEventHandler(this.method_0); this.iactiveViewEvents_Event_0.ItemDeleted += new IActiveViewEvents_ItemDeletedEventHandler(this.method_7); } } catch { } this.imapControl3_0.Map.ClearLayers(); (this.imapControl3_0.Map as IActiveView).ContentsChanged(); this.imapControl3_0.Map.MapUnits = focusMap.MapUnits; this.imapControl3_0.Map.SpatialReferenceLocked = false; this.imapControl3_0.Map.SpatialReference = focusMap.SpatialReference; this.imapControl3_0.Map.Name = focusMap.Name; for (i = 0; i < focusMap.LayerCount; i++) { ILayer layer = focusMap.Layer[i]; this.imapControl3_0.AddLayer(layer, i); } (this.imapControl3_0.Map as IGraphicsContainer).DeleteAllElements(); IGraphicsContainer graphicsContainer = focusMap as IGraphicsContainer; graphicsContainer.Reset(); IElement element = graphicsContainer.Next(); int num = 0; while (element != null) { (this.imapControl3_0.Map as IGraphicsContainer).AddElement(element, num); num++; element = graphicsContainer.Next(); } (this.imapControl3_0.Map as ITableCollection).RemoveAllTables(); ITableCollection tableCollection = focusMap as ITableCollection; for (i = 0; i < tableCollection.TableCount; i++) { (this.imapControl3_0.Map as ITableCollection).AddTable(tableCollection.Table[i]); } this.imapControl3_0.ActiveView.Extent = (focusMap as IActiveView).Extent; this.imapControl3_0.ActiveView.Refresh(); } }
private void method_1() { if (this.itable_0 != null) { int num; IFields fields = this.itable_0.Fields; if (fields != null) { for (num = 0; num < fields.FieldCount; num++) { IField field = fields.get_Field(num); switch (field.Type) { case esriFieldType.esriFieldTypeDouble: case esriFieldType.esriFieldTypeInteger: case esriFieldType.esriFieldTypeOID: case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeSmallInteger: case esriFieldType.esriFieldTypeString: this.cboRelatingField.Properties.Items.Add(field.Name); break; } } } if (this.cboRelatingField.Properties.Items.Count > 0) { this.cboRelatingField.SelectedIndex = 0; } if (this.ibasicMap_0 != null) { ITable attributeTable; ILayer layer = null; for (num = 0; num < this.ibasicMap_0.LayerCount; num++) { layer = this.ibasicMap_0.get_Layer(num); if (layer != this.itable_0) { if (layer is IAttributeTable) { attributeTable = (layer as IAttributeTable).AttributeTable; this.cboRelatingTable.Properties.Items.Add(new ObjectWrap(layer)); } else if (layer is ICompositeLayer) { this.method_0(layer as ICompositeLayer); } } } ITableCollection tables = this.ibasicMap_0 as ITableCollection; for (num = 0; num < tables.TableCount; num++) { attributeTable = tables.get_Table(num); this.cboRelatingTable.Properties.Items.Add(new ObjectWrap(attributeTable)); } if (this.cboRelatingTable.Properties.Items.Count > 0) { this.cboRelatingTable.SelectedIndex = 0; } } } }
public static Task <ITable[]> GetRandomTablesAsync(this ITableCollection tableCollection, Func <ITable, bool> predicate) { return(GetRandomTablesAsync(tableCollection, TableFlags.None, predicate)); }
public static Task <ITable[]> GetRandomTablesAsync(this ITableCollection tableCollection, TableFlags tableFlags) { return(GetRandomTablesAsync(tableCollection, tableFlags, DefaultPredicate)); }
public static Task <string> GenerateNewTableNameAsync(this ITableCollection tableCollection, string tableName) { return(tableCollection.Dispatcher.InvokeAsync(() => NameUtility.GenerateNewName(tableName, tableCollection.Select(item => item.Name)))); }
public static Task <string> GenerateNewTableNameAsync(this ITableCollection tableCollection) { return(GenerateNewTableNameAsync(tableCollection, "Table")); }
public static Task <ITable[]> GetTablesAsync(this ITableCollection tableCollection) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.ToArray())); }
public static Task <int> GetCountAsync(this ITableCollection tableCollection) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.Count)); }
public static Task <bool> ContainsAsync(this ITableCollection tableCollection, string tableName) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.Contains(tableName))); }
public static Task <ITable> GetRandomTableAsync(this ITableCollection tableCollection, TableFlags tableFlags, Func <ITable, bool> predicate) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.RandomOrDefault(item => TableFlagsUtility.Test(item, tableFlags) == true && predicate(item) == true))); }
public static Task AddTablesDeletedAsync(this ITableCollection tableCollection, ItemsDeletedEventHandler <ITable> handler) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.TablesDeleted += handler)); }
public static Task <ITable> GetTableAsync(this ITableCollection tableCollection, string tableName) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection[tableName])); }
public static Task RemoveTablesCreatedAsync(this ITableCollection tableCollection, ItemsCreatedEventHandler <ITable> handler) { return(tableCollection.Dispatcher.InvokeAsync(() => tableCollection.TablesCreated -= handler)); }