コード例 #1
0
ファイル: Chunk.cs プロジェクト: tyy996/Banana-Game
        public void GraphicalClear()
        {
            VertexList.Clear();
            IndexList.Clear();

            VertexCount = 0;
        }
コード例 #2
0
        public void Clear()
        {
            VertexList.Clear();
            IndexList.Clear();

            VertexCount = 0;
        }
コード例 #3
0
        /// <summary>
        ///     Deserialize the indexes
        /// </summary>
        protected override void DeserializeIndexes()
        {
            IndexList.Clear();

            foreach (var index in Driver.DeserializeIndex <TKey, TIndex1, TIndex2>(typeof(T), Name) ?? new ConcurrentDictionary <TKey, Tuple <TIndex1, TIndex2> >())
            {
                IndexList.Add(new TableIndex <T, TIndex1, TIndex2, TKey>(index.Value.Item1, index.Value.Item2, index.Key, Resolver));
            }
        }
コード例 #4
0
        /// <summary>
        ///     Deserialize the indexes
        /// </summary>
        protected override async Task DeserializeIndexesAsync()
        {
            IndexList.Clear();

            var indexes = await Driver.DeserializeIndexAsync <TKey, TIndex1, TIndex2>(typeof(T), Name).ConfigureAwait(false);

            foreach (var index in indexes ?? new Dictionary <TKey, Tuple <TIndex1, TIndex2> >())
            {
                IndexList.Add(new TableIndex <T, TIndex1, TIndex2, TKey>(index.Value.Item1, index.Value.Item2, index.Key, Resolver));
            }
        }
コード例 #5
0
        private void UpdateIndexList()
        {
            IndexList.Clear();

            if (TotalIndex <= 7)
            {
                for (var i = 1; i <= TotalIndex; i++)
                {
                    IndexList.Add(i);
                }
            }
            else
            {
                IndexList.Add(1);
                IndexList.Add(2);


                if (CurrentIndex == 1 || CurrentIndex == 2 || CurrentIndex == 3 || CurrentIndex == 4)
                {
                    IndexList.Add(3);
                    IndexList.Add(4);
                    IndexList.Add(5);
                }

                IndexList.Add(null);

                if (CurrentIndex >= TotalIndex - 3)
                {
                    IndexList.Add(null);

                    for (var i = TotalIndex - 4; i <= TotalIndex; i++)
                    {
                        IndexList.Add(i);
                    }
                    return;
                }
                if (CurrentIndex != 1 && CurrentIndex != 2 && CurrentIndex != 3 && CurrentIndex != 4)
                {
                    for (var i = CurrentIndex - 1; i <= (CurrentIndex + 1); i++)
                    {
                        IndexList.Add(i);
                    }
                }
                IndexList.Add(null);
                for (var i = TotalIndex - 1; i <= TotalIndex; i++)
                {
                    IndexList.Add(i);
                }
            }
        }
コード例 #6
0
        private void Initialize()
        {
            IndexList.Clear();
            ItemsCount = 0;
            InnerCollection.Clear();

            foreach (var item in Source)
            {
                var isTarget = Filter(item);
                IndexList.Add(isTarget ? (int?)ItemsCount : null);
                if (isTarget)
                {
                    ItemsCount++;
                    InnerCollection.Add(item);
                }
            }
        }
コード例 #7
0
        private IndexList BuildSortIndex(SortColumnCollection col)
        {
            IndexList arrayList = new IndexList();

            PropertyDescriptor[] sortProperties = BuildSortProperties(col);
            for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++)
            {
                object   rowItem = this.baseList[rowIndex];
                object[] values  = new object[col.Count];

                // Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
                for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++)
                {
                    object value = sortProperties[criteriaIndex].GetValue(rowItem);
                    // Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
                    // Muss IComparable und gleicher Typ sein.

                    if (value != null && value != DBNull.Value)
                    {
                        if (!(value is IComparable))
                        {
                            throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
                        }

                        values[criteriaIndex] = value;
                    }
                }
                arrayList.Add(new SortComparer(col, rowIndex, values));
            }

            if (arrayList[0].ObjectArray.GetLength(0) == 1)
            {
                List <BaseComparer> lbc = BaseListStrategy.GenericSorter(arrayList);
                arrayList.Clear();
                arrayList.AddRange(lbc);
            }
            else
            {
                arrayList.Sort();
            }
            return(arrayList);
        }
