本文整理汇总了C#中System.Collections.SortedList.GetByIndex方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.GetByIndex方法的具体用法?C# SortedList.GetByIndex怎么用?C# SortedList.GetByIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.SortedList
的用法示例。
在下文中一共展示了SortedList.GetByIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadMoudelTree
public void LoadMoudelTree(string roleCode)
{
DataTable tempTable = roleBll.GetUserModuleListByRoleCode(roleCode);
this.UltraWebTreeModule.Nodes.Clear();
SortedList allTreeNodes = new SortedList();
foreach (DataRow row in tempTable.Rows)
{
Node newNode = base.CreateNode(Convert.ToString(row["modulecode"]), FunctionText.ResourceManager.GetString(row["LANGUAGE_KEY"].ToString()) + this.CreateFunctionList(Convert.ToString(row["FunctionList"]), Convert.ToString(row["FunctionListed"]), Convert.ToString(row["Authorized"])), Convert.ToString(row["authorized"]).Equals("Y"), Convert.ToDecimal(tempTable.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M);
allTreeNodes.Add(Convert.ToString(row["modulecode"]), newNode);
if (row["parentmodulecode"].ToString().Trim().Length > 0)
{
if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
{
((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"])));
}
}
else
{
this.UltraWebTreeModule.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["modulecode"]))));
}
foreach (Node node in this.UltraWebTreeModule.Nodes)
{
node.Expand(true);
}
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string strDepName;
try
{
if (!this.Page.IsPostBack)
{
this.ModuleCode.Value = "KQMSYS306";
this.UltraWebTreeData.Nodes.Clear();
SortedList allTreeNodes = new SortedList();
RelationSelectorBll bll = new RelationSelectorBll();
DataTable tempTable = bll.GetTypeDataList(CurrentUserInfo.Personcode, "Foxconn", this.ModuleCode.Value, "N");
foreach (DataRow row in tempTable.Rows)
{
strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
if (row["costcode"].ToString().Trim().Length > 0)
{
strDepName = strDepName + "-" + row["costcode"].ToString();
}
Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
if (row["deleted"].ToString().Equals("Y"))
{
node.Style.BorderColor = Color.DarkGray;
}
allTreeNodes.Add(row["depcode"].ToString(), node);
if (row["parentdepcode"].ToString().Trim().Length > 0)
{
if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
{
((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
}
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
}
}
}
}
catch (Exception ex)
{
//base.WriteMessage(2, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message);
}
}
示例3: VisitDocumentElements
internal override void VisitDocumentElements(DocumentElements elements)
{
SortedList splitParaList = new SortedList();
for (int idx = 0; idx < elements.Count; ++idx)
{
Paragraph paragraph = elements[idx] as Paragraph;
if (paragraph != null)
{
Paragraph[] paragraphs = paragraph.SplitOnParaBreak();
if (paragraphs != null)
splitParaList.Add(idx, paragraphs);
}
}
int insertedObjects = 0;
for (int idx = 0; idx < splitParaList.Count; ++idx)
{
int insertPosition = (int)splitParaList.GetKey(idx);
Paragraph[] paragraphs = (Paragraph[])splitParaList.GetByIndex(idx);
foreach (Paragraph paragraph in paragraphs)
{
elements.InsertObject(insertPosition + insertedObjects, paragraph);
++insertedObjects;
}
elements.RemoveObjectAt(insertPosition + insertedObjects);
--insertedObjects;
}
}
示例4: Button
public Button()
{
this.m_bNoScalingOnSetRect = true;
Name = "Button";
this.MouseActive = true;
m_plStateSprites = new SortedList();
Frame spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Up");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Leave, (Sprite)spFrame);
spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Down");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Enter, (Sprite)spFrame);
for (int i = 0; i < m_plStateSprites.Count; i++)
{
((Sprite)m_plStateSprites.GetByIndex(i)).Visible = false;
}
((Sprite)m_plStateSprites[MouseEventType.Leave]).Visible = true;
}
示例5: Main
static void Main(string[] args)
{
SortedList traductor = new SortedList();
traductor.Add("{", "begin");
traductor.Add("}", "begin");
traductor.Add("WriteLine", "WriteLn");
traductor.Add("ReadLine", "ReadLn");
traductor.Add("void", "procedure");
traductor.Add("Console", "");
//StreamReader fichero_origen;
//fichero_origen = File.OpenText("prueba.cs");
List<string> lista = File.ReadAllLines("prueba.cs").ToList();
//fichero_origen.Close();
string itemaux = "";
foreach (string item in lista)
{
itemaux = item;
for (int i = 0; i < traductor.Count; i++)
{
if (item.Contains(traductor.GetKey(i).ToString()))
itemaux = item.Replace(traductor.GetKey(i).ToString(), traductor.GetByIndex(i).ToString());
}
Console.WriteLine(itemaux);
}
}
示例6: Main
static void Main(string[] args)
{
// Here we define the Hashtable obect and initialize it
Hashtable countryCodes = new Hashtable();
countryCodes.Add("358", "Finland");
countryCodes.Add("1", "Canada");
countryCodes.Add("254", "Kenya");
// Here we print the full content of the Hashtable
foreach (string code in countryCodes.Keys)
Console.WriteLine(code + " --> " + countryCodes[code]);
// Here we print all values in the Hastable
Console.WriteLine("Values in the hash table: ");
foreach (string value in countryCodes.Values)
Console.WriteLine(value);
SortedList countryAbbr = new SortedList();
countryAbbr.Add("FI", "Finland");
countryAbbr.Add("NL", "Netherlands");
countryAbbr.Add("IR", "Iran");
countryAbbr.Add("CA", "Canada");
Console.WriteLine("Country with abbreviation NL in sorted list: " + countryAbbr["NL"]);
Console.WriteLine("Third value in the sorted list: " + countryAbbr.GetByIndex(2));
// Here we print the full content of the SortedList
Console.WriteLine("The contnet of the sorted list: ");
foreach (string abbr in countryAbbr.Keys)
Console.WriteLine(abbr + " --> " + countryAbbr[abbr]);
// Here we print all values in the Hastable
Console.WriteLine("Values in the SortedList: ");
foreach (string abbr in countryAbbr.Values)
Console.WriteLine(abbr);
}
示例7: CalcCachedInterpolationInfo
public double[,] CalcCachedInterpolationInfo(double a_dTime, SortedList a_sorted)
{
double[,] aReturn = new double[,]{{1}};
int nIndex = 0;
// if (a_sorted.ContainsKey(a_dTime))
nIndex = a_sorted.IndexOfKey(a_dTime);
if (nIndex >= 0)
{
return new double[,]{{(double)a_sorted.GetByIndex(nIndex)}};
}
else
{
a_sorted.Add(a_dTime, -4711);
nIndex = a_sorted.IndexOfKey(a_dTime);
a_sorted.RemoveAt(nIndex);
}
//nIndex is meant to represent the next index after a_dTime.
//If a_dTime is the same as a key, nIndex should be that key's index - 1
if (nIndex <= 0)
return new double[,]{{(double)a_sorted.GetByIndex(0)}};
if (nIndex >= a_sorted.Count)
return new double[,]{{(double)a_sorted.GetByIndex(a_sorted.Count-1)}};
double dTimeAtIndexBefore = (double)a_sorted.GetKey(nIndex-1);
double dTimeAtIndexAfter = (double)a_sorted.GetKey(nIndex);
if (a_dTime == dTimeAtIndexAfter)
{
/* if (nPos < nCnt) then nPos = nPos+1
fTimePosBefore = a_paList.getPropAt(nPos-1)
fTimePosAfter = a_paList.getPropAt(nPos)*/
}
double dVal1 = 0;
double dVal2 = (double)a_sorted.GetValueList()[nIndex-1];
double dVal3 = (double)a_sorted.GetValueList()[nIndex];
double dVal4 = 0;
//TODO: support commands in the list!
//if (ilk(mvVal2) = #List) then mvVal2 = mvVal3
//if (ilk(mvVal3) = #List) then mvVal3 = mvVal2
if (nIndex == 1)
dVal1 = dVal2;
else
dVal1 = (double)a_sorted.GetValueList()[nIndex-2];
//if (ilk(mvVal1) = #List) then mvVal1 = mvVal2
if (nIndex == a_sorted.Count-1)
dVal4 = dVal3;
else
dVal4 = (double)a_sorted.GetValueList()[nIndex+1];
//TODO if (ilk(mvVal4) = #List) then mvVal4 = mvVal3
aReturn = new double[,] {{dVal1, 0}, {dVal2, dTimeAtIndexBefore}, {dVal3, dTimeAtIndexAfter}, {dVal4,0}};
return aReturn;
}
示例8: TargetSelectorCallback
protected void TargetSelectorCallback(Address start, SortedList score_table, Address current) {
Assert.IsTrue(score_table.Count > 0);
if (current == null) {
Address min_target = (Address) score_table.GetByIndex(0);
Assert.AreEqual(_addr_list[_idx++], min_target);
}
}
示例9: Main
static void Main(string[] args)
{
SortedList sl = new SortedList();
sl.Add("Stack", "Represents a LIFO collection of objects.");
sl.Add("Queue", "Represents a FIFO collection of objects.");
sl.Add("SortedList", "Represents a collection of key/value pairs.");
foreach (DictionaryEntry de in sl)
{
Console.WriteLine("{0,12}: {1}", de.Key, de.Value);
}
Console.WriteLine("\n" + sl["Queue"]);
Console.WriteLine(sl.GetByIndex(1));
Console.WriteLine("\nName Value Collection:");
NameValueCollection nvc = new NameValueCollection();
nvc.Add("Stack", "Represents a LIFO collection of objects.");
nvc.Add("Stack", "A pile of pancakes.");
nvc.Add("Queue", "Represents a FIFO collection of objects.");
nvc.Add("Queue", "In England, a line.");
nvc.Add("SortedList", "Represents a collection of key/value pairs.");
foreach (string s in nvc.GetValues(0))
Console.WriteLine(s);
foreach (string s in nvc.GetValues("Queue"))
Console.WriteLine(s);
}
示例10: Main
/// <summary>
/// The main entry point of the application - does all the work, really.
/// </summary>
public static void Main()
{
SortedList table = new SortedList();
string fileData = string.Empty;
Console.WriteLine("This program counts how many times each word occurs in a file.");
Console.Write("Enter the filename of the file to read from:\n > ");
string filename = Console.ReadLine();
while (string.IsNullOrEmpty(filename))
{
Console.Write("You cannot enter a blank path name - try again:\n > ");
filename = Console.ReadLine();
}
// Try to access the file and bail out if an error occurred
try
{
fileData = File.ReadAllText(filename);
}
catch
{
Console.WriteLine("File was not accessible. Please make sure it exists and you have appropriate permission to read it.");
return;
}
// Get the file contents, convert to lowercase and remove all non-alpha and non-space characters,
// then get a raw array (still contains duplicates) of all the words
string[] rawWordArray = WordCountExampleProgram.GetWordsArray(fileData.ToLower());
// For each for in the array...
for (int i = 0; i < rawWordArray.Length; i++)
{
if (!table.ContainsKey(rawWordArray[i]))
{
// If the table does not already contain the key, add it to the list with a count of 1
table.Add(rawWordArray[i], 1);
}
else
{
// Otherwise it was already in the table, increment its previous count by one
table[rawWordArray[i]] = Convert.ToInt32(table[rawWordArray[i]]) + 1;
}
}
// Make a variable to count total words
int totalWords = 0;
// Print out the key and value of each along with some headers
Console.WriteLine("\nWord" + string.Empty.PadRight(50 - "Word".Length, ' ') + "Count\n" + string.Empty.PadRight(50 + "Count".Length, '-'));
for (int i = 0; i < table.Count; i++)
{
int value = Convert.ToInt32(table.GetByIndex(i));
totalWords += value;
Console.WriteLine(String.Format("{0,-50}{1}", table.GetKey(i), value));
}
Console.WriteLine("{0,-50}{1}\n", "TOTAL", totalWords);
}
示例11: Page_Load
/// <summary>
/// 頁面加載--組織樹
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
string strDepName;
if (!this.Page.IsPostBack)
{
this.ModuleCode.Value = Request.QueryString["ModuleCode"].ToString();
string personCode = CurrentUserInfo.Personcode;
string companyId = CurrentUserInfo.CompanyId;
this.UltraWebTreeData.Nodes.Clear();
SortedList allTreeNodes = new SortedList();
RelationSelectorBll bll = new RelationSelectorBll();
DataTable tempTable = bll.GetTypeDataList(personCode, companyId, this.ModuleCode.Value, "N");
foreach (DataRow row in tempTable.Rows)
{
strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
if (row["costcode"].ToString().Trim().Length > 0)
{
strDepName = strDepName + "-" + row["costcode"].ToString();
}
Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
if (row["deleted"].ToString().Equals("Y"))
{
node.Style.ForeColor = Color.DarkGray;
}
allTreeNodes.Add(row["depcode"].ToString(), node);
if (row["parentdepcode"].ToString().Trim().Length > 0)
{
if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
{
((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
}
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
}
}
}
}
示例12: PrintKeysAndValues
public static void PrintKeysAndValues(SortedList myList)
{
Console.WriteLine("\t-KEY-\t-VALUE-");
for (int i = 0; i < myList.Count; i++)
{
Console.WriteLine("\t{0}:\t{1}", myList.GetKey(i), myList.GetByIndex(i));
}
Console.WriteLine();
}
示例13: DoCreateSection
/// <summary>
/// Retourne le dictionnaire de la section nommée dans line, crée la section si nécessaire
/// </summary>
/// <param name="sections">Dictionnaire des sections</param>
/// <param name="line">Ligne contenant un délimiteur de section</param>
/// <returns>Le dictionnaire associé à la section</returns>
protected SortedList DoCreateSection( SortedList sections, string line ) {
string name = line.Substring( 1, line.Length - 2 ) ;
int index = sections.IndexOfKey( name ) ;
if (index == -1) {
SortedList result = new SortedList() ;
sections.Add( name, result ) ;
return result ;
} else return (SortedList) sections.GetByIndex( index ) ;
}
示例14: CheckBoxAbate_CheckedChanged
protected void CheckBoxAbate_CheckedChanged(object sender, EventArgs e)
{
moudelCode = Request.QueryString["modulecode"].ToString();
this.UltraWebTreeData.Nodes.Clear();
SortedList allTreeNodes = new SortedList();
hrmEmpOtherMoveBll.GetDepCodeTable(CurrentUserInfo.Personcode, moudelCode, CurrentUserInfo.CompanyId, "", chkAbate.Checked ? "Y" : "N",logmodel);
dt = hrmEmpOtherMoveBll.GetAuthorizedTreeDept(CurrentUserInfo.Personcode, CurrentUserInfo.CompanyId, moudelCode);
string strDepName = "";
foreach (DataRow row in dt.Rows)
{
strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
if (Convert.ToString(row["costcode"]).Trim().Length > 0)
{
strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
}
Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
if (Convert.ToString(row["deleted"]).Equals("Y"))
{
node.Style.ForeColor = Color.Red;
}
allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
if (row["parentdepcode"].ToString().Trim().Length > 0)
{
if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
{
((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
}
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
}
}
foreach (Node node in this.UltraWebTreeData.Nodes)
{
node.Expand(false);
}
}
示例15: chkAbate_CheckedChanged
//綁定所有的組織代碼 (包含已失效的)
protected void chkAbate_CheckedChanged(object sender, EventArgs e)
{
string strDepName;
string personCode = CurrentUserInfo.Personcode;
string companyId = CurrentUserInfo.CompanyId;
this.UltraWebTreeData.Nodes.Clear();
SortedList allTreeNodes = new SortedList();
DataTable dt = bll.GetTypeDataList(personCode, companyId, moduleCode);
foreach (DataRow row in dt.Rows)
{
strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
if (Convert.ToString(row["costcode"]).Trim().Length > 0)
{
strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
}
Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
if (Convert.ToString(row["deleted"]).Equals("Y") || Convert.ToString(row["deleted"]).Equals(""))
{
node.Style.ForeColor = Color.Red;
}
allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
if (row["parentdepcode"].ToString().Trim().Length > 0)
{
if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
{
((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
}
}
else
{
this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
}
}
foreach (Node node in this.UltraWebTreeData.Nodes)
{
node.Expand(false);
}
}