IndexOf() public method

public IndexOf ( Object value ) : int
value Object
return int
Example #1
0
        public static ArrayList generaCamposRelacion(ArrayList tabSelec, ArrayList alias, ArrayList camposRel)
        {
            ArrayList resp = new ArrayList();
            if (camposRel != null)
            {
                foreach (ArrayList regCam in camposRel)
                {
                    string nombreTabB = (string)regCam[2];
                    string nombreTabR = (string)regCam[3];

                    string nombreCampoTB = (string)regCam[4];
                    string nombreCampoTR = (string)regCam[5];

                    int indexTB = tabSelec.IndexOf(nombreTabB);
                    int indexTR = tabSelec.IndexOf(nombreTabR);

                    string aliasTB = (string)alias[indexTB];
                    string aliasTR = (string)alias[indexTR];

                    resp.Add(aliasTB + "." + nombreCampoTB + " = " + aliasTR + "." + nombreCampoTR);

                }
            }

            return resp;
        }
Example #2
0
 public static void SwapPosition(ArrayList lista, Object node1, Object node2)
 {
     int exp1idx = lista.IndexOf(node1);
     int exp2idx = lista.IndexOf(node2);
     lista.RemoveAt(exp1idx);
     lista.Insert(exp1idx, node2);
     lista.RemoveAt(exp2idx);
     lista.Insert(exp2idx, node1);
 }
        public static HashSet<float[]> Consolidate(ArrayList al, int w, int h, TextWriter log)
        {
            ArrayList al2 = new ArrayList();

             foreach (float[] i in al)
             {
             al2.Add(i);
             }

             foreach (float[] i in al)
             {
             foreach (float[] j in al)
             {
                 if (!((Math.Abs(i[0] - j[0]) > w) ||
                     (Math.Abs(i[1] - j[1]) > h) ||
                     (Math.Sqrt(Math.Pow(i[0] - j[0], 2) + Math.Pow(i[1] - j[1], 2)) > Math.Sqrt(Math.Pow(w, 2) + Math.Pow(h, 2)))))
                 {

                     if (i[2] > j[2])
                     {
                         al2[al.IndexOf(j)] = i;
                     }
                     else if (i[2] < j[2])
                     {
                         al2[al.IndexOf(i)] = j;
                     }
                 }
             }
             }

             HashSet<float[]> hash = new HashSet<float[]>();

             foreach (float[] i in al2)
             {
             hash.Add(i);
             }

             log.WriteLine("The count of al2: " + al2.Count);
             log.WriteLine("The count of hash: " + hash.Count);

             al.Clear();

             foreach (float[] i in hash)
             {
             al.Add(i);
             }

             log.WriteLine("The count after hash: " + al.Count);

             return hash;
        }
Example #4
0
        public override bool OnInsertFile(ManagerEngine man, IFile file)
        {
            HttpResponse response = HttpContext.Current.Response;
            HttpRequest request = HttpContext.Current.Request;
            HttpCookie cookie;
            ArrayList chunks;

            if ((cookie = request.Cookies["hist"]) == null)
                cookie = new HttpCookie("hist");

            cookie.Expires = DateTime.Now.AddDays(30);

            if (cookie.Value != null) {
                chunks = new ArrayList(cookie.Value.Split(new char[]{','}));

                if (chunks.IndexOf(man.EncryptPath(file.AbsolutePath)) == -1)
                    chunks.Add(man.EncryptPath(file.AbsolutePath));

                cookie.Value = this.Implode(chunks, ",");
            } else
                cookie.Value = man.EncryptPath(file.AbsolutePath);

            response.Cookies.Remove("hist");
            response.Cookies.Add(cookie);

            return true;
        }
