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


C# SortedList.IndexOfValue方法代码示例

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


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

示例1: createViewDatatable

		private void createViewDatatable(SortedList columnOrder)
		{
			ViewDatatable = new DataTable();

			for(int i=0;i<columnOrder.Count; i++)
			{
				viewTableColumnNames viewColumnName;
				Common.Interface.ImportFileColumns dataColumnName;
				string temp = (string)columnOrder.GetKey(
					columnOrder.IndexOfValue(i));
				dataColumnName = convertImportFileColumnsName(temp);
				switch(dataColumnName)
				{
					case Common.Interface.ImportFileColumns.ClubId:
						viewColumnName = viewTableColumnNames.Klubb;
						break;
					case Common.Interface.ImportFileColumns.Email:
						viewColumnName = viewTableColumnNames.Epost;
						break;
					case Common.Interface.ImportFileColumns.Givenname:
						viewColumnName = viewTableColumnNames.Fornamn;
						break;
					case Common.Interface.ImportFileColumns.Lane:
						viewColumnName = viewTableColumnNames.Bana;
						break;
					case Common.Interface.ImportFileColumns.Patrol:
						viewColumnName = viewTableColumnNames.Patrull;
						break;
					case Common.Interface.ImportFileColumns.ShooterClass:
						viewColumnName = viewTableColumnNames.Klass;
						break;
					case Common.Interface.ImportFileColumns.ShooterId:
						viewColumnName = viewTableColumnNames.Skyttekort;
						break;
					case Common.Interface.ImportFileColumns.Surname:
						viewColumnName = viewTableColumnNames.Efternamn;
						break;
					case Common.Interface.ImportFileColumns.WeaponId:
						viewColumnName = viewTableColumnNames.Vapen;
						break;
					default:
						throw new ApplicationException("Unknown datacolumn");
				}
				try
				{
					ViewDatatable.Columns.Add(viewColumnName.ToString(), typeof(string));
				}
				catch(Exception)
				{
				}
			}
		}
开发者ID:WinShooter,项目名称:WinShooter-Legacy,代码行数:52,代码来源:CFileImport.cs

