Example #1
0
 private void Reload()
 {
     _notNeedCanCloseEvent = true;
     if (CanCloseInternal())
     {
         try
         {
             WaitStart();
             _fileName = string.Empty;
             _designerViewModel.ReloadDesigner(_activity ?? new ActivityBuilder());
         }
         finally
         {
             _notNeedCanCloseEvent = false;
             WaitStop();
         }
     }
 }
Example #2
0
        private void UpdateModel()
        {
            _modelTimer.Stop();

            ErrorVisibility = Visibility.Collapsed;
            ErrorText       = string.Empty;
            OnPropertyChanged("ErrorVisibility");
            OnPropertyChanged("ErrorText");
            try
            {
                var designerSurface = _designerViewModel.CurrentSurface as IDesignerSurface;
                if (designerSurface != null)
                {
                    if (designerSurface.Designer.Text == Document.Text)
                    {
                        return;
                    }



                    var text = Document.Text.Trim();

                    /*while (text.StartsWith(" "))
                     * {
                     *  text = text.Substring(1);
                     * }*/

                    var root = text.StartsWith("<Activity ")
                        ? XamlServices.Load(
                        ActivityXamlServices.CreateBuilderReader(new XamlXmlReader(new StringReader(text))))
                        : ActivityXamlServices.Load(new StringReader(text));

                    if (root == null)
                    {
                        throw new ApplicationException("Nothing to load");
                    }
                    _designerViewModel.ReloadDesigner(root);
                }
            }
            catch (Exception ex)
            {
                ErrorVisibility = Visibility.Visible;
                ErrorText       = ex.Message;
                OnPropertyChanged("ErrorVisibility");
                OnPropertyChanged("ErrorText");
            }
        }