コード例 #1
0
        public void TestConstructorWithSource()
        {
            var numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
            var sl      = new SquareList <int>(16, numbers);

            Assert.IsTrue(sl.SequenceEqual(numbers));
            sl.Insert(13);
            sl.Insert(100);
            sl.Insert(39);
            sl.Insert(23);
            sl.Insert(93);
            sl.Insert(12);
            sl.Insert(14);
            sl.Insert(15);
            sl.Insert(16);
            sl.Insert(17);
            sl.Insert(18);
            sl.Insert(19);
            sl.Insert(20);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(24, sl.Size);
            sl.Delete(100);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(93, sl.Max);
            Assert.AreEqual(23, sl.Size);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: RiedigerD2/OpenHouse
 public Menu(SquareList list)
 {
     children = list;
     myTimer = new Timer();
     myTimer.Interval = 90000;
     myTimer.Enabled = true;
 }
コード例 #3
0
        public void TestMultipleInsertAndMultipleDelete()
        {
            var sl = new SquareList <int>();

            sl.Insert(1);
            sl.Insert(2);
            sl.Insert(3);
            sl.Insert(4);
            sl.Insert(5);
            sl.Insert(6);
            sl.Insert(7);
            sl.Insert(8);
            sl.Insert(9);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(9, sl.Max);
            Assert.AreEqual(9, sl.Size);
            sl.Delete(1);
            sl.Delete(2);
            sl.Delete(3);
            sl.Delete(4);
            sl.Delete(5);
            Assert.AreEqual(6, sl.Min);
            Assert.AreEqual(9, sl.Max);
            Assert.AreEqual(4, sl.Size);
        }
コード例 #4
0
ファイル: Algorithm.cs プロジェクト: samuel-clemens/WSN
        public string Recognize(SquareList a)
        {
            double[] example = a.ToDoubleArray();
            var      list    = GiveAnswer(ref example);

            return(FormatAnswer(list));
        }
コード例 #5
0
        public void TestSmallWithRepetitions()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(15);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(10, sl.Size);
            sl.Delete(13); // only the first;
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(9, sl.Size);
            sl.Delete(13, true); // all remaining;
            Assert.AreEqual(15, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(1, sl.Size);
            sl.Delete(15, true); // all;
            Assert.AreEqual(0, sl.Min);
            Assert.AreEqual(0, sl.Max);
            Assert.AreEqual(0, sl.Size);
        }
コード例 #6
0
ファイル: NUnitTester.cs プロジェクト: ddemland/Games
        public void TurnOverWrongState()
        {
            var grid       = new Grid();
            var squareList = new SquareList();

            Assert.AreEqual(0, grid.GetTurnOverList(3, 4, false, ref squareList));
        }
コード例 #7
0
        public void TestLarge()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            sl.Insert(100);
            sl.Insert(39);
            sl.Insert(23);
            sl.Insert(93);
            sl.Insert(1);
            sl.Insert(2);
            sl.Insert(3);
            sl.Insert(4);
            sl.Insert(5);
            sl.Insert(6);
            sl.Insert(7);
            sl.Insert(8);
            sl.Insert(9);
            sl.Insert(10);
            sl.Insert(11);
            sl.Insert(12);
            sl.Insert(14);
            sl.Insert(15);
            sl.Insert(16);
            sl.Insert(17);
            sl.Insert(18);
            sl.Insert(19);
            sl.Insert(20);
            sl.Insert(21);
            sl.Insert(22);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(26, sl.Size);
        }
