Ejemplo n.º 1
0
        public async void RequestDeleteNodeHandler(IDatabaseViewModel vm, IDatabaseNodeViewModel node)
        {
            DebugHelper.Trace($"Delete requested for node {node.Node.Title.ClearValue}");

            MessageDialog dialog = new MessageDialog(
                GetString(DatabaseView.DeletePromptKey),
                GetString(DatabaseView.DeletePromptTitleKey)
                );

            IUICommand yesCommand = new UICommand(GetString("Yes"));
            IUICommand noCommand  = new UICommand(GetString("No"));

            dialog.Commands.Add(yesCommand);
            dialog.Commands.Add(noCommand);

            dialog.DefaultCommandIndex = 0;
            dialog.CancelCommandIndex  = 1;

            IUICommand chosenCommand = await dialog.ShowAsync();

            if (chosenCommand == noCommand)
            {
                // User chose not to delete after all, abort.
                return;
            }

            // Otherwise the user confirmed the delete, so do it.
            ViewModel.DeleteNodeAndSave(node.Node);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the selection for editing.
        /// </summary>
        private void EditSelection()
        {
            IDatabaseNodeViewModel selectedNode = this.childGridView.SelectedItem as IDatabaseNodeViewModel;

            DebugHelper.Assert(selectedNode != null);

            selectedNode.RequestEditDetailsCommand.Execute(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a Popup that will allow renaming of the currently selected node.
        /// </summary>
        private void PromptToRenameSelection()
        {
            IDatabaseNodeViewModel selectedNode = this.childGridView.SelectedItem as IDatabaseNodeViewModel;

            DebugHelper.Assert(selectedNode != null);

            selectedNode.RequestRenameCommand.Execute(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Confirms the user's choice and then deletes the currently selected node.
        /// </summary>
        /// <remarks>
        /// This function currently deletes ONE SelectedItem.
        /// </remarks>
        private void PromptToDeleteSelection()
        {
            IDatabaseNodeViewModel selectedNode = this.childGridView.SelectedItem as IDatabaseNodeViewModel;

            DebugHelper.Assert(selectedNode != null);

            DebugHelper.Assert(ViewModel.PersistenceService.CanSave);
            selectedNode.RequestDeleteCommand.Execute(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Invoked when the user begins to drag an item in the node GridView.
        /// </summary>
        /// <param name="sender">The node GridView.</param>
        /// <param name="e">EventArgs for the drag operation.</param>
        private void childGridView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
        {
            DebugHelper.Assert(e.Items.Count == 1);

            IDatabaseNodeViewModel viewModel = e.Items[0] as IDatabaseNodeViewModel;

            DebugHelper.Assert(viewModel != null);

            e.Data.SetText(viewModel.Node.Uuid.EncodedValue);
        }
Ejemplo n.º 6
0
        public void RequestRenameNodeHandler(IDatabaseViewModel vm, IDatabaseNodeViewModel node)
        {
            DebugHelper.Trace($"Rename requested for node {node.Node.Title.ClearValue}");
            this.nodeBeingRenamed = node;

            TextBox inputBox = RenameFlyout.Content as TextBox;

            DebugHelper.Assert(inputBox != null);

            inputBox.Text = node.Node.Title.ClearValue;
            RenameFlyout.ShowAt(this.childGridView.ContainerFromItem(node) as FrameworkElement);

            inputBox.SelectAll();
        }
Ejemplo n.º 7
0
        public void RequestDetailsHandler(IDatabaseViewModel vm, IDatabaseNodeViewModel node)
        {
            DebugHelper.Trace($"Details requested for node {node.Node.Title.ClearValue}");

            if (node.Node is IKeePassEntry entry)
            {
                Frame.Navigate(
                    typeof(EntryDetailsView),
                    ViewModel.GetEntryDetailsViewModel(entry, /* editing */ true)
                    );
            }
            else
            {
                IKeePassGroup group = node.Node as IKeePassGroup;
                DebugHelper.Assert(group != null);
                Frame.Navigate(
                    typeof(GroupDetailsView),
                    ViewModel.GetGroupDetailsViewModel(group, /* editing */ true)
                    );
            }
        }
Ejemplo n.º 8
0
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element == null)
            {
                return(null);
            }

            DataTemplate groupTemplate = (DataTemplate)Application.Current.Resources[
                String.Format("{0}{1}", NodeTemplateSelector.GroupPrefix, Suffix)
                                         ];
            DataTemplate entryTemplate = (DataTemplate)Application.Current.Resources[
                String.Format("{0}{1}", NodeTemplateSelector.EntryPrefix, Suffix)
                                         ];

            IDatabaseNodeViewModel node = item as IDatabaseNodeViewModel;

            if (node == null)
            {
                return(null);
            }

            IDatabaseEntryViewModel entry = node as IDatabaseEntryViewModel;

            if (entry == null)
            {
                // Group only
                return(groupTemplate);
            }
            else
            {
                // Entry
                return(entryTemplate);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Invoked when the node rename flyout is closed.
 /// </summary>
 /// <param name="sender">The flyout.</param>
 /// <param name="e">N/A</param>
 private void RenameFlyout_Closed(object sender, object e)
 {
     this.nodeBeingRenamed = null;
 }