Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ListEditorForm"/> class.
        /// </summary>
        /// <param name="initValue">The init value.</param>
        /// <param name="propertyType">Type of the property.</param>
        /// <param name="context">The context.</param>
        /// <param name="readOnly">Cannot add/remove data</param>
        public ListEditorForm(
            [CanBeNull] IList initValue,
            [NotNull] Type propertyType,
            [NotNull] ITypeDescriptorContext context,
            bool readOnly)
        {
            InitializeComponent();

            var formStateManager = new FormStateManager <ListEditorFormState>(this);

            formStateManager.RestoreState();
            FormClosed += delegate { formStateManager.SaveState(); };

            // _initValue = initValue;
            PropertyType = propertyType;
            Context      = context;
            _readOnly    = readOnly;

            _propertyGrid.ToolbarVisible = false;

            var sourceTable = new DataTable();

            sourceTable.Columns.Add(_positionColumnName, typeof(int));
            sourceTable.Columns.Add(_itemColumnName, PropertyType);

            columnPosition.DataPropertyName = _positionColumnName;
            columnItem.DataPropertyName     = _itemColumnName;

            if (initValue != null)
            {
                for (var i = 0; i < initValue.Count; i++)
                {
                    sourceTable.Rows.Add(i + 1, initValue[i]);
                }
            }

            _sourceView = new DataView(sourceTable)
            {
                AllowDelete = false,
                AllowNew    = false,
                Sort        = _positionColumnName
            };

            _dataGridView.DataSource = _sourceView;
            _suspend = false;

            string displayName = Assert.NotNull(context.PropertyDescriptor).DisplayName;

            _attributeName = displayName.Trim('[').Trim(']');

            base.Text = $@"{_attributeName} Editor";

            _textBoxItem.Text        = _attributeName;
            _textBoxDescription.Text = context.PropertyDescriptor.Description;

            EnableButtons();
        }