コード例 #8
0
        public void ReadFromFile(string filename)
        {
            try
            {
                using (var sr = new StreamReader(filename))
                {
                    string   firstLine     = sr.ReadLine();
                    string[] firstLineData = firstLine.Split(new char[] { ' ' });
                    string   cols          = firstLineData[0];
                    string   rows          = firstLineData[1];
                    string   perceptrons   = firstLineData[2];

                    if (Int32.Parse(cols) != Globals.Cols || Int32.Parse(rows) != Globals.Rows)
                    {
                        throw new Exception("Zły plik");
                    }

                    this.Samples.Clear();

                    string      nextLine;
                    SampleGroup group     = new SampleGroup();
                    bool        firstTime = true;
                    while ((nextLine = sr.ReadLine()) != null)
                    {
                        if (nextLine[0] == '%')
                        {
                            if (firstTime)
                            {
                                firstTime = false;
                            }
                            else
                            {
                                Samples.Add(group);
                            }
                            group        = new SampleGroup();
                            nextLine     = sr.ReadLine();
                            group.Number = int.Parse(nextLine);
                            group.List   = new List <SquareList>();
                        }
                        else
                        {
                            SquareList list = new SquareList();
                            for (int i = 0; i < nextLine.Count(); ++i)
                            {
                                if (nextLine[i] == '1')
                                {
                                    list[i].IsFilled = true;
                                }
                            }
                            group.List.Add(list);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
ファイル: Algorithm.cs プロジェクト: samuel-clemens/WSN
        public void CorrectWeights(SquareList image, int id, int C)
        {
            var array = image.ToDoubleArray();

            for (int i = 0; i < 2; ++i)
            {
                wieże[id].Correct(array, C);
            }
        }
コード例 #10
0
 public SquareList RemoveNoise(SquareList image)
 {
     int[] array = image.ToIntArray();
     for (int i = 0; i < pixelsCount; ++i)
     {
         array[i] = perceptrons[i].Analize(array);
     }
     return(SquareList.Parse(array, pixelsCount));
 }
コード例 #11
0
        public void CorrectWeights(SquareList image, int id, int C)
        {
            var array = image.ToDoubleArray();

            double[] dftArray = DFT(array);
            for (int i = 0; i < 2; ++i)
            {
                perceptrons[id].Correct(dftArray, C);
            }
        }
コード例 #12
0
        public void TestContains()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(13, sl.Max);
            Assert.AreEqual(false, sl.Contains(39));
            Assert.AreEqual(true, sl.Contains(13));
            Assert.AreEqual(false, sl.Contains(0));
        }
コード例 #13
0
        public void TestEmpty()
        {
            var sl = new SquareList <int>();

            Assert.AreEqual(0, sl.Min);
            Assert.AreEqual(0, sl.Max);
            var slref = new SquareList <SimpleComparable>();

            Assert.AreEqual(null, slref.Min);
            Assert.AreEqual(null, slref.Max);
        }
コード例 #14
0
        public void TestDeleteOnEmpty()
        {
            var sl = new SquareList <int>();

            Assert.AreEqual(0, sl.Min);
            Assert.AreEqual(0, sl.Max);
            Assert.AreEqual(0, sl.Size);
            sl.Delete(13);
            Assert.AreEqual(0, sl.Min);
            Assert.AreEqual(0, sl.Max);
            Assert.AreEqual(0, sl.Size);
        }
コード例 #15
0
        public void TestConstructorWithSourceWithBadSequence()
        {
            Exception exception = null;
            var       numbers   = new int[] { 1, 2, 3, 6, 4, 9, 7, 8, 5, 10, 11 };

            try {
                var sl = new SquareList <int>(16, numbers);
            } catch (Exception e) {
                exception = e;
            }
            Assert.IsNotNull(exception);
            Assert.AreEqual(typeof(ArgumentException), exception.GetType());
        }
コード例 #16
0
        public void TestSingleInsertAndDelete()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(13, sl.Max);
            Assert.AreEqual(1, sl.Size);
            sl.Delete(13);
            Assert.AreEqual(0, sl.Min);
            Assert.AreEqual(0, sl.Max);
            Assert.AreEqual(0, sl.Size);
        }
コード例 #17
0
        private static Results RunTestsFor(int size)
        {
            GC.Collect();
            var results = new Results(size);
            int dummy   = 0;
            var sl      = new SortedList <int, int>(size);

            results.slCre    = Time(() => Create((i) => sl.Add(i, i), size));
            results.slDel    = Time(() => DoAThousandTimes((i) => sl.Remove(i), size));
            results.slIns    = Time(() => DoAThousandTimes((i) => sl.Add(i, i), size));
            results.slSearch = Time(() => DoAThousandTimes((i) => sl.ContainsKey(i), size));
            results.slMin    = Time(() => DoAMillionTimes(() => dummy = sl.Keys[0]));
            results.slMax    = Time(() => DoAMillionTimes(() => dummy = sl.Keys[sl.Keys.Count - 1]));
            SquareList <int> sql = null;

            results.sqlCre = Time(() => sql = new SquareList <int>(size, Range(size)));
            if (!sql.Take(10).SequenceEqual(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }))
            {
                throw new InvalidOperationException();
            }
            results.sqlDel = Time(() => DoAThousandTimes((i) => sql.Delete(i), size));
            if (sql.Size != size - SmallerRepetition)
            {
                throw new InvalidOperationException();
            }
            results.sqlIns = Time(() => DoAThousandTimes((i) => sql.Insert(i), size));
            if (!sql.Take(10).SequenceEqual(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }))
            {
                throw new InvalidOperationException();
            }
            results.sqlDupIns = Time(() => DoAHundredTimes((i) => sql.Insert(i), size));
            if (!sql.Take(2).SequenceEqual(new int[] { 1, 1 }))
            {
                throw new InvalidOperationException();
            }
            results.sqlSearch    = Time(() => DoAThousandTimes((i) => sql.Contains(i), size));
            results.sqlCutInHalf = Time(() => sql.DeleteBelow(size / 2));
            results.sqlShrink    = Time(() => sql.ShrinkWithSlackOf(0));
            if (sql.Min != (size / 2))
            {
                throw new InvalidOperationException();
            }
            results.slMin = Time(() => DoAMillionTimes(() => dummy = sql.Min));
            if (sql.Max != size)
            {
                throw new InvalidOperationException();
            }
            results.slMax = Time(() => DoAMillionTimes(() => dummy = sql.Max));

            return(results);
        }
コード例 #18
0
        public void TestSingle()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(13, sl.Max);
            var slref = new SquareList <SimpleComparable>();
            var c     = new SimpleComparable(13);

            slref.Insert(c);
            Assert.AreSame(c, slref.Min);
            Assert.AreSame(c, slref.Max);
        }