コード例 #8
0
        protected void BuildGroup(IndexList list)
        {
            string compVal = String.Empty;

            IndexList.Clear();
            IndexList childList = null;

            foreach (BaseComparer element in list)
            {
                string groupValue = ExtractValue(element);

                if (compVal != groupValue)
                {
                    childList = new IndexList();
                    GroupComparer gc = CreateGroupHeader(element);
                    gc.IndexList = childList;
                }
                CreateGroupedChildren(childList, element);
                compVal = groupValue;
            }
//			ShowIndexList(IndexList);
        }
コード例 #9
0
        private IndexList  BuildSortIndex(ColumnCollection col)
        {
            IndexList arrayList = new IndexList();

            for (int rowIndex = 0; rowIndex < this.table.Rows.Count; rowIndex++)
            {
                DataRow  rowItem = this.table.Rows[rowIndex];
                object[] values  = new object[col.Count];
                for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++)
                {
                    object value = ExtractColumnValue(rowItem, col, criteriaIndex);

                    if (value != null && value != DBNull.Value)
                    {
                        values[criteriaIndex] = value;
                    }
                    else
                    {
                        values[criteriaIndex] = DBNull.Value;
                    }
                }

                arrayList.Add(new SortComparer(col, rowIndex, values));
            }

            if (arrayList[0].ObjectArray.GetLength(0) == 1)
            {
                List <BaseComparer> lbc = BaseListStrategy.GenericSorter(arrayList);
                arrayList.Clear();
                arrayList.AddRange(lbc);
            }
            else
            {
                arrayList.Sort();
            }
            return(arrayList);
        }
コード例 #10
0
		private  IndexList BuildSortIndex(SortColumnCollection col) 
		{
			IndexList arrayList = new IndexList();
			PropertyDescriptor[] sortProperties = BuildSortProperties (col);
			for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
				object rowItem = this.baseList[rowIndex];
				object[] values = new object[col.Count];
				
				// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
				for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
					object value = sortProperties[criteriaIndex].GetValue(rowItem);
					// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
					// Muss IComparable und gleicher Typ sein.
					
					if (value != null && value != DBNull.Value)
					{
						if (!(value is IComparable)){
							throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
						}
						
						values[criteriaIndex] = value;
					}
				}
				arrayList.Add(new SortComparer(col, rowIndex, values));
			}
			
			if (arrayList[0].ObjectArray.GetLength(0) == 1) {
				List<BaseComparer> lbc = BaseListStrategy.GenericSorter (arrayList);
				arrayList.Clear();
				arrayList.AddRange(lbc);
			}
			else {
				arrayList.Sort();
			}
			return arrayList;
		}
コード例 #11
0
		private IndexList  BuildSortIndex(ColumnCollection col)
		{
			IndexList arrayList = new IndexList();
			
			for (int rowIndex = 0; rowIndex < this.table.Rows.Count; rowIndex++){
				DataRow rowItem = this.table.Rows[rowIndex];
				object[] values = new object[col.Count];
				for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++)
				{
					object value = ExtractColumnValue(rowItem,col,criteriaIndex);
					
					if (value != null && value != DBNull.Value)
					{
						values[criteriaIndex] = value;
					}   else {
						values[criteriaIndex] = DBNull.Value;
					}
				}
				
				arrayList.Add(new SortComparer(col, rowIndex, values));
			}
			
			if (arrayList[0].ObjectArray.GetLength(0) == 1) {
				List<BaseComparer> lbc = BaseListStrategy.GenericSorter (arrayList);
				arrayList.Clear();
				arrayList.AddRange(lbc);
			}
			else {
				arrayList.Sort();
			}
			return arrayList;
		}
