Example #1
0
        /// <summary>
        /// Shows a dialog box with a property grid.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static DialogResult Show(string title, ref Entity_cl value)
        {
            Form mForm = new Form();
            PropertyGrid mPropertyGrid = new PropertyGrid();
            Button mOKButton = new Button();

            mForm.Text = title + " Properties";
            mPropertyGrid.SelectedObject = value;
            mOKButton.Text = "OK";
            mOKButton.DialogResult = DialogResult.OK;

            mForm.ClientSize = new Size(320, 320);
            mPropertyGrid.SetBounds(4, 4, mForm.ClientSize.Width - 4, mForm.ClientSize.Height - 40);
            mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, mForm.ClientSize.Height - 36, 64, 22);

            mPropertyGrid.Anchor = AnchorStyles.Top;
            mOKButton.Anchor = AnchorStyles.Bottom;

            mForm.Controls.AddRange(new Control[] { mPropertyGrid, mOKButton });
            mForm.FormBorderStyle = FormBorderStyle.FixedSingle;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.AcceptButton = mOKButton;

            DialogResult dialogResult = mForm.ShowDialog();
            return dialogResult;
        }
        private void InitializeComponent()
        {
            _btnOK             = new Button();
            _btnCancel         = new Button();
            _btnUp             = new Button();
            _btnDown           = new Button();
            _btnAdd            = new Button();
            _btnRemove         = new Button();

            _txtType           = new TextBox();
            _tvDefinedStyles   = new TreeView();
            _lvAvailableStyles = new ListView();
            _samplePreview     = new MSHTMLHost();
            _propertyBrowser   = new PropertyGrid();
            _cntxtMenuItem     = new MenuItem();
            _cntxtMenu         = new ContextMenu();

            GroupLabel grplblStyleList = new GroupLabel();
            grplblStyleList.SetBounds(6, 5, 432, 16);
            grplblStyleList.Text = SR.GetString(SR.StylesEditorDialog_StyleListGroupLabel);
            grplblStyleList.TabStop = false;
            grplblStyleList.TabIndex = 0;

            Label lblAvailableStyles = new Label();
            lblAvailableStyles.SetBounds(14, 25, 180, 16);
            lblAvailableStyles.Text = SR.GetString(SR.StylesEditorDialog_AvailableStylesCaption);
            lblAvailableStyles.TabStop = false;
            lblAvailableStyles.TabIndex = 1;

            ColumnHeader chStyleType = new System.Windows.Forms.ColumnHeader();
            ColumnHeader chStyleNamespace = new System.Windows.Forms.ColumnHeader();

            chStyleType.Width = 16;
            chStyleType.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
            chStyleNamespace.Width = 16;
            chStyleNamespace.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;

            _lvAvailableStyles.SetBounds(14, 41, 180, 95);
            _lvAvailableStyles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
            _lvAvailableStyles.MultiSelect = false;
            _lvAvailableStyles.HideSelection = false;
            _lvAvailableStyles.FullRowSelect = true;
            _lvAvailableStyles.View = System.Windows.Forms.View.Details;
            _lvAvailableStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] {chStyleType, chStyleNamespace});
            _lvAvailableStyles.SelectedIndexChanged += new EventHandler(this.OnNewStyleTypeChanged);
            _lvAvailableStyles.DoubleClick += new EventHandler(this.OnDoubleClick);
            _lvAvailableStyles.Sorting = SortOrder.Ascending;
            _lvAvailableStyles.TabIndex = 2;
            _lvAvailableStyles.TabStop = true;

            _btnAdd.AccessibleName = SR.GetString(SR.EditableTreeList_AddName);
            _btnAdd.AccessibleDescription = SR.GetString(SR.EditableTreeList_AddDescription);
            _btnAdd.Name = SR.GetString(SR.EditableTreeList_AddName);
            _btnAdd.SetBounds(198, 77, 32, 25);
            _btnAdd.Text = SR.GetString(SR.StylesEditorDialog_AddBtnCation);
            _btnAdd.Click += new EventHandler(this.OnClickAddButton);
            _btnAdd.TabIndex = 3;
            _btnAdd.TabStop = true;

            Label lblDefinedStyles = new Label();
            lblDefinedStyles.SetBounds(234, 25, 166, 16);
            lblDefinedStyles.Text = SR.GetString(SR.StylesEditorDialog_DefinedStylesCaption);
            lblDefinedStyles.TabStop = false;
            lblDefinedStyles.TabIndex = 4;;

            _tvDefinedStyles.SetBounds(234, 41, 166, 95);
            _tvDefinedStyles.AfterSelect += new TreeViewEventHandler(OnStylesSelected);
            _tvDefinedStyles.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit);
            _tvDefinedStyles.LabelEdit = true;
            _tvDefinedStyles.ShowPlusMinus = false;
            _tvDefinedStyles.HideSelection = false;
            _tvDefinedStyles.Indent = 15;
            _tvDefinedStyles.ShowRootLines = false;
            _tvDefinedStyles.ShowLines = false;
            _tvDefinedStyles.ContextMenu = _cntxtMenu;
            _tvDefinedStyles.TabIndex = 5;
            _tvDefinedStyles.TabStop = true;
            _tvDefinedStyles.KeyDown += new KeyEventHandler(OnKeyDown);
            _tvDefinedStyles.MouseUp += new MouseEventHandler(OnListMouseUp);
            _tvDefinedStyles.MouseDown += new MouseEventHandler(OnListMouseDown);

            _btnUp.AccessibleName = SR.GetString(SR.EditableTreeList_MoveUpName);
            _btnUp.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveUpDescription);
            _btnUp.Name = SR.GetString(SR.EditableTreeList_MoveUpName);
            _btnUp.SetBounds(404, 41, 28, 27);
            _btnUp.Click += new EventHandler(this.OnClickUpButton);
            _btnUp.Image = GenericUI.SortUpIcon; 
            _btnUp.TabIndex = 6;
            _btnUp.TabStop = true;

            _btnDown.AccessibleName = SR.GetString(SR.EditableTreeList_MoveDownName);
            _btnDown.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveDownDescription);
            _btnDown.Name = SR.GetString(SR.EditableTreeList_MoveDownName);
            _btnDown.SetBounds(404, 72, 28, 27);
            _btnDown.Click += new EventHandler(this.OnClickDownButton);
            _btnDown.Image = GenericUI.SortDownIcon;
            _btnDown.TabIndex = 7;
            _btnDown.TabStop = true;

            _btnRemove.AccessibleName = SR.GetString(SR.EditableTreeList_DeleteName);
            _btnRemove.AccessibleDescription = SR.GetString(SR.EditableTreeList_DeleteDescription);
            _btnRemove.Name = SR.GetString(SR.EditableTreeList_DeleteName);
            _btnRemove.SetBounds(404, 109, 28, 27);
            _btnRemove.Click += new EventHandler(this.OnClickRemoveButton);
            _btnRemove.Image = GenericUI.DeleteIcon;
            _btnRemove.TabIndex = 8;
            _btnRemove.TabStop = true;

            GroupLabel grplblStyleProperties = new GroupLabel();
            grplblStyleProperties.SetBounds(6, 145, 432, 16);
            grplblStyleProperties.Text = SR.GetString(SR.StylesEditorDialog_StylePropertiesGroupLabel);
            grplblStyleProperties.TabStop = false;
            grplblStyleProperties.TabIndex = 9;

            Label lblType = new Label();
            lblType.SetBounds(14, 165, 180, 16);
            lblType.Text = SR.GetString(SR.StylesEditorDialog_TypeCaption);
            lblType.TabIndex = 10;
            lblType.TabStop = false;

            _txtType.SetBounds(14, 181, 180, 16);
            _txtType.ReadOnly = true;
            _txtType.TabIndex = 11;
            _txtType.TabStop = true;

            Label lblSample = new Label();
            lblSample.SetBounds(14, 213, 180, 16);
            lblSample.Text = SR.GetString(SR.StylesEditorDialog_SampleCaption);
            lblSample.TabStop = false;
            lblSample.TabIndex = 12;

            _samplePreview.SetBounds(14, 229, 180, 76);
            _samplePreview.TabStop = false;
            _samplePreview.TabIndex = 13;

            Label lblProperties = new Label();
            lblProperties.SetBounds(234, 165, 198, 16);
            lblProperties.Text = SR.GetString(SR.StylesEditorDialog_PropertiesCaption);
            lblProperties.TabIndex = 14;
            lblProperties.TabStop = false;

            _propertyBrowser.SetBounds(234, 181, 198, 178);
            _propertyBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;
            _propertyBrowser.ToolbarVisible = false;
            _propertyBrowser.HelpVisible = false;
            _propertyBrowser.TabIndex = 15;
            _propertyBrowser.TabStop = true;
            _propertyBrowser.PropertySort = PropertySort.Alphabetical;
            _propertyBrowser.PropertyValueChanged += new PropertyValueChangedEventHandler(this.OnPropertyValueChanged);

            _btnOK.DialogResult = DialogResult.OK;
            _btnOK.Location = new System.Drawing.Point(282, 370);
            _btnOK.Size = new System.Drawing.Size(75, 23);
            _btnOK.TabIndex = 16;
            _btnOK.Text = SR.GetString(SR.GenericDialog_OKBtnCaption);
            _btnOK.Click += new EventHandler(this.OnClickOKButton);

            _btnCancel.DialogResult = DialogResult.Cancel;
            _btnCancel.Location = new System.Drawing.Point(363, 370);
            _btnCancel.Size = new System.Drawing.Size(75, 23);
            _btnCancel.TabIndex = 17;
            _btnCancel.Text = SR.GetString(SR.GenericDialog_CancelBtnCaption);

            _cntxtMenuItem.Text = SR.GetString(SR.EditableTreeList_Rename);
            _cntxtMenu.MenuItems.Add(_cntxtMenuItem);
            _cntxtMenu.Popup += new EventHandler(OnPopup);
            _cntxtMenuItem.Click += new EventHandler(OnContextMenuItemClick);

            GenericUI.InitDialog(this, _styleSheet.Site);

            this.Text = _styleSheet.ID + " - " + SR.GetString(SR.StylesEditorDialog_Title);
            this.ClientSize = new Size(444, 401);
            this.AcceptButton = _btnOK;
            this.CancelButton = _btnCancel;
            this.Activated += new System.EventHandler(StylesEditorDialog_Activated);
            this.Controls.AddRange(new Control[]
                           {
                               grplblStyleList,
                               lblAvailableStyles,
                               _lvAvailableStyles,
                               _btnAdd,
                               lblDefinedStyles,
                               _tvDefinedStyles,
                               _btnUp,
                               _btnDown,
                               _btnRemove,
                               grplblStyleProperties,
                               lblType,
                               _txtType,
                               lblSample,
                               _samplePreview,
                               lblProperties,
                               _propertyBrowser,
                               _btnOK,
                               _btnCancel,
                           });
        }