コード例 #19
0
        public void TestDeleteOnNotFound()
        {
            var sl = new SquareList <int>();

            sl.Insert(1);
            sl.Insert(23);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(23, sl.Max);
            Assert.AreEqual(2, sl.Size);
            sl.Delete(13);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(23, sl.Max);
            Assert.AreEqual(2, sl.Size);
        }
コード例 #20
0
        public Board(Canvas canvas, bool isPlayer)
        {
            int height = 10;
            int width  = 10;
            int posGap = 50;

            for (int vertical = 0; vertical < width; vertical++)
            {
                for (int horizontal = 0; horizontal < height; horizontal++)
                {
                    _square = new Square(canvas, horizontal * posGap, vertical * posGap, new Coord(horizontal, vertical),
                                         _squareId = Convert.ToInt32(string.Format("{0}{1}", vertical, horizontal)), isPlayer); //clean it!
                    SquareList.Add(_square);
                }
            }
        }
コード例 #21
0
        public void TestQuadrupleInsertAndDoubleDeleteLastOnes()
        {
            var sl = new SquareList <int>();

            sl.Insert(1);
            sl.Insert(2);
            sl.Insert(3);
            sl.Insert(4);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(4, sl.Max);
            Assert.AreEqual(4, sl.Size);
            sl.Delete(3);
            sl.Delete(4);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(2, sl.Max);
            Assert.AreEqual(2, sl.Size);
        }
コード例 #22
0
        public void AddSampleToList(SquareList sample, int number)
        {
            SampleGroup item = Samples.Find(s => s.Number == number);

            if (item == null)
            {
                var group = new SampleGroup();
                group.Number = number;
                group.List   = new List <SquareList>();
                group.List.Add(sample);
                Samples.Add(group);
            }
            else
            {
                item.List.Add(sample);
            }
        }
