Пример #1
0
        private void listBox_serviceView_SidSort(object sender, RoutedEventArgs e)
        {
            // 昇順・逆順用コンパレーター
            var comparerator = ((sender as MenuItem).Tag as int?) == 0 ?
                               new Func <ushort, ushort, bool>((a, b) => a <= b) : new Func <ushort, ushort, bool>((a, b) => a >= b);

            // 実質、高々3つの並べ替えなので Bubble Sort で十分
            var sort = new Action <int, int>((start, end) =>
            {
                for (int i = start; i < end; i++)
                {
                    for (int j = i + 1; j <= end; j++)
                    {
                        if (comparerator((listBox_serviceView.Items[j] as ServiceViewItem).ServiceInfo.SID, (listBox_serviceView.Items[i] as ServiceViewItem).ServiceInfo.SID))
                        {
                            var tmp = listBox_serviceView.Items[i];
                            listBox_serviceView.Items[i] = listBox_serviceView.Items[j];
                            listBox_serviceView.Items[j] = tmp;
                        }
                    }
                }
            });

            //選択状態を保存
            var listKeeper = new ListViewSelectedKeeper(listBox_serviceView, true, item => (item as ServiceViewItem).Key);

            //ソート
            sortList.ForEach(data => sort(data.Item1, data.Item2));

            //選択状態を復元
            listKeeper.RestoreListViewSelected();
        }
Пример #2
0
        public bool ReloadInfoData(Func <List <T>, bool> reloadData)
        {
            try
            {
                RefreshStyle();

                //更新前の選択情報の保存
                var oldItems = new ListViewSelectedKeeper(listView, true, GridViewSorter.GetKeyFunc(typeof(T)));

                listView.ItemsSource = null;
                dataList.Clear();

                if (CommonManager.Instance.IsConnected == false)
                {
                    return(false);
                }

                if (reloadData(dataList) == false)
                {
                    return(false);
                }

                if (IsSortViewOnReload == true)
                {
                    this.gvSorter.SortByMultiHeader(dataList);
                }
                else
                {
                    this.gvSorter.ResetSortParams();
                }

                listView.ItemsSource = dataList;

                //選択情報の復元
                oldItems.RestoreListViewSelected();
                return(true);
            }
            catch (Exception ex) { CommonUtil.DispatcherMsgBoxShow(ex.ToString()); }
            return(false);
        }
Пример #3
0
        private void listBox_serviceView_SidSort(object sender, RoutedEventArgs e)
        {
            // 昇順・逆順用コンパレーター
            var comparerator = ((sender as MenuItem).Tag as int?) == 0 ?
                new Func<ushort, ushort, bool>((a, b) => a <= b) : new Func<ushort, ushort, bool>((a, b) => a >= b);

            // 実質、高々3つの並べ替えなので Bubble Sort で十分
            var sort = new Action<int, int>((start, end) =>
            {
                for (int i = start; i < end; i++)
                {
                    for (int j = i + 1; j <= end; j++)
                    {
                        if (comparerator((listBox_serviceView.Items[j] as ChSet5Item).SID, (listBox_serviceView.Items[i] as ChSet5Item).SID))
                        {
                            var tmp = listBox_serviceView.Items[i];
                            listBox_serviceView.Items[i] = listBox_serviceView.Items[j];
                            listBox_serviceView.Items[j] = tmp;
                        }
                    }
                }
            });

            //選択状態を保存
            var listKeeper = new ListViewSelectedKeeper(listBox_serviceView, true, item => (item as ChSet5Item).Key);

            //ソート
            sortList.ForEach(data => sort(data.Item1,data.Item2));

            //選択状態を復元
            listKeeper.RestoreListViewSelected();
        }
Пример #4
0
 public StateListMain(EpgListMainView view) : base(view)
 {
     selectID   = view.GetSelectID();
     selectList = new ListViewSelectedKeeper(null, false, item => (item as SearchItem).KeyID);
     selectList.StoreListViewSelected(view.listView_event);
 }