Example #5
0
        //输入必经点集合
        public ArrayList getPath(ArrayList pointList, int[,] A, int n,int start)
        {
            int[,] dist = run(A,n);
            bool[] flag = new bool[n + 1];
            for (int i = 0; i <= n;i++ )
            {
                flag[i] = false;
            }
            ArrayList list = new ArrayList();
            list.Add(start);

            int reachPoint = start;
            for (int i = 0; i < pointList.Count; i++)
            {
                int min = MAXINT;
                for (int j = 1; j <= n; j++)
                {
                    if ((dist[reachPoint, j] < min) && (pointList.IndexOf(j)!=-1) && (!flag[j]))
                    {
                        min = dist[reachPoint,j];
                        reachPoint = j;
                        flag[j] = true;
                        list.Add(j);
                    }
                }
            }
                return list;
        }
        public void fun1()
        {
            ArrayList a1 = new ArrayList();
            a1.Add(1);
            a1.Add('c');
            a1.Add("string1");

            ArrayList al2 = new ArrayList();
            al2.Add('a');
            al2.Add(5);

            int n = (int)a1[0];
            Console.WriteLine(n);
            a1[0] = 20;
            Console.WriteLine(a1.Count);
            Console.WriteLine(a1.Contains(55));
            Console.WriteLine(a1.IndexOf(55));
            //int[] num = (int[])a1.ToArray();

            a1.Add(45);
            a1.Add(12);
            a1.Add(67);

            a1.Insert(1, "new value");
            //a1.AddRange(al2);
            a1.InsertRange(1, al2);
            a1.Remove("string1");
            a1.RemoveAt(2);
            a1.RemoveRange(0, 2);

            foreach (object o in a1)
            {
                Console.WriteLine(o.ToString());
            }
        }
Example #7
0
        /// <summary>  
        /// 获取Excel文件数据表列表  
        /// </summary>  
        public static ArrayList GetExcelTables(string ExcelFileName)
        {
            DataTable dt = new DataTable();
            ArrayList TablesList = new ArrayList();
            if (File.Exists(ExcelFileName))
            {
                using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;Data Source=" + ExcelFileName))
                {
                    try
                    {
                        conn.Open();
                        dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                    }
                    catch (Exception exp)
                    {
                        throw exp;
                    }

                    //获取数据表个数  
                    int tablecount = dt.Rows.Count;
                    for (int i = 0; i < tablecount; i++)
                    {
                        string tablename = dt.Rows[i][2].ToString().Trim().TrimEnd('$');
                        if (TablesList.IndexOf(tablename) < 0)
                        {
                            TablesList.Add(tablename);
                        }
                    }
                }
            }
            return TablesList;
        }
