示例#1
0
        private async void DeleteFeed(RoutedEventArgs e)
        {
            if (_selectedNode == null)
            {
                return;
            }
            SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode;

            Model.Feed selectedFeed = null;
            if (tvm.Node is Model.Feed)
            {
                selectedFeed = (Model.Feed)tvm.Node;
            }
            else
            {
                return;
            }


            // Hides browser otherwise dialog gets behind it
            IsBrowserVisible = false;
            RaisePropertyChanged("IsBrowserVisible");

            MessageDialogResult result = await _dialogCoordinator.ShowMessageAsync(this, "Delete Feed", "This action also deletes all downloaded articles and cannot be undone. Are you sure?", MessageDialogStyle.AffirmativeAndNegative);

            if (result == MessageDialogResult.Affirmative)
            {
                string errMsg = null;
                try
                {
                    Data.Feed feed = new Data.Feed(selectedFeed);
                    feed.Delete();
                }
                catch (Exception ex)
                {
                    errMsg = ex.Message;
                }
                if (errMsg != null)
                {
                    await _dialogCoordinator.ShowMessageAsync(this, "Edit Feed", "Unable to edit feed with the supplied URL: " + errMsg);
                }
            }
            IsBrowserVisible = true;
            RaisePropertyChanged("IsBrowserVisible");
            InitializeData(true);
        }
示例#2
0
        private async void DeleteFeed(RoutedEventArgs e)
        {
            if (_selectedNode == null)
                return;
            SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode;
            Model.Feed selectedFeed = null;
            if (tvm.Node is Model.Feed)
            {
                selectedFeed = (Model.Feed)tvm.Node;
            }
            else
                return;


            // Hides browser otherwise dialog gets behind it
            IsBrowserVisible = false;
            RaisePropertyChanged("IsBrowserVisible");

            MessageDialogResult result = await _dialogCoordinator.ShowMessageAsync(this, "Delete Feed", "This action also deletes all downloaded articles and cannot be undone. Are you sure?", MessageDialogStyle.AffirmativeAndNegative);

            if (result == MessageDialogResult.Affirmative)
            {
                string errMsg = null;
                try
                {
                    Data.Feed feed = new Data.Feed(selectedFeed);
                    feed.Delete();
                }
                catch (Exception ex)
                {
                    errMsg = ex.Message;
                }
                if (errMsg != null)
                {
                    await _dialogCoordinator.ShowMessageAsync(this, "Edit Feed", "Unable to edit feed with the supplied URL: " + errMsg);
                }
            }
            IsBrowserVisible = true;
            RaisePropertyChanged("IsBrowserVisible");
            InitializeData(true);
        }