public void Navigate(PageViewModelBase page)
 {
     if (page != null)
     {
         this.SetPage(page);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Redefine document content based on given page definition and collection of objects.
        /// </summary>
        /// <param name="newDocumentRoot"></param>
        /// <param name="coll"></param>
        public void LoadFileFromCollection(PageViewModelBase newDocumentRoot,
                                           IEnumerable <ShapeViewModelBase> coll)
        {
            try
            {
                if (this.mDocRoot == null)
                {
                    this.setCreateRoot();
                }
                else
                {
                    this.mDocRoot.Clear();
                }

                if (newDocumentRoot != null)
                {
                    this.SetDocRoot(newDocumentRoot, coll);
                }

                this.ClearUndoRedo();
                this.mHasUnsavedData = false;
                this.mMaxId          = 0;

                this.State = ModelState.Ready;
                this.SendPropertyChanged("HasUndoData", "HasRedoData", "HasUnsavedData");
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Recreate document collection from Xml persistence in a string.
        /// </summary>
        /// <param name="parentOfShapes"></param>
        /// <param name="xmlText"></param>
        private void RecreateShapeCollectionFromXml(IShapeParent parentOfShapes, string xmlText)
        {
            // Look-up plugin model
            string          plugin = this.PluginModelName;
            PluginModelBase m      = PluginManager.GetPluginModel(plugin);

            // Look-up shape converter
            UmlTypeToStringConverterBase conv = null;

            conv = m.ShapeConverter;

            // Convert Xml document into a list of shapes and page definition
            List <ShapeViewModelBase> coll;
            PageViewModelBase         page = conv.ReadDocument(xmlText, parentOfShapes, out coll);

            if (coll == null)
            {
                return;
            }

            if (coll.Count == 0)
            {
                return;
            }

            // Page definition properties are not in scope of undo/redo
            this.ResetDocRoot(coll);
        }
Ejemplo n.º 4
0
 public void Append(PageViewModelBase content, bool select = true)
 {
     _tabs.Add(content);
     if (select)
     {
         SetTabIndex(_tabs.Count - 1);
     }
 }
Ejemplo n.º 5
0
        protected override void OnRemovedFromJournal(JournalEntryRemovedEventArgs e)
        {
            base.OnRemovedFromJournal(e);

            Debug.Assert(DataContext is PageViewModelBase);
            PageViewModelBase vm = DataContext as PageViewModelBase;

            vm.OnRemovedFromJournal(e);
        }
Ejemplo n.º 6
0
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            base.OnBackKeyPress(e);

            Debug.Assert(DataContext is PageViewModelBase);
            PageViewModelBase vm = DataContext as PageViewModelBase;

            vm.OnBackKeyPress(e);
        }
Ejemplo n.º 7
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);

            Debug.Assert(DataContext is PageViewModelBase);
            PageViewModelBase vm = DataContext as PageViewModelBase;

            vm.SaveState(State);
            vm.OnNavigatedFrom(e);
        }
Ejemplo n.º 8
0
        public List <KeyValuePair <string, string> > GenerateUsingSingleTitle <TResolver>(string title) where TResolver : PathBarResolver <PageViewModelBase>, new()
        {
            var viewModel = new PageViewModelBase()
            {
                PageTitle = title
            };
            var resolver = new TResolver();

            return(resolver.GeneratePathBarDictionary(viewModel));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Constructor initializing the data model as an empty document.
        /// </summary>
        public DocumentDataModel(string pluginModelName)
        {
            this.mPluginModelName = pluginModelName;

            this.mRoot = new PageViewModelBase();

            this.setDocRoot(this.mRoot);
            ////this.setDocumentRoot(new XElement("invalid"));

            this.State = ModelState.Invalid;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Window.Current.SizeChanged += Current_SizeChanged;
            var viewModel = this.DataContext as INotifyPropertyChanged;

            PageViewModel = viewModel as PageViewModelBase;

#if WINDOWS_PHONE_APP
            VisualStateManager.GoToState(this, "Tiny", false);
#else
            VisualStateManager.GoToState(this, "Wide", false);
#endif
        }
Ejemplo n.º 11
0
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            PageViewModelBase viewModel = DataContext as PageViewModelBase;

            Size      pageSize;
            Thickness pageMargins;

            if (this.getValues(out pageSize, out pageMargins))
            {
                viewModel.prop_PageSize    = pageSize;
                viewModel.prop_PageMargins = pageMargins;
                this.DialogResult          = true;
                this.Close();
            }
        }
Ejemplo n.º 12
0
        private void SetDocRoot(PageViewModelBase newDocumentRoot,
                                IEnumerable <ShapeViewModelBase> coll)
        {
            double pageWidth = newDocumentRoot.prop_PageSize.Width;

            double pageHeight = newDocumentRoot.prop_PageSize.Height;

            this.setDocRoot(new PageViewModelBase()
            {
                prop_PageSize    = new Size(pageWidth, pageHeight),
                prop_PageMargins = newDocumentRoot.prop_PageMargins
            });

            this.ResetDocRoot(coll);
        }
Ejemplo n.º 13
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Debug.Assert(DataContext is PageViewModelBase);
            PageViewModelBase vm = DataContext as PageViewModelBase;

            if (!_initialized)
            {
                _initialized = true;
                vm.Initialize(NavigationContext.QueryString, e);
                vm.RestoreState(State);
            }

            vm.OnNavigatedTo(e);
        }
