private Image GetAny() { Image oPic; string sname; System.Collections.SortedList filelist = new System.Collections.SortedList(); foreach (string newname in oExt.ArchiveFileNames) { if (IsImage(newname)) { filelist.Add(newname, newname); } } sname = Convert.ToString(filelist.GetByIndex(0)); Random anyimageindex = new Random(); sname = Convert.ToString(filelist.GetByIndex(anyimageindex.Next(filelist.Count))); Stream iStream = new System.IO.MemoryStream(); try { oExt.ExtractFile(sname, iStream); } catch (Exception ex) { ComicError("Connot extract " + sname + " from " + currentFile); ComicError(ex.Message); return(null); } oPic = System.Drawing.Bitmap.FromStream(iStream); return(oPic); }
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); } } }
public void MethodSortedList() { sl.Add("key", "SortedObject"); int index = sl.IndexOfKey("key"); if (!(sl["key"].Equals("SortedObject"))) { Environment.Exit(-1); } if (!(sl.GetByIndex(index).Equals("SortedObject"))) { Environment.Exit(-1); } sl["key"] = "NewSortedObject"; if (!(sl["key"].Equals("NewSortedObject"))) { Environment.Exit(-1); } if (!(sl.GetByIndex(index).Equals("NewSortedObject"))) { Environment.Exit(-1); } }
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); } }
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; }
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); }
private void tvcWindows_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { mcPage aPage; mcServer aServer = (mcServer)Servers.GetByIndex(Servers.IndexOfKey(e.Node.Tag)); /* * Locate the server instance. * aServer will never be null, as if the above fails * the client will crash. This should be OK though * s we should NOT be trying to select a non-existant window ;) */ /* find our page */ aPage = aServer.FindPage(e.Node.Text); if (aPage == null) { /* * all this generally means is that they selected, for example, * a "messages" or "channels" node. */ aPage = aServer.CurrentPage; } /* now, we should have a page - focus on it */ aPage.DoFocus(); }
private void m_btIComparerNumeroTexto_Click(object sender, System.EventArgs e) { System.Collections.SortedList sortListTest = new System.Collections.SortedList(new mdlComponentesColecoes.clsComparerNumbersTexts()); // Inserindo os Items sortListTest.Add("1", "1"); sortListTest.Add("2", "2"); sortListTest.Add("5", "5"); sortListTest.Add("10", "10"); sortListTest.Add("11", "11"); sortListTest.Add("Thiago", "Thiago"); sortListTest.Add("22", "22"); sortListTest.Add("", ""); sortListTest.Add("Silvio", "Silvio"); sortListTest.Add("Paulo", "Paulo"); sortListTest.Add("32", "32"); sortListTest.Add("Robson", "Robson"); sortListTest.Add("27", "27"); for (int nCont = 300; nCont < 400; nCont++) { sortListTest.Add(nCont.ToString(), nCont.ToString()); } m_lvOutput.Items.Clear(); for (int nCont = 0; nCont < sortListTest.Count; nCont++) { m_lvOutput.Items.Add((string)sortListTest.GetByIndex(nCont)); } }
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); }
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; } }
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); } }
/// <summary> /// Returns a list of data source names from the local machine. /// </summary> public SortedList GetAllDataSourceNames() { // Get the list of user DSN's first. System.Collections.SortedList dsnList = GetUserDataSourceNames(); // Get list of System DSN's and add them to the first list. System.Collections.SortedList systemDsnList = GetSystemDataSourceNames(); for (int i = 0; i < systemDsnList.Count; i++) { string sName = systemDsnList.GetKey(i) as string; DataSourceType type = (DataSourceType)systemDsnList.GetByIndex(i); try { // This dsn to the master list dsnList.Add(sName, type); } catch { // An exception can be thrown if the key being added is a duplicate so // we just catch it here and have to ignore it. } } return(dsnList); }
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); } }
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; }
/// <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); }
/// <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()))); } } } }
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(); }
/// <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 ) ; }
public GridItem this [int index] { get { if (index >= list.Count) { throw new ArgumentOutOfRangeException("index"); } return((GridItem)list.GetByIndex(index)); } }
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); } }
//綁定所有的組織代碼 (包含已失效的) 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); } }
private Image GetCover() { Image oPic = null; string sname = ""; int xfile = 0; System.Collections.SortedList filelist = new System.Collections.SortedList(); foreach (string newname in oExt.ArchiveFileNames) { if (IsImage(newname)) { filelist.Add(newname, newname); } } sname = Convert.ToString(filelist.GetByIndex(0)); if (oExt.ArchiveFileNames.Contains("ComicInfo.xml")) { MemoryStream xmlStream = new MemoryStream(); oExt.ExtractFile("ComicInfo.xml", xmlStream); xmlStream.Position = 0; xfile = coverfromxml(xmlStream); if (xfile != -1) { sname = Convert.ToString(filelist.GetByIndex(xfile)); } } Stream iStream = new System.IO.MemoryStream(); try { oExt.ExtractFile(sname, iStream); } catch (Exception ex) { ComicError("Connot open " + currentFile); ComicError(ex.Message); return(null); } oPic = System.Drawing.Bitmap.FromStream(iStream); return(oPic); }
/***************************** Constructor *********************************/ public Classification(SortedList columnList, int classLabeCount) { // Initialize DecisionTree decisionAttributes = new DecisionVariable[columnList.Count]; for (int i = 0; i < decisionAttributes.Length; i++) { decisionAttributes[i] = new DecisionVariable((string)columnList.GetByIndex(i), DecisionVariableKind.Continuous); } int classCount = classLabeCount; descisionTree = new DecisionTree(decisionAttributes, classCount); }
// Искать контекст (контекстный анализ) // выходная информация ArrayList (value - IE_Count) // элементы отсортированны по степени их значимости для данной тематики // range – диапазон анализируемой окрестности // screen - порог (в выходном списке будут присутствовать // только те элементы, которые встретились screen и более раз public ArrayList SearchContext(SortedList subject, int range, int screen) { if (subject == null) return null; SortedList candidate = new SortedList(); foreach (/*InfoElement*/IE_Value ie in subject.Values) { // Перебираем все инф. потоки проходящие через данный инф. // элемент for (int i = 0; i < ie.IE.InOut.Count; i++) { int startIndex = (int)ie.IE.InOut.GetKey(i); // Проверяем вперед по инф. потоку Element ie_next = ie.IE; for (int index = startIndex; index < startIndex + range; index++) { Element ie_v = ((InOut)ie_next.InOut[index]).OutIE; if (ie_v == null) break; int index_v = index + 1; CandidateTest(ie_v, index_v, subject, candidate); ie_next = ie_v; } // Проверяем назад по инф. потоку Element ie_prev = ie.IE; for (int index = startIndex; index > startIndex - range; index--) { Element ie_v = ((InOut)ie_prev.InOut[index]).InIE; if (ie_v == null) break; int index_v = index - 1; CandidateTest(ie_v, index_v, subject, candidate); ie_prev = ie_v; } } } // Копируем в выходной массив только те инф. элементы, // которые встречались screen и более раз ArrayList result = new ArrayList(); for (int i = 0; i < candidate.Count; i++) { IE_Index ie_index = (IE_Index)candidate.GetByIndex(i); if (ie_index.Index.Count >= screen) result.Add(new IE_Count(ie_index.IE, ie_index.Index.Count)); } // Копируем в выходной массив множество первичных инф. элементов for (int i = 0; i < subject.Count; i++) { IE_Value ie = (IE_Value)subject.GetByIndex(i); result.Add(new IE_Count(ie.IE, ie.IE.InOut.Count)); } // Соритировка по количеству повторений (по IE_Count.Count) //SortArrayList sort = new SortArrayList(result); return result; }
/// <summary> /// WebTree控件綁定數據 /// </summary> protected void WebTreeBind() { this.UltraWebTreeData.Nodes.Clear(); SortedList allTreeNodes = new SortedList(); DataTable tempTable = moduleBll.GetUserModuleTable(); foreach (DataRow row in tempTable.Rows) { allTreeNodes.Add(Convert.ToString(row["ModuleCode"]), base.CreateNode(Convert.ToString(row["ModuleCode"]), Convert.ToString(row["description"]), false, Convert.ToDecimal(tempTable.Compute("count(ModuleCode)", "parentmodulecode='" + row["ModuleCode"] + "'")) == 0M)); 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.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["ModuleCode"])))); } } }
public void DisplayEmployeesNameAge() { System.Collections.SortedList nameAge = new System.Collections.SortedList(); nameAge.Add("Alicia", 30); nameAge.Add("Mike", 29); nameAge.Add("Adam", 22); nameAge.Add("Andrew", 39); for (int i = 0; i < nameAge.Count; i++) { Console.WriteLine("{0}: {1}", nameAge.GetKey(i), nameAge.GetByIndex(i)); } }
public static int Compare(SortedList a, SortedList b, IComparer comparer) { if (a == null || b == null) { return 1; } int cmp; int limit = (a.Count < b.Count) ? a.Count : b.Count; for(int i=0; i < limit; i++) { if(0 != (cmp = comparer.Compare(a.GetByIndex(i), b.GetByIndex(i)))) { return cmp; } } return a.Count - b.Count; }
public void fun3() { SortedList s1 = new SortedList(); s1.Add(9, 'a'); s1.Add(5, 'f'); s1.Add(7, 'h'); Console.WriteLine(s1.GetKey(0)); Console.WriteLine(s1.GetByIndex(0)); foreach (DictionaryEntry de in s1) { Console.WriteLine("key ={0} value = {1}", de.Key, de.Value); } }
static void Main(string[] args) { SortedList mySL = new SortedList(); mySL.Add("One", "1"); mySL.Add("Two", "2"); mySL.Add("Three", "3"); // Result will be displayed in sorted order as all keys are auto stored in sorted order System.Console.WriteLine("KEY\tVALUE"); System.Console.WriteLine("---\t-----"); for (int i = 0; i < mySL.Count; i++) { System.Console.WriteLine("{0}\t{1}", mySL.GetKey(i), mySL.GetByIndex(i)); } System.Console.WriteLine("\nCapacity of this SortedList: {0}", mySL.Capacity); System.Console.WriteLine("Does this SortedList contain \"One\" as key: {0}", mySL.Contains("One")); System.Console.WriteLine("Number of objects presently in this SortedList: {0}", mySL.Count); System.Console.ReadLine(); }
public void addCategories() { CategoryTypeCollection cats = (CategoryTypeCollection)Session[Global.CATEGORIES]; string name; SortedList catSL = new SortedList(); foreach (CategoryType cat in cats) { if( !cat.LeafCategory ) continue; catSL.Add(int.Parse(cat.CategoryID), cat); } for ( int i = 0; i < catSL.Count; i++ ) { CategoryType cat = (CategoryType) catSL.GetByIndex(i); name = cat.CategoryName; int csId=int.MinValue; bool hasCharacterstic=false; if(cat.CharacteristicsSets!=null &&cat.CharacteristicsSets.Count>0) { csId = cat.CharacteristicsSets[0].AttributeSetID; hasCharacterstic=true; } string csID=hasCharacterstic?("-" + csId):string.Empty; if (name != null && name.Length > 1) { Response.Write("<option value=\"" + cat.CategoryID + "\"" + ">" + cat.CategoryName + " (" + cat.CategoryID + csID + ")</option>"); } else { Response.Write("<option value=\"" + cat.CategoryID + "\"" + ">" + cat.CharacteristicsSets[0].Name + "[" + cat.CategoryID + csID + "]</option>"); } } }
private static void postProcessFolders(SortedList foldersToProcess, bool persistName) { if (foldersToProcess.Count > 0) // && Project.photoAnalyzeOnLoad { // delayed processing of photo images in folder(s), as we need to have all trackpoints in memory first to relate to them: LibSys.StatusBar.Trace("IP: delayed processing..."); for (int i = 0; i < foldersToProcess.Count; i++) { PhotoFolderToProcess pf = (PhotoFolderToProcess)foldersToProcess.GetByIndex(i); warnPhotoAnalyzeOnLoad(pf.name); // can turn Project.photoAnalyzeOnLoad off if (Project.photoAnalyzeOnLoad || AllFormats.isZipFile(pf.name)) { LibSys.StatusBar.Trace("IP: delayed processing in folder=" + pf.name); // use "my camera shift" as default for files w/o photo settings - reset for each folder: Project.photoTimeShiftTypeCurrent = 0; if (!Project.photoModeReprocess) { // may overwrite Project.photoTimeShiftFile, Project.photoTimeZoneIdFile: FileAndZipIO.readPhotoParameters(pf.name, out FileAndZipIO.usedPhotoParametersFile); } // call imageProcessor on all image files in the folder: if (processImagesInPhotoFolder(pf.imageFileProcessor, pf.name, true) > 0) { if (persistName) { FileInfo fi = new FileInfo(Project.GetLongPathName(pf.name)); Project.photoFileName = fi.FullName; } } } } } else { LibSys.StatusBar.Trace("IP: no delayed processing - photoAnalyzeOnLoad=" + Project.photoAnalyzeOnLoad); } }
/// <summary> /// Get the names of the tables to process in the order they should be processed, according to their dependencies. /// </summary> /// <returns>A StringCollection containing the ordered table names.</returns> private StringCollection GetSortedTableNames() { StringCollection sortedTableNames = new StringCollection(); SortedList unsortedTableNames = new SortedList(); // index the table names foreach (TableDefinition tableDefinition in this.tableDefinitions) { unsortedTableNames.Add(tableDefinition.Name, tableDefinition.Name); } // resolve the dependencies for each table while (0 < unsortedTableNames.Count) { this.ResolveTableDependencies(Convert.ToString(unsortedTableNames.GetByIndex(0)), unsortedTableNames, sortedTableNames); } return sortedTableNames; }
public Tpoint GetByIndex(int index) { return((Tpoint)tpoints.GetByIndex(index)); }
private void DataUIBind() { string OrgCode = ""; string ShiftNo = ""; string ShiftDesc = ""; string strTemp = ""; string[] temVal = null; SortedList SListOrgCodeShiftDesc = new SortedList(); string ShiftDate = this.textBoxBatchOtDate.Text; try { ShiftDate = Convert.ToDateTime(ShiftDate).ToString("yyyy/MM/dd"); } catch (Exception) { ShiftDate = DateTime.Now.ToString("yyyy/MM/dd"); } foreach (DataRow dr in this.tempDataTable.Rows) { OrgCode = dr["dCode"].ToString(); if (Convert.ToString(dr["ShiftDesc"]).Length == 0) { if (SListOrgCodeShiftDesc.IndexOfKey(OrgCode) >= 0) { ShiftDesc = SListOrgCodeShiftDesc.GetByIndex(SListOrgCodeShiftDesc.IndexOfKey(OrgCode)).ToString(); if (ShiftDesc.Length > 0) { dr["ShiftDesc"] = ShiftDesc; dr["ShiftFlag"] = "N"; } } else { strTemp = bll.GetEmpOrgShift(OrgCode, ShiftDate); if (strTemp.Length > 0) { temVal = strTemp.Split(new char[] { '|' }); ShiftNo = temVal[0].ToString(); if (ShiftNo.Length > 0) { ShiftDesc = bll.GetValue("select ShiftDesc from (select ShiftNo||':'||ShiftDesc||'['||(select dataValue from GDS_ATT_TYPEDATA b where b.datatype='ShiftType' and b.datacode=a.shifttype)||']' ShiftDesc from GDS_ATT_WORKSHIFT a where a.ShiftNo='" + ShiftNo + "')") + "(" + temVal[4].ToString() + ")"; dr["ShiftDesc"] = ShiftDesc; dr["ShiftFlag"] = "N"; SListOrgCodeShiftDesc.Add(OrgCode, ShiftDesc); } else { SListOrgCodeShiftDesc.Add(OrgCode, ""); } } else { SListOrgCodeShiftDesc.Add(OrgCode, ""); } } } } if (this.tempDataTable == null || this.tempDataTable.Rows.Count==0) { DataTable dt = new DataTable(); dt = new DataTable(); dt.Columns.Add("WorkNo", Type.GetType("System.String")); dt.Columns.Add("LocalName", Type.GetType("System.String")); dt.Columns.Add("OverTimeType", Type.GetType("System.String")); dt.Columns.Add("ShiftDesc", Type.GetType("System.String")); DataRow rw01 = dt.NewRow(); rw01["WorkNo"] = "F3228771 "; rw01["LocalName"] = "李玉亭"; rw01["OverTimeType"] = "A2"; rw01["ShiftDesc"] = "Test"; dt.Rows.Add(rw01); this.tempDataTable = dt; } this.tempDataTable.DefaultView.Sort = "ShiftDesc ASC"; this.GridEmployee.DataSource = this.tempDataTable; this.GridEmployee.DataBind(); }
public double GetOtHours(string WorkNo, string OTDate, string StrBtime, string StrEtime, string OTType) { try { double OtHours = 0.0; double RestHours = 0.0; string condition = ""; if (OTType.Length != 0) { DateTime dtTempBeginTime; DateTime dtTempEndTime; string dtShiftOnTime; string dtShiftOffTime; string dtAMRestSTime; string dtAMRestETime; TimeSpan tsOTHours; if (OTType.Equals("G4") && (TimeSpan.Parse(Convert.ToDateTime(StrBtime).ToString("HH:mm")) < TimeSpan.Parse("06:30"))) { OTDate = Convert.ToDateTime(OTDate).AddDays(-1.0).ToString("yyyy/MM/dd"); } string strShiftNo = exceptionQryBll.GetShiftNo(WorkNo.ToUpper(), OTDate); if (strShiftNo.Length == 0) { return OtHours; } if ((StrBtime.Length > 8) & (StrEtime.Length > 8)) { dtTempBeginTime = DateTime.Parse(StrBtime); dtTempEndTime = DateTime.Parse(StrEtime); } else { dtTempBeginTime = DateTime.Parse(OTDate + " " + StrBtime); dtTempEndTime = DateTime.Parse(OTDate + " " + StrEtime); SortedList list = new SortedList(); list = this.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, strShiftNo); dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A"))); dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B"))); } if (OTType.Equals("G4") && !(dtTempBeginTime.ToString("yyyy/MM/dd").Equals(dtTempEndTime.ToString("yyyy/MM/dd")) || Convert.ToDateTime(StrBtime).ToString("HH:mm").Equals("00:00"))) { return OtHours; } string dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"); string dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm"); DataTable sdt = exceptionQryBll.GetDataTableBySQL(strShiftNo); if (sdt.Rows.Count == 0) { return OtHours; } string ShiftOnTime = Convert.ToString(sdt.Rows[0]["OnDutyTime"]); string ShiftOffTime = Convert.ToString(sdt.Rows[0]["OffDutyTime"]); string AMRestSTime = Convert.ToString(sdt.Rows[0]["AMRestSTime"]); string AMRestETime = Convert.ToString(sdt.Rows[0]["AMRestETime"]); string PMRestSTime = Convert.ToString(sdt.Rows[0]["PMRestSTime"]); string PMRestETime = Convert.ToString(sdt.Rows[0]["PMRestETime"]); string ShiftType = Convert.ToString(sdt.Rows[0]["ShiftType"]); string dtPMRestSTime = ""; string dtPMRestETime = ""; if (TimeSpan.Parse(ShiftOnTime) < TimeSpan.Parse(ShiftOffTime)) { dtShiftOnTime = DateTime.Parse(OTDate + " " + ShiftOnTime).ToString("yyyy/MM/dd HH:mm"); dtShiftOffTime = DateTime.Parse(OTDate + " " + ShiftOffTime).ToString("yyyy/MM/dd HH:mm"); dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm"); dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).ToString("yyyy/MM/dd HH:mm"); if ((PMRestSTime.Length > 0) && (PMRestETime.Length > 0)) { if (TimeSpan.Parse(PMRestSTime) <= TimeSpan.Parse(PMRestETime)) { dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).ToString("yyyy/MM/dd HH:mm"); dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).ToString("yyyy/MM/dd HH:mm"); } else { dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).ToString("yyyy/MM/dd HH:mm"); dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); } } } else { dtShiftOnTime = DateTime.Parse(OTDate + " " + ShiftOnTime).ToString("yyyy/MM/dd HH:mm"); dtShiftOffTime = DateTime.Parse(OTDate + " " + ShiftOffTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); if ((TimeSpan.Parse(AMRestSTime) <= TimeSpan.Parse(AMRestETime)) && (TimeSpan.Parse(ShiftOnTime) < TimeSpan.Parse(AMRestETime))) { dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm"); dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).ToString("yyyy/MM/dd HH:mm"); } else if ((TimeSpan.Parse(AMRestSTime) <= TimeSpan.Parse(AMRestETime)) && (TimeSpan.Parse(ShiftOnTime) > TimeSpan.Parse(AMRestETime))) { dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); } else { dtAMRestSTime = DateTime.Parse(OTDate + " " + AMRestSTime).ToString("yyyy/MM/dd HH:mm"); dtAMRestETime = DateTime.Parse(OTDate + " " + AMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); } if ((PMRestSTime.Length > 0) && (PMRestETime.Length > 0)) { dtPMRestSTime = DateTime.Parse(OTDate + " " + PMRestSTime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); dtPMRestETime = DateTime.Parse(OTDate + " " + PMRestETime).AddDays(1.0).ToString("yyyy/MM/dd HH:mm"); } } if (string.Compare(dtBtime, dtEtime) >= 0) { return OtHours; } if (OTType.Equals("G1")) { if (((string.Compare(dtBtime, dtShiftOnTime) >= 0) && (string.Compare(dtShiftOffTime, dtBtime) > 0)) || ((string.Compare(dtEtime, dtShiftOnTime) > 0) && (string.Compare(dtShiftOffTime, dtEtime) >= 0))) { return OtHours; } if (string.Compare(dtShiftOnTime, dtBtime) > 0) { if (string.Compare(dtEtime, dtShiftOnTime) > 0) { return OtHours; } tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } else if (string.Compare(dtBtime, dtShiftOffTime) >= 0) { if (dtPMRestSTime.Length > 0) { if ((string.Compare(dtBtime, dtPMRestSTime) >= 0) && (string.Compare(dtPMRestETime, dtBtime) > 0)) { if ((string.Compare(dtEtime, dtPMRestSTime) > 0) && (string.Compare(dtPMRestETime, dtEtime) >= 0)) { return OtHours; } tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - dtTempBeginTime); RestHours += tsOTHours.TotalMinutes; } else if (string.Compare(dtPMRestSTime, dtBtime) >= 0) { if (string.Compare(dtPMRestSTime, dtEtime) >= 0) { tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } else if (string.Compare(dtPMRestETime, dtEtime) >= 0) { tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestSTime) - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } else { tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime)); RestHours = tsOTHours.TotalMinutes; } } else { tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } } else { tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } } } else { if (string.Compare(dtShiftOnTime, dtBtime) > 0) { dtTempBeginTime = Convert.ToDateTime(dtShiftOnTime); dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"); } if ((string.Compare(dtAMRestETime, dtBtime) >= 0) && (string.Compare(dtBtime, dtAMRestSTime) >= 0)) { dtTempBeginTime = Convert.ToDateTime(dtAMRestETime); dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"); } if ((string.Compare(dtAMRestETime, dtEtime) >= 0) && (string.Compare(dtEtime, dtAMRestSTime) >= 0)) { dtTempEndTime = Convert.ToDateTime(dtAMRestSTime); dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm"); } if ((string.Compare(dtPMRestETime, dtBtime) >= 0) && (string.Compare(dtBtime, dtPMRestSTime) >= 0)) { dtTempBeginTime = Convert.ToDateTime(dtPMRestETime); dtBtime = dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"); } if ((string.Compare(dtPMRestETime, dtEtime) >= 0) && (string.Compare(dtEtime, dtPMRestSTime) >= 0)) { dtTempEndTime = Convert.ToDateTime(dtPMRestSTime); dtEtime = dtTempEndTime.ToString("yyyy/MM/dd HH:mm"); } if (string.Compare(dtBtime, dtEtime) >= 0) { return OtHours; } if ((string.Compare(dtAMRestSTime, dtBtime) >= 0) && (string.Compare(dtEtime, dtAMRestETime) >= 0)) { tsOTHours = (TimeSpan)(Convert.ToDateTime(dtAMRestETime) - Convert.ToDateTime(dtAMRestSTime)); RestHours += tsOTHours.TotalMinutes; if ((dtPMRestETime.Length > 0) && (string.Compare(dtEtime, dtPMRestETime) > 0)) { tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime)); RestHours += tsOTHours.TotalMinutes; } } else if ((dtPMRestETime.Length > 0) && ((string.Compare(dtPMRestSTime, dtBtime) > 0) && (string.Compare(dtEtime, dtPMRestETime) > 0))) { tsOTHours = (TimeSpan)(Convert.ToDateTime(dtPMRestETime) - Convert.ToDateTime(dtPMRestSTime)); RestHours += tsOTHours.TotalMinutes; } tsOTHours = (TimeSpan)(dtTempEndTime - dtTempBeginTime); OtHours = tsOTHours.TotalMinutes; } if (exceptionQryBll.GetValue("condition5", null, null, null, null).Equals("Y")) { OtHours = Math.Round((double)(Math.Floor((double)((OtHours - RestHours) / 10.0)) / 6.0), 1); } else { OtHours = Math.Round((double)(((OtHours - RestHours) / 60.0) * 100.0)) / 100.0; if ((OtHours % 0.5) != 0.0) { double ihours = Math.Floor(OtHours); if (OtHours > (ihours + 0.5)) { OtHours = ihours + 0.5; } else { OtHours = ihours; } } } if ((OtHours >= 20.0) || (OtHours < 0.0)) { OtHours = 0.0; } } return OtHours; } catch (Exception) { return 0.0; } }
private void RefreshRelatoriosPadrao() { System.Windows.Forms.ListViewItem lviItem; System.Collections.SortedList sortLstRelatoriosPadrao = new System.Collections.SortedList(); m_lvPadrao.Columns[0].Width = m_lvPadrao.Width - 20; m_lvPadrao.Items.Clear(); // Ordenando e Dividindo os Relatorios mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow dtrwRelatorio; for (int nCont = 0; nCont < m_typDatSetTbRelatoriosPadrao.tbRelatorios.Rows.Count; nCont++) { dtrwRelatorio = (mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow)m_typDatSetTbRelatoriosPadrao.tbRelatorios.Rows[nCont]; if (dtrwRelatorio.nIdRelatorio < 1) { // Padrao if (!sortLstRelatoriosPadrao.Contains(dtrwRelatorio.strNomeRelatorio)) { sortLstRelatoriosPadrao.Add(dtrwRelatorio.strNomeRelatorio, dtrwRelatorio); } } } // Inserindo os Relatorios na Lista View for (int nCont = 0; nCont < sortLstRelatoriosPadrao.Count; nCont++) { dtrwRelatorio = (mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow)sortLstRelatoriosPadrao.GetByIndex(nCont); lviItem = m_lvPadrao.Items.Add(dtrwRelatorio.strNomeRelatorio); lviItem.Tag = dtrwRelatorio.nIdRelatorio; lviItem.Font = new System.Drawing.Font(lviItem.Font, System.Drawing.FontStyle.Bold); } }
[SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override Object GetByIndex(int index) { lock (_root) { return(_list.GetByIndex(index)); } }
// // SortedList overrides // public override Object GetByIndex(int index) { lock (host.SyncRoot) { return(host.GetByIndex(index)); } }
void DotNetNuke.Entities.Modules.IPortable.ImportModule(int ModuleID, string Content, string Version, int UserID) { XmlNode xmlCategories = DotNetNuke.Common.Globals.GetContent(Content, "Categories"); SortedList slCategories = new SortedList(xmlCategories.ChildNodes.Count); int intIndexID = Null.NullInteger; foreach (XmlNode xmlCategory in xmlCategories) { CategoryInfo categoryInfo = new CategoryInfo(); categoryInfo.PortalID = PortalId; categoryInfo.CategoryName = xmlCategory["Name"].InnerText; categoryInfo.CategoryDescription = xmlCategory["Description"].InnerText; categoryInfo.Message = xmlCategory["Message"].InnerText; categoryInfo.Archived = Convert.ToBoolean(xmlCategory["Archived"].InnerText); categoryInfo.CreatedByUser = UserId.ToString(); categoryInfo.CreatedDate = DateTime.Now; categoryInfo.OrderID = Convert.ToInt32(xmlCategory["OrderID"].InnerText); intIndexID = slCategories.IndexOfKey(Convert.ToInt32(xmlCategory["ParentCategoryID"].InnerText)); if (intIndexID > -1) { categoryInfo.ParentCategoryID = (int)slCategories.GetByIndex(intIndexID); } else { categoryInfo.ParentCategoryID = -1; } slCategories.Add(Convert.ToInt32(xmlCategory["CategoryID"].InnerText), AddCategory(categoryInfo)); } }
// Internal Methods internal static void RecycleServicePoints () { ArrayList toRemove = new ArrayList (); lock (servicePoints) { IDictionaryEnumerator e = servicePoints.GetEnumerator (); while (e.MoveNext ()) { ServicePoint sp = (ServicePoint) e.Value; if (sp.AvailableForRecycling) { toRemove.Add (e.Key); } } for (int i = 0; i < toRemove.Count; i++) servicePoints.Remove (toRemove [i]); if (maxServicePoints == 0 || servicePoints.Count <= maxServicePoints) return; // get rid of the ones with the longest idle time SortedList list = new SortedList (servicePoints.Count); e = servicePoints.GetEnumerator (); while (e.MoveNext ()) { ServicePoint sp = (ServicePoint) e.Value; if (sp.CurrentConnections == 0) { while (list.ContainsKey (sp.IdleSince)) sp.IdleSince = sp.IdleSince.AddMilliseconds (1); list.Add (sp.IdleSince, sp.Address); } } for (int i = 0; i < list.Count && servicePoints.Count > maxServicePoints; i++) servicePoints.Remove (list.GetByIndex (i)); } }
private void RefreshRelatoriosNormal() { System.Windows.Forms.ListViewItem lviItem; System.Collections.SortedList sortLstRelatorios = new System.Collections.SortedList(); m_lvCriados.Columns[0].Width = m_lvCriados.Width - 20; m_lvCriados.Items.Clear(); // Ordenando e Dividindo os Relatorios mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow dtrwRelatorio; for (int nCont = 0; nCont < m_typDatSetTbRelatorios.tbRelatorios.Rows.Count; nCont++) { dtrwRelatorio = (mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow)m_typDatSetTbRelatorios.tbRelatorios.Rows[nCont]; if (dtrwRelatorio.nIdRelatorio > 0 && dtrwRelatorio.nIdExportador == m_nIdExportador) { // Normal if (!sortLstRelatorios.Contains(dtrwRelatorio.strNomeRelatorio)) { sortLstRelatorios.Add(dtrwRelatorio.strNomeRelatorio, dtrwRelatorio); } } } // Inserindo os Relatorios na Lista View for (int nCont = 0; nCont < sortLstRelatorios.Count; nCont++) { dtrwRelatorio = (mdlDataBaseAccess.Tabelas.XsdTbRelatorios.tbRelatoriosRow)sortLstRelatorios.GetByIndex(nCont); lviItem = m_lvCriados.Items.Add(dtrwRelatorio.strNomeRelatorio); lviItem.Tag = dtrwRelatorio.nIdRelatorio; } }
protected void ButtonSave_Click(object sender, EventArgs e) { try { if (this.GridSelEmployee.Rows.Count == 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + Message.common_message_data_no_select_employees + "')</script>"); //base.WriteMessage(1, base.GetResouseValue("common.message.data.no.select.employees")); } else if (((CheckData(this.textBoxOTDate.Text, Message.overtime_date) && CheckData(this.textBoxBeginTime.Text, Message.start_time)) && (CheckData(this.textBoxEndTime.Text, Message.end_time) && CheckData(this.textBoxHours.Text, Message.times))) && CheckData(this.textBoxWorkDesc.Text, Message.overtime_desc)) { int i; this.tempDataTable = bll.GetDataByCondition_1("and 1=2").Tables[0]; int failCount = 0; int successCount = 0; string OTMSGFlag = ""; string tmpRemark = ""; string msg = ""; string condition = ""; string OTDate = ""; try { OTDate = DateTime.Parse(this.textBoxOTDate.Text.ToString()).ToString("yyyy/MM/dd"); } catch (Exception) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('"+Message.ErrDate+"')</script>"); //base.WriteMessage(1, base.GetResouseValue("common.message.data.errordate")); return; } string tmpOTType = ""; string Hour = this.textBoxHours.Text.Trim(); string WorkDesc = this.textBoxWorkDesc.Text; string StrBtime = this.textBoxBeginTime.Text.ToString(); string StrEtime = this.textBoxEndTime.Text.ToString(); DateTime dtTempBeginTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrBtime); DateTime dtTempEndTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrEtime); DateTime dtMidTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " 12:00"); //Function CommonFun = new Function(); SortedList list = new SortedList(); string OTMAdvanceBeforeDays = bll.GetValue("select nvl(max(paravalue),'2') from GDS_SC_PARAMETER where paraname='OTMAdvanceBeforeDays'"); if (!bll.GetValue("select nvl(max(workno),'Y') from GDS_ATT_EMPLOYEE where workno='" + CurrentUserInfo.Personcode + "'").Equals("Y")) { i = 0; int WorkDays = 0; string UserOTType = ""; while (i < Convert.ToDouble(OTMAdvanceBeforeDays)) { UserOTType = this.FindOTType(DateTime.Now.AddDays((double)((-1 - i) - WorkDays)).ToString("yyyy/MM/dd"), CurrentUserInfo.Personcode); if (UserOTType.Length == 0) { break; } if (UserOTType.Equals("G1")) { i++; } else { WorkDays++; } } OTMAdvanceBeforeDays = Convert.ToString((int)(i + WorkDays)); } condition = "select trunc(sysdate)-to_date('" + OTDate + "','yyyy/mm/dd') from dual"; if (Convert.ToDecimal(bll.GetValue(condition)) > Convert.ToDecimal(OTMAdvanceBeforeDays)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('"+Message.checkapproveflag+"')</script>"); //base.WriteMessage(1, base.GetResouseValue("otm.message.checkadvancedaysbefore") + ":" + OTMAdvanceBeforeDays); } else { for (i = 0; i < this.GridSelEmployee.Rows.Count; i++) { tmpRemark = ""; OTMSGFlag = ""; this.WorkNo = this.GridSelEmployee.Rows[i].Cells.FromKey("WorkNo").Text.ToString().Trim(); this.ShiftNo = bll.GetShiftNo(this.WorkNo, OTDate); dtTempBeginTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrBtime); dtTempEndTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrEtime); dtMidTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " 12:00"); if ((this.ShiftNo == null) || (this.ShiftNo == "")) { msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_exception_errorshiftno_1; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else { tmpOTType = this.FindOTType(OTDate, this.WorkNo); if (tmpOTType.Length == 0) { msg = msg + "<br>" + this.WorkNo + ": " + Message.OTMType + Message.Required; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else { Hour = this.GetOTHours(this.WorkNo, OTDate, StrBtime, StrEtime, tmpOTType); if (Convert.ToDouble(Hour) < 0.5) { msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_othourerror; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else { list = bll.ReturnOTTTime(this.WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, this.ShiftNo); dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A"))); dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B"))); if (!CheckLeaveOverTime(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm"))) { msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_Leaveovertime_repeart; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else if (!CheckWorkTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo)) { msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_worktime_repeart; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else if (!CheckOverTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo, true)) { msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_multi_repeart; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else if (!CheckOTOverETM(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"))) { msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_etmrepeart; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else { OTMSGFlag = GetOTMSGFlag(this.WorkNo, OTDate, Convert.ToDouble(Hour), tmpOTType, "N", ""); if (OTMSGFlag != "") { tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1); OTMSGFlag = OTMSGFlag.Substring(0, 1); } if (OTMSGFlag.Equals("A")) { msg = msg + "<br>" + this.WorkNo + ": " + tmpRemark; failCount++; this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red; } else { List<OverTimeModel> mod_list = new List<OverTimeModel>(); OverTimeModel mod = new OverTimeModel(); mod.Workno = this.WorkNo; mod.Applydate = Convert.ToDateTime(this.textBoxApplyDate.Text.Trim()); mod.Otdate = Convert.ToDateTime(OTDate); mod.Ottype = tmpOTType; mod.Begintime = dtTempBeginTime; mod.Endtime = dtTempEndTime; mod.Hours = Convert.ToInt32(Hour); mod.Workdesc = WorkDesc; mod.G2isforrest = "N"; mod.Otshiftno = this.ShiftNo; mod.Isproject = "N"; mod.Update_user = CurrentUserInfo.Personcode; mod.Update_date = DateTime.Now; mod.Remark = tmpRemark; mod.Status = "0"; mod.Otmsgflag = OTMSGFlag; mod.Update_user = CurrentUserInfo.Personcode; mod_list.Add(mod); bll.SaveData(mod_list, "Add", string.Empty); //DataRow row = this.tempDataTable.NewRow(); //row.BeginEdit(); //row["WORKNO"] = this.WorkNo; //row["OTDate"] = OTDate; //row["BeginTime"] = dtTempBeginTime; //row["EndTime"] = dtTempEndTime; //row["Hours"] = Hour; //row["OTType"] = tmpOTType; //row["WorkDesc"] = WorkDesc; //row["OTMSGFlag"] = OTMSGFlag; //row["Remark"] = tmpRemark; //row["ApplyDate"] = this.textBoxApplyDate.Text.Trim(); //row["Modifier"] = this.Session["appUser"].ToString(); //row["ModifyDate"] = DateTime.Now.ToLongDateString(); //row["IsProject"] = "N"; //row["OTShiftNo"] = this.ShiftNo; //row.EndEdit(); //this.tempDataTable.Rows.Add(row); //this.tempDataTable.AcceptChanges(); // ((ServiceLocator)this.Session["serviceLocator"]).GetOTMAdvanceApplyData().SaveData("Add", this.tempDataTable); // this.tempDataTable.Clear(); successCount++; } } } } } } if ((failCount > 0) || (successCount > 0)) { this.labMessage.Text = string.Concat(new object[] { Message.common_success, successCount.ToString(), ";", Message.common_fault, ";", failCount, ";", msg }); this.labMessage.Visible = true; } this.ButtonSave.Enabled = false; } } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('" + ex.Message + "')</script>"); //base.WriteMessage(2, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message); } }
public static Hashtable FillFeatureCache(ITable inputSignsTable, int inFromIDFI, int inToIDFI, IFeatureClass inputLineFeatures, string linesIDFieldName, ITrackCancel trackcancel) { // make and fill a SortedList from the IDs referenced in the table // for MultiNet data, there is only one ID field, so its index will be // passed in as inFromIDFI, while -1 will be passed in to inToIDFI. SortedList IDs = new System.Collections.SortedList(); ICursor inCursor = inputSignsTable.Search(null, true); IRow row; long fromID, toID; bool exists; int cancelCheckInterval = 100; if (inToIDFI == -1) { while ((row = inCursor.NextRow()) != null) { fromID = Convert.ToInt64(row.get_Value(inFromIDFI)); exists = IDs.Contains(fromID); if (!exists) { IDs.Add(fromID, fromID); } } } else { while ((row = inCursor.NextRow()) != null) { fromID = Convert.ToInt64(row.get_Value(inFromIDFI)); toID = Convert.ToInt64(row.get_Value(inToIDFI)); exists = IDs.Contains(fromID); if (!exists) { IDs.Add(fromID, fromID); } exists = IDs.Contains(toID); if (!exists) { IDs.Add(toID, toID); } } } // make the query filter for fetching features IQueryFilter queryFilter = new QueryFilterClass(); queryFilter.SubFields = "*"; // Now fetch batches of features long currID; int numFeaturesPerQuery = 200; int numToFetch = IDs.Count; int totalRemaining, totalDone = 0; int linesIDFieldIndex = inputLineFeatures.FindField(linesIDFieldName); Hashtable outputFeatures = new System.Collections.Hashtable((int)numToFetch); if (numFeaturesPerQuery > numToFetch) { numFeaturesPerQuery = numToFetch; } while (totalDone < numToFetch) { // Populate the QueryDef Where clause IN() statement for the current batch of features. // This is going to be very slow unless linesIDFieldName is indexed and this is why // we added a warning to the GP message window if this is the case. If you cannot // index linesIDFieldName, then this code would run faster scanning the whole feature // class looking for the records we need (no Where clause). string whereClause = linesIDFieldName + " IN("; for (int i = 0; i < numFeaturesPerQuery; i++) { currID = Convert.ToInt64(IDs.GetByIndex(totalDone + i), System.Globalization.CultureInfo.InvariantCulture); whereClause += Convert.ToString(currID, System.Globalization.CultureInfo.InvariantCulture); if (i != (numFeaturesPerQuery - 1)) { whereClause += ","; } else { whereClause += ")"; } } queryFilter.WhereClause = whereClause; // select the features IFeatureCursor inputFeatureCursor = inputLineFeatures.Search(queryFilter, false); // get the features IFeature feature; while ((feature = inputFeatureCursor.NextFeature()) != null) { // keep a copy of the OID and shape of feature - skip records that cause errors // (perhaps pass the GPMessages in and log warnings in there if you need to log exceptions) try { FeatureData data = new FeatureData(feature.OID, feature.ShapeCopy); outputFeatures.Add(Convert.ToInt64(feature.get_Value(linesIDFieldIndex)), data); } catch { } if ((totalDone % cancelCheckInterval) == 0) { // check for user cancel if (trackcancel != null && !trackcancel.Continue()) { throw (new COMException("Function cancelled.")); } } } // finished? set up for next batch totalDone += numFeaturesPerQuery; totalRemaining = numToFetch - totalDone; if (totalRemaining > 0) { if (numFeaturesPerQuery > totalRemaining) { numFeaturesPerQuery = totalRemaining; } } } return(outputFeatures); }
/// <summary> /// Retrieves an array with the supported languages /// </summary> /// <returns>Array with the supported languages</returns> public static string[] SupportedLanguages() { if (_languages == null) { if (_stringProvider == null) Load(null); CultureInfo[] cultures = _stringProvider.AvailableLanguages(); SortedList sortedLanguages = new SortedList(); foreach (CultureInfo culture in cultures) sortedLanguages.Add(culture.EnglishName, culture.EnglishName); _languages = new string[sortedLanguages.Count]; for (int i = 0; i < sortedLanguages.Count; i++) { _languages[i] = (string)sortedLanguages.GetByIndex(i); } } return _languages; }
/// <summary> /// Draw the the PlotSurface2D and all contents [axes, drawables, and legend] on the /// supplied graphics surface. /// </summary> /// <param name="g">The graphics surface on which to draw.</param> /// <param name="bounds">A bounding box on this surface that denotes the area on the /// surface to confine drawing to.</param> public void Draw(Graphics g, Rectangle bounds) { // determine font sizes and tick scale factor. float scale = DetermineScaleFactor(bounds.Width, bounds.Height); // if there is nothing to plot, return. if (drawables_.Count == 0) { // draw title float x_center = (bounds.Left + bounds.Right) / 2.0f; float y_center = (bounds.Top + bounds.Bottom) / 2.0f; Font scaled_font; if (AutoScaleTitle) { scaled_font = Utils.ScaleFont(titleFont_, scale); } else { scaled_font = titleFont_; } g.DrawString(title_, scaled_font, titleBrush_, new PointF(x_center, y_center), titleDrawFormat_); return; } // determine the [non physical] axes to draw based on the axis properties set. Axis xAxis1 = null; Axis xAxis2 = null; Axis yAxis1 = null; Axis yAxis2 = null; DetermineAxesToDraw(out xAxis1, out xAxis2, out yAxis1, out yAxis2); // apply scale factor to axes as desired. if (xAxis1.AutoScaleTicks) { xAxis1.TickScale = scale; } if (xAxis1.AutoScaleText) { xAxis1.FontScale = scale; } if (yAxis1.AutoScaleTicks) { yAxis1.TickScale = scale; } if (yAxis1.AutoScaleText) { yAxis1.FontScale = scale; } if (xAxis2.AutoScaleTicks) { xAxis2.TickScale = scale; } if (xAxis2.AutoScaleText) { xAxis2.FontScale = scale; } if (yAxis2.AutoScaleTicks) { yAxis2.TickScale = scale; } if (yAxis2.AutoScaleText) { yAxis2.FontScale = scale; } // determine the default physical positioning of those axes. PhysicalAxis pXAxis1 = null; PhysicalAxis pYAxis1 = null; PhysicalAxis pXAxis2 = null; PhysicalAxis pYAxis2 = null; DeterminePhysicalAxesToDraw( bounds, xAxis1, xAxis2, yAxis1, yAxis2, out pXAxis1, out pXAxis2, out pYAxis1, out pYAxis2); float oldXAxis2Height = pXAxis2.PhysicalMin.Y; // Apply axes constraints for (int i = 0; i < axesConstraints_.Count; ++i) { ((AxesConstraint)axesConstraints_[i]).ApplyConstraint( pXAxis1, pYAxis1, pXAxis2, pYAxis2); } ///////////////////////////////////////////////////////////////////////// // draw legend if have one. // Note: this will update axes if necessary. Point legendPosition = new Point(0, 0); if (legend_ != null) { legend_.UpdateAxesPositions( pXAxis1, pYAxis1, pXAxis2, pYAxis2, drawables_, scale, padding_, bounds, out legendPosition); } float newXAxis2Height = pXAxis2.PhysicalMin.Y; float titleExtraOffset = oldXAxis2Height - newXAxis2Height; // now we are ready to define the bounding box for the plot area (to use in clipping // operations. plotAreaBoundingBoxCache_ = new Rectangle( Math.Min(pXAxis1.PhysicalMin.X, pXAxis1.PhysicalMax.X), Math.Min(pYAxis1.PhysicalMax.Y, pYAxis1.PhysicalMin.Y), Math.Abs(pXAxis1.PhysicalMax.X - pXAxis1.PhysicalMin.X + 1), Math.Abs(pYAxis1.PhysicalMin.Y - pYAxis1.PhysicalMax.Y + 1) ); bbXAxis1Cache_ = pXAxis1.GetBoundingBox(); bbXAxis2Cache_ = pXAxis2.GetBoundingBox(); bbYAxis1Cache_ = pYAxis1.GetBoundingBox(); bbYAxis2Cache_ = pYAxis2.GetBoundingBox(); // Fill in the background. if (plotBackColor_ != null) { g.FillRectangle( new System.Drawing.SolidBrush((Color)plotBackColor_), (Rectangle)plotAreaBoundingBoxCache_); } else if (plotBackBrush_ != null) { g.FillRectangle( plotBackBrush_.Get((Rectangle)plotAreaBoundingBoxCache_), (Rectangle)plotAreaBoundingBoxCache_); } else if (plotBackImage_ != null) { g.DrawImage( Utils.TiledImage(plotBackImage_, new Size( ((Rectangle)plotAreaBoundingBoxCache_).Width, ((Rectangle)plotAreaBoundingBoxCache_).Height)), (Rectangle)plotAreaBoundingBoxCache_); } // draw title float xt = (pXAxis2.PhysicalMax.X + pXAxis2.PhysicalMin.X) / 2.0f; float yt = bounds.Top + padding_ - titleExtraOffset; Font scaledFont; if (AutoScaleTitle) { scaledFont = Utils.ScaleFont(titleFont_, scale); } else { scaledFont = titleFont_; } g.DrawString(title_, scaledFont, titleBrush_, new PointF(xt, yt), titleDrawFormat_); //count number of new lines in title. int nlCount = 0; for (int i = 0; i < title_.Length; ++i) { if (title_[i] == '\n') { nlCount += 1; } } SizeF s = g.MeasureString(title_, scaledFont); bbTitleCache_ = new Rectangle((int)(xt - s.Width / 2), (int)(yt), (int)(s.Width), (int)(s.Height) * (nlCount + 1)); // draw drawables.. System.Drawing.Drawing2D.SmoothingMode smoothSave = g.SmoothingMode; g.SmoothingMode = smoothingMode_; bool legendDrawn = false; for (int i_o = 0; i_o < ordering_.Count; ++i_o) { int i = (int)ordering_.GetByIndex(i_o); double zOrder = (double)ordering_.GetKey(i_o); if (zOrder > legendZOrder_) { // draw legend. if (!legendDrawn && legend_ != null) { legend_.Draw(g, legendPosition, drawables_, scale); legendDrawn = true; } } IDrawable drawable = (IDrawable)drawables_[i]; XAxisPosition xap = (XAxisPosition)xAxisPositions_[i]; YAxisPosition yap = (YAxisPosition)yAxisPositions_[i]; PhysicalAxis drawXAxis; PhysicalAxis drawYAxis; if (xap == XAxisPosition.Bottom) { drawXAxis = pXAxis1; } else { drawXAxis = pXAxis2; } if (yap == YAxisPosition.Left) { drawYAxis = pYAxis1; } else { drawYAxis = pYAxis2; } // set the clipping region.. (necessary for zoom) g.Clip = new Region((Rectangle)plotAreaBoundingBoxCache_); // plot. drawable.Draw(g, drawXAxis, drawYAxis); // reset it.. g.ResetClip(); } if (!legendDrawn && legend_ != null) { legend_.Draw(g, legendPosition, drawables_, scale); } // cache the physical axes we used on this draw; pXAxis1Cache_ = pXAxis1; pYAxis1Cache_ = pYAxis1; pXAxis2Cache_ = pXAxis2; pYAxis2Cache_ = pYAxis2; g.SmoothingMode = smoothSave; // now draw axes. Rectangle axisBounds; pXAxis1.Draw(g, out axisBounds); pXAxis2.Draw(g, out axisBounds); pYAxis1.Draw(g, out axisBounds); pYAxis2.Draw(g, out axisBounds); #if DEBUG_BOUNDING_BOXES g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbXAxis1Cache_); g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbXAxis2Cache_); g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbYAxis1Cache_); g.DrawRectangle(new Pen(Color.Orange), (Rectangle)bbYAxis2Cache_); g.DrawRectangle(new Pen(Color.Red, 5.0F), (Rectangle)plotAreaBoundingBoxCache_); //if(this.ShowLegend)g.DrawRectangle( new Pen(Color.Chocolate, 3.0F), (Rectangle) bbLegendCache_); g.DrawRectangle(new Pen(Color.DeepPink, 2.0F), (Rectangle)bbTitleCache_); #endif }