当前位置: 首页>>代码示例>>C#>>正文


C# SortedList.Remove方法代码示例

本文整理汇总了C#中System.Collections.SortedList.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.Remove方法的具体用法?C# SortedList.Remove怎么用?C# SortedList.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.SortedList的用法示例。


在下文中一共展示了SortedList.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetIsReadOnlyBasic

        public void TestGetIsReadOnlyBasic()
        {
            String strValue;
            SortedList dic1;

            dic1 = new SortedList();
            for (int i = 0; i < 10; i++)
            {
                strValue = "String_" + i;
                dic1.Add(i, strValue);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.True(dic1.Contains(i));
            }

            //we'll do the ReadOnly test
            Assert.False(dic1.IsReadOnly);

            //we'll make sure by doing a modifiable things!!
            dic1.Remove(0);
            Assert.False(dic1.Contains(0));
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:24,代码来源:PropertyIsReadOnlyTests.cs

示例2: foreach

        /// <summary>
        /// this will return a SortedList, the key is the interface name,
        /// and the value is the type definition of the class that implements that interface;
        /// connectors are identified namespace ending with Connectors
        /// </summary>
        private static SortedList <string, TypeDeclaration>GetConnectors(List <CSParser>ACSFiles)
        {
            SortedList <string, TypeDeclaration>Result = new SortedList <string, TypeDeclaration>();

            foreach (CSParser CSFile in ACSFiles)
            {
                foreach (TypeDeclaration t in CSFile.GetClasses())
                {
                    if (t.UserData.ToString().EndsWith("Connectors"))
                    {
                        string Interface = CSParser.GetImplementedInterface(t);

                        if (Interface.Length > 0)
                        {
                            string ServerNamespace = t.UserData.ToString();
                            string ServerNamespaceWithClassName = ServerNamespace + "." + t.Name;
                            string key = ServerNamespaceWithClassName + ":" + Interface;

                            if (Result.ContainsKey(ServerNamespaceWithClassName))
                            {
                                // there is already the other part of the partial class

                                TypeDeclaration partialType = Result[ServerNamespaceWithClassName];

                                Result.Remove(ServerNamespaceWithClassName);

                                foreach (INode child in partialType.Children)
                                {
                                    t.AddChild(child);
                                }
                            }

                            Result.Add(key, t);

                            if (TLogging.DebugLevel > 1)
                            {
                                // TLogging.Log("adding new Connector " + key);
                            }
                        }
                        // either a webconnector, or a partial class
                        else
                        {
                            // web connectors don't derive from an interface, because the methods are static

                            string ServerNamespace = t.UserData.ToString();
                            string key = ServerNamespace + "." + t.Name;

                            if (Result.ContainsKey(key))
                            {
                                // partial class
                                foreach (INode child in t.Children)
                                {
                                    Result[key].AddChild(child);
                                }
                            }
                            else if (t.Name.EndsWith("UIConnector"))
                            {
                                // this could be the partial class of a UIConnector
                                // try to find a key that starts with this type
                                bool foundType = false;

                                foreach (string k in Result.Keys)
                                {
                                    if (k.StartsWith(key + ":"))
                                    {
                                        foundType = true;

                                        foreach (INode child in t.Children)
                                        {
                                            Result[k].AddChild(child);
                                        }
                                    }
                                }

                                if (!foundType)
                                {
                                    Result.Add(key, t);
                                }
                            }
                            else
                            {
                                Result.Add(key, t);
                            }

                            if (TLogging.DebugLevel > 1)
                            {
                                // TLogging.Log("adding new Connector " + key);
                            }
                        }
                    }
                }
            }

            return Result;
        }
开发者ID:Davincier,项目名称:openpetra,代码行数:100,代码来源:CollectConnectors.cs

示例3: GridCell


//.........这里部分代码省略.........

                        _CellEnvironment.Add("NPP", _CellEnvironment["LandNPP"]);
                        _CellEnvironment.Add("DiurnalTemperatureRange", _CellEnvironment["LandDTR"]);
                    }
                }
                else
                {
                    //This is a land cell
                    tempVector = new double[1];
                    tempVector[0] = 1.0;
                    _CellEnvironment.Add("Realm", tempVector);

                    _CellEnvironment.Add("NPP", _CellEnvironment["LandNPP"]);
                    _CellEnvironment.Add("DiurnalTemperatureRange", _CellEnvironment["LandDTR"]);

                }
            }
            else
            {
                Debug.Fail("No land sea mask defined - a mask is required to initialise appropriate ecology");
            }

            //Calculate and add the standard deviation of monthly temperature as a measure of seasonality
            //Also calculate and add the annual mean temperature for this cell
            tempVector = new double[12];
            double[] sdtemp = new double[12];
            double[] meantemp = new double[12];

            tempVector = _CellEnvironment["Temperature"];

            double Average = tempVector.Average();
            meantemp[0] = Average;
            double SumOfSquaresDifferences = tempVector.Select(val => (val - Average) * (val - Average)).Sum();
            sdtemp[0] = Math.Sqrt(SumOfSquaresDifferences / tempVector.Length);

            _CellEnvironment.Add("SDTemperature", sdtemp);
            _CellEnvironment.Add("AnnualTemperature", meantemp);

            //Remove unrequired cell environment layers
            if (_CellEnvironment.ContainsKey("LandNPP")) _CellEnvironment.Remove("LandNPP");
            if (_CellEnvironment.ContainsKey("LandDTR")) _CellEnvironment.Remove("LandDTR");
            if (_CellEnvironment.ContainsKey("OceanNPP")) _CellEnvironment.Remove("OceanNPP");
            if (_CellEnvironment.ContainsKey("OceanDTR")) _CellEnvironment.Remove("OceanDTR");
            if (_CellEnvironment.ContainsKey("SST")) _CellEnvironment.Remove("SST");

            // CREATE NPP SEASONALITY LAYER
            _CellEnvironment.Add("Seasonality", CalculateNPPSeasonality(_CellEnvironment["NPP"], _CellEnvironment["Missing Value"][0]));

            // Calculate other climate variables from temperature and precipitation
            // Declare an instance of the climate variables calculator
            ClimateVariablesCalculator CVC = new ClimateVariablesCalculator();

            // Calculate the fraction of the year that experiences frost
            double[] NDF = new double[1];
            NDF[0] = CVC.GetNDF(_CellEnvironment["FrostDays"], _CellEnvironment["Temperature"],_CellEnvironment["Missing Value"][0]);
            _CellEnvironment.Add("Fraction Year Frost", NDF);

            double[] frostMonthly = new double[12];
            frostMonthly[0] = Math.Min(_CellEnvironment["FrostDays"][0] / 31.0, 1.0);
            frostMonthly[1] = Math.Min(_CellEnvironment["FrostDays"][1] / 28.0, 1.0);
            frostMonthly[2] = Math.Min(_CellEnvironment["FrostDays"][2] / 31.0, 1.0);
            frostMonthly[3] = Math.Min(_CellEnvironment["FrostDays"][3] / 30.0, 1.0);
            frostMonthly[4] = Math.Min(_CellEnvironment["FrostDays"][4] / 31.0, 1.0);
            frostMonthly[5] = Math.Min(_CellEnvironment["FrostDays"][5] / 30.0, 1.0);
            frostMonthly[6] = Math.Min(_CellEnvironment["FrostDays"][6] / 31.0, 1.0);
            frostMonthly[7] = Math.Min(_CellEnvironment["FrostDays"][7] / 31.0, 1.0);
            frostMonthly[8] = Math.Min(_CellEnvironment["FrostDays"][8] / 30.0, 1.0);
            frostMonthly[9] = Math.Min(_CellEnvironment["FrostDays"][9] / 31.0, 1.0);
            frostMonthly[10] = Math.Min(_CellEnvironment["FrostDays"][10] / 30.0, 1.0);
            frostMonthly[11] = Math.Min(_CellEnvironment["FrostDays"][11] / 31.0, 1.0);

            _CellEnvironment.Add("Fraction Month Frost", frostMonthly);
            _CellEnvironment.Remove("FrostDays");

            // Calculate AET and the fractional length of the fire season
            Tuple<double[], double, double> TempTuple = new Tuple<double[], double, double>(new double[12], new double(), new double());
            TempTuple = CVC.MonthlyActualEvapotranspirationSoilMoisture(_CellEnvironment["AWC"][0], _CellEnvironment["Precipitation"], _CellEnvironment["Temperature"]);
            _CellEnvironment.Add("AET", TempTuple.Item1);
            _CellEnvironment.Add("Fraction Year Fire", new double[1] { TempTuple.Item3 / 360 });

            // Designate a breeding season for this grid cell, where a month is considered to be part of the breeding season if its NPP is at
            // least 80% of the maximum NPP throughout the whole year
            double[] BreedingSeason = new double[12];
            for (int i = 0; i < 12; i++)
            {
                if ((_CellEnvironment["Seasonality"][i] / _CellEnvironment["Seasonality"].Max()) > 0.5)
                {
                    BreedingSeason[i] = 1.0;
                }
                else
                {
                    BreedingSeason[i] = 0.0;
                }
            }
            _CellEnvironment.Add("Breeding Season", BreedingSeason);

            // Initialise the grid cell cohort and stock handlers
            _GridCellCohorts = new GridCellCohortHandler(cohortFunctionalGroups.GetNumberOfFunctionalGroups());
            _GridCellStocks = new GridCellStockHandler(stockFunctionalGroups.GetNumberOfFunctionalGroups());
        }