Ejemplo n.º 14
0
        public PageViewModelBase GetXmlElementDocRoot()
        {
            this.VerifyAccess();

            PageViewModelBase docRoot = new PageViewModelBase(this.mRoot);

            if (this.mDocRoot != null)
            {
                foreach (var item in this.mDocRoot)
                {
                    docRoot.Add(item);
                }
            }

            return(docRoot);
        }
Ejemplo n.º 15
0
        public override bool Execute(KeyRoutedEventArgs e)
        {
            PageViewModelBase pageViewModel = this.GetCurrentPageDataContextAs <PageViewModelBase>();

            if (pageViewModel != null)
            {
                pageViewModel.GoBackCommand.Execute(null);
                return(true);
            }
            else if (this.navigationService.CanGoBack)
            {
                this.navigationService.GoBack();
                return(true);
            }

            return(false);
        }
Ejemplo n.º 16
0
        public override bool Execute(KeyRoutedEventArgs e)
        {
            // try to find quick add first
            PageViewModelBase pageViewModel = this.GetCurrentPageDataContextAs <QuickAddTaskViewModel>();

            if (pageViewModel == null)
            {
                pageViewModel = this.GetCurrentPageDataContextAs <PageViewModelBase>();
            }

            if (pageViewModel != null)
            {
                pageViewModel.SaveCommand.Execute(null);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 17
0
        private void setDocRoot(PageViewModelBase root)
        {
/*** TODO XXX Dirkster: Not sure why this is needed (maybe to set busy states?)
 *    if (_documentRoot != null)
 *    {
 *      _documentRoot.Changed -= documentRoot_Changed;
 *      _documentRoot.Changing -= documentRoot_Changing;
 *    }
 *
 *    if (newDocumentRoot != null)
 *    {
 *      newDocumentRoot.Changed += documentRoot_Changed;
 *      newDocumentRoot.Changing += documentRoot_Changing;
 *    }
 ***/
            this.PageSize    = root.prop_PageSize;
            this.PageMargins = root.prop_PageMargins;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Save document to a file.
        /// </summary>
        public void Save(string filename)
        {
            VerifyAccess();
            VerifyState(ModelState.Ready);
            State = ModelState.Saving;

            try
            {
                PageViewModelBase docRoot = this.GetXmlElementDocRoot();
                docRoot.SaveDocument(filename, _DocRoot);

                _HasUnsavedData = false;
            }
            finally
            {
                State = ModelState.Ready;
            }

            NotifyPropertyChanged(() => HasUnsavedData);
        }
Ejemplo n.º 19
0
        private void OnBackRequested(object sender, BackRequestedEventArgs e)
        {
            if (this.navigationService != null)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame != null && rootFrame.Content is Page)
                {
                    Page page = (Page)rootFrame.Content;

                    // from main page, a back request put the app in background (and we have nothing to do)
                    if (page is MainPage)
                    {
                        return;
                    }

                    if (page.Content is FrameworkElement)
                    {
                        FrameworkElement pageContent = (FrameworkElement)page.Content;
                        if (pageContent.DataContext is PageViewModelBase)
                        {
                            PageViewModelBase viewmodel = (PageViewModelBase)pageContent.DataContext;
                            e.Handled = true;
                            viewmodel.GoBackCommand.Execute(null);
                            return;
                        }
                    }
                }

                this.navigationService.GoBack();
                e.Handled = true;
            }
            else
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame.CanGoBack)
                {
                    e.Handled = true;
                    rootFrame.GoBack();
                }
            }
        }
        protected void SetPageMetaData(PageViewModelBase vm)
        {
            var startPage = CmsFinder.FindStartPageOf(CurrentItem) as StartPage;
            var item      = CurrentItem as PageModelBase;

            if (item != null && vm != null)
            {
                if (!string.IsNullOrEmpty(item.Description))
                {
                    vm.SeoMetaDescription = item.Description;
                }
                if (!string.IsNullOrEmpty(item.Keywords))
                {
                    vm.SeoMetaKeywords = item.Keywords;
                }

                vm.Metadata.TwitterTitle       = !(string.IsNullOrEmpty(item.TwitterTitle)) ? item.TwitterTitle : vm.SeoTitleTag;
                vm.Metadata.TwitterImageSrc    = item.TwitterImageSrc;
                vm.Metadata.TwitterImageWidth  = item.TwitterImageWidth;
                vm.Metadata.TwitterImageHeight = item.TwitterImageHeight;
                vm.Metadata.TwitterData1       = item.TwitterData1;
                vm.Metadata.TwitterLabel1      = item.TwitterLabel1;
                vm.Metadata.TwitterData2       = item.TwitterData2;
                vm.Metadata.TwitterLabel2      = item.TwitterLabel2;
                vm.Metadata.TwitterDescription = !string.IsNullOrEmpty(item.TwitterDescription) ? item.TwitterDescription : vm.SeoMetaDescription;
                vm.Metadata.TwitterCard        = item.TwitterCard;
                vm.Metadata.OgImage            = item.OgImage;
                vm.Metadata.OgType             = item.OgType;
                vm.Metadata.OgTitle            = !string.IsNullOrEmpty(item.OgTitle) ? item.OgTitle : vm.PageTitle;
                vm.Metadata.OgDescription      = !string.IsNullOrEmpty(item.OgDescription) ? item.OgDescription : vm.SeoMetaDescription;
            }
            if (startPage != null && vm != null)
            {
                vm.Metadata.FacebookAppId   = startPage.FacebookAppId;
                vm.Metadata.TwitterSite     = startPage.TwitterSite;
                vm.Metadata.ApplicationName = startPage.ApplicationName;
                vm.Metadata.OgSiteName      = startPage.OgSiteName;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Create a new document.
        /// </summary>
        public void New(PageViewModelBase root)
        {
            this.VerifyAccess();

            this.VerifyState(ModelState.Ready, ModelState.Invalid);

            this.mRoot = root;
            this.NotifyPropertyChanged(() => this.PageSize);
            this.NotifyPropertyChanged(() => this.PageMargins);

            this.setDocRoot(root);

            this.ClearUndoRedo();
            this.mMaxId          = 0;
            this.mHasUnsavedData = false;

            this.State = ModelState.Ready;

            this.SendPropertyChanged("HasUndoData",
                                     "HasRedoData",
                                     "HasUnsavedData");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Save document to a file.
        /// </summary>
        public void Save(string filename)
        {
            this.VerifyAccess();

            this.VerifyState(ModelState.Ready);

            this.State = ModelState.Saving;

            try
            {
                PageViewModelBase docRoot = this.GetXmlElementDocRoot();

                docRoot.SaveDocument(filename, this.mDocRoot);

                this.mHasUnsavedData = false;
            }
            finally
            {
                this.State = ModelState.Ready;
            }

            this.SendPropertyChanged("HasUnsavedData");
        }
 public SequenceEditorPage(PageViewModelBase vm, IBackgroundService backgroundService, IDialogServerHost dialogServerHost)
     : base(backgroundService, dialogServerHost)
 {
     InitializeComponent();
     AfterInitialize(vm);
 }
 public ControllerProfilePage(PageViewModelBase vm, IBackgroundService backgroundService, IDialogServerHost dialogServerHost)
     : base(backgroundService, dialogServerHost)
 {
     InitializeComponent();
     AfterInitialize(vm);
 }
 public void GotoEditPage() => CurrentPage   = new EditPageViewModel(this);
 public void GotoSearchPage() => CurrentPage = new SearchPageViewModel(this, _itemsSource, _clientsClient);
 protected void SetPage(PageViewModelBase page)
 {
     page.ParentWindow = this;
     this.CurrentPage  = page;
 }
Ejemplo n.º 28
0
 public DeleteCommand(CatalogBase <T> catalog, PageViewModelBase <T> pageVM)
     : base(catalog, pageVM)
 {
 }
Ejemplo n.º 29
0
 public PlayerPage(PageViewModelBase vm, IBackgroundService backgroundService) : base(backgroundService)
 {
     InitializeComponent();
     BindingContext = vm;
 }
 public ChannelSetupPage(PageViewModelBase vm, IBackgroundService backgroundService, IDialogServerHost dialogServerHost)
     : base(backgroundService, dialogServerHost)
 {
     InitializeComponent();
     AfterInitialize(vm);
 }