Example #8
0
        private int CycleDigits(
            int number
            )
        {
            var diffList = new ArrayList();

            var diff = 10;
            while (true)
            {
                if (diff % number != diff)
                {
                    diff = diff % number;

                    if (diff == 0)
                    {
                        return 0;
                    }

                    if (diffList.Contains(diff))
                    {
                        return diffList.Count - diffList.IndexOf(diff);
                    }

                    diffList.Add(diff);
                    diff = diff * 10;
                }
                else
                {
                    diff = diff * 10;
                }
            }
        }
 /// <summary>
 /// kozos inicializalas
 /// </summary>
 /// <param name="valtpanelek">
 /// valtozaspanelek tombje
 /// </param>
 /// <param name="szulopanelek">
 /// szulopanelek tombje
 /// </param>
 /// <param name="sajatpanelek">
 /// alap panelek tombje vagy null
 /// </param>
 public void ValtszulopluszSzuloInit(Panel[] valtpanelek, Panel[] szulopanelek, Panel[] sajatpanelek)
 {
     object[] alap = null;
     if (sajatpanelek != null)
         alap = new object[] { Alapinfotipus.Alap, sajatpanelek };
     object[] valt = null;
     object[] szulogy=null;
     Panel[] panelek = new Panel[] { panel1, panel2, panel4, panel5 ,panel11};
     ArrayList eredetiar = new ArrayList(panelek);
     ArrayList ar = new ArrayList(valtpanelek);
     bool[] van = new bool[5];
     for (int i = 0; i < van.Length; i++)
     {
         Panel eredeti = (Panel)eredetiar[i];
         if (ar.IndexOf(eredeti) != -1)
             van[i] = true;
     }
     for (int i = 0; i < van.Length; i++)
     {
         if (!van[i])
             this.Controls.Remove((Control)eredetiar[i]);
     }
     if (valtpanelek != null)
     {
         valt = new object[] { Alapinfotipus.Valtozasok, valtpanelek };
     }
     if(szulopanelek!=null)
         szulogy = new object[] { Alapinfotipus.SzuloGyerekValtozasok, szulopanelek };
     if (alap == null)
         AlapinfoInit(new object[] { valt, szulogy });
     else
         AlapinfoInit(new object[] { alap, valt, szulogy });
 }
		protected void Page_Load(object sender, System.EventArgs e)
		{
			try
			{

				if(Page.IsPostBack && Request["_BIP_ACTION"] == "AddRelatedDoc" )
				{
					ArrayList docEnum = new ArrayList();
					if(m_Document.RefDocuments != null)
					{
						foreach(int ids in m_Document.RefDocuments)
							docEnum.Add(ids);
					}

					int id = Convert.ToInt32(Request["_BIP_ACTION_ARGS"]);
					if(Request["_BIP_ACTION"] == "AddRelatedDoc")
					{
						if(docEnum.IndexOf(id) == -1)
							docEnum.Add(id);
					}
					m_Document.RefDocuments = docEnum;
					m_Document.Update();
				}
			
				ddlDocLinks.Items.Clear();
				System.Collections.ArrayList docList = new System.Collections.ArrayList();
				if(m_Document.ParentId >0)
					docList.Add(m_Document.ParentId);
				if(m_Document.PreviousVersionId >0)
					docList.Add(m_Document.PreviousVersionId);
				foreach(object obj in m_Document.RefDocuments)
					docList.Add(obj);
				DataTable tab =DocumentEnt.FindEnum(docList);
				if(tab != null)
				{
					ddlDocLinks.DataSource = tab;
					ddlDocLinks.DataValueField = "Id";
					ddlDocLinks.DataTextField = "Header";
					ddlDocLinks.DataBind();
					tab.Dispose();
				
				}
				
				ddlDocLinks.Items.Insert(0, new ListItem("<" + Bip.Components.BipResources.GetString("StrRelatedDocuments") + ">", "0"));

				PanAddDocLink.Visible = m_Document.CanEdit;

			
				if(m_Document.CanEdit || tab != null)

						PanOpenRefDocuments.Visible = true;
				else	PanOpenRefDocuments.Visible = false;

			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
		}
 internal static int fastRemove(ArrayList a, object o)
 {
     int num1 = -1;
     int num2 = a.Count;
     if (num2 > 1000)
     {
         num1 = a.IndexOf(o, num2 - 50, 50);
     }
     if (num1 < 0)
     {
         num1 = a.IndexOf(o);
     }
     if (num1 >= 0)
     {
         a.RemoveAt(num1);
     }
     return num1;
 }
 // Helper Method
 protected bool haveSameStringsAtSameIndex(ArrayList list1, ArrayList list2)
 {
     bool haveSameElements = list1.Count == list2.Count;
     for (int i = 0; i < list1.Count; ++i)
     {
         bool sameItemAtIndexI = list1.IndexOf(i) == list2.IndexOf(i);
         haveSameElements = haveSameElements && sameItemAtIndexI;
     }
     return haveSameElements;
 }
Example #13
0
 public ArrayList getCollectIdList(DataSet ds)
 {
     ArrayList CollectIdList = new ArrayList();
     foreach (DataRow row in ds.Tables[0].Rows)
     {
         if (CollectIdList.IndexOf(row["CollectId"].ToString()) == -1)
             CollectIdList.Add(row["CollectId"].ToString());
     }
     return CollectIdList;
 }
 public string pathCreationDeletion(ArrayList argumentList, int Index, string argument, string path)
 {
     #region Creates and removes the file paths for the log and dictionary files
     Index = argumentList.IndexOf(argument) + 1; // Finds the index of either -f or -l and takes whatever is ahead of it as the new file/log path
     path = argumentList[Index].ToString();
     argumentList.RemoveAt(Index); // Removes the file/log path arguments to not mess up the query and update commands later
     argumentList.RemoveAt(argumentList.IndexOf(argument));
     return path;
     #endregion
 }
Example #15
0
        static void Main(string[] args)
        {
            // Array
            Console.WriteLine("Create an Array type collection of Animal objects and use it:");

            Animal[] animalArray = new Animal[2]; // Strongly typed
            Cow myCow1 = new Cow("Deirdre");
            animalArray[0] = myCow1;
            animalArray[1] = new Chicken("Ken");

            foreach (Animal myAnimal in animalArray)
            {
                Console.WriteLine("New {0} object added to Array collection, "
                    + "Name = {1}", myAnimal.ToString(), myAnimal.Name);
            }

            Console.WriteLine("Array collection {0} objects.", animalArray.Length);

            animalArray[0].Feed(); // invoke Animal method directly
            ((Chicken)animalArray[1]).LayEgg(); // cast to Chicken to invoke subclass method
            Console.WriteLine();

            // ArrayList
            Console.WriteLine("Create an ArrayList type collection of Animal "
                + "objects and se it:");

            ArrayList animalArrayList = new ArrayList(); // A collection of System.Objects
            Cow myCow2 = new Cow("Hayley");
            animalArrayList.Add(myCow2);
            animalArrayList.Add(new Chicken("Row"));

            foreach (Animal myAnimal in animalArrayList)
            {
                Console.WriteLine("New {0} object added to ArrayList collection,"
                    + " Name = {1}", myAnimal.ToString(), myAnimal.Name);
            }

            Console.WriteLine("ArrayList collection contains {0} objects.", animalArrayList.Count);
            ((Animal)animalArrayList[0]).Feed(); // cast to Animal
            ((Chicken)animalArrayList[1]).LayEgg(); // cast to Chicken to invoke subclass method
            Console.WriteLine();

            // Additional ArrayList manipulation
            Console.WriteLine("Additional manipulation of ArrayList:");
            animalArrayList.RemoveAt(0);
            ((Animal)animalArrayList[0]).Feed();
            animalArrayList.AddRange(animalArray);
            ((Chicken)animalArrayList[2]).LayEgg();

            Console.WriteLine("The animal called {0} is at index {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1));
            myCow1.Name = "Janice";
            Console.WriteLine("The animal is now called {0}.", ((Animal)animalArrayList[1]).Name);

            Console.ReadKey();
        }
Example #16
0
        public static bool CreateExcelFile(string excelFile, string sheetName, DataTable frTable,
                                           ArrayList columnList, ArrayList headerList)
        {
            string SQLCmd = "";
            OleDbConnection oleDbConn = OpenConnection(excelFile);
            if (oleDbConn == null) return false;
            try
            {
                string columName;
                int columnNo;
                for (int idx = 0; idx < frTable.Columns.Count; idx++)
                {
                    if (columnList != null)
                    {
                        columnNo = columnList.IndexOf(frTable.Columns[idx].ColumnName.ToUpper());
                        if (columnNo < 0) continue;
                        columName = headerList[columnNo].ToString();
                    }
                    else columName = frTable.Columns[idx].ColumnName.ToString();

                    SQLCmd += (SQLCmd == "" ? "" : ",") + "[" + columName + "]";
                    switch (frTable.Columns[idx].DataType.ToString().Trim())
                    {
                        case "System.Double":
                        case "System.Decimal":
                        case "System.Int64":
                            SQLCmd = " double";
                            break;
                        case "System.DateTime":
                            SQLCmd = " date ";
                            break;
                        case "System.Boolean":
                            SQLCmd += " bit";
                            break;
                        default:
                            SQLCmd += " string";
                            break;
                    }
                }
                SQLCmd = "CREATE TABLE [" + sheetName + "] (" + SQLCmd + ");";
                OleDbCommand oleDbComm = new OleDbCommand(SQLCmd, oleDbConn);
                oleDbComm.ExecuteNonQuery();
                oleDbConn.Close();
                return true;
            }
            catch (Exception er)
            {
                lastErrorMessage = er.Message.ToString();
            }
            finally
            {
                if (oleDbConn != null && oleDbConn.State == ConnectionState.Open) oleDbConn.Close();
            }
            return false;
        }
Example #17
0
        private static void DisplayInformation(ArrayList arrayList)
        {
            foreach (var element in arrayList)
                Console.Write(element + " ");
            Console.WriteLine("\n Size = " + arrayList.Count + "; Capacity = " + arrayList.Capacity);

            int index = arrayList.IndexOf("BLUE");

            if (index != -1)
                Console.WriteLine("The arraylist contains Blue at index " + index);
            else
                Console.WriteLine("The arraylist does not contain Blue");
        }
Example #18
0
        public int CheckForUpdate(string serverXmlFile, string localXmlFile, out Hashtable updateFileList)
        {
            updateFileList = new Hashtable();
            if (!File.Exists(localXmlFile) || !File.Exists(serverXmlFile))
            {
                return -1;
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");//5+1+a+s+p+x

            int k = 0;
            for (int i = 0; i < newNodeList.Count; i++)
            {
                string[] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for (int j = 0; j < oldNodeList.Count; j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);

                }
                int pos = oldFileAl.IndexOf(newFileName);
                if (pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k, fileList);
                    k++;
                }
                else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k, fileList);
                    k++;
                }

            }
            return k;
        }