开发者ID:pierovisconti,项目名称:C-sharp-version-of-Madingley-Development,代码行数:101,代码来源:GridCell.cs

示例4: TestRemove

		public void TestRemove ()
		{
			SortedList sl1 = new SortedList (24);
			string s = null;
			int k;
			for (int i = 0; i < 50; i++) sl1.Add ("kala " + i, i);

			try {
				sl1.Remove (s);
				Assert.Fail ("#A");
			} catch (ArgumentNullException) {
			}

			k = sl1.Count;
			sl1.Remove ("kala ");
			Assert.AreEqual (k, sl1.Count, "#B");

			try {
				sl1.Remove (15);
				Assert.Fail ("#C");
			} catch (InvalidOperationException) {
			}

			for (int i = 15; i < 20; i++)
				sl1.Remove ("kala " + i);
			for (int i = 45; i < 55; i++)
				sl1.Remove ("kala " + i);

			Assert.AreEqual (40, sl1.Count, "#D1");
			for (int i = 45; i < 55; i++)
				Assert.IsNull (sl1 ["kala " + i], "#D2:" + i);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:32,代码来源:SortedListTest.cs

示例5: TestIndexOfValueBasic


//.........这里部分代码省略.........

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;
            string s3 = null;
            string s4 = null;

            int i = 0;
            int j = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //  with null - should return -1
            // null val
            j = sl2.IndexOfValue((string)null);
            Assert.Equal(-1, j);

            //  invalid val - should return -1
            j = sl2.IndexOfValue("No_Such_Val");
            Assert.Equal(-1, j);

            // null is a valid value
            sl2.Add("Key_0", null);
            j = sl2.IndexOfValue(null);
            Assert.NotEqual(-1, j);

            // first occurrence check
            sl2.Add("Key_1", "Val_Same");
            sl2.Add("Key_2", "Val_Same");

            j = sl2.IndexOfValue("Val_Same");
            Assert.Equal(1, j);

            sl2.Clear();

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //
            //   Testcase: test IndexOfVal 
            //
            for (i = 0; i < sl2.Count; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_"); //key
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_"); //value
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                //  now use IndexOfKey and IndexOfVal to obtain the same object and check
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1)); //Get the index of this key and then get object
                s4 = (string)sl2.GetByIndex(sl2.IndexOfValue(s2)); //Get the index of this val and then get object
                Assert.True(s3.Equals(s4));

                // now Get using the index obtained thru IndexOfKey () and compare it with s2
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1));
                Assert.True(s3.Equals(s2));
            }

            //
            // Remove a key and then check
            //
            sblMsg.Length = 0;
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

            sl2.Remove(s1); //removes "Key_50"
            j = sl2.IndexOfValue(s1);
            Assert.Equal(-1, j);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:IndexOfValueTests.cs

