Esempio n. 1
0
        void ReportError(string errorMessage)
        {
            // Invoking error message box will cause LostFocus of the control.
            // Thus we need to disable LostFocus first and then add the handlers back.
            DisableKeyboardLostFocus();
            ErrorReporting.ShowErrorMessage(errorMessage);

            this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
            {
                if (this.ErrorCallback != null)
                {
                    this.ErrorCallback(this);
                    this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                    {
                        RegainFocus();
                        EnableKeyboardLostFocus();
                    }));
                }
                else
                {
                    RegainFocus();
                    EnableKeyboardLostFocus();
                }
            }));
        }
Esempio n. 2
0
 void OnNewKeyCommitted(object sender, RoutedEventArgs e)
 {
     this.addNewCaseLabel.Visibility = Visibility.Collapsed;
     try
     {
         AddNewCase(this.NewKey);
     }
     catch (ArgumentException ex)
     {
         ErrorReporting.ShowErrorMessage(ex.Message);
     }
 }
 private void OnOkButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         CommitDanglingTransactions();
         CommitRootTransaction();
         SignalCloseParentDialog();
     }
     catch (Exception ex)
     {
         ErrorReporting.ShowErrorMessage(ex.Message);
     }
 }
        // <summary>
        // Called when there is an error setting or getting a PropertyValue.
        // Displays an error dialog.
        // </summary>
        // <param name="e"></param>
        protected override void OnPropertyValueException(PropertyValueExceptionEventArgs e)
        {
            if (e.Source == PropertyValueExceptionSource.Set)
            {
                if (e.Exception != null)
                {
                    Debug.WriteLine(e.Exception.ToString());
                }

                ErrorReporting.ShowErrorMessage(e.Exception.Message);

                base.OnPropertyValueException(e);
            }
            else
            {
                base.OnPropertyValueException(e);
            }
        }
Esempio n. 5
0
 void LoadBindings()
 {
     try
     {
         this.bindingElements.Add(new BindingDescriptor { BindingName = (string)(this.TryFindResource("bindingEditorEmptyBindingLabel") ?? "none"), Value = null });
         Configuration machineConfig = ConfigurationManager.OpenMachineConfiguration();              
         ServiceModelSectionGroup section = ServiceModelSectionGroup.GetSectionGroup(machineConfig);
         if (null != section && null != section.Bindings)
         {
             this.bindingElements.AddRange(section.Bindings.BindingCollections
                 .OrderBy(p => p.BindingName)
                 .Select<BindingCollectionElement, BindingDescriptor>(p => new BindingDescriptor() { BindingName = p.BindingName, Value = p }));
         }
     }
     catch (ConfigurationErrorsException err)
     {
         ErrorReporting.ShowErrorMessage(err.Message);
     }
 }
Esempio n. 6
0
        void OnNewTransitionCommitted(object sender, RoutedEventArgs e)
        {
            this.addNewTransitionLabel.Visibility = Visibility.Collapsed;

            try
            {
                string selectedItem = this.NewTransition as string;

                if (null != selectedItem)
                {
                    AddNewTransition(selectedItem);
                }

                this.addNewTransitionBox.ResetText();
            }
            catch (ArgumentException ex)
            {
                ErrorReporting.ShowErrorMessage(ex.Message);
            }
        }
        // This creates a link from modelItems[i] to modelItems[i+1] - foreach i between 0 and modelItems.Count-2;
        void CreateLinks(List <ModelItem> modelItems)
        {
            Fx.Assert(modelItems.Count > 1, "Link creation requires more than one ModelItem");
            modelItems.ForEach(p => { Fx.Assert(this.modelElement.ContainsKey(p), "View should be in the flowchart"); });
            ModelItem[] modelItemsArray = modelItems.ToArray();
            string      errorMessage    = string.Empty;

            for (int i = 0; i < modelItemsArray.Length - 1; i++)
            {
                string error = string.Empty;
                CreateLinkGesture(this.modelElement[modelItemsArray[i]], this.modelElement[modelItemsArray[i + 1]], out error, null);
                if (!string.Empty.Equals(error))
                {
                    errorMessage += string.Format(CultureInfo.CurrentUICulture, "Link{0}:{1}\n", i + 1, error);
                }
            }
            if (!string.Empty.Equals(errorMessage))
            {
                ErrorReporting.ShowErrorMessage(errorMessage);
            }
        }
        internal void ValidateKey(CorrelationDataWrapper wrapper, string oldKey)
        {
            string newKey = wrapper.Key;

            if (string.IsNullOrEmpty(newKey))
            {
                ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, System.Activities.Core.Presentation.SR.NullOrEmptyKeyName));
                wrapper.Key = oldKey;
            }
            else
            {
                // At this point, the key of the entry has already been changed. If there are
                // entries with duplicate keys, the number of those entries is greater than 1.
                // Thus, we only need to check the entry count.
                int entryCount = this.CorrelationInitializeData.Count(entry => entry.Key == newKey);
                if (entryCount > 1)
                {
                    ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, System.Activities.Core.Presentation.SR.DuplicateKeyName, newKey));
                    wrapper.Key = oldKey;
                }
            }
        }
