public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (service != null && context.Instance is CustomObject)
            {
                var customObject = context.Instance as CustomObject;
                
                var valueAsString = value as string;
                // ReSharper disable SuspiciousTypeConversion.Global
                var gridItem = provider as GridItem;
                // ReSharper restore SuspiciousTypeConversion.Global
                

                var propertyName = "Value";
                if (gridItem != null)
                {
                    propertyName = gridItem.Label;
                    if (customObject.Properties.All(p => p.Name != gridItem.Label && p.Type != typeof(string)))
                    {
                        return string.Empty;
                    }
                }
                using (var form = new TextForm(string.Format("Edit {0}", propertyName), propertyName, valueAsString, true))
                {
                    form.Size = new Size(600, 320);
                    if (service.ShowDialog(form) == DialogResult.OK)
                    {
                        value = form.Content;
                    }
                }
            }
            // ReSharper disable AssignNullToNotNullAttribute
            return value;
            // ReSharper restore AssignNullToNotNullAttribute
        } 
        private void btnOpenUserMetadataForm_Click(object sender, EventArgs e)
        {
            var form = new TextForm(UserMetadata, txtUserMetadata.Text);

            if (form.ShowDialog() == DialogResult.OK)
            {
                txtUserMetadata.Text = form.Content;
            }
        }
        private void btnOpenActionForm_Click(object sender, EventArgs e)
        {
            var form = new TextForm(ActionExpression, txtAction.Text);

            if (form.ShowDialog() == DialogResult.OK)
            {
                txtAction.Text = form.Content;
            }
        }
        private void openOpenFilterForm_Click(object sender, EventArgs e)
        {
            var form = new TextForm(FilterExpression, txtFilter.Text);

            if (form.ShowDialog() == DialogResult.OK)
            {
                txtFilter.Text = form.Content;
            }
        }
 private void btnOpen_Click(object sender, EventArgs e)
 {
     using (var form = new TextForm(MessageTextTitle, txtMessageText.Text))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             txtMessageText.Text = form.Content;
         }
     }
 }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            var service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (service != null && context.Instance is CustomObject)
            {
                var customObject = context.Instance as CustomObject;

                var valueAsString = value as string;
                // ReSharper disable SuspiciousTypeConversion.Global
                var gridItem = provider as GridItem;
                // ReSharper restore SuspiciousTypeConversion.Global


                var propertyName = "Value";
                if (gridItem != null)
                {
                    propertyName = gridItem.Label;
                    if (customObject.Properties.All(p => p.Name != gridItem.Label && p.Type != typeof(string)))
                    {
                        return(string.Empty);
                    }
                }
                using (var form = new TextForm(string.Format("Edit {0}", propertyName), propertyName, valueAsString, true))
                {
                    form.Size = new Size(600, 320);
                    if (service.ShowDialog(form) == DialogResult.OK)
                    {
                        value = form.Content;
                    }
                }
            }
            // ReSharper disable AssignNullToNotNullAttribute
            return(value);
            // ReSharper restore AssignNullToNotNullAttribute
        }
 private void btnOpenUserMetadataForm_Click(object sender, EventArgs e)
 {
     using (var form = new TextForm(UserMetadata, txtUserMetadata.Text))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             txtUserMetadata.Text = form.Content;
         }
     }
 }
 private void pictFindDeadletter_Click(object sender, EventArgs e)
 {
     try
     {
         deadletterDataGridView.SuspendDrawing();
         deadletterDataGridView.SuspendLayout();
         if (deadletterBindingList == null)
         {
             return;
         }
         using (var form = new TextForm(FilterExpressionTitle, FilterExpressionLabel, deadletterFilterExpression))
         {
             form.Size = new Size(600, 200);
             if (form.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             deadletterFilterExpression = form.Content;
             if (string.IsNullOrWhiteSpace(deadletterFilterExpression))
             {
                 deadletterBindingSource.DataSource = deadletterBindingList;
                 deadletterDataGridView.DataSource = deadletterBindingSource;
                 writeToLog(FilterExpressionRemovedMessage);
             }
             else
             {
                 Filter filter;
                 try
                 {
                     var sqlFilter = new SqlFilter(deadletterFilterExpression);
                     sqlFilter.Validate();
                     filter = sqlFilter.Preprocess();
                 }
                 catch (Exception ex)
                 {
                     writeToLog(string.Format(FilterExpressionNotValidMessage, deadletterFilterExpression, ex.Message));
                     return;
                 }
                 var filteredList = deadletterBindingList.Where(filter.Match).ToList();
                 var bindingList = new SortableBindingList<BrokeredMessage>(filteredList)
                 {
                     AllowEdit = false,
                     AllowNew = false,
                     AllowRemove = false
                 };
                 deadletterBindingSource.DataSource = bindingList;
                 deadletterDataGridView.DataSource = deadletterBindingSource;
                 writeToLog(string.Format(FilterExpressionAppliedMessage, deadletterFilterExpression, bindingList.Count));
             }
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
     finally
     {
         deadletterDataGridView.ResumeLayout();
         deadletterDataGridView.ResumeDrawing();
     }
 }
 private void btnOpenActionForm_Click(object sender, EventArgs e)
 {
     using (var form = new TextForm(ActionExpression, txtAction.Text))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             txtAction.Text = form.Content;
         }
     }
 }
 private void openOpenFilterForm_Click(object sender, EventArgs e)
 {
     using (var form = new TextForm(FilterExpression, txtFilter.Text))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             txtFilter.Text = form.Content;
         }
     }
 }