コード例 #23
0
ファイル: NUnitTester.cs プロジェクト: ddemland/Games
        public void TurnOverUpperRightLowerLeft()
        {
            int row, column;
            var grid       = new Grid();
            var squareList = new SquareList();

            grid.SetSquareToPlayer(0, 7, false);
            grid.SetSquareToPlayer(1, 6, true);
            grid.SetSquareToPlayer(2, 5, true);

            grid.SetSquareToPlayer(4, 3, true);
            grid.SetSquareToPlayer(5, 2, true);
            grid.SetSquareToPlayer(6, 1, false);

            grid.SetSquareEmpty(3, 4);
            grid.SetCanSelect(3, 4);
            Assert.AreNotEqual(0, grid.GetTurnOverList(3, 4, false, ref squareList));

            while (!squareList.AtEndOfList())
            {
                squareList.GetSquare(out row, out column);
                grid.SetTurnOverSelect(row, column, true);
                squareList.GoToNextSquare();
            }

            for (row = 0; row < Grid.MaxSide; row++)
            {
                for (column = 0; column < Grid.MaxSide; column++)
                {
                    if (((row == 1) && (column == 6)) ||
                        ((row == 2) && (column == 5)) ||
                        ((row == 4) && (column == 3)) ||
                        ((row == 5) && (column == 2)))
                    {
                        Assert.IsTrue(grid.IsTurnOverSelect(row, column));
                    }
                    else
                    {
                        Assert.IsFalse(grid.IsTurnOverSelect(row, column));
                    }
                }
            }
        }
コード例 #24
0
        public int Recognize(SquareList image)
        {
            var array = image.ToDoubleArray();

            double[] dftArray             = DFT(array);
            Tuple <int, double>[] outputs = new Tuple <int, double> [perceptronsCount];

            int max = 0;

            for (int i = 0; i < perceptronsCount; ++i)
            {
                outputs[i] = new Tuple <int, double>(perceptrons[i].Id, perceptrons[i].DotProduct(ref dftArray));
                if (outputs[max].Item2 < outputs[i].Item2)
                {
                    max = i;
                }
            }
            return(outputs[max].Item1);
        }
コード例 #25
0
        public void TestSmall()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            sl.Insert(39);
            sl.Insert(93);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(93, sl.Max);
            var slref = new SquareList <SimpleComparable>();
            var c1    = new SimpleComparable(13);
            var c2    = new SimpleComparable(39);
            var c3    = new SimpleComparable(93);

            slref.Insert(c1);
            slref.Insert(c2);
            slref.Insert(c3);
            Assert.AreSame(c3, slref.Min);
            Assert.AreSame(c1, slref.Max);
        }
コード例 #26
0
        public void TestUnremove()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(13);
            sl.Insert(15);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(10, sl.Size);
            sl.Delete(13, true); // all of them;
            Assert.AreEqual(15, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(1, sl.Size);
            sl.Insert(1);
            sl.Insert(2);
            sl.Insert(3);
            sl.Insert(4);
            sl.Insert(5);
            sl.Insert(6);
            sl.Insert(7);
            sl.Insert(8);
            sl.Insert(9);
            sl.Insert(10);
            sl.Insert(11);
            sl.Insert(12);
            sl.Insert(13);
            sl.Insert(14);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(15, sl.Max);
            Assert.AreEqual(15, sl.Size);
        }
コード例 #27
0
        public override List <GeneralParserPhrase> Parse(string inputText)
        {
            InitLexer(inputText);
            var parser = new SquareList(CommonTokenStream, Output, ErrorOutput);

            Parser = parser;
            parser.ErrorHandler = new BailErrorStrategy();
            try
            {
                var context = parser.bareSquares();
                var visitor = new SquareListVisitor(this);
                visitor.Visit(context);
                return(visitor.Lines);
            }
            catch (Antlr4.Runtime.Misc.ParseCanceledException e)
            {
                return(new List <GeneralParserPhrase>());
            }
            catch (RecognitionException e)
            {
                return(new List <GeneralParserPhrase>());
            }
        }
コード例 #28
0
        public void TestEnumeration()
        {
            var sl = new SquareList <int>();

            sl.Insert(13);
            sl.Insert(39);
            sl.Insert(93);
            Assert.AreEqual(13, sl.Min);
            Assert.AreEqual(93, sl.Max);
            Assert.AreEqual(3, sl.Count());
            Assert.IsTrue(sl.SequenceEqual(new int[] { 13, 39, 93 }));
            var slref = new SquareList <SimpleComparable>();
            var c1    = new SimpleComparable(13);
            var c2    = new SimpleComparable(39);
            var c3    = new SimpleComparable(93);

            slref.Insert(c1);
            slref.Insert(c2);
            slref.Insert(c3);
            Assert.AreSame(c3, slref.Min);
            Assert.AreSame(c1, slref.Max);
            Assert.AreEqual(3, slref.Count());
            Assert.IsTrue(slref.SequenceEqual(new SimpleComparable[] { c3, c2, c1 }));
        }
