コード例 #1
0
        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});
        }
コード例 #2
0
ファイル: MainControl.cs プロジェクト: KingRider/XrmToolBox
        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);
            }
        }