コード例 #1
0
 private void TreeViewSelectedItemChanged(object item)
 {
     if (SelectedTreeItem != item)
     {
         SelectedTreeItem = item;
         ListItemsSource.Refresh();
     }
 }
 public void Refresh()
 {
     OnUIThread(() =>
     {
         ListItemsSource.Refresh();
         SendEventToShell();
     });
 }
コード例 #3
0
        /// <summary>
        /// 引发分页更改事件
        /// </summary>
        private void RaisePageChanged()
        {
            if (pageChangedEventArgs == null)
            {
                pageChangedEventArgs = new PageChangedEventArgs(PageChangedEvent, PageSize, PageIndex);
            }
            else
            {
                pageChangedEventArgs.PageSize  = this.PageSize;
                pageChangedEventArgs.PageIndex = this.PageIndex;
            }
            RaiseEvent(pageChangedEventArgs);
            //calc start、end
            if (ListItemsSource == null && DataViewItemsSource == null)
            {
                Start = End = PageCount = Total = 0;
            }
            if (ListItemsSource != null)
            {
                int curCount = ListItemsSource.Count();
                Start = (PageIndex - 1) * PageSize + 1;
                End   = Start + curCount - 1;

                if (Total % PageSize != 0)
                {
                    PageCount = Total / PageSize + 1;
                }
                else
                {
                    PageCount = Total / PageSize;
                }
            }
            if (DataViewItemsSource != null)
            {
                int curCount = DataViewItemsSource.Count;
                Start = (PageIndex - 1) * PageSize + 1;
                End   = Start + curCount - 1;

                if (Total % PageSize != 0)
                {
                    PageCount = Total / PageSize + 1;
                }
                else
                {
                    PageCount = Total / PageSize;
                }
            }

            //调整图片的显示
            btnFirst.IsEnabled = btnPrev.IsEnabled = (PageIndex != 1);
            btnNext.IsEnabled  = btnLast.IsEnabled = (PageIndex != PageCount);
        }
コード例 #4
0
        protected void ItemDuplicate(IList <IViewModelDetailBase> selectedItemsList)
        {
            var selectionCount = selectedItemsList.Count;

            if (selectionCount > 0)
            {
                string joinedNames = null;
                var    names       = selectedItemsList.Take(4).Select(x => ((ViewModelBase)x).DisplayName);

                joinedNames = string.Join(",\n", names);
                if (selectionCount > 4)
                {
                    joinedNames += "...";
                }

                var confirmation = new ConditionalConfirmation()
                {
                    Content = joinedNames,
                    Title   = "Are you sure you want to create duplicate?".Localize()
                };

                CommonConfirmRequest.Raise(confirmation,
                                           (x) =>
                {
                    if (x.Confirmed)
                    {
                        OnUIThread(() => ShowLoadingAnimation = true);
                        var anyOperationSucceded = false;
                        try
                        {
                            foreach (var item in selectedItemsList.Where(y => y != null))
                            {
                                item.Duplicate();
                                anyOperationSucceded = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            ShowErrorDialog(ex, string.Format("An error occurred when trying to create duplicate\n{0}", joinedNames));
                        }
                        finally
                        {
                            OnUIThread(() => ShowLoadingAnimation = false);
                            if (anyOperationSucceded)
                            {
                                ListItemsSource.Refresh();
                            }
                        }
                    }
                });
            }
        }
コード例 #5
0
        protected void ItemDelete(ConditionalConfirmation confirmation, IList selectedItemsList, IRepository repository)
        {
            var selectionCount = selectedItemsList.Count;

            if (selectionCount > 0)
            {
                CommonConfirmRequest.Raise(confirmation,
                                           (x) =>
                {
                    if (x.Confirmed)
                    {
                        OnUIThread(() => ShowLoadingAnimation = true);
                        var anyOperationSucceded = false;
                        try
                        {
                            foreach (var item in selectedItemsList)
                            {
                                if (item is IViewModelDetailBase)
                                {
                                    (item as IViewModelDetailBase).Delete();
                                }
                                else if (item is T)
                                {
                                    repository.Attach(item);
                                    repository.Remove(item);
                                    repository.UnitOfWork.Commit();
                                }
                                anyOperationSucceded = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            ShowErrorDialog(ex, string.Format("An error occurred when trying to remove"));
                        }
                        finally
                        {
                            OnUIThread(() => ShowLoadingAnimation = false);
                            if (anyOperationSucceded)
                            {
                                ListItemsSource.Refresh();
                            }
                        }
                    }
                });
            }
        }
コード例 #6
0
 protected override void RaiseRefreshCommand()
 {
     ListItemsSource.Refresh();
     ReportFolder = _reportService.GetReportsFolders();
     OnPropertyChanged("ReportFolder");
 }
コード例 #7
0
 protected virtual void AfterItemAddSaved(object item)
 {
     ListItemsSource.Refresh();
 }
 private void DoSearch()
 {
     ListItemsSource.Refresh();
     SelectedItem = null;
 }
コード例 #9
0
 public void Refresh()
 {
     OnUIThread(() => ListItemsSource.Refresh());
 }