Exemplo n.º 1
0
        /// <summary>
        /// item context menu delete click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemContextMenuDelete_Click(object sender, RoutedEventArgs e)
        {
            var model  = (this._itemMenu.Tag as ListViewItem)?.DataContext as ItemModel;
            var dialog = new ItemDeleteConfirm(this, model);

            if (true != dialog.ShowDialog())
            {
                dialog.Close();
                return;
            }

            using (var table = new ItemsTable(this._profileDatabase)) {
                if (table.DeleteById(model.Id) < 0)
                {
                    AppCommon.ShowErrorMsg(string.Format(ErrorMsg.FailToDelete, "profile"));
                }
                if (true == dialog.DeleteFile)
                {
                    new FileOperator(model.FilePath).Delete();
                }
            }
            dialog.Close();
            this._itemList.Remove(model);
        }