Example #1
0
        /// <summary>Enables or disables all buttons on the form</summary>
        /// <param name="enabled"></param>
        internal void EnableControls(bool enabled)
        {
            MethodInvoker mi = delegate
            {
                try
                {
                    tsbNew.Enabled            = enabled;
                    tsbOpen.Enabled           = enabled;
                    tsmiOpenFile.Enabled      = enabled;
                    tsmiOpenView.Enabled      = enabled && Service != null;
                    tsmiOpenML.Visible        = enabled && Service != null && GetEntity("list") != null;
                    tsmiOpenCWP.Visible       = enabled && Service != null && GetEntity("cint_feed") != null;
                    tsbReturnToCaller.Visible = CallerWantsResults();
                    tsbSave.Enabled           = enabled;
                    tsmiSaveFile.Enabled      = enabled && dockControlBuilder?.FetchChanged == true && !string.IsNullOrEmpty(FileName);
                    tsmiSaveFileAs.Enabled    = enabled;
                    tsmiSaveView.Enabled      = enabled && Service != null && View != null && View.IsCustomizable();
                    tsmiSaveViewAs.Enabled    = enabled && Service != null && (tsmiSaveView.Enabled || settings.Results.WorkWithLayout);
                    tsmiSaveML.Enabled        = enabled && Service != null && DynML != null;
                    tsmiSaveCWP.Visible       = enabled && Service != null && GetEntity("cint_feed") != null;
                    tsmiSaveCWP.Enabled       = enabled && Service != null && dockControlBuilder?.FetchChanged == true && !string.IsNullOrEmpty(CWPFeed);
                    tsbView.Enabled           = enabled;
                    tsbExecute.Enabled        = enabled && Service != null;
                    tsmiSelect.Enabled        = enabled && Service != null;
                    tsbAbort.Visible          = settings.Results.RetrieveAllPages;
                    tsbBDU.Visible            = bduexists && callerArgs?.SourcePlugin != "Bulk Data Updater";
                    tsbBDU.Enabled            = enabled && (dockControlBuilder?.IsFetchAggregate() == false);
                    tsmiShowLayoutXML.Enabled = enabled && Service != null && (dockControlBuilder?.IsFetchAggregate() == false) && settings.Results.WorkWithLayout;
                    dockControlBuilder?.EnableControls(enabled);
                    buttonsEnabled = enabled;
                }
                catch
                {
                    // Now what?
                }
            };

            if (InvokeRequired)
            {
                Invoke(mi);
            }
            else
            {
                mi();
            }
        }
 private bool ValidateForm()
 {
     if (TreeBuilderControl.IsFetchAggregate(node))
     {
         if (string.IsNullOrWhiteSpace(txtAlias.Text))
         {
             MessageBox.Show("Alias must be specified in aggregate queries", "Condition error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             //txtAlias.Focus();
             return(false);
         }
     }
     return(true);
 }
 private void PopulateControls(TreeNode node, AttributeMetadata[] attributes)
 {
     cmbAttribute.Items.Clear();
     if (attributes != null)
     {
         foreach (var attribute in attributes)
         {
             AttributeItem.AddAttributeToComboBox(cmbAttribute, attribute, false, FetchXmlBuilder.friendlyNames);
         }
     }
     aggregate            = TreeBuilderControl.IsFetchAggregate(node);
     cmbAggregate.Enabled = aggregate;
     chkGroupBy.Enabled   = aggregate;
     if (!aggregate)
     {
         cmbAggregate.SelectedIndex = -1;
         chkGroupBy.Checked         = false;
     }
 }
        protected override ControlValidationResult ValidateControl(Control control)
        {
            if (control == cmbAttribute)
            {
                if (string.IsNullOrWhiteSpace(cmbAttribute.Text))
                {
                    return(new ControlValidationResult(ControlValidationLevel.Error, "Attribute is required"));
                }
                if (fxb.Service != null && !cmbAttribute.Items.OfType <AttributeItem>().Any(a => a.ToString() == cmbAttribute.Text))
                {
                    return(new ControlValidationResult(ControlValidationLevel.Warning, "Attribute is not valid"));
                }
            }
            else if (control == txtAlias)
            {
                if (TreeBuilderControl.IsFetchAggregate(Node) && string.IsNullOrWhiteSpace(txtAlias.Text))
                {
                    return(new ControlValidationResult(ControlValidationLevel.Error, "Alias must be specified in aggregate queries"));
                }
            }

            return(base.ValidateControl(control));
        }
        protected override void PopulateControls()
        {
            var aggregate = TreeBuilderControl.IsFetchAggregate(Node);

            if (!aggregate)
            {
                cmbAttribute.Items.Clear();
                if (attributes != null)
                {
                    foreach (var attribute in attributes)
                    {
                        AttributeItem.AddAttributeToComboBox(cmbAttribute, attribute, false, friendly);
                    }
                }
            }
            else
            {
                cmbAlias.Items.Clear();
                cmbAlias.Items.Add("");
                cmbAlias.Items.AddRange(GetAliases(Tree.tvFetch.Nodes[0]).ToArray());
            }
            cmbAttribute.Enabled = !aggregate;
            cmbAlias.Enabled     = aggregate;
        }