Example #11
0
 private void btnOpen_Click(object sender, EventArgs e)
 {
     using (var form = new TextForm(MessageTextTitle, txtMessageText.Text))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             txtMessageText.Text = form.Content;
         }
     }
 }
 private void pictFindRegistrations_Click(object sender, EventArgs e)
 {
     try
     {
         registrationsDataGridView.SuspendDrawing();
         registrationsDataGridView.SuspendLayout();
         if (registrationPageList == null || registrationPageList.Count == 0)
         {
             return;
         }
         using (var form = new TextForm(FilterExpressionTitle, FilterExpressionLabel, registrationsFilterExpression))
         {
             form.Size = new Size(600, 200);
             if (form.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             registrationsFilterExpression = form.Content;
             if (string.IsNullOrWhiteSpace(registrationsFilterExpression))
             {
                 currentRegistrationPage = 0;
                 SetRegistrationPage();
                 writeToLog(FilterExpressionRemovedMessage);
             }
             else
             {
                 IEnumerable<RegistrationDescription> filteredCollection;
                 try
                 {
                     var expressionBuilder = new ExpressionBuilder<RegistrationDescription>();
                     var predicate = expressionBuilder.GetExpression(registrationsFilterExpression).Compile();
                     filteredCollection = registrationPageList.SelectMany(rd => rd).Where(predicate).ToList();
                 }
                 catch (Exception ex)
                 {
                     writeToLog(string.Format(FilterExpressionNotValidMessage, registrationsFilterExpression));
                     HandleException(ex);
                     return;
                 }
                 RegistrationInfo.SetRegistrations(filteredCollection);
                 var bindingList = new SortableBindingList<RegistrationInfo>(RegistrationInfo.Registrations)
                 {
                     AllowEdit = false,
                     AllowNew = false,
                     AllowRemove = false
                 };
                 registrationsBindingSource.DataSource = bindingList;
                 registrationsDataGridView.DataSource = registrationsBindingSource;
                 writeToLog(string.Format(FilterExpressionAppliedMessage, registrationsFilterExpression, bindingList.Count));
             }
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
     finally
     {
         registrationsDataGridView.ResumeLayout();
         registrationsDataGridView.ResumeDrawing();
     }
 }