/// <summary>
        /// Switch model contexts.
        /// </summary>
        /// <param name="newContextVM">New model context vm.</param>
        /// <param name="oldContextVM">Old model context vm.</param>
        /// <returns>True if a switch did occur. False otherwise.</returns>
        protected virtual bool SwitchContexts(ModelContextViewModel newContextVM, ModelContextViewModel oldContextVM)
        {
            if (this.ModelData.CurrentModelContext.RootElement != null)
            {
                // notify that the current document will be closed
                IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>();
                if (messageBox.ShowYesNoCancel("The currently opened document will be closed in the process of a context switch! Do you want to proceed?", CustomDialogIcons.Question) != CustomDialogResults.Yes)
                {
                    return(false);
                }
            }


            PleaseWaitHelper.Show();
            BeforeSwitchContexts(newContextVM, oldContextVM);

            if (this.ModelData.CurrentModelContext.RootElement != null)
            {
                this.ModelData.CurrentModelContext.Reset();
            }
            this.Reset();

            // update model data
            this.ModelData.CurrentModelContext = newContextVM.ModelContext;

            AfterSwitchContexts(newContextVM, oldContextVM);


            PleaseWaitHelper.Hide();
            return(true);
        }
        //internal static LongWaitMessager lwm;
        public void HandleException(Exception e)
        {
            LogExceptionDelegate logDelegate = new LogExceptionDelegate(LogException);

            if (e is System.Reflection.ReflectionTypeLoadException)
            {
                var typeLoadException = e as System.Reflection.ReflectionTypeLoadException;
                foreach (var item in typeLoadException.LoaderExceptions)
                {
                    MessageBox.Show(item.Message.ToString()); MessageBox.Show(item.Message.ToString());
                }
            }
            switch (notificationType)
            {
            case NotificationType.Ask:
                if (MessageBox.Show("An unexpected error occurred - " + e.Message +
                                    ". Do you wish to log the error?", "Error", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }
                logDelegate.BeginInvoke(e, new AsyncCallback(LogCallBack), null);
                break;

            case NotificationType.Inform:
                if (counter == 0)
                {
                    counter++;
                    logDelegate.BeginInvoke(e, new AsyncCallback(LogCallBack), null);
                    System.Windows.MessageBox.Show("An unexpected error occurred -\n " + e.Message + "\n\n" + e.StackTrace);
                    //System.Windows.MessageBox.Show("An unexpected error occurred -\n " + e.Message + "\n\n" + e.StackTrace);
                    Thread.Sleep(3);    //capture the screen
                    //lwm = new LongWaitMessager("I'am Try To Process The Exception,Please Waiting...");
                    //lwm.Show();
                    PleaseWaitHelper.Show("I'am Try To Process The Exception,Please Waiting...");
                }
                else
                {
                    textLoggerEvent.Wait(20000);
                    emailLoggerEvent.Wait(20000);
                    //if (lwm!=null)
                    //{
                    //    lwm.Close();
                    //}
                    PleaseWaitHelper.Hide();
                    System.Windows.MessageBox.Show("We Are Sorry To Show This Message To You,\nWe Will Solve The Problem As Soon As Possible, Thanks! \n");
                    Application.Current.Shutdown();
                }

                break;

            case NotificationType.Silent:
                logDelegate.BeginInvoke(e, new AsyncCallback(LogCallBack), null);
                break;
            }
            SaveOnException.SafeInvoke(this);
        }
        /// <summary>
        /// Document loaded.
        /// </summary>
        public override void OnDocumentLoaded()
        {
            base.OnDocumentLoaded();

            if (!isInitialyInitialized)
            {
                PleaseWaitHelper.Show();
                this.Initialize();
                PleaseWaitHelper.Hide();
            }
        }
 partial void ShowBusyIndicator()
 {
     PleaseWaitHelper.Show(_lastStatus);
 }
        /// <summary>
        /// New command executed.
        /// </summary>
        protected virtual void NewModelCommandExecuted()
        {
            if (this.SelectedModelContextViewModel == null)
            {
                return;
            }
            if (this.SelectedModelContextViewModel.ModelContext == null)
            {
                return;
            }

            if (CloseModelCommandCanExecute())
            {
                if (!CloseModelCommandExecute())
                {
                    return;
                }
            }

            ISaveFileService saveFileService = this.GlobalServiceProvider.Resolve <ISaveFileService>();

            saveFileService.Filter = this.SelectedModelContextViewModel.EditorTitle + " files|*.xml|All files|*.*";
            if (saveFileService.ShowDialog(null) == true)
            {
                System.IO.StreamWriter writer = System.IO.File.CreateText(saveFileService.FileName);
                writer.Close();

                using (new ToolFramework.Modeling.Visualization.ViewModel.UI.WaitCursor())
                {
                    this.Reset();
                    this.SelectedModelContextViewModel.ModelContext.Load(saveFileService.FileName, false);

                    // add to mru list
                    this.MRUFilesViewModel.AddMRUEntry(saveFileService.FileName);

                    if (this.SelectedModelContextViewModel.ModelContext.SerializationResult.Count() > 0)
                    {
                        // clear current error list
                        this.EventManager.GetEvent <ErrorListClearItems>().Publish(this);

                        // add serialization result items
                        List <BaseErrorListItemViewModel> items = new List <BaseErrorListItemViewModel>();
                        foreach (SerializationMessage serializationMessage in this.SelectedModelContextViewModel.ModelContext.SerializationResult)
                        {
                            SerializationErrorListItemViewModel item = new SerializationErrorListItemViewModel(this.ViewModelStore, serializationMessage);
                            items.Add(item);
                        }

                        // notify of change
                        this.EventManager.GetEvent <ErrorListAddItems>().Publish(items);
                    }
                }
            }

            if (!this.isInitialyInitialized)
            {
                PleaseWaitHelper.Show();
                this.Initialize();
                PleaseWaitHelper.Hide();
            }

            this.CloseCommand.RaiseCanExecuteChanged();
            this.SaveAsModelCommand.RaiseCanExecuteChanged();
            this.SaveModelCommand.RaiseCanExecuteChanged();
        }
Exemple #6
0
 /// <summary>
 /// Shows the please wait window with the specified status text and executes the work delegate (in a background thread). When the work
 /// is finished, the please wait window will be automatically closed.
 /// </summary>
 /// <param name="workDelegate">The work delegate.</param>
 /// <param name="status">The status.</param>
 public virtual void Show(PleaseWaitWorkDelegate workDelegate, string status = "")
 {
     PleaseWaitHelper.Show(workDelegate, null, status);
 }
Exemple #7
0
 /// <summary>
 /// Shows the please wait window with the specified status text.
 /// </summary>
 /// <param name="status">The status. When the string is <c>null</c> or empty, the default please wait text will be used.</param>
 /// <remarks></remarks>
 public virtual void Show(string status = "")
 {
     PleaseWaitHelper.Show(status);
 }
Exemple #8
0
 partial void ShowBusyIndicator(bool indeterminate)
 {
     PleaseWaitHelper.Show(_lastStatus);
 }