Example #1
0
        private async void AddButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (_store == null)
            {
                return;
            }

            // Create the blank document
            var document = new DrxDocumentViewModel(new DrxDocument {
                Store = _store.Model, Header = { BodyType = DrxBodyType.Rtf }
            }, _store);
            var result = await new DocumentPropertiesDialog(document, true).ShowAsync();

            // Ensure the user didn't click Cancel and the title is set.
            if (result != ContentDialogResult.Primary ||
                string.IsNullOrWhiteSpace(document.Model.Header.Title))
            {
                return;
            }

            // Add it to the view model and persist
            _store.Documents.Add(document);
            await document.Model.SaveAsync();

            UpdateDocuments();

            Analytics.TrackEvent("Document(s) added.");
        }
Example #2
0
        public void HandleCommand(object command)
        {
            if (!(command is DrxCommand drxCommand))
            {
                return;
            }
            switch (drxCommand.Subject)
            {
            case DrxCommandSubject.StoreDocuments:
                switch (drxCommand.Command)
                {
                case "new":
                    AddButton_OnClick(this, new RoutedEventArgs());
                    break;
                }
                break;

            case DrxCommandSubject.Document:
                // Resolve the document here
                DrxDocumentViewModel document = null;
                if (drxCommand.Parameters.ContainsKey("contextId"))
                {
                    document = _store.Documents.FirstOrDefault(s =>
                                                               s.Model.Id == (Guid)drxCommand.Parameters["contextId"]);
                }
                else if (drxCommand.Parameters.ContainsKey("documentName"))
                {
                    document = _store.Documents.FirstOrDefault(s =>
                                                               s.Title == (string)drxCommand.Parameters["documentName"]);
                }

                // Resolve failed
                if (document == null)
                {
                    break;
                }

                // Use this document now
                SetSelectedItems(new List <DrxDocumentViewModel> {
                    document
                });

                switch (drxCommand.Command)
                {
                case "open":
                    // We've already opened it by selecting it
                    break;

                case "delete":
                    //DeleteConfirmation_Click(this, new RoutedEventArgs());
                    break;

                case "properties":
                    // TODO, must convert to ICommand
                    break;
                }
                break;
            }
        }
        public DocumentPropertiesDialog(DrxDocumentViewModel document, bool creating = false)
        {
            InitializeComponent();
            Document = document;

            if (!creating)
            {
                return;
            }
            Title             = "New Document";
            PrimaryButtonText = "Create";
        }
 public DocumentVrelDialog(DrxDocumentViewModel document)
 {
     InitializeComponent();
     Document = document;
 }