public void LoadEntities() { // Loads listview header column for entities ListViewColumnHelper.AddColumnsHeader(entityListView, typeof(EntityMetadataInfo), ListViewColumnsSettings.EntityFirstColumns, lvcSettings.EntitySelectedAttributes, ListViewColumnsSettings.EntityAttributesToIgnore); WorkAsync("Loading Entities...", e => { // Search for all entities metadata var request = new RetrieveAllEntitiesRequest { EntityFilters = EntityFilters.Entity }; var response = (RetrieveAllEntitiesResponse)Service.Execute(request); currentAllMetadata = response.EntityMetadata; // return listview items e.Result = BuildEntityItems(currentAllMetadata.ToList()); }, e => { entityListView.Items.Clear(); // Add listview items to listview entityListView.Items.AddRange(((List <ListViewItem>)e.Result).ToArray()); }); }
public EntityPropertiesControl(EntityMetadata emd, ListViewColumnsSettings lvcSettings, ConnectionDetail connectionDetail) { InitializeComponent(); if (new Version(connectionDetail.OrganizationVersion) < new Version(7, 1)) { // Hide Keys tab if under CRM 2015 Update 1 tabControl1.TabPages.Remove(tabPage7); } this.emd = emd; this.connectionDetail = connectionDetail; this.lvcSettings = (ListViewColumnsSettings)lvcSettings.Clone(); ListViewColumnHelper.AddColumnsHeader(attributeListView, typeof(AttributeMetadataInfo), ListViewColumnsSettings.AttributeFirstColumns, this.lvcSettings.AttributeSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(OneToManyListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.OtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(manyToOneListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.OtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(manyToManyListView, typeof(ManyToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.MtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(privilegeListView, typeof(SecurityPrivilegeInfo), ListViewColumnsSettings.PrivFirstColumns, this.lvcSettings.PrivSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(keyListView, typeof(KeyMetadataInfo), ListViewColumnsSettings.KeyFirstColumns, this.lvcSettings.KeySelectedAttributes, new string[] { }); attributesSplitContainer.Panel2Collapsed = true; manyToManySplitContainer.Panel2Collapsed = true; manyToOneSplitContainer.Panel2Collapsed = true; oneToManySplitContainer.Panel2Collapsed = true; privilegeSplitContainer.Panel2Collapsed = true; keySplitContainer.Panel2Collapsed = true; RefreshContent(emd); }
private void tsbColumns_Click(object sender, EventArgs e) { switch (((ToolStripButton)sender).Name) { case "tsbEntityColumns": { var dialog = new ColumnSelector(typeof(EntityMetadataInfo), ListViewColumnsSettings.EntityFirstColumns, ListViewColumnsSettings.EntityAttributesToIgnore, lvcSettings.EntitySelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.EntitySelectedAttributes = dialog.UpdatedCurrentAttributes; entityListView.Columns.Clear(); entityListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(entityListView, typeof(EntityMetadataInfo), ListViewColumnsSettings.EntityFirstColumns, lvcSettings.EntitySelectedAttributes, ListViewColumnsSettings.EntityAttributesToIgnore); entityListView.Items.AddRange(BuildEntityItems(currentAllMetadata).ToArray()); } } break; default: { MessageBox.Show(this, "Unexpected source for hiding panels"); } break; } try { lvcSettings.SaveSettings(); foreach (TabPage page in mainTabControl.TabPages) { if (page.TabIndex == 0) { continue; } ((EntityPropertiesControl)page.Controls[0]).RefreshColumns(lvcSettings); } } catch (UnauthorizedAccessException error) { MessageBox.Show(this, "An error occured while trying to save your settings: " + error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void RefreshColumns(ListViewColumnsSettings lvcUpdatedSettings) { if (lvcSettings.AttributeSelectedAttributes != lvcUpdatedSettings.AttributeSelectedAttributes) { lvcSettings.AttributeSelectedAttributes = (string[])lvcUpdatedSettings.AttributeSelectedAttributes.Clone(); attributeListView.Columns.Clear(); ListViewColumnHelper.AddColumnsHeader(attributeListView, typeof(AttributeMetadataInfo), ListViewColumnsSettings.AttributeFirstColumns, lvcSettings.AttributeSelectedAttributes, new string[] { }); LoadAttributes(emd.Attributes); } if (lvcSettings.OtmRelSelectedAttributes != lvcUpdatedSettings.OtmRelSelectedAttributes) { lvcSettings.OtmRelSelectedAttributes = (string[])lvcUpdatedSettings.OtmRelSelectedAttributes.Clone(); OneToManyListView.Columns.Clear(); manyToOneListView.Columns.Clear(); ListViewColumnHelper.AddColumnsHeader(OneToManyListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.OtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(manyToOneListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.OtmRelSelectedAttributes, new string[] { }); LoadOneToManyRelationships(emd.OneToManyRelationships); LoadManyToOneRelationships(emd.ManyToOneRelationships); } if (lvcSettings.MtmRelSelectedAttributes != lvcUpdatedSettings.MtmRelSelectedAttributes) { lvcSettings.MtmRelSelectedAttributes = (string[])lvcUpdatedSettings.MtmRelSelectedAttributes.Clone(); manyToManyListView.Columns.Clear(); ListViewColumnHelper.AddColumnsHeader(manyToManyListView, typeof(ManyToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.MtmRelSelectedAttributes, new string[] { }); LoadManyToManyRelationships(emd.ManyToManyRelationships); } if (lvcSettings.PrivSelectedAttributes != lvcUpdatedSettings.PrivSelectedAttributes) { lvcSettings.PrivSelectedAttributes = (string[])lvcUpdatedSettings.PrivSelectedAttributes.Clone(); privilegeListView.Columns.Clear(); ListViewColumnHelper.AddColumnsHeader(privilegeListView, typeof(SecurityPrivilegeInfo), ListViewColumnsSettings.PrivFirstColumns, lvcSettings.PrivSelectedAttributes, new string[] { }); LoadPrivileges(emd.Privileges); } if (lvcSettings.KeySelectedAttributes != lvcUpdatedSettings.KeySelectedAttributes) { lvcSettings.KeySelectedAttributes = (string[])lvcUpdatedSettings.KeySelectedAttributes.Clone(); keyListView.Columns.Clear(); ListViewColumnHelper.AddColumnsHeader(keyListView, typeof(KeyMetadataInfo), ListViewColumnsSettings.KeyFirstColumns, lvcSettings.KeySelectedAttributes, new string[] { }); LoadKeys(emd.Keys); } lvcSettings = lvcUpdatedSettings; }
public MainControl() { InitializeComponent(); lvcSettings = ListViewColumnsSettings.LoadSettings(); if (initialLoading) { // Loads listview header column for entities ListViewColumnHelper.AddColumnsHeader(entityListView, typeof(EntityMetadataInfo), ListViewColumnsSettings.EntityFirstColumns, lvcSettings.EntitySelectedAttributes, ListViewColumnsSettings.EntityAttributesToIgnore); initialLoading = false; } this.Enter += MainControl_Enter; }
public EntityPropertiesControl(EntityMetadata emd, ListViewColumnsSettings lvcSettings) { InitializeComponent(); this.emd = emd; this.lvcSettings = (ListViewColumnsSettings)lvcSettings.Clone(); ListViewColumnHelper.AddColumnsHeader(attributeListView, typeof(AttributeMetadataInfo), ListViewColumnsSettings.AttributeFirstColumns, this.lvcSettings.AttributeSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(OneToManyListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.OtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(manyToOneListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.OtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(manyToManyListView, typeof(ManyToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, this.lvcSettings.MtmRelSelectedAttributes, new string[] { }); ListViewColumnHelper.AddColumnsHeader(privilegeListView, typeof(SecurityPrivilegeInfo), ListViewColumnsSettings.PrivFirstColumns, this.lvcSettings.PrivSelectedAttributes, new string[] { }); attributesSplitContainer.Panel2Collapsed = true; manyToManySplitContainer.Panel2Collapsed = true; manyToOneSplitContainer.Panel2Collapsed = true; oneToManySplitContainer.Panel2Collapsed = true; privilegeSplitContainer.Panel2Collapsed = true; RefreshContent(emd); }
private void tsbColumns_Click(object sender, EventArgs e) { switch (((ToolStripButton)sender).Name) { case "tsbAttributeColumns": { var dialog = new ColumnSelector(typeof(AttributeMetadataInfo), ListViewColumnsSettings.AttributeFirstColumns, new string[] { }, lvcSettings.AttributeSelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.AttributeSelectedAttributes = dialog.UpdatedCurrentAttributes; attributeListView.Columns.Clear(); attributeListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(attributeListView, typeof(AttributeMetadataInfo), ListViewColumnsSettings.AttributeFirstColumns, lvcSettings.AttributeSelectedAttributes, new string[] { }); LoadAttributes(emd.Attributes); } } break; case "tsbOneToManyColumns": { var dialog = new ColumnSelector(typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, new string[] { }, lvcSettings.OtmRelSelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.OtmRelSelectedAttributes = dialog.UpdatedCurrentAttributes; OneToManyListView.Columns.Clear(); OneToManyListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(OneToManyListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.OtmRelSelectedAttributes, new string[] { }); LoadOneToManyRelationships(emd.OneToManyRelationships); } } break; case "tsbManyToOneColumns": { var dialog = new ColumnSelector(typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, new string[] { }, lvcSettings.OtmRelSelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.OtmRelSelectedAttributes = dialog.UpdatedCurrentAttributes; manyToOneListView.Columns.Clear(); manyToOneListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(manyToOneListView, typeof(OneToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.OtmRelSelectedAttributes, new string[] { }); LoadManyToOneRelationships(emd.ManyToOneRelationships); } } break; case "tsbManyToManyColumns": { var dialog = new ColumnSelector(typeof(ManyToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, new string[] { }, lvcSettings.MtmRelSelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.MtmRelSelectedAttributes = dialog.UpdatedCurrentAttributes; manyToManyListView.Columns.Clear(); manyToManyListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(manyToManyListView, typeof(ManyToManyRelationshipMetadataInfo), ListViewColumnsSettings.RelFirstColumns, lvcSettings.MtmRelSelectedAttributes, new string[] { }); LoadManyToManyRelationships(emd.ManyToManyRelationships); } } break; case "tsbPrivilegeColumns": { var dialog = new ColumnSelector(typeof(SecurityPrivilegeInfo), ListViewColumnsSettings.PrivFirstColumns, new string[] { }, lvcSettings.PrivSelectedAttributes); if (dialog.ShowDialog(this) == DialogResult.OK) { lvcSettings.PrivSelectedAttributes = dialog.UpdatedCurrentAttributes; privilegeListView.Columns.Clear(); privilegeListView.Items.Clear(); ListViewColumnHelper.AddColumnsHeader(privilegeListView, typeof(SecurityPrivilegeInfo), ListViewColumnsSettings.PrivFirstColumns, lvcSettings.PrivSelectedAttributes, new string[] { }); LoadPrivileges(emd.Privileges); } } break; default: { MessageBox.Show(this, "Unexpected source for hiding panels"); } break; } RaiseOnColumnSettingsUpdated(new ColumnSettingsUpdatedEventArgs { Settings = lvcSettings, Control = this }); }