コード例 #29
0
 /// <summary>
 /// Creates Individual menu
 /// </summary>
 /// <param name="children">the list used to populate the menu</param>
 /// <param name="board">board will begin after a set time of no interactions</param>
 public IndividualMenu(SquareList children,Storyboard board)
     : base(children)
 {
     this.board=board;
     myTimer.Tick += new EventHandler(myTimer_Tick);
 }
コード例 #30
0
        public AllHouseListViewModel(string search)
        {
            SearchContent = search;

            SortTypeList  = new[] { "出售", "出租" };
            DistrictList  = new[] { "全部区域", "青白江区", "郫都区", "金牛区", "成华区", "高新西区", "武侯区", "锦江区", "高新区", "天府新区", "温江区", "新都区", "青羊区", "双流区", "龙泉驿区" };
            RoomStyleList = new[] { "全部房型", "1房", "2房", "3房", "4房及以上" };
            SalePriceList = new[] { "全部价格", "0-30万", "30-50万", "50-100万", "100-150万", "150-200万", "200-300万", "300-500万", "500万以上" };
            SquareList    = new[] { "全部面积", "0-20平", "20-50平", "50-100平", "100-150平", "150-200平", "200-250平", "250-500平", "500-800平", "800平以上" };

            //UsageList = new List<string> { "全部用途", "住宅", "商住", "商铺", "网店", "写字楼", "厂房", "写厂", "铺厂", "仓库", "地皮", "车位", "其他" };
            //PanTypeList = new List<string> { "全部类型", "公盘", "私盘", "特盘", "封盘" };

            SortType  = SortTypeList[0];
            District  = DistrictList[0];
            RoomStyle = RoomStyleList[0];
            SalePrice = SalePriceList[0];
            Square    = SquareList[0];

            HouseItemList     = new ObservableCollection <HouseItemInfo>();
            saleHouseItemList = new List <HouseItemInfo>();
            rentHouseItemList = new List <HouseItemInfo>();
            saleHouseList     = new List <HouseInfo>();
            rentHouseList     = new List <HouseInfo>();

            SaleHousePara = new HousePara
            {
                DistrictName  = "区域",
                CountF        = "房型",
                Price         = "价格",
                Square        = "面积",
                PropertyUsage = "用途",
                EstateName    = "",
                BuildNo       = "",
                RoomNo        = "",
                PanType       = "有效",
                Floor         = "",
                MinPrice      = "",
                MaxPrice      = "",
                EmpID         = ""
            };

            SortList = new ObservableCollection <string>();

            //radios = new bool[5] { false, false, false, false, false };
            radios     = new BitArray(5);
            tempRadios = new BitArray(5);

            SortCommand = new Command <string>((t) =>
            {
                Visible = !Visible;
                if (!Visible)
                {
                    return;
                }

                SortList.Clear();
                switch (t)
                {
                //分类
                case "0":
                    {
                        tempRadios[0] = true;
                        radios        = radios.Or(tempRadios).And(tempRadios); //先或再与,保证只有一个true
                        tempRadios[0] = false;
                        //for (int i = 0; i < 5; i++)
                        //{
                        //    radios[i] = false;
                        //}
                        //radios[0] = true;

                        //SortList.Clear();
                        SortTypeList.ForEach(item => { SortList.Add(item); });
                    }
                    break;

                //区域
                case "1":
                    {
                        tempRadios[1] = true;
                        radios        = radios.Or(tempRadios).And(tempRadios);
                        tempRadios[1] = false;
                        //for (int i = 0; i < 5; i++)
                        //{
                        //    radios[i] = false;
                        //}
                        //radios[1] = true;

                        //SortList.Clear();
                        DistrictList.ForEach(item => { SortList.Add(item); });
                    }
                    break;

                //房型
                case "2":
                    {
                        tempRadios[2] = true;
                        radios        = radios.Or(tempRadios).And(tempRadios);
                        tempRadios[2] = false;
                        //for (int i = 0; i < 5; i++)
                        //{
                        //    radios[i] = false;
                        //}
                        //radios[2] = true;

                        //SortList.Clear();
                        RoomStyleList.ForEach(item => { SortList.Add(item); });
                    }
                    break;

                //价格
                case "3":
                    {
                        tempRadios[3] = true;
                        radios        = radios.Or(tempRadios).And(tempRadios);
                        tempRadios[3] = false;
                        //for (int i = 0; i < 5; i++)
                        //{
                        //    radios[i] = false;
                        //}
                        //radios[3] = true;

                        //SortList.Clear();
                        SalePriceList.ForEach(item => { SortList.Add(item); });
                    }
                    break;

                //面积
                case "4":
                    {
                        tempRadios[4] = true;
                        radios        = radios.Or(tempRadios).And(tempRadios);
                        tempRadios[4] = false;
                        //for (int i = 0; i < 5; i++)
                        //{
                        //    radios[i] = false;
                        //}
                        //radios[4] = true;

                        //SortList.Clear();
                        SquareList.ForEach(item => { SortList.Add(item); });
                    }
                    break;

                default:
                    break;
                }
            }, (t) => { return(true); });

            OnSortChangedCommand = new Command <string>((t) =>
            {
                int index = 0;
                foreach (var item in radios)
                {
                    if ((bool)item)
                    {
                        break;
                    }
                    index++;
                }

                switch (index)
                {
                //分类
                case 0:
                    {
                        SortType = t;
                        if (SortType == "出售")
                        {
                            if (saleHouseItemList.Count == 0)
                            {
                                GetHouseList();
                            }
                            else
                            {
                                HouseItemList.Clear();
                                saleHouseItemList.ForEach(item => { HouseItemList.Add(item); });
                            }
                        }
                        else if (SortType == "出租")
                        {
                            if (rentHouseItemList.Count == 0)
                            {
                                GetHouseList();
                            }
                            else
                            {
                                HouseItemList.Clear();
                                rentHouseItemList.ForEach(item => { HouseItemList.Add(item); });
                            }
                        }
                    }
                    break;

                //区域
                case 1:
                    {
                        District = t;
                        SaleHousePara.DistrictName = District == "全部区域" ? "区域" : District.TrimEnd('区');
                        GetHouseList();
                    }
                    break;

                //房型
                case 2:
                    {
                        RoomStyle            = t;
                        SaleHousePara.CountF = RoomStyle == "全部房型" ? "房型" : RoomStyle;
                        GetHouseList();
                    }
                    break;

                //价格
                case 3:
                    {
                        SalePrice           = t;
                        SaleHousePara.Price = SalePrice == "全部价格" ? "价格" : SalePrice;
                        GetHouseList();
                    }
                    break;

                //面积
                case 4:
                    {
                        Square = t;
                        SaleHousePara.Square = Square == "全部面积" ? "面积" : Square;
                        GetHouseList();
                    }
                    break;

                default:
                    break;
                }
                Visible = false;
            }, (t) => { return(true); });

            /*SortCommand = new Command<string>(async (t) =>
             * {
             *  switch (t)
             *  {
             *      //分类
             *      case "0":
             *          {
             *              string result = await Application.Current.MainPage.DisplayActionSheet("分类", "取消", null, SortTypeList);
             *              SortType = result == null || result == "取消" ? SortType: result;
             *
             *              if (SortType == "出售")
             *              {
             *                  if (saleHouseItemList.Count == 0)
             *                  {
             *                      GetHouseList();
             *                  }
             *                  else
             *                  {
             *                      HouseItemList.Clear();
             *                      saleHouseItemList.ForEach(item => { HouseItemList.Add(item); });
             *                  }
             *              }
             *              else if (SortType == "出租")
             *              {
             *                  if (rentHouseItemList.Count == 0)
             *                  {
             *                      GetHouseList();
             *                  }
             *                  else
             *                  {
             *                      HouseItemList.Clear();
             *                      rentHouseItemList.ForEach(item => { HouseItemList.Add(item); });
             *                  }
             *              }
             *          }
             *          break;
             *
             *      //区域
             *      case "1":
             *          {
             *              string result = await Application.Current.MainPage.DisplayActionSheet("区域", "取消", null, DistrictList);
             *              District = result == null || result == "取消" ? District : result;
             *              SaleHousePara.DistrictName = District == "全部区域" ? "区域" : District.TrimEnd('区');
             *              GetHouseList();
             *          }
             *          break;
             *
             *      //房型
             *      case "2":
             *          {
             *              string result = await Application.Current.MainPage.DisplayActionSheet("区域", "取消", null, RoomStyleList);
             *              RoomStyle = result == null || result == "取消" ? RoomStyle : result;
             *              SaleHousePara.CountF = RoomStyle == "全部房型" ? "房型" : RoomStyle;
             *              GetHouseList();
             *          }
             *          break;
             *
             *      //价格
             *      case "3":
             *          {
             *              string result = await Application.Current.MainPage.DisplayActionSheet("价格", "取消", null, SalePriceList);
             *              SalePrice = result == null || result == "取消" ? SalePrice : result;
             *              SaleHousePara.Price = SalePrice == "全部价格" ? "价格" : SalePrice;
             *              GetHouseList();
             *          }
             *          break;
             *
             *      //面积
             *      case "4":
             *          {
             *              string result = await Application.Current.MainPage.DisplayActionSheet("面积", "取消", null, SquareList);
             *              Square = result == null || result == "取消" ? Square : result;
             *              SaleHousePara.Square = Square == "全部面积" ? "面积" : Square;
             *              GetHouseList();
             *          }
             *          break;
             *
             *      default:
             *          break;
             *  }
             * }, (t) => { return true; });*/

            VisibleCommand = new Command(() =>
            {
                Visible = !Visible;
            }, () => { return(true); });

            SearchCommand = new Command(() =>
            {
                GetHouseList();
            }, () => { return(true); });

            TappedCommand = new Command <string>((h) =>
            {
                if (SortType == "出售")
                {
                    saleHouseList.ForEach((item) =>
                    {
                        if (item.PropertyID == h)
                        {
                            HouseDetailPage houseDetailPage = new HouseDetailPage(item);
                            Application.Current.MainPage.Navigation.PushAsync(houseDetailPage);
                        }
                    });
                }
                else
                {
                    rentHouseList.ForEach((item) =>
                    {
                        if (item.PropertyID == h)
                        {
                            HouseDetailPage houseDetailPage = new HouseDetailPage(item);
                            Application.Current.MainPage.Navigation.PushAsync(houseDetailPage);
                        }
                    });
                }
            }, (h) => { return(true); });

            GetHouseList();
        }