Esempio n. 9
0
 void Commit()
 {
     // In case of error, the popup can make the control lose focus; we don't want to commit twice.
     if (!this.isCommitting)
     {
         BindingExpression binding = this.GetBindingExpression(ComboBox.TextProperty);
         if (binding != null)
         {
             this.isCommitting = true;
             try
             {
                 binding.UpdateSource();
             }
             catch (ArgumentException exception)
             {
                 ErrorReporting.ShowErrorMessage(exception.Message);
                 binding.UpdateTarget();
             }
             this.isCommitting = false;
         }
     }
 }
Esempio n. 10
0
 void IVersionEditor.ShowErrorMessage(string message)
 {
     ErrorReporting.ShowErrorMessage(message);
 }
        internal static void UpdateInvalidArgumentsIfNecessary(object sender, ValidationService.ErrorsMarkedEventArgs args)
        {
            if (args.Reason != ValidationReason.ModelChange)
            {
                return;
            }

            if (args.Errors.Count == 0)
            {
                return;
            }

            using (EditingScope editingScope = args.ModelTreeManager.CreateEditingScope(string.Empty))
            {
                // Prevent the validation -> fix arguments -> validation loop.
                editingScope.SuppressUndo = true;

                // Suppress validation. We will do it ourselves (see below)
                editingScope.SuppressValidationOnComplete = true;

                // Re-compile erroreous expressions to see if update is necessary
                ValidationService            validationService            = args.Context.Services.GetRequiredService <ValidationService>();
                ArgumentAccessorWrapperCache argumentAccessorWrapperCache = new ArgumentAccessorWrapperCache();
                List <ExpressionReplacement> expressionReplacements       = ComputeExpressionReplacements(args.Errors.Select(error => error.Source).OfType <ActivityWithResult>(), args.Context, argumentAccessorWrapperCache);
                bool argumentReplacementOccurred = false;
                if (expressionReplacements.Count > 0)
                {
                    try
                    {
                        foreach (ExpressionReplacement expressionReplacement in expressionReplacements)
                        {
                            if (expressionReplacement.TryReplaceArgument(args.ModelTreeManager, validationService))
                            {
                                argumentReplacementOccurred = true;
                            }
                        }

                        if (argumentReplacementOccurred)
                        {
                            args.Handled = true;
                            editingScope.Complete();
                        }
                    }
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }

                        // We handle exception here instead of letting WF Designer handle it, so that the validation below will run even
                        // if any of the ArgumentAccessor.Setter methods throw exceptions.
                        ErrorReporting.ShowErrorMessage(e);
                    }

                    // Since any pending validation will be canceled if argument replacement occured (=has model change), we need to re-validate the workflow.
                    // We suppressed validation upon EditingScope completion and do it ourselves, because
                    // the argument replacement could have been done directly to the underlying activity instance, rather than thru ModelItem.
                    if (argumentReplacementOccurred)
                    {
                        validationService.ValidateWorkflow();
                    }
                }
            }
        }