Example #19
0
        static void Main(string[] args)
        {
            Console.WriteLine ("Create an Array type collection of Animal " + 
                               "objects and use it:"); 
                               // Создание коллекции типа Array из объектов 
                               // Animal и ее использование 
            Animal[] animalArray = new Animal[2]; 
            Cow myCow1 = new Cow("Deirdre"); 
            animalArray[0] = myCow1; 
            animalArray[1] = new Chicken ("Ken") ; 
            foreach (Animal myAnimal in animalArray) 
            { 
                Console.WriteLine("New {0} object added to Array collection, " + 
                                   "Name = {1}", myAnimal.ToString() , myAnimal.Name) ; 
                                  // В коллекцию Array добавлен новый объект 
            }
            Console.WriteLine("Array collection contains {0} objects.", animalArray.Length);
                                 // Вывод количества объектов в коллекции Array  

            animalArray[0].Feed(); 
            ((Chicken)animalArray[1]).LayEgg(); 
            Console.WriteLine(); 
            Console.WriteLine("Create an ArrayList type collection of Animal " + "objects and use it:") ; 
            ArrayList animalArrayList = new ArrayList () ; 
            Cow myCow2 = new Cow("Hayley"); 
            animalArrayList.Add(myCow2); 
            animalArrayList.Add(new Chicken ("Roy")); 
            foreach (Animal myAnimal in animalArrayList) 
            { 
                Console.WriteLine ("New {0} object added to ArrayList collection," + 
                                    " Name = {1}", myAnimal.ToString() , myAnimal.Name) ; 
            } 
            Console.WriteLine("ArrayList collection contains {0} objects.", 
                               animalArrayList.Count); 
            ((Animal)animalArrayList[0]).Feed(); 
            ((Chicken)animalArrayList[1]).LayEgg(); 
            Console.WriteLine(); 
            Console. WriteLine ("Additional manipulation of ArrayList:") ; 
                                // Дополнительное манипулирование коллекцией ArrayList 
            animalArrayList.RemoveAt(0); 
            ((Animal)animalArrayList[0]).Feed(); 
            animalArrayList.AddRange(animalArray); 
            ((Chicken)animalArrayList[2]).LayEgg(); 
            Console.WriteLine("The animal called {0} is at index {1}.", 
                               myCow1.Name, animalArrayList.IndexOf(myCow1)); 
                             // Вывод животных и позиций 
            myCow1.Name = "Janice"; 
            Console.WriteLine("The animal is now called {0}.", ((Animal) animalArrayList[1]).Name) ; 
                             // Вывод животных 
            Console.ReadKey(); 
        }