示例6: VerifyResourceNames

 private static SortedList VerifyResourceNames(Dictionary<string, ResourceData> resourceList, CodeDomProvider codeProvider, ArrayList errors, out Hashtable reverseFixupTable)
 {
     reverseFixupTable = new Hashtable(0, StringComparer.InvariantCultureIgnoreCase);
     SortedList list = new SortedList(StringComparer.InvariantCultureIgnoreCase, resourceList.Count);
     foreach (KeyValuePair<string, ResourceData> pair in resourceList)
     {
         string key = pair.Key;
         if ((string.Equals(key, "ResourceManager") || string.Equals(key, "Culture")) || (typeof(void) == pair.Value.Type))
         {
             errors.Add(key);
         }
         else
         {
             if (((key.Length <= 0) || (key[0] != '$')) && (((key.Length <= 1) || (key[0] != '>')) || (key[1] != '>')))
             {
                 if (!codeProvider.IsValidIdentifier(key))
                 {
                     string str2 = VerifyResourceName(key, codeProvider, false);
                     if (str2 == null)
                     {
                         errors.Add(key);
                         goto Label_0185;
                     }
                     string item = (string) reverseFixupTable[str2];
                     if (item != null)
                     {
                         if (!errors.Contains(item))
                         {
                             errors.Add(item);
                         }
                         if (list.Contains(str2))
                         {
                             list.Remove(str2);
                         }
                         errors.Add(key);
                         goto Label_0185;
                     }
                     reverseFixupTable[str2] = key;
                     key = str2;
                 }
                 ResourceData data = pair.Value;
                 if (!list.Contains(key))
                 {
                     list.Add(key, data);
                 }
                 else
                 {
                     string str4 = (string) reverseFixupTable[key];
                     if (str4 != null)
                     {
                         if (!errors.Contains(str4))
                         {
                             errors.Add(str4);
                         }
                         reverseFixupTable.Remove(key);
                     }
                     errors.Add(pair.Key);
                     list.Remove(key);
                 }
             }
         Label_0185:;
         }
     }
     return list;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:65,代码来源:StronglyTypedResourceBuilder.cs

示例7: RunFormatTests

        protected void RunFormatTests(String workbookName, CellValue valueGetter)
        {

            OpenWorkbook(workbookName);

            ReadFlags(workbook);

            SortedList<string, object> runCategories = new SortedList<string, object>(StringComparer.InvariantCultureIgnoreCase);
            String RunCategoryList = flagString("Categories", "");
            Regex regex = new Regex("\\s*,\\s*");
            if (RunCategoryList != null)
            {
                foreach (string s in regex.Split(RunCategoryList))
                    if (!runCategories.ContainsKey(s))
                        runCategories.Add(s, null);
                runCategories.Remove(""); // this can be found and means nothing
            }

            ISheet sheet = workbook.GetSheet("Tests");
            int end = sheet.LastRowNum;
            // Skip the header row, therefore "+ 1"
            for (int r = sheet.FirstRowNum + 1; r <= end; r++)
            {
                IRow row = sheet.GetRow(r);
                if (row == null)
                    continue;
                int cellnum = 0;
                String expectedText = row.GetCell(cellnum).StringCellValue;
                String format = row.GetCell(1).StringCellValue;
                String testCategoryList = row.GetCell(3).StringCellValue;
                bool byCategory = RunByCategory(runCategories, testCategoryList);
                if ((expectedText.Length > 0 || format.Length > 0) && byCategory)
                {
                    ICell cell = row.GetCell(2);
                    tryFormat(r, expectedText, format, valueGetter, cell);
                }
            }
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:38,代码来源:CellFormatTestBase.cs

示例8: MatchCheques


//.........这里部分代码省略.........
            {
                lock (thisLock)
                {
                    iterations += 1;
                    try
                    {
                        Excel.Workbook myWorkBook = oExcel.Workbooks.Open(currentFile);

                        //Check each worksheet in the book
                        foreach (Excel.Worksheet currWorksheet in myWorkBook.Worksheets)
                        {
                            Excel.Range lastCell = currWorksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing);

                            //if there's something in the worksheet then try and find the cheque
                            if (lastCell.Column > 1)
                            {
                                Excel.Range firstCell = currWorksheet.get_Range("A1", Type.Missing);
                                Excel.Range entireSheetRange = currWorksheet.get_Range(firstCell, lastCell);
                                //foreach (var currCheque in chequeList) //I want to remove items as I'm going so am using the iterate backwards method, and using an enumerator causes errors!
                                for (int currChequeIndex = chequeList.Count - 1; currChequeIndex > -1; currChequeIndex--)
                                {
                                    int currChequeKey = chequeList.Keys[currChequeIndex];
                                    Tuple<string, string> currChequeValues = chequeList.Values[currChequeIndex];
                                    Excel.Range currentFind = null;

                                    currentFind = entireSheetRange.Find(currChequeKey, Type.Missing,
                                                 Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlWhole,
                                                 Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false,
                                                 Type.Missing, Type.Missing);
                                    //Found the cheque, write out the info we want
                                    if (currentFind != null)
                                    {
                                        //Remove the cheque from our list, as we're now wasting time looking for it
                                        chequeList.Remove(currChequeKey);

                                        AddText(outputFileStream, "\"" + currChequeKey.ToString() + "\"" + delimiter);
                                        AddText(outputFileStream, "\"" + currChequeValues.Item1 + "\"" + delimiter);
                                        AddText(outputFileStream, "\"" + currChequeValues.Item2 + "\"" + delimiter);
                                        AddText(outputFileStream, "\"" + currentFile + "\"" + delimiter);
                                        int numCols = currentFind.EntireRow.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Column;
                                        for (int i = 1; i <= numCols; i++)
                                        {
                                            if (i != numCols)
                                            {
                                                AddText(outputFileStream, "\"" + currentFind.EntireRow.Cells[1, i].Text + "\"" + delimiter);
                                            }
                                            else
                                            {
                                                AddText(outputFileStream, "\"" + currentFind.EntireRow.Cells[1, i].Text + "\"" + Environment.NewLine);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        myWorkBook.Close(false, false, Type.Missing);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(myWorkBook); //http://support.microsoft.com/kb/317109

                    }
                    catch (Exception excelOpenFailure)
                    {

                        AddText(errorStream, "\"Excel operation error occurred. Trying to continue. Exception message: " + excelOpenFailure.Message + "\"" + Environment.NewLine);
                        errorCount += 1;
                        lblErrorCount.Text = ("Excel Error Count: " + errorCount);
                        /*//if we fail, try and close the Excel instance if poss, and recreate it! If this completely fails, crash inelegantly :(
开发者ID:Oblongmana,项目名称:Stale-Cheque-Manager,代码行数:67,代码来源:Form1.cs

示例9: Param

        private SortedList Param()
        {
            string POSTStr = PostInput();
            SortedList SortList = new SortedList();
            int index = POSTStr.IndexOf("&");
            string[] Arr = { };
            if (index != -1) //参数传递不只一项
            {
                Arr = POSTStr.Split('&');
                for (int i = 0; i < Arr.Length; i++)
                {
                    int equalindex = Arr[i].IndexOf('=');
                    string paramN = Arr[i].Substring(0, equalindex);
                    string paramV = Arr[i].Substring(equalindex + 1);
                    if (!SortList.ContainsKey(paramN)) //避免用户传递相同参数
                    { SortList.Add(paramN, paramV); }
                    else //如果有相同的,一直删除取最后一个值为准
                    { SortList.Remove(paramN); SortList.Add(paramN, paramV); }
                }
            }
            else //参数少于或等于1项
            {
                int equalindex = POSTStr.IndexOf('=');
                if (equalindex != -1)
                { //参数是1项
                    string paramN = POSTStr.Substring(0, equalindex);
                    string paramV = POSTStr.Substring(equalindex + 1);
                    SortList.Add(paramN, paramV);

                }
                else //没有传递参数过来
                { SortList = null; }
            }
            return SortList;
        }
开发者ID:yinchengzhi,项目名称:C_Sharp_Study,代码行数:35,代码来源:UploadPicTest.aspx.cs

示例10: txtPack_KeyPress

        private void txtPack_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 13)
            {
                e.Handled = true;
            }

            if (e.KeyChar == 13)
            {
                if (CheckNullEvent())
                {
                    SortedList sList = new SortedList(); // 可以打多包

                    int pVolume = int.Parse(txtVolume.Text.Trim());// 每包册数

                    int pNumber = int.Parse(txtItem.Text.Trim());// 每件包数

                    int totalNumber = int.Parse(txtPack.Text.Trim());//总包数

                    // ------------------------------------------------------------//

                    int Index = 1;  //件数

                    int packagenum = 0;

                    int totalVolume = totalNumber * pVolume; // 当前总册数

                    int MaxVolume = BookInfo.PxVolume - BookInfo.DbVolume;//最多可发数量

                    if (totalVolume > MaxVolume)
                    {
                        PMess("发货数量不能大于开单数量, 最多可发" + MaxVolume + "册");
                        return;
                    }

                    if (totalNumber < pNumber)
                    {
                        NNetworkDAO.BuildBatchPackage(ref sList, Index, totalVolume);
                    }
                    else
                    {
                        Index = totalNumber / pNumber; //总件数

                        NNetworkDAO.BuildBatchPackage(ref sList, Index, pNumber * pVolume);

                        if (!(totalNumber % pNumber).Equals(0))
                        {
                            NNetworkDAO.BuildBatchPackage(ref sList, 1, (totalNumber % pNumber) * pVolume);
                        }
                    }

                    if (sList.Count != 0)
                    {
                        sList.Remove(sList.GetKey(sList.Count - 1));
                    }

                    if (sList.Count > 0)
                    {
                        printer.Remark = txtCode.Text.Trim();
                        printer.PackType = 0;
                        printer.Dgv = dgv_PackInfo;
                        printer.PrintList = sList;
                        printer.Print();
                    }

                    //打包进度
                    ScanProgress();
                    SBookInfo();
                    txtItem.Text = "";
                    txtPack.Text = "";
                    txtVolume.Text = "";
                    txtBarcode.Text = "";
                    txtBarcode.Focus();
                    LoadPacksInfo();
                }
            }
        }
开发者ID:rsdgjb,项目名称:ScanApplication,代码行数:77,代码来源:MainForm.cs

示例11: collapseVectors

        protected void collapseVectors(SortedList vectors)
        {
            ArrayList vertices;
            int steps = 0;
            while (vectors.Count > 0) {
                VectorPixel vectorOld = (VectorPixel)vectors.GetByIndex(0); // ensures we begin at start/end of some line (as opposed to an inner segment)
                IntVector2 startPnt = vectorOld.fromPnt;
                VectorPixel vectorNow;
                VectorPixel vectorNew;
                VectorPixel vectorPrev = null;
                Line line = new Line(vectorOld);
                vertices = new ArrayList(1000);
                do {
                    printProgress(ref steps, 2000);
                    vectorNow = (VectorPixel)vectors[vectorOld.toPnt];
                    vectorNew = (VectorPixel)vectors[vectorNow.toPnt];
                    if (!vectorNow.fromPnt.Equals(startPnt) && !vectorNow.toPnt.Equals(startPnt) && vectorNow.linkVector() && line.sameDir(vectorNow) && !vectorNew.linkVector() && line.sameDir(vectorNew) ) {
                        if (line.satisfiesInner(vectorNew)) {
                            // new segment ok, let's try the next one
                            line.update(vectorNew);
                            vectors.Remove(vectorNow.fromPnt);
                            vectorOld = vectorNew;
                        } else if (line.satisfiesOuter(vectorNew)) {
                            // vectorNow can be an outer segment
                            line.update(vectorNew);

                            vertices.Add(new DoubleVector2(line.toPnt));
                            vectors.Remove(vectorNew.fromPnt);
                            vectors.Remove(vectorNow.fromPnt);
                            vectorOld = (VectorPixel)vectors[vectorNew.toPnt];
                            line = new Line(vectorOld);
                        } else {
                            // new segment off, but link is ok as an outer segment
                            line.update(vectorNow);
                            vertices.Add(new DoubleVector2(line.toPnt));
                            vectors.Remove(vectorNow.fromPnt);
                            vectorOld = vectorNew;
                            line = new Line(vectorOld);
                        }
                    } else if (!vectorNow.fromPnt.Equals(startPnt) && line.sameDir(vectorNow)) {
                        // vectorNow is not a simple link between two segments
                        if (line.satisfiesInner(vectorNow)) {
                            // new segment ok, let's try the next one
                            line.update(vectorNow);
                            vectorOld = vectorNow;
                        } else if (line.satisfiesOuter(vectorNow)) {
                            // vectorNow can be an outer segment
                            line.update(vectorNow);
                            vertices.Add(new DoubleVector2(line.toPnt));
                            vectors.Remove(vectorNow.fromPnt);
                            vectorOld = vectorNew;
                            line = new Line(vectorOld);
                        } else {
                            // vectorNow just won't fit - process it separately
                            vertices.Add(new DoubleVector2(line.toPnt));
                            vectorOld = vectorNow;
                            line = new Line(vectorOld);
                        }
                    } else {
                        // vectorNow just won't fit - process it separately
                        vertices.Add(new DoubleVector2(line.toPnt));
                        vectorOld = vectorNow;
                        line = new Line(vectorOld);
                    }
                    if (vectorPrev != null)
                        vectors.Remove(vectorPrev.fromPnt);
                    vectorPrev = vectorOld;
                } while (!vectorOld.fromPnt.Equals(startPnt));
                vectors.Remove(startPnt);
                vertices.TrimToSize();
                polygons.Add(vertices);
            }
        }
开发者ID:piskvorky,项目名称:VectRast,代码行数:73,代码来源:vectrast.cs

示例12: createVectors


//.........这里部分代码省略.........
                     (pixelOn[i + 2, j + 1] & 1);
                 if (type1 == 2 && type2 == 0 || type1 == 0 && type2 == 2 ) { // get rid of illegal situations
                     pixelOn[i + 2, j + 1] |= 1;
                     pixelOn[i + 1, j + 2] |= 1;
                     printWarning("\nillegal pixel configuration at [" + i + ", " + j + "]");
                 }
             }
         }
     for (int j = -1; j < bmp.Height; j++)
         for (int i = -1; i < bmp.Width; i++) {
             printProgress(ref steps, 400000);
             int type =
                 (pixelOn[i + 1, j + 1] & 1) +
                 ((pixelOn[i + 2, j + 1] & 1) << 1) +
                 ((pixelOn[i + 1, j + 2] & 1) << 2) +
                 ((pixelOn[i + 2, j + 2] & 1) << 3);
             IntVector2 fromPnt = new IntVector2();
             IntVector2 toPnt = new IntVector2();
             switch (type) { // create horizontal and vertical vectors between adjacent pixels
                 case 3:
                     // xx
                     // --
                     fromPnt = new IntVector2(i, j);
                     toPnt = new IntVector2(i + 1, j);
                     break;
                 case 12:
                     // --
                     // xx
                     fromPnt = new IntVector2(i + 1, j + 1);
                     toPnt = new IntVector2(i, j + 1);
                     break;
                 case 5:
                     // x-
                     // x-
                     fromPnt = new IntVector2(i, j + 1);
                     toPnt = new IntVector2(i, j);
                     break;
                 case 10:
                     // -x
                     // -x
                     fromPnt = new IntVector2(i + 1, j);
                     toPnt = new IntVector2(i + 1, j + 1);
                     break;
                 case 14:
                     // -x
                     // xx
                     fromPnt = new IntVector2(i + 1, j);
                     toPnt = new IntVector2(i, j + 1);
                     break;
                 case 13:
                     // x-
                     // xx
                     fromPnt = new IntVector2(i + 1, j + 1);
                     toPnt = new IntVector2(i, j);
                     break;
                 case 11:
                     // xx
                     // -x
                     fromPnt = new IntVector2(i, j);
                     toPnt = new IntVector2(i + 1, j + 1);
                     break;
                 case 7:
                     // xx
                     // x-
                     fromPnt = new IntVector2(i, j + 1);
                     toPnt = new IntVector2(i + 1, j);
                     break;
             }
             if (fromPnt.defined) {
                 if (vectorsReverse.Contains(fromPnt)) {
                     VectorPixel oldVP = (VectorPixel)vectorsReverse[fromPnt];
                     if ((toPnt - fromPnt).extension(oldVP.toPnt - oldVP.fromPnt))  {
                         vectors.Remove(oldVP.fromPnt);
                         vectorsReverse.Remove(oldVP.toPnt);
                         fromPnt = oldVP.fromPnt;
                     }
                 }
                 if (vectors.Contains(toPnt)) {
                     VectorPixel oldVP = (VectorPixel)vectors[toPnt];
                     if ((toPnt - fromPnt).extension(oldVP.toPnt - oldVP.fromPnt))  {
                         vectors.Remove(oldVP.fromPnt);
                         vectorsReverse.Remove(oldVP.toPnt);
                         toPnt = oldVP.toPnt;
                     }
                 }
                 if (!fromPnt.Equals(toPnt)) { // do not add null vectors, they ugly :/
                     VectorPixel newVP = new VectorPixel(fromPnt, toPnt);
                     if (vectors.Contains(newVP.fromPnt))
                         throw new Exception("illegal edge configuration at pixel [" + newVP.fromPnt.x + ", " + newVP.fromPnt.y + "]");
                     else
                         vectors.Add(newVP.fromPnt, newVP);
                     if (vectorsReverse.Contains(newVP.toPnt))
                         throw new Exception("illegal edge configuration at pixel [" + newVP.toPnt.x + ", " + newVP.toPnt.y + "]");
                     else
                         vectorsReverse.Add(newVP.toPnt, newVP);
                 }
             }
         }
     return vectors;
 }
开发者ID:piskvorky,项目名称:VectRast,代码行数:101,代码来源:vectrast.cs

示例13: RemoveRule

		internal PswaAuthorizationRule RemoveRule(SortedList<int, PswaAuthorizationRule> allRules, int id)
		{
			PswaAuthorizationRule item = null;
			if (allRules.ContainsKey(id))
			{
				item = allRules[id];
				allRules.Remove(id);
			}
			return item;
		}
开发者ID:nickchal,项目名称:pash,代码行数:10,代码来源:PswaAuthorizationRuleManager.cs

示例14: TestRemoveBasic

        public void TestRemoveBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;
            string s3 = null;

            int i = 0;

            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            Assert.Null(s3);

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //  Verify that the SortedList is empty.
            Assert.Equal(100, sl2.Count);

            //
            //   Testcase: test Remove (Object)
            //
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sl2.Remove(s1); // remove the current object
                Assert.Equal(sl2.Count, (100 - (i + 1)));
            }

            //
            // Boundary - Remove a invalid key: No_Such_Key
            //
            sblMsg.Length = 0;
            sblMsg.Append("No_Such_Key");
            s1 = sblMsg.ToString();
            sl2.Remove(s1);

            //
            // Boundary - null key - pk
            //
            Assert.Throws<ArgumentNullException>(() => { sl2.Remove((string)null); });
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:76,代码来源:RemoveTests.cs

示例15: ShowUsers

        private void ShowUsers()
        {
            Cursor csr = null;
            Database db;
            ListViewItem UsersListViewItem;

            try
            {
                csr = this.Cursor;   // Save the old cursor
                this.Cursor = Cursors.WaitCursor;   // Display the waiting cursor

                // Clear the user list
                UsersListView.Items.Clear();

                // Limit the properties returned to just those that we use
                SqlServerSelection.SetDefaultInitFields(typeof(User),
                    new string[] { "Name", "Login", "ID" });

                // Show the current users for the selected database
                if (DatabasesComboBox.SelectedIndex >= 0)
                {
                    db = (Database)DatabasesComboBox.SelectedItem;

                    // Load list of logins
                    SortedList logins =
                        new SortedList(SqlServerSelection.Logins.Count);

                    foreach (Login userLogin in SqlServerSelection.Logins)
                    {
                        logins.Add(userLogin.Name, null);
                    }

                    // Add users to list view and remove from logins
                    foreach (User usr in db.Users)
                    {
                        UsersListViewItem = UsersListView.Items.Add(usr.Name);
                        UsersListViewItem.SubItems.Add(usr.Login);
                        UsersListViewItem.SubItems.Add(usr.ID.ToString(
                            System.Globalization.CultureInfo.InvariantCulture));

                        // Remove from logins
                        logins.Remove(usr.Login);
                    }

                    // Populate the logins combo box
                    LoginsComboBox.Items.Clear();
                    foreach (DictionaryEntry dictLogin in logins)
                    {
                        // Eliminate sa login from list
                        if ((string)dictLogin.Key != "sa")
                        {
                            LoginsComboBox.Items.Add(dictLogin.Key);
                        }
                    }

                    // Select the first item in the list
                    if (UsersListView.Items.Count > 0)
                    {
                        UsersListView.Items[0].Selected = true;
                        UsersListView.Items[0].EnsureVisible();
                    }
                }
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
            finally
            {
                this.Cursor = csr;  // Restore the original cursor
            }
        }
开发者ID:rcdosado,项目名称:SMO,代码行数:73,代码来源:ManageDatabaseUsers.cs


注:本文中的System.Collections.SortedList.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。