Пример #2
0
        public WpfHostingWinForm([NotNull] UserControl wpfControl)
        {
            _wpfControl = wpfControl;

            InitializeComponent();

            string contextId = _wpfControl.GetType().Name;

            _formStateManager = new FormStateManager <FormState>(this, contextId);
            _formStateManager.RestoreState();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TypeFinderForm"/> class.
        /// </summary>
        /// <param name="allowMultiSelection">if set to <c>true</c> the form allows to select
        /// multiple types. Otherwise only one can be selected.</param>
        /// <param name="targetType">Type of the target.</param>
        public TypeFinderForm(bool allowMultiSelection, [CanBeNull] Type targetType)
        {
            InitializeComponent();

            string contextID = targetType == null
                                                   ? string.Empty
                                                   : targetType.FullName;

            _formStateManager = new FormStateManager <TypeFinderFormState>(this, contextID);
            _formStateManager.RestoreState();

            _dataGridView.AutoGenerateColumns = false;
            _dataGridView.MultiSelect         = allowMultiSelection;

            _buttonSelectAll.Visible  = allowMultiSelection;
            _buttonSelectNone.Visible = allowMultiSelection;

            new DataGridViewFindController(_dataGridView, _dataGridViewFindToolStrip);
        }
Пример #4
0
        private FinderForm([NotNull] IEnumerable <ColumnDescriptor> columnDescriptors,
                           bool allowMultipleSelection              = false,
                           bool keepFindTextBetweenCalls            = true,
                           [CanBeNull] string filterSettingsContext = null)
        {
            Assert.ArgumentNotNull(columnDescriptors, nameof(columnDescriptors));

            InitializeComponent();

            KeepFindTextBetweenCalls = keepFindTextBetweenCalls;

            _toolStripStatusLabelMessage.Text = string.Empty;

            Type   type     = typeof(T);
            string typeName = Assert.NotNull(type.FullName,
                                             "type has no name: {0}", type);

            _formStateManager = new FormStateManager <FinderFormState>(this, typeName);

            _formStateManager.RestoreState();

            if (!StringUtils.IsNullOrEmptyOrBlank(filterSettingsContext))
            {
                _contextSettingsPersister = CreateContextSettingsPersister(typeName,
                                                                           filterSettingsContext);
                _restoredContextSpecificSettings = _contextSettingsPersister.Read();
            }

            _gridHandler = new BoundDataGridHandler <T>(
                _dataGridView,
                restoreSelectionAfterUserSort: true);
            _gridHandler.SelectionChanged += _gridHandler_SelectionChanged;

            // configure the datagrid
            _dataGridView.SuspendLayout();

            _dataGridView.MultiSelect = allowMultipleSelection;

            _gridHandler.AddColumns(columnDescriptors);

            _dataGridView.AutoGenerateColumns = false;

            _findController = new DataGridViewFindController(_dataGridView,
                                                             _dataGridViewFindToolStrip);
            _findController.FindResultChanged += _findController_FindResultChanged;

            if (allowMultipleSelection)
            {
                _toolStripButtonSelectFindResultRows =
                    new ToolStripButton(LocalizableStrings.FinderForm_SelectRows)
                {
                    Enabled      = false,
                    ImageScaling = ToolStripItemImageScaling.None,
                    Image        = Resources.SelectAll
                };

                _toolStripButtonSelectFindResultRows.Click +=
                    _toolStripButtonSelectFindResultRows_Click;

                _dataGridViewFindToolStrip.Items.Add(
                    _toolStripButtonSelectFindResultRows);
            }
        }
Пример #5
0
        private void QAVerificationForm_Load(object sender, EventArgs e)
        {
            // leads to errors in control designer when specified in control designer
            _splitContainerDetail.Panel2MinSize = 150;

            // restore in Load event due to splitter distance problem when maximized
            // http://social.msdn.microsoft.com/forums/en-US/winforms/thread/57f38145-b3b1-488d-8988-da8c397e4d80/
            _formStateManager.RestoreState();

            Color colorNoIssues  = Color.LightGreen;
            Color colorErrors    = Color.FromArgb(255, 100, 100);
            Color colorWarnings  = Color.Yellow;
            Color colorCancelled = Color.Orange;

            _textBoxSpecification.Text = _verification.SpecificationName;
            _textBoxDescription.Text   = _verification.SpecificationDescription;

            int right = _labelContext.Right;

            _labelContext.Text     = string.Format("{0}:", _contextType);
            _labelContext.Location = new Point(right - _labelContext.Width, _labelContext.Top);
            _textBoxContext.Text   = _contextName;

            _textBoxStartDate.Text = FormatDate(_verification.StartDate);
            _textBoxEndDate.Text   = FormatDate(_verification.EndDate);

            TimeSpan timeSpan = _verification.EndDate - _verification.StartDate;

            _textBoxTotalTime.Text = FormatTimeSpan(timeSpan);
            TimeSpan cpuTime = TimeSpan.FromSeconds(_verification.ProcessorTimeSeconds);

            _textBoxCPUTime.Text = FormatTimeSpan(cpuTime);

            _textBoxUser.Text = _verification.Operator;

            if (_verification.Fulfilled)
            {
                _textBoxVerificationStatus.Text =
                    LocalizableStrings.QualityVerificationStatusFulfilled;
                _textBoxVerificationStatus.BackColor = colorNoIssues;
            }
            else if (_verification.Cancelled)
            {
                _textBoxVerificationStatus.Text =
                    LocalizableStrings.QualityVerificationStatusCancelled;
                _textBoxVerificationStatus.BackColor = colorCancelled;
            }
            else
            {
                _textBoxVerificationStatus.Text =
                    LocalizableStrings.QualityVerificationStatusNotFulfilled;
                _textBoxVerificationStatus.BackColor = colorErrors;
            }

            int issueCount   = _verification.IssueCount;
            int warningCount = _verification.WarningCount;
            int errorCount   = _verification.ErrorCount;

            _textBoxIssueCount.Text = issueCount.ToString("N0");
            if (errorCount > 0)
            {
                _textBoxIssueCount.BackColor = colorErrors;
            }
            else if (warningCount > 0)
            {
                _textBoxIssueCount.BackColor = colorWarnings;
            }
            else
            {
                _textBoxIssueCount.BackColor = colorNoIssues;
            }

            _textBoxErrorCount.Text      = errorCount.ToString("N0");
            _textBoxErrorCount.BackColor = errorCount == 0
                                                               ? colorNoIssues
                                                               : colorErrors;

            _textBoxWarningCount.Text      = warningCount.ToString("N0");
            _textBoxWarningCount.BackColor = warningCount == 0
                                                                 ? colorNoIssues
                                                                 : colorWarnings;

            Render(SelectedDisplayMode);

            _loaded = true;
        }