Example #20
0
 public void CanIncludeWithEagerLoading()
 {
     var myarray = new ArrayList();
       using (var db = new mybooksEntities())
       {
     var author = db.myauthors.Include("mybooks.myeditions").AsEnumerable().First();
     var strquery = ((ObjectQuery)db.myauthors.Include("mybooks.myeditions").AsEnumerable()).ToTraceString();
     CheckSql(strquery, SQLSyntax.JoinUsingInclude);
     foreach (var book in author.mybooks.ToList())
     {
       foreach (var edition in book.myeditions.ToList())
       {
     myarray.Add(edition.Title);
       }
     }
     myarray.Sort();
     Assert.AreEqual(0, myarray.IndexOf("Another Book First Edition"));
     Assert.AreEqual(1, myarray.IndexOf("Another Book Second Edition"));
     Assert.AreEqual(2, myarray.IndexOf("Another Book Third Edition"));
     Assert.AreEqual(3, myarray.IndexOf("Some Book First Edition"));
     Assert.AreEqual(myarray.Count, 4);
       }
 }
Example #21
0
        public static ArrayList buildSynonymsList(string p_dir, OracleConnection conn)
        {
            Console.WriteLine("Processing scripts ... {0}", p_dir);
            // First read all files from the file system
            string configSqlFileList = Settings.getSqlFileList(true);
            string configIgnoreDirList = Settings.getIgnoreDirList(true);
            string configIgnoreFileList = Settings.getIgnoreFileList(true);

            Log.Info("grants", "Searching for sql scripts");
            string[] files = FolderSearch.Search(p_dir, true, configSqlFileList, configIgnoreDirList, configIgnoreFileList);

            ArrayList fileList = new ArrayList();
            // each file can contain 0 or more blocks
            foreach (string filename in files)
            {
                ArrayList sqlCommandList = new ArrayList(SqlScript.Load(filename));
                foreach (SqlObject sqlCommand in sqlCommandList)
                {
                    if (sqlCommand.commandType == "SQL" && sqlCommand.objectType == "SYNONYM")
                        fileList.Add(parseSynonymSql(sqlCommand.sqlText, filename));
                }
            }

            // TODO: Check for duplicate synonyms

            Console.WriteLine("Processing database catalog ...");
            // Read all entries from user_tab_privs_made
            string cmdQuery = "select user, synonym_name, table_owner||'.'||table_name||nvl2(db_link,'@','')||db_link targetName from user_synonyms";
            OracleCommand cmd = new OracleCommand(cmdQuery, conn);
            OracleDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                SynonymObject currObject = new SynonymObject(reader.GetString(0), reader.GetString(1), reader.GetString(2), false);
                int existingObjectIndex = fileList.IndexOf(currObject);

                // This object does not exist in arrayList
                if (existingObjectIndex == -1) fileList.Add(currObject);

                // because of duplicates loop through all occurences
                while (existingObjectIndex >= 0)
                {
                    SynonymObject existingFileItem = (SynonymObject)fileList[existingObjectIndex];
                    existingFileItem.existsInSchema = true;
                    existingObjectIndex = fileList.IndexOf(currObject, existingObjectIndex + 1);
                }
            }

            return fileList;
        }