コード例 #31
0
 public IntList(IEnumerable <int> source)
 {
     items   = source.ToArray();
     Squares = new SquareList(this);
 }
コード例 #32
0
        public void TestShrink()
        {
            var sl = new SquareList <int>(9);

            sl.Insert(13);
            sl.Insert(100);
            sl.Insert(39);
            sl.Insert(23);
            sl.Insert(93);
            sl.Insert(1);
            sl.Insert(2);
            sl.Insert(3);
            sl.Insert(4);
            sl.Insert(5);
            sl.Insert(6);
            sl.Insert(7);
            sl.Insert(8);
            sl.Insert(9);
            sl.Insert(10);
            sl.Insert(11);
            sl.Insert(12);
            sl.Insert(14);
            sl.Insert(15);
            sl.Insert(16);
            sl.Insert(17);
            sl.Insert(18);
            sl.Insert(19);
            sl.Insert(20);
            sl.Insert(21);
            sl.Insert(22);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(26, sl.Size);
            Assert.AreEqual(30, sl.Capacity);
            Assert.AreEqual(86, sl.Ratio);
            sl.Delete(2);
            sl.Delete(3);
            sl.Delete(4);
            sl.Delete(5);
            sl.Delete(6);
            sl.Delete(7);
            sl.Delete(8);
            sl.Delete(9);
            sl.Delete(10);
            sl.Delete(11);
            sl.Delete(12);
            sl.Delete(14);
            sl.Delete(15);
            sl.Delete(16);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(12, sl.Size);
            Assert.AreEqual(30, sl.Capacity);
            Assert.AreEqual(40, sl.Ratio);
            sl.ShrinkWithSlackOf(1);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(12, sl.Size);
            Assert.AreEqual(30, sl.Capacity);
            Assert.AreEqual(40, sl.Ratio);
            sl.ShrinkWithSlackOf(0);
            Assert.AreEqual(1, sl.Min);
            Assert.AreEqual(100, sl.Max);
            Assert.AreEqual(12, sl.Size);
            Assert.AreEqual(20, sl.Capacity);
            Assert.AreEqual(60, sl.Ratio);
        }