示例2: TestIndexOfValue2

		public void TestIndexOfValue2 ()
		{
			SortedList list = new SortedList ();
			list.Add ("key0", "la la");
			list.Add ("key1", "value");
			list.Add ("key2", "value");

			int i = list.IndexOfValue ("value");
			Assert.AreEqual (1, i);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:10,代码来源:SortedListTest.cs

示例3: TestIndexOfValue

		public void TestIndexOfValue ()
		{
			SortedList sl1 = new SortedList (24);
			string s = null;
			for (int i = 0; i < 50; i++) {
				s = string.Format ("{0:D2}", i);
				sl1.Add ("kala " + s, 100 + i * i);
			}
			for (int i = 0; i < 50; i++) {
				s = string.Format ("{0:D2}", i + 50);
				sl1.Add ("kala " + s, 100 + i * i);
			}
			Assert.AreEqual (-1, sl1.IndexOfValue (102), "#1");
			Assert.AreEqual (-1, sl1.IndexOfValue (null), "#2");
			for (int i = 0; i < 50; i++)
				Assert.AreEqual (i, sl1.IndexOfValue (100 + i * i), "#3:" + i);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:17,代码来源:SortedListTest.cs

示例4: RenderContents

		/// -----------------------------------------------------------------------------
		/// <summary>
		/// 
		/// </summary>
		/// <param name="writer"></param>
		/// <remarks>
		/// </remarks>
		/// <history>
		/// 	[jbrinkman]	5/6/2004	Created
		///		[jhenning] 2/22/2005	Added properties
		/// </history>
		/// -----------------------------------------------------------------------------
		protected override void RenderContents(HtmlTextWriter writer)
		{
			writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
			writer.AddAttribute(HtmlTextWriterAttribute.Class, m_objMenu.CssClass);
			writer.AddAttribute(HtmlTextWriterAttribute.Name, m_objMenu.UniqueID);
			writer.AddAttribute(HtmlTextWriterAttribute.Id, m_objMenu.ClientID);

			writer.AddAttribute("orient", ((int)m_objMenu.Orientation).ToString());
			if (m_objMenu.SubMenuOrientation != Orientation.Vertical)
			{
				writer.AddAttribute("suborient", ((int)m_objMenu.SubMenuOrientation).ToString());
			}
			writer.AddAttribute("sysimgpath", m_objMenu.SystemImagesPath);
			if (!String.IsNullOrEmpty(m_objMenu.Target)) writer.AddAttribute("target", m_objMenu.Target); 

			//--- imagelist logic ---
			if (m_objMenu.ImageList.Count > 0)
			{
				SortedList objImagePaths = new SortedList();
				string strList = "";
				string strImagePathList = "";
				foreach (NodeImage objNodeImage in m_objMenu.ImageList) {
					if (objNodeImage.ImageUrl.IndexOf("/") > -1)
					{
						string strPath = objNodeImage.ImageUrl.Substring(0, objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						string strImage = objNodeImage.ImageUrl.Substring(objNodeImage.ImageUrl.LastIndexOf("/") + 1);
						if (objImagePaths.ContainsValue(strPath) == false)
						{
							objImagePaths.Add(objImagePaths.Count, strPath);
						}
						objNodeImage.ImageUrl = string.Format("[{0}]{1}", objImagePaths.IndexOfValue(strPath).ToString(), strImage);
					}
                        strList += (String.IsNullOrEmpty(strList) ? "" : ",") + objNodeImage.ImageUrl;
				}
				for (int intPaths = 0; intPaths <= objImagePaths.Count - 1; intPaths++) 
                    {
                        strImagePathList += (String.IsNullOrEmpty(strImagePathList) ? "" : ",") + objImagePaths.GetByIndex(intPaths).ToString();
				}
				writer.AddAttribute("imagelist", strList);
				writer.AddAttribute("imagepaths", strImagePathList);
			}

			//--- urllist logic ---'
			//Dim objUsedTokens As ArrayList = New ArrayList
			//Me.AssignUrlTokens(m_objMenu.MenuNodes, Nothing, objUsedTokens)
			//If objUsedTokens.Count > 0 Then
			//	writer.AddAttribute("urllist", Join(objUsedTokens.ToArray(), ","))				  'comma safe?!?!?!
			//End If

			if (!String.IsNullOrEmpty(m_objMenu.RootArrowImage)) writer.AddAttribute("rarrowimg", m_objMenu.RootArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.ChildArrowImage)) writer.AddAttribute("carrowimg", m_objMenu.ChildArrowImage); 
			if (!String.IsNullOrEmpty(m_objMenu.WorkImage)) writer.AddAttribute("workimg", m_objMenu.WorkImage); 

			//css attributes
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClass)) writer.AddAttribute("css", m_objMenu.DefaultNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultChildNodeCssClass)) writer.AddAttribute("csschild", m_objMenu.DefaultChildNodeCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassOver)) writer.AddAttribute("csshover", m_objMenu.DefaultNodeCssClassOver); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultNodeCssClassSelected)) writer.AddAttribute("csssel", m_objMenu.DefaultNodeCssClassSelected); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuBarCssClass)) writer.AddAttribute("mbcss", m_objMenu.MenuBarCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.MenuCssClass)) writer.AddAttribute("mcss", m_objMenu.MenuCssClass); 
			if (!String.IsNullOrEmpty(m_objMenu.DefaultIconCssClass)) writer.AddAttribute("cssicon", m_objMenu.DefaultIconCssClass); 

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction)) writer.AddAttribute("js", m_objMenu.JSFunction); 
			if (m_objMenu.UseTables == false) writer.AddAttribute("usetables", "0"); 
			if (m_objMenu.EnablePostbackState) writer.AddAttribute("enablepbstate", "1"); 
			if (m_objMenu.MouseOutDelay != 500) writer.AddAttribute("moutdelay", m_objMenu.MouseOutDelay.ToString()); 
			if (m_objMenu.MouseInDelay != 250) writer.AddAttribute("mindelay", m_objMenu.MouseInDelay.ToString()); 

			writer.AddAttribute("postback", ClientAPI.GetPostBackEventReference(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "Click"));

			if (m_objMenu.PopulateNodesFromClient)
			{
				if (DotNetNuke.UI.Utilities.ClientAPI.BrowserSupportsFunctionality(Utilities.ClientAPI.ClientFunctionality.XMLHTTP))
				{
					writer.AddAttribute("callback", DotNetNuke.UI.Utilities.ClientAPI.GetCallbackEventReference(m_objMenu, "'[NODEXML]'", "this.callBackSuccess", "oMNode", "this.callBackFail", "this.callBackStatus"));
				}
				else
				{
					writer.AddAttribute("callback", ClientAPI.GetPostBackClientHyperlink(m_objMenu, "[NODEID]" + ClientAPI.COLUMN_DELIMITER + "OnDemand"));
				}
				if (!String.IsNullOrEmpty(m_objMenu.CallbackStatusFunction))
				{
					writer.AddAttribute("callbacksf", m_objMenu.CallbackStatusFunction);
				}

			}

			if (!String.IsNullOrEmpty(m_objMenu.JSFunction))