Example #22
0
        /// <summary>
        /// 30进制转10进制
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public static Int64 ThirtyToDecimal(string num_str)
        {
            ArrayList ar = new ArrayList(key);
            Int64 k;
            Int64 num = 0;

            for (int i = 0; i < num_str.Length; i++)
            {
                k = ar.IndexOf(num_str[i].ToString());
                if (k < 0) throw new Exception("有非法数据!");
                k *= (Int64)Math.Pow(30, num_str.Length - i - 1);
                num += k;
            }
            return num;
        }
Example #23
0
        static void Main(string[] args)
        {
            ArrayList myArrayList = new ArrayList();
            myArrayList.Add(1);
            myArrayList.Add("SEIP");
            myArrayList.Add(12.5);

            Console.WriteLine(myArrayList.IndexOf("SEIP"));//to see index number
            Console.WriteLine(myArrayList[1]);
            foreach (var VARIABLE in myArrayList)
            {
                Console.WriteLine(VARIABLE);
            }
            Console.ReadKey();
        }
 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ�󾶷���Ӻ���
 public void LinkFolder(string inputPath, FileInfo[] classList, string targetPath, string[] exCludePath, string[] exCludeFile)
 {
     if (Directory.Exists(inputPath))
     {
         DirectoryInfo folder = new DirectoryInfo(inputPath);
         FileInfo[] list = folder.GetFiles("*.as", SearchOption.AllDirectories);
         int linkCount = list.Length;
         int exCludeCount = 0;
         ArrayList exCludeList = new ArrayList();
         for (int i = 0; i < list.Length; i++)
         {
             FileInfo obFile = list[i];
             bool allowLink = true;
             for (int j = 0; j < exCludeFile.Length; j++)
             {
                 string fileName = obFile.FullName;
                 if (fileName.Equals(exCludeFile[j], StringComparison.InvariantCultureIgnoreCase))
                 {
                     allowLink = false;
                     linkCount--;
                     exCludeCount++;
                     exCludeList.Add(fileName);
                 }
             }
             for (int j = 0; j < exCludePath.Length; j++)
             {
                 string folderName = obFile.DirectoryName;
                 if (folderName.Equals(exCludePath[j], StringComparison.InvariantCultureIgnoreCase))
                 {
                     allowLink = false;
                     linkCount--;
                     exCludeCount++;
                     if (exCludeList.IndexOf(folderName) < 0)
                     {
                         exCludeList.Add(folderName);
                     }
                 }
             }
             if (allowLink)
             {
                 LinkFile(obFile.FullName, classList, targetPath, true);
             }
         }
         string info = string.Join("\r\n", exCludeList.ToArray(typeof(string)) as string[]);
         string countInfo = linkCount.ToString() + " + " + exCludeCount.ToString() + " = " + list.Length.ToString();
         ErrorBox.Show(countInfo + " \r\n" + info, "BatchClassLinkerError");
     }
 }