コード例 #12
0
        public void ReadFromFile()
        {
            const int Cir       = 1;
            const int Pos       = 2;
            const int xPlace    = 3;
            const int yPlace    = 4;
            const int Angle     = 5;
            const int startLine = 6;

            try
            {
                string path = filePath + AppGen.Inst.OrderParams.CarrierName;
                if (!System.IO.File.Exists(path))
                {
                    System.Windows.Forms.MessageBox.Show("CARRIER File not found");
                    return;
                }

                string[] lines = System.IO.File.ReadAllLines(path);
                IndexList.Clear();
                CarrierIndex carrierIndex;

                for (int ii = startLine; ii < lines.Length; ii++)
                {
                    string line = lines[ii];
                    if (line == "")
                    {
                        break;
                    }                         //end of carrier
                    string[] parts = line.Split(("").ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length == 0)
                    {
                        continue;
                    }

                    carrierIndex              = new CarrierIndex();
                    carrierIndex.Master.X     = double.Parse(parts[xPlace]);
                    carrierIndex.Master.Y     = double.Parse(parts[yPlace]);
                    carrierIndex.Master.Cir   = int.Parse(parts[Cir]);
                    carrierIndex.Master.Pos   = int.Parse(parts[Pos]);
                    carrierIndex.Master.Angle = double.Parse(parts[Angle]);

                    IndexList.Add(carrierIndex);

                    if (LastCircleNo < carrierIndex.Master.Cir)
                    {
                        //start Old
                        // CircleRadius[carrierIndex.Master.Cir] = carrierIndex.Master.X;    //first index in circle is the radius (x=radius, y=0)
                        //end old
                        //start New
                        CircleRadius[carrierIndex.Master.Cir] = Math.Sqrt(Math.Pow(carrierIndex.Master.X, 2) + Math.Pow(carrierIndex.Master.Y, 2));    //first index in circle is the radius of srqt of Y and Y <<new>>
                        //end New
                    }
                    LastCircleNo = carrierIndex.Master.Cir;
                    NoOfCircles  = carrierIndex.Master.Cir;
                    NoOfInsAtCircle[carrierIndex.Master.Cir] += 1;    //how many inserts in each cycle


                    //if (ii == startLine)           //first index is the radius (x=radius, y=0)
                    //{
                    //    CircleRadius[1] = carrierIndex.Master.X;
                    //}
                    // CircleRadius[1] = Math.Max(1,2);
                    //if (CurrCycle < carrierIndex.Master.Cir)
                    //{
                    //    CircleRadius[CurrCycle] = carrierIndex.Master.X;
                    //}
                    //CurrCycle = carrierIndex.Master.Cir;
                    //NoOfCircles = Math.Max(NoOfCircles, carrierIndex.Master.Cir);

                    //////////////////////////////////
                    //tbd: read from file!!!:
                    //NoOfInsAtCircle[1] = 15;      //how many inserts in first cycle
                    //NoOfInsAtCircle[2] = 8;       //how many inserts in second cycle

                    //NoOfCircles = 2;              //No of circles

                    //CircleRadius[1] = 86.9;       //radius of first cycle
                    //CircleRadius[2] = 50.1;       //radius of second cycle
                    //////////////////////////////////
                }
            }
            catch { }
        }