//.........这里部分代码省略.........
开发者ID:huayang912,项目名称:cs-dotnetnuke,代码行数:101,代码来源:DNNMenuUpLevelWriter.cs

示例5: DownloadAmeriFluxTS

 private XmlDocument DownloadAmeriFluxTS(string SiteCodeTS, string[] VariableCodes, string StartDate, string EndDate)
 {
     if (VariableCodes.Length == 0)
     {
         throw new Exception("No variable codes provided");
     }
     XmlDocument found = null;
     System.DateTime dtStart;
     System.DateTime dtEnd;
     dtStart = Convert.ToDateTime(StartDate);
     dtEnd = Convert.ToDateTime(EndDate);
     string sURL;
     sURL = BuildAmeriFluxTSURL(SiteCodeTS, VariableCodes, dtStart, dtEnd);
     string sTxt;
     sTxt = utils.DownloadASCII(sURL);
     int i;
     int j;
     i = sTxt.IndexOf(".csv");
     if (i == 0)
     {
         throw new Exception("URL did not return link to csv file: " + Environment.NewLine + sURL);
     }
     sTxt = sTxt.Substring(i + 5);
     i = sTxt.IndexOf(".csv");
     sTxt = sTxt.Substring(0, i + 4);
     sTxt = utils.DownloadASCII(sTxt);
     string[] sLines;
     string[] sParts;
     string sPart;
     sLines = sTxt.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
     System.Collections.SortedList slFields = new System.Collections.SortedList();
     System.Collections.SortedList slUnits = new System.Collections.SortedList();
     string sUnits;
     string sField;
     sParts = sLines[0].Split(',');
     for (int k = 0; k <= sParts.Length - 1; k++)
     {
         sPart = sParts[k].Trim();
         i = sPart.IndexOf("(");
         if (i > -1)
         {
             sField = sPart.Substring(0, i).Trim();
             j = sPart.IndexOf(")", i);
             if (j == -1)
             {
                 j = sPart.Length - 1;
             }
             sUnits = sPart.Substring(i + 1, j - i - 1).Trim();
         }
         else
         {
             sField = sPart;
             sUnits = "";
         }
         if (sPart.Length > 0)
         {
             slFields.Add(k, sField);
             slUnits.Add(k, sUnits);
         }
     }
     if (sLines.Length < 2)
     {
         throw new Exception("No time series values returned for site " + SiteCodeTS);
     }
     XmlElement root;
     XmlElement parent;
     XmlElement row;
     XmlElement element;
     XmlDocument xmlDoc = new XmlDocument();
     root = xmlDoc.CreateElement("AmeriFluxTimeSeries");
     xmlDoc.AppendChild(root);
     XmlElement metadata;
     metadata = xmlDoc.CreateElement("Metadata");
     element = xmlDoc.CreateElement("SiteCode");
     element.InnerText = SiteCodeTS;
     metadata.AppendChild(element);
     element = xmlDoc.CreateElement("SiteName");
     i = slFields.IndexOfValue("Site");
     sParts = sLines[1].Split(',');
     element.InnerText = sParts[i].Replace("'", "");
     metadata.AppendChild(element);
     parent = xmlDoc.CreateElement("Flags");
     metadata.AppendChild(parent);
     row = xmlDoc.CreateElement("Flag");
     parent.AppendChild(row);
     element = xmlDoc.CreateElement("FlagValue");
     element.InnerText = ".";
     row.AppendChild(element);
     element = xmlDoc.CreateElement("FlagMeaning");
     element.InnerText = "Missing value";
     row.AppendChild(element);
     System.DateTime dtGMT;
     System.DateTime dtSite;
     sParts = sLines[1].Split(',');
     i = slFields.IndexOfValue("Year");
     dtSite = DateTime.Parse("1/1/" + sParts[i]);
     i = slFields.IndexOfValue("JD");
     dtSite = dtSite.AddDays(Convert.ToDouble(sParts[i]) - 1);
     i = slFields.IndexOfValue("Hour");
     dtSite = dtSite.AddHours(Convert.ToDouble(sParts[i]));
//.........这里部分代码省略.........
开发者ID:CUAHSI,项目名称:CUAHSI-GenericWOF_vs2013,代码行数:101,代码来源:AmerifluxService.cs

示例6: TestIndexOfValueBasic

        public void TestIndexOfValueBasic()
        {
            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;
            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();

//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:IndexOfValueTests.cs

示例7: IsConnectionOptimal

    /**
     * Checks if connection to the current address is optimal. 
     * Scores can vary over time, and there might be "tight" race for the optimal.
     * We may end up in a situation that we are trimming a connection that is not optimal, even 
     * though the penalty for not using the optimal is marginal. The following algorithm
     * checks that the current selection is in the top-percentile and also the penalty for not
     * using the current optimal is marginal. 
     * @param curr_address address of the current connection target. 
     * @param score_table candidate addresses sorted by scores.
     * @param max_rank maximum rank within the score table, beyond which connection 
     *                 is treated suboptimal.
     */
    protected bool IsConnectionOptimal(Address curr_address, SortedList score_table, int max_rank) {
      if (score_table.Count == 0) {
        if (LogEnabled) {
          ProtocolLog.Write(ProtocolLog.SCO, 
                            String.Format("SCO local: {0}, Not sufficient scores available to determine optimality: {1}.", 
                                          _node.Address, curr_address));
        }
        return true;
      }
            
      bool optimal = false; //if shortcut is optimal.
      bool doubtful = false; //if there is doubt on optimality of this connection.
      int curr_rank = score_table.IndexOfValue(curr_address);
      if (curr_rank == -1) {
        if (LogEnabled) {
          ProtocolLog.Write(ProtocolLog.SCO, 
                            String.Format("SCO local: {0}, No score available for current: {1}.", 
                                          _node.Address, curr_address));
        }
        
        //doubtful case
        doubtful = true;
      } else if (curr_rank == 0) {
        //definitely optimal
        optimal = true;
      } else if (curr_rank <= max_rank) {
        //not the minimum, but still in top percentile.
        double penalty = (double) score_table.GetKey(curr_rank)/(double) score_table.GetKey(0);
        if (LogEnabled) {
          ProtocolLog.Write(ProtocolLog.SCO, 
                            String.Format("SCO local: {0}, Penalty for using current: {1} penalty: {2}).", 
                                          _node.Address, curr_address, penalty));
        }

        //we allow for 10 percent penalty for not using the optimal
        if (penalty < 1.1 ) {
          optimal = true;
        }
      } else {
        if (LogEnabled) {        
          ProtocolLog.Write(ProtocolLog.SCO, 
                            String.Format("SCO local: {0}, Current: {1} too poorly ranked: {2}.", 
                                  _node.Address, curr_address, curr_rank));
        }
      }

      /** 
       * If we are doubtful about the current selection, we will continue to treat it
       * optimal for sometime.
       */
      string log = null;
      lock(_sync) {
        if (optimal) {
          //clear the entry
          _doubts_table.Remove(curr_address);
        } 
        else if (doubtful) { //if we have doubt about the selection
          //make sure that we are not being to generous
          if (!_doubts_table.ContainsKey(curr_address)) {
            _doubts_table[curr_address] = 1;
          } 
          int idx = (int) _doubts_table[curr_address];
          if (idx < MAX_DOUBT_BENEFITS) {
            _doubts_table[curr_address] = idx + 1;
            log = String.Format("SCO local: {0}, Giving benfit: {1} of doubt for current: {2}.", 
                                       _node.Address, idx, curr_address);
            optimal = true;
          } else {
            log = String.Format("SCO local: {0}, Reached quota: {1} on doubts for current: {2}.", 
                                _node.Address, idx, curr_address);
          }
        }
        
        //all efforts to make the connection look optimal have failed
        if (!optimal) {
          //clear the entry
          _doubts_table.Remove(curr_address);          
        }
      } //end of lock
      if (LogEnabled) {
        ProtocolLog.Write(ProtocolLog.SCO, log);
      }
      return optimal;
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:96,代码来源:StructuredShortcutConnectionOverlord.cs

示例8: GetUpperPowerTextureSize

        public EPoint GetUpperPowerTextureSize(EPoint a_size)
        {
            EPoint sizeReturn = new EPoint();
            SortedList aAllowedSizes = new SortedList();
            int n = 4;
            for (int i = 0; i < 10; i++)
            {
                aAllowedSizes.Add(n,i);
                n*=2;
            }

            int nVal = a_size.X;
            for (int i = 0; i < 2; i++)
            {
                aAllowedSizes.Add(nVal, -1);
                int nIndex = aAllowedSizes.IndexOfValue(-1);
                aAllowedSizes.RemoveAt(nIndex);
                if (nIndex > aAllowedSizes.Count)
                    nIndex--;
                nVal = Convert.ToInt32(aAllowedSizes.GetKey(nIndex));
                if (i == 0)
                    sizeReturn.X = nVal;
                else
                    sizeReturn.Y = nVal;

                nVal = a_size.Y;
            }
            return sizeReturn;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:29,代码来源:MemberBitmapBase.cs

示例9: WriteBrushElement

		private void WriteBrushElement(System.Xml.XmlWriter writer,
			FlowChartX.Brush brush, SortedList brushes)
		{
			if(brush == null)
				return;

			int ix = brushes.IndexOfValue(brush);
			if(ix < 0)
				throw new Exception(
					"Brush not found in the brush list!");

			writer.WriteStartElement("Brush");
			writer.WriteAttributeString("Id",
				XmlConvert.FromInt32((int)brushes.GetKey(ix)));

			if(brush.GetType().Equals(typeof(FlowChartX.SolidBrush)))
			{
				FlowChartX.SolidBrush bb =
					(FlowChartX.SolidBrush)brush;

				writer.WriteAttributeString("Type", "Solid");

				writer.WriteElementString("Color",
					XmlConvert.FromColor(bb.Color));
			}
			else if(brush.GetType().Equals(typeof(FlowChartX.HatchBrush)))
			{
				FlowChartX.HatchBrush bb =
					(FlowChartX.HatchBrush)brush;

				writer.WriteAttributeString("Type", "Hatch");

				writer.WriteElementString("ForeColor",
					XmlConvert.FromColor(bb.ForegroundColor));
				writer.WriteElementString("BackColor",
					XmlConvert.FromColor(bb.BackgroundColor));
				writer.WriteElementString("Style",
					bb.HatchStyle.ToString());
			}
			else if(brush.GetType().Equals(typeof(FlowChartX.LinearGradientBrush)))
			{
				FlowChartX.LinearGradientBrush bb =
					(FlowChartX.LinearGradientBrush)brush;

				writer.WriteAttributeString("Type", "Gradient");

				// Write angle
				writer.WriteElementString("Angle",
					XmlConvert.FromSingle(bb.Angle));

				// Write blend pattern
				if(bb.Blend != null)
				{
					writer.WriteStartElement("Blend");

					WriteFloatArrayElement(writer, bb.Blend.Positions,
						"Positions", "Pos");
					WriteFloatArrayElement(writer, bb.Blend.Factors,
						"Factors", "Fac");

					writer.WriteEndElement();
				}

				// Write linear colors
				writer.WriteElementString("Color1",
					XmlConvert.FromColor(bb.LinearColors[0]));
				writer.WriteElementString("Color2",
					XmlConvert.FromColor(bb.LinearColors[1]));

				// Write interpolation colors
				if(bb.InterpolationColor != null)
				{
					writer.WriteStartElement("ColorBlend");

					WriteFloatArrayElement(writer, bb.InterpolationColor.Positions,
						"Positions", "Pos");
					writer.WriteStartElement("Colors");
					writer.WriteAttributeString("Count",
						XmlConvert.FromInt32(bb.InterpolationColor.Colors.Length));
					for(int j = 0; j < bb.InterpolationColor.Colors.Length; j++)
					{
						Color c = (Color)
							bb.InterpolationColor.Colors.GetValue(j);
						writer.WriteElementString("Color",
							XmlConvert.FromColor(c));
					}
					writer.WriteEndElement();

					writer.WriteEndElement();
				}
			}
			else if(brush.GetType().Equals(typeof(FlowChartX.TextureBrush)))
			{
				FlowChartX.TextureBrush bb =
					(FlowChartX.TextureBrush)brush;

				writer.WriteAttributeString("Type", "Texture");

				writer.WriteElementString("WrapMode",
					bb.WrapMode.ToString());
//.........这里部分代码省略.........
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:101,代码来源:XmlWriter.cs

示例10: WriteBrushRefElement

		private void WriteBrushRefElement(System.Xml.XmlWriter writer,
			FlowChartX.Brush brush, string element, SortedList brushes)
		{
			writer.WriteStartElement(element);
			if(brush != null)
			{
				int bi = brushes.IndexOfValue(brush);

				writer.WriteAttributeString("Id",
					XmlConvert.FromInt32((int)brushes.GetKey(bi)));
			}
			else
			{
				writer.WriteAttributeString("Id", "-1");
			}
			writer.WriteEndElement();
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:17,代码来源:XmlWriter.cs

示例11: Write


//.........这里部分代码省略.........
				WriteProperties(writer, t, _tableProps, null);

				writer.WriteEndElement();

				sl.Add(id, t); // map tables to ids
				id++;
			}

			// Close tables element
			writer.WriteEndElement();

			// Write containers in v7
			writer.WriteStartElement("Containers");
			writer.WriteAttributeString("Count", "0");
			writer.WriteEndElement();

			// Write arrows data
			writer.WriteStartElement("Arrows");
			writer.WriteAttributeString("Count",
				XmlConvert.FromInt32(_diagram.Arrows.Count));

			int oi, di;
			int aid = id;
			foreach(Arrow a in _diagram.Arrows)
			{
				writer.WriteStartElement("Arrow");
				writer.WriteAttributeString("Id",
					XmlConvert.FromInt32(aid));
				writer.WriteAttributeString("ZIndex",
					XmlConvert.FromInt32(a.ZIndex));

				if (a.Origin != _diagram.Dummy)
				{
					oi = sl.IndexOfValue(a.Origin);
					if(oi < 0)
						throw new Exception("Unexpected arrow origin index");
					id = (int)sl.GetKey(oi);
				}
				else
				{
					id = -1;
				}

				writer.WriteAttributeString("From", XmlConvert.FromInt32(id));
				if(a.Origin is Table)
					writer.WriteAttributeString("RowFrom",
						XmlConvert.FromInt32(a.OrgnIndex));

				if (a.Destination != _diagram.Dummy)
				{
					di = sl.IndexOfValue(a.Destination);
					if(di < 0)
						throw new Exception("Unexpected arrow destination index");
					id = (int)sl.GetKey(di);
				}
				else
				{
					id = -1;
				}

				writer.WriteAttributeString("To", XmlConvert.FromInt32(id));
				if(a.Destination is Table)
					writer.WriteAttributeString("RowTo",
						XmlConvert.FromInt32(a.DestIndex));

				// Write control points
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:67,代码来源:XmlWriter.cs

示例12: SetupMetadataFilesNode

		private TreeNode SetupMetadataFilesNode(TreeNode projectNode) {
			
			TreeNode metadataFilesNode = GetContextNode(_project.MetadataFiles, tvwProject.Nodes);
			SortedList sortedItems = new SortedList();
			
			if (metadataFilesNode == null) {
				metadataFilesNode = projectNode.Nodes.Add("Metadata Files");
			}
			
			//TreeNode metadataFilesNode = projectNode.Nodes.Add("Metadata Files");
			metadataFilesNode.ImageIndex = Images.Indexes.FolderOpen;
			metadataFilesNode.SelectedImageIndex = Images.Indexes.FolderOpen;
			metadataFilesNode.Tag = _project.MetadataFiles;
			//metadataFilesNode.Nodes.Clear();
			
			foreach (MetadataFile file in _project.MetadataFiles) {
				TreeNode node = GetContextNode(file, metadataFilesNode.Nodes);
				if (node == null) {
					node = new TreeNode();
				}
//				try 
//				{
					node.Tag = file;
					node.Text = file.Name;
					if (File.Exists(file.FullPath) && !sortedItems.ContainsKey(node.Text))
					{
						sortedItems.Add(node.Text, node);
						node.ImageIndex = Images.Indexes.DocumentText;
						node.SelectedImageIndex = Images.Indexes.DocumentText;
					}
					else
					{
						if (sortedItems.ContainsKey(node.Text))
						{
							node.Text = file.Name + " [duplicate 1]" + ERROR_MESSAGE_1;
						}
						else
						{
							node.Text = file.Name + ERROR_MESSAGE_1;
						}
						int i = 1;
						while (sortedItems.ContainsKey(node.Text))
						{
							node.Text = file.Name + string.Format(" [duplicate {0}]", i++) + ERROR_MESSAGE_1;
						}
						sortedItems.Add(node.Text, node);
						node.ImageIndex = Images.Indexes.Delete;
						node.SelectedImageIndex = Images.Indexes.Delete;
					}
//				}
//				catch
//				{
//					if (node == null)
//						node = new TreeNode(file.Name);
//				}
			}
			if (Directory.Exists(_project.GetFullMetadataPath())) 
			{
				string[] files = Directory.GetFiles(_project.GetFullMetadataPath(), "*.xml");
				foreach (string file in files) 
				{
					if (!_project.MetadataFiles.Contains(file)) 
					{
						TreeNode node = new TreeNode(Path.GetFileName(file));
						node.ImageIndex = Images.Indexes.DocumentText + Images.Count;
						node.SelectedImageIndex = Images.Indexes.DocumentText + Images.Count;
						node.Tag = new MetadataFilePlaceholder(Path.GetFileName(file), file);
						sortedItems.Add(Path.GetFileName(file), node);
					}
				}
			}
			for (int i = metadataFilesNode.Nodes.Count - 1; i >= 0; i--)
			{
				TreeNode node = metadataFilesNode.Nodes[i];
				if (sortedItems.IndexOfValue(node) < 0)
				{
					metadataFilesNode.Nodes.Remove(node);
				}
			}
//			foreach (TreeNode node in metadataFilesNode.Nodes)
//			{
//				if (
//					node.Tag != null && node.Tag is MetadataFile &&
//					!_project.MetadataFiles.Contains((MetadataFile) node.Tag)) 
//				{
//					node.Remove();
//				}
//			}
			foreach (DictionaryEntry entry in sortedItems)
			{
				TreeNode node = (TreeNode)entry.Value;
				int index = metadataFilesNode.Nodes.IndexOf(node);
				if (index >= 0 && index != sortedItems.IndexOfValue(node))
				{
					metadataFilesNode.Nodes.Remove(node);
				}
				TreeNode contextNode = GetContextNode(node.Tag, metadataFilesNode.Nodes);
				if (contextNode == null)
				{
					metadataFilesNode.Nodes.Insert(sortedItems.IndexOfValue(node), node);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:101,代码来源:MainForm.cs

示例13: CreateFunctionList

        private string CreateFunctionList(string strFunctionList, string strFunctionListed, string strAuthorized)
        {
            string SValue = "";
               //     if ((strFunctionList.Length <= 0) || !strAuthorized.Equals("Y"))
                if ((strFunctionList.Length <= 0))

            {
                return SValue;
            }
            if (strFunctionListed.Length > 0)
            {
                int i;
                SortedList SortedFunctionListed = new SortedList();
                string[] arrB = strFunctionListed.Split(new char[] { ',' });
                for (i = 0; i < arrB.Length; i++)
                {
                    SortedFunctionListed.Add(SortedFunctionListed.Count, arrB[i]);
                }
                string[] arrA = strFunctionList.Split(new char[] { ',' });
                for (i = 0; i < arrA.Length; i++)
                {
                    if (SortedFunctionListed.IndexOfValue(arrA[i].ToString()) >= 0)
                    {
                        SValue = SValue + "<font color=red>" + arrA[i].ToString() + "</font>,";
                    }
                    else
                    {
                        SValue = SValue + "<font color=grey>" + arrA[i].ToString() + "</font>,";
                    }
                }
                return ("(" + SValue.TrimEnd(new char[] { ',' }) + ")");
            }
            return ("(<font color=grey>" + strFunctionList.TrimEnd(new char[] { ',' }) + "</font>)");
        }
开发者ID:chanhan,项目名称:Project,代码行数:34,代码来源:AuthorityForm.aspx.cs

示例14: TestIndexOfValue

	public void TestIndexOfValue() {
		SortedList sl1 = new SortedList(24);
		string s=null;
		for (int i = 0; i < 50; i++) {
			s=string.Format("{0:D2}", i); 
			sl1.Add("kala "+s,100+i*i);
		}
		for (int i = 0; i < 50; i++) {
			s=string.Format("{0:D2}", i+50); 
			sl1.Add("kala "+s,100+i*i);
		}
		AssertEquals("sl.IndexOfValue: does not return -1 for non-existing value(1)", -1, sl1.IndexOfValue(102));
		AssertEquals("sl.IndexOfValue: does not return -1 for non-existing value(2)", -1, sl1.IndexOfValue(null));
		for (int i=0; i<50; i++) {
			AssertEquals("sl.IndexOfValue: incorrect index key", i, sl1.IndexOfValue(100+i*i));
		}
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:17,代码来源:SortedListTest.cs

示例15: TestIndexOfValue3

		public void TestIndexOfValue3 ()
		{
			SortedList list = new SortedList ();
			int i = list.IndexOfValue ((string) null);
			Assert.AreEqual (1, -i);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:6,代码来源:SortedListTest.cs


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