示例#1
0
 private void AddSuccess_Click(object sender, RoutedEventArgs e)
 {
     //add list view      ***judge is existed the same title***
     tipTextBlock.Text = "";
     if (tipTextBox.Text.Length > 0)
     {
         addFlyout.Hide();
         //data
         System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
         long            timeStamp = (long)(DateTime.Now - startTime).TotalMilliseconds;
         ObservableCollection <CardTitleViewModel> lists = new ObservableCollection <CardTitleViewModel>();
         lists.Add(new CardTitleViewModel {
             CardId = timeStamp, HeaderTitle = tipTextBox.Text, Contents = new ObservableCollection <CardContent>()
         });
         //add userControl
         this.cardListViewModel.CardLists.Add(new CardTitleViewModel {
             CardId = timeStamp, HeaderTitle = tipTextBox.Text, Contents = new ObservableCollection <CardContent>()
         });;
         CardTitleViewModel    lastVM       = this.cardListViewModel.CardLists[this.cardListViewModel.CardLists.Count - 1];
         SingleCardUserControl singleCardUC = new SingleCardUserControl();
         singleCardUC.cardTitleVM         = lastVM;
         singleCardUC.HorizontalAlignment = HorizontalAlignment.Left;
         singleCardUC.Margin = new Thickness(15, 0, 0, 0);
         singleCardUC.DeleteCardListEvent     += deleteCardListAction;
         singleCardUC.ListViewChangeItemEvent += SingleCardUC_ListViewChangeItemEvent;
         CardPanel.Children.Add(singleCardUC);
         tipTextBox.Text   = "";
         tipTextBlock.Text = "";
         this.cardUCLists.Add(singleCardUC);
     }
     else
     {
         tipTextBlock.Text = "The title is empty.Please enter a title";
     }
 }
示例#2
0
        private void CardContentListView_DragItemsStarting(object sender, DragItemsStartingEventArgs e)
        {
            CardContent        dragCardContent     = e.Items[0] as CardContent;
            CardTitleViewModel originalCardTitleVM = this.cardTitleVM;

            ListViewChangeItemEvent(originalCardTitleVM, dragCardContent);
        }
示例#3
0
 private void SingleCardUC_ListViewChangeItemEvent(CardTitleViewModel exchangeCardTitleVM, CardContent exchangeContent)
 {
     if (exchangeContent != null)
     {
         this.dragCardContent     = exchangeContent;
         this.originalCardTitleVM = exchangeCardTitleVM;
     }
     else
     {
         //complete
         this.originalCardTitleVM.Contents.Remove(this.dragCardContent);
         exchangeCardTitleVM.Contents.Insert(0, this.dragCardContent);
     }
 }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is CardTitleViewModel)
     {
         this.model = e.Parameter as CardTitleViewModel;
     }
     if (e.Parameter is ObservableCollection <object> )
     {
         ObservableCollection <object> lists = e.Parameter as ObservableCollection <object>;
         this.model           = lists[0] as CardTitleViewModel;
         this.editCardContent = lists[1] as CardContent;
     }
 }
示例#5
0
        //public CardTitleVM cardTitleVM { get; set; }

        private async void deleteCardListAction(object parameter)
        {
            //dialog
            CardTitleViewModel model        = parameter as CardTitleViewModel;
            ContentDialog      deleteDialog = new ContentDialog
            {
                Title             = "Delete",
                Content           = "Are you sure to delete" + " \"" + model.HeaderTitle + " \" list",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };

            ContentDialogResult result = await deleteDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                int index = 0;
                for (int i = 0; i < this.cardListViewModel.CardLists.Count; i++)
                {
                    CardTitleViewModel singleVM = this.cardListViewModel.CardLists[i];
                    if (singleVM.CardId == model.CardId)
                    {
                        index = i;
                        break;
                    }
                }
                SingleCardUserControl deleteCardUC = this.cardUCLists[index];
                CardPanel.Children.Remove(deleteCardUC);
                this.cardUCLists.RemoveAt(index);
                this.cardListViewModel.CardLists.RemoveAt(index);

                foreach (CardContent content in deleteCardUC.cardTitleVM.Contents)
                {
                    if (content.AlarmTime != null)
                    {
                        ToastUtil toastUtil = new ToastUtil();
                        toastUtil.removeToast(content);
                    }
                }
            }
        }