Example #25
0
 /// <summary>
 /// inicializalas, ha Alap tipusunk is van
 /// </summary>
 /// <param name="valtpanelek">
 /// a panelek tombje
 /// </param>
 /// <param name="sajatpanelek">
 /// Alap tipusu panelek tombje vagy null
 /// </param>
 public virtual void ValtozasokInit(Panel[] valtpanelek, Panel[] sajatpanelek)
 {
     object[] alap = null;
     if (sajatpanelek != null)
         alap = new object[] { Alapinfotipus.Alap, sajatpanelek };
     object[] valt = new object[] { Alapinfotipus.Valtozasok, valtpanelek };
     Panel[] panelek = new Panel[]{panel1,panel2,panel3,panel4,panel5};
     ArrayList eredetiar = new ArrayList(panelek);
     ArrayList ar = new ArrayList(valtpanelek);
     bool[] van = new bool[5];
     for (int i = 0; i < van.Length; i++)
     {
         Panel eredeti = (Panel)eredetiar[i];
         if (ar.IndexOf(eredeti) != -1)
             van[i] = true;
     }
     for (int i = 0; i < van.Length; i++)
     {
         if (!van[i])
             this.Controls.Remove((Control)eredetiar[i]);
     }
     //switch (valtpanelek.Length)
     //{
     //    case 1:
     //        this.Controls.Remove(panel2);
     //        this.Controls.Remove(panel3);
     //        this.Controls.Remove(panel4);
     //        this.Controls.Remove(panel5);
     //        break;
     //    case 2:
     //        this.Controls.Remove(panel3);
     //        this.Controls.Remove(panel4);
     //        this.Controls.Remove(panel5);
     //        break;
     //    case 3:
     //        this.Controls.Remove(panel4);
     //        this.Controls.Remove(panel5);
     //        break;
     //    case 4:
     //        this.Controls.Remove(panel5);
     //        break;
     //}
     if (alap == null)
         AlapinfoInit(new object[] { valt });
     else
         AlapinfoInit(new object[] { alap, valt });
 }
Example #26
0
        //Main_7_9_2
        public static void Main_7_9_2()
        {
            //���弯������
            ArrayList arrs = new ArrayList();
            //����Add���������Ӽ���Ԫ��
            arrs.Add(10);
            arrs.Add(new object());
            arrs.Add("I'm OK.");
            arrs.Add(new MyClass());
            arrs.Add(100);

            //����Remove�������Ƴ�ָ������
            arrs.Remove(100);

            //����Insert�������������ָ������λ��
            arrs.Insert(2, "A insert value");

            //IndexOf���������ڴ���ʼλ�������������ص�һ��ƥ���������λ��
            Int32 index = arrs.IndexOf("I'm OK.");

            //��ȡ���ϵ�ָ��Ԫ��
            object obj = arrs[index];
            Console.WriteLine("{0} -- {1}", obj, index);

            //��ȡ���ϵ�Ԫ�ظ���
            Console.WriteLine(arrs.Count);

            //ͨ��ö������������Ԫ��
            IEnumerator myEnumerator = arrs.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                Console.WriteLine(myEnumerator.Current);
            }

            //����ӵķ�ʽ����Ϊ
            foreach (object o in arrs)
            {
                Console.WriteLine(o.ToString());
            }

            //������ϵ�����Ԫ��
            arrs.Clear();
        }
Example #27
0
        /// <summary>
        /// Converts Bitmap images to XPM data for use with ScintillaNet.
        /// Warning: images with more than (around) 50 colors will generate incorrect XPM
        /// tColor: specified transparent color in format: "#00FF00".
        /// </summary>
        static public string ConvertToXPM(Bitmap bmp, string tColor)
        {
            StringBuilder sb = new StringBuilder();
            ArrayList colors = new ArrayList();
            ArrayList chars  = new ArrayList();

            OctreeQuantizer quantizer = new OctreeQuantizer(50, 8, ColorTranslator.FromHtml(tColor));
            Bitmap reducedBmp = quantizer.Quantize(bmp);

            int width = reducedBmp.Width;
            int height = reducedBmp.Height;
            int index;
            sb.Append("/* XPM */static char * xmp_data[] = {\"").Append(width).Append(" ").Append(height).Append(" ? 1\"");
            int colorsIndex = sb.Length;
            string col;
            char c;
            for (int y = 0; y<height; y++)
            {
                sb.Append(",\"");
                for (int x = 0; x<width; x++)
                {
                    col = ColorTranslator.ToHtml(reducedBmp.GetPixel(x,y));
                    index = colors.IndexOf(col);
                    if (index < 0)
                    {
                        index = colors.Add(col)+65;
                        if (index > 90) index += 6;
                        c = Encoding.ASCII.GetChars(new byte[]{(byte)(index & 0xff)})[0];
                        chars.Add(c);
                        sb.Insert(colorsIndex, ",\""+c+" c "+col+"\"");
                        colorsIndex += 14;
                    }
                    else c = (char)chars[index];
                    sb.Append(c);
                }
                sb.Append("\"");
            }
            sb.Append("};");
            string result = sb.ToString();
            int p = result.IndexOf("?");
            string finalColor = result.Substring(0, p)+colors.Count+result.Substring(p+1).Replace(tColor.ToUpper(), "None");
            return finalColor;
        }