コード例 #13
0
        public void RefreshZn()
        {
            Fjcclist.Clear();
            IndexList.Clear();
            for (int i = 0; i < Sbhlist.Length; i++)
            {
                FJCClist    list    = new FJCClist();
                MES_PD_SCRW pd_scrw = new MES_PD_SCRW();
                pd_scrw.SBBH = Sbhlist[i].SBBH;
                pd_scrw.GC   = getGC("value");
                //pd_scrw.GZZXBH = getUserInfo("gzzxvalue");
                pd_scrw.ZPRQ = Convert.ToDateTime(ServicModel.PUBLIC_FUNC.GET_TIME(getToken())).AddHours(-4).ToString("yyyy-MM-dd");
                SELECT_MES_PD_SCRW Smodel = ServicModel.PD_SCRW.SELECT(pd_scrw, getToken());
                if (Smodel.MES_RETURN.TYPE.Equals("S"))
                {
                    list.RwArr = Smodel;
                }
                else
                {
                    list.RwArr = new SELECT_MES_PD_SCRW();
                }
                list.SbStruct = Sbhlist[i];
                Fjcclist.Add(list);
            }
            for (int i = 0; i < Fjcclist.Count; i++)
            {
                if (Fjcclist[i].RwArr.MES_PD_SCRW_LIST == null)
                {
                    IndexList.Add(-2);
                    continue;
                }
                else
                {
                    if (Fjcclist[i].RwArr.MES_PD_SCRW_LIST.Length == Fjcclist[i].RwArr.MES_PD_SCRW_LIST.Count(p => p.ISACTION == 2))
                    {
                        IndexList.Add(-1);
                        continue;
                    }
                    ;
                    int action1Index = Fjcclist[i].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 1);
                    if (action1Index >= 0)
                    {
                        IndexList.Add(action1Index);
                        continue;
                    }
                    int action0Index = Fjcclist[i].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 0);
                    if (action0Index >= 0)
                    {
                        IndexList.Add(action0Index);
                        continue;
                    }
                }
            }
            int panelCount = 0;

            foreach (Control p1 in totalpanel.Controls)
            {
                if (p1 is Panel)
                {
                    foreach (Control item in p1.Controls)
                    {
                        if (Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST == null)
                        {
                            p1.BackColor = Color.FromArgb(252, 228, 214);
                            if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100)
                            {
                                //item.Visible = false;
                                item.Visible = true;
                            }
                            else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100)
                            {
                                item.Visible = true;
                            }
                            else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100)
                            {
                                item.Visible = false;
                            }
                            else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100)
                            {
                                item.Visible = false;
                            }

                            break;
                        }
                        else
                        {
                            if (Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.Length == Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.Count(p => p.ISACTION == 2))
                            {
                                p1.BackColor = Color.FromArgb(252, 228, 214);
                                if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }

                                continue;
                            }
                            ;
                            int action1Index = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 1);
                            if (action1Index >= 0)
                            {
                                p1.BackColor = Color.FromArgb(146, 208, 80);
                                MES_PD_SCRW_LIST[] data = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST;
                                if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titleth) + data[action1Index].TH.ToString();//"桶号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlepf) + data[action1Index].PFDH;//"配方:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlepldh) + data[action1Index].PLDH;//"配料单号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlexfcd) + data[action1Index].XFCDNAME;//"锌粉产地:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlexfcd) + data[action1Index].XFPC;//"锌粉批号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible   = true;
                                    lb.Text      = q(Msg_Type.titlezt) + q(Msg_Type.fieldytl);//"状态:已投料";
                                    lb.ForeColor = Color.Black;
                                }
                                else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100)
                                {
                                    Button btn = (Button)item;
                                    btn.Enabled = true;
                                    btn.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100)
                                {
                                    Button btn = (Button)item;
                                    btn.Enabled = true;
                                    btn.Visible = true;
                                }
                                continue;
                            }
                            int action0Index = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST.ToList().FindIndex(p => p.ISACTION == 0);
                            if (action0Index >= 0)
                            {
                                p1.BackColor = Color.FromArgb(252, 228, 214);
                                MES_PD_SCRW_LIST[] data = Fjcclist[panelCount].RwArr.MES_PD_SCRW_LIST;

                                if (Convert.ToInt32(item.Tag) == 1 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 2 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titleth) + data[action0Index].TH.ToString();//"桶号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 3 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlepf) + data[action0Index].PFDH;//"配方:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 4 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlepldh) + data[action0Index].PLDH;//"配料单号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 5 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlexfcd) + data[action0Index].XFCDNAME;//"锌粉产地:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 6 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible = true;
                                    lb.Text    = q(Msg_Type.titlexfph) + data[action0Index].XFPC;//"锌粉批号:"
                                }
                                else if (Convert.ToInt32(item.Tag) == 7 + panelCount * 100)
                                {
                                    Label lb = (Label)item;
                                    lb.Visible   = true;
                                    lb.Text      = q(Msg_Type.titlezt) + q(Msg_Type.fieldnotl);//"状态:未投料";
                                    lb.ForeColor = Color.Red;
                                }
                                else if (Convert.ToInt32(item.Tag) == 8 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 9 + panelCount * 100)
                                {
                                    item.Visible = false;
                                }
                                else if (Convert.ToInt32(item.Tag) == 10 + panelCount * 100)
                                {
                                    item.Visible = true;
                                }
                                else if (Convert.ToInt32(item.Tag) == 11 + panelCount * 100)
                                {
                                    Button btn = (Button)item;
                                    btn.Visible = true;
                                    btn.Enabled = false;
                                }
                                continue;
                            }
                        }
                    }

                    panelCount++;
                }
            }
        }
