Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        //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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Document loaded.
        /// </summary>
        public override void OnDocumentLoaded()
        {
            base.OnDocumentLoaded();

            if (!isInitialyInitialized)
            {
                PleaseWaitHelper.Show();
                this.Initialize();
                PleaseWaitHelper.Hide();
            }
        }
Exemplo n.º 4
0
 partial void HideBusyIndicator()
 {
     PleaseWaitHelper.Hide();
 }
Exemplo n.º 5
0
 partial void ShowBusyIndicator()
 {
     PleaseWaitHelper.Show(_lastStatus);
 }
Exemplo n.º 6
0
 partial void SetStatus(string status)
 {
     PleaseWaitHelper.UpdateStatus(status);
 }
Exemplo n.º 7
0
        /// <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();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Hides this please wait window.
        /// </summary>
        public virtual void Hide()
        {
            PleaseWaitHelper.Hide();

            _showCounter = 0;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Updates the status and shows a progress bar with the specified status text. The percentage will be automatically calculated.
 /// <para />
 /// The busy indicator will automatically hide when the <paramref name="totalItems"/> is larger than <paramref name="currentItem"/>.
 /// <para/>
 /// When providing the <paramref name="statusFormat"/>, it is possible to use <c>{0}</c> (represents current item) and
 /// <c>{1}</c> (represents total items).
 /// </summary>
 /// <param name="currentItem">The current item.</param>
 /// <param name="totalItems">The total items.</param>
 /// <param name="statusFormat">The status format. Can be empty, but not <c>null</c>.</param>
 /// <exception cref="ArgumentOutOfRangeException">The <paramref name="currentItem"/> is smaller than zero.</exception>
 /// <exception cref="ArgumentNullException">The <paramref name="statusFormat"/> is <c>null</c>.</exception>
 public virtual void UpdateStatus(int currentItem, int totalItems, string statusFormat = "")
 {
     PleaseWaitHelper.UpdateStatus(statusFormat, currentItem, totalItems);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Updates the status text.
 /// </summary>
 /// <param name="status">The status.</param>
 public virtual void UpdateStatus(string status)
 {
     PleaseWaitHelper.UpdateStatus(status);
 }
Exemplo n.º 11
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);
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
0
 partial void ShowBusyIndicator(bool indeterminate)
 {
     PleaseWaitHelper.Show(_lastStatus);
 }