Example #28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Создание коллекции типа Array из объектов Animal и её использование.");
            Animal[] animalArray = new Animal[2];
            Cow myCow1 = new Cow("Бурёнка");

            animalArray[0] = myCow1;
            animalArray[1] = new Chicken("Дося");

            foreach (var animal in animalArray)
            {
                Console.WriteLine("Объект {0} был добавлен в коллекцию Array, " + "Имя = {1}.", animal.ToString(), animal.Name);
            }

            Console.WriteLine("Коллекция Array содержит {0} объектов.", animalArray.Length);
            animalArray[0].Feed();
            ((Chicken)animalArray[1]).LayEgg();
            Console.WriteLine();
            Console.WriteLine("Сщздание коллекции объектов Animal типа Array и её использование.");
            ArrayList animalArrayList = new ArrayList();
            Cow myCow2 = new Cow("Таня");
            animalArrayList.Add(myCow2);
            animalArrayList.Add(new Chicken("Феня"));

            foreach(Animal myAnimal in animalArrayList)
            {
                Console.WriteLine("Объект {0}  был добавлен в коллекцию ArrayList, " + " Имя = {1}.", myAnimal.ToString(), myAnimal.Name);
            }
            Console.WriteLine("Коллекция ArrayList содержит {0} объктов.", animalArrayList.Count);
            ((Animal)animalArrayList[0]).Feed();
            ((Chicken)animalArrayList[1]).LayEgg();
            Console.WriteLine();

            Console.WriteLine("Дополнительное манипулирование коллекцией ArrayList:");
            animalArrayList.RemoveAt(0);
            ((Animal)animalArrayList[0]).Feed();
            animalArrayList.AddRange(animalArray);
            ((Chicken)animalArrayList[2]).LayEgg();
            Console.WriteLine("Животное по имени {0} находится под индексом {1}.", myCow1.Name, animalArrayList.IndexOf(myCow1));
            myCow1.Name = "Джанис";
            Console.WriteLine("Животное теперь зовут {0}!", ((Animal)animalArrayList[1]).Name);
            Console.ReadKey();
        }
Example #29
0
        /// <summary>  
        /// 将Excel文件导出至DataTable(第一行作为表头)  
        /// </summary>  
        /// <param name="ExcelFilePath">Excel文件路径</param>  
        /// <param name="TableName">数据表名,如果数据表名错误,默认为第一个数据表名</param>  
        public static DataTable InputFromExcel(string ExcelFilePath, string TableName)
        {
            if (!File.Exists(ExcelFilePath))
            {
                throw new Exception("Excel文件不存在!");
            }

            //如果数据表名不存在,则数据表名为Excel文件的第一个数据表  
            ArrayList TableList = new ArrayList();
            TableList = GetExcelTables(ExcelFilePath);

            if (TableList.IndexOf(TableName) < 0)
            {
                TableName = TableList[0].ToString().Trim();
            }

            DataTable table = new DataTable();
            OleDbConnection dbcon = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelFilePath + ";Extended Properties=Excel 8.0");
            OleDbCommand cmd = new OleDbCommand("select * from [" + TableName + "$]", dbcon);
            OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

            try
            {
                if (dbcon.State == ConnectionState.Closed)
                {
                    dbcon.Open();
                }
                adapter.Fill(table);
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                if (dbcon.State == ConnectionState.Open)
                {
                    dbcon.Close();
                }
            }
            return table;
        }
Example #30
0
        public Window1(Config appConfig)
        {
            InitializeComponent();
            configObj = appConfig;
            dataGrid1.ItemsSource = _configObj.imageLinks;
            dataGrid2.ItemsSource = _configObj.distributors;

            ArrayList knownColors = new ArrayList();
            foreach (KnownColor col in Enum.GetValues(typeof(KnownColor)))
            {
                System.Drawing.Color color = System.Drawing.Color.FromKnownColor(col);
                if (!color.IsSystemColor)
                {
                    knownColors.Add(col.ToString());
                }
            }

            ColorPicker.ItemsSource = knownColors;
            ColorPicker.SelectedIndex = knownColors.IndexOf(appConfig.contactColor);
        }