コード例 #14
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="source">source collection</param>
        /// <param name="filter">filter function</param>
        public FilteredReadOnlyObservableCollection(TCollection source, Func <TElement, bool> filter)
        {
            Source = source;
            Filter = filter;

            Initialize();

            {
                // propertychanged
                source.ObserveElementPropertyChanged <TCollection, TElement>()
                .Subscribe(x =>
                {
                    var index         = source.IndexOf(x.Sender);
                    var filteredIndex = IndexList[index];
                    var isTarget      = Filter(x.Sender);
                    if (isTarget && filteredIndex == null)
                    {
                        // add
                        AppearNewItem(index);
                    }
                    else if (!isTarget && filteredIndex.HasValue)
                    {
                        // remove
                        DisappearItem(index);
                        IndexList[index] = null;
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, x.Sender, filteredIndex.Value));
                    }
                })
                .AddTo(Subscription);
            }
            {
                // collection changed(support single changed only)
                source.CollectionChangedAsObservable()
                .Subscribe(x =>
                {
                    switch (x.Action)
                    {
                    case NotifyCollectionChangedAction.Add:
                        // appear
                        IndexList.Insert(x.NewStartingIndex, null);
                        if (Filter(x.NewItems.Cast <TElement>().Single()))
                        {
                            AppearNewItem(x.NewStartingIndex);
                        }
                        break;

                    case NotifyCollectionChangedAction.Move:
                        throw new NotSupportedException("Move is not supported");

                    case NotifyCollectionChangedAction.Remove:
                        var removedIndex = IndexList[x.OldStartingIndex];
                        if (removedIndex.HasValue)
                        {
                            DisappearItem(x.OldStartingIndex);
                            IndexList.RemoveAt(x.OldStartingIndex);
                            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
                                                                                     x.OldItems.Cast <TElement>().Single(), removedIndex.Value));
                        }
                        else
                        {
                            IndexList.RemoveAt(x.OldStartingIndex);
                        }
                        break;

                    case NotifyCollectionChangedAction.Replace:
                        var index    = IndexList[x.NewStartingIndex];
                        var isTarget = Filter(x.NewItems.Cast <TElement>().Single());
                        if (index == null && isTarget)
                        {
                            // add
                            AppearNewItem(x.NewStartingIndex);
                        }
                        else if (index.HasValue && isTarget)
                        {
                            // replace
                            InnerCollection[index.Value] = x.NewItems.Cast <TElement>().Single();
                            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace,
                                                                                     x.NewItems.Cast <TElement>().Single(), x.OldItems.Cast <TElement>().Single(), index.Value));
                        }
                        else if (index.HasValue && !isTarget)
                        {
                            // remove
                            DisappearItem(x.NewStartingIndex);
                            IndexList[x.NewStartingIndex] = null;
                            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
                                                                                     x.OldItems.Cast <TElement>().Single(), index.Value));
                        }

                        break;

                    case NotifyCollectionChangedAction.Reset:
                        IndexList.Clear();
                        InnerCollection.Clear();
                        OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                        if (source.Any())
                        {
                            throw new NotSupportedException("Reset is clear only");
                        }
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                })
                .AddTo(Subscription);
            }
        }