Example #1
0
    public ArrayList updatePath(Vector2 startPos, Vector2 endPos)
    {
        List<Vector2> closed = new List<Vector2>();
        List<Vector2> open = new List<Vector2>();
        open.Add(startPos);

        Dictionary<Vector2,Vector2> came_from = new Dictionary<Vector2,Vector2>();
        Dictionary<Vector2,float> g = new Dictionary<Vector2,float>();
        g[startPos] = 0.0f;
        Dictionary<Vector2,float> h = new Dictionary<Vector2,float>();
        h[startPos] = estimate(startPos,endPos);
        Dictionary<Vector2,float> f = new Dictionary<Vector2,float>();
        f[startPos] = h[startPos];

        while(open.Count != 0)
        {
            Vector2 current = findLowest(open,f);
            if(current.x == endPos.x && current.y == endPos.y)
            {
                //return reconstructed path
                ArrayList result = new ArrayList();
                while(came_from.ContainsKey(current))
                {
                    result.Insert(0,current);
                    //Debug.Log(g[current]);
                    current = came_from[current];
                }
                result.Insert(0,current);
                return result;
            }
            open.Remove(current);
            closed.Add(current);
            foreach(Vector2 next in connections(current))
            {
                if(!closed.Contains(next))
                {
                    float initialScore = g[current] + gm.influence[(int)current.x,(int)current.y];
                    bool better = false;
                    if(!open.Contains(next))
                    {
                        open.Add(next);
                        better = true;
                    }
                    else if(initialScore < g[next])
                    {
                        better = true;
                    }
                    if(better)
                    {
                        came_from[next] = current;
                        g[next] = initialScore;
                        h[next] = estimate(next,endPos);
                        f[next] = g[next] + h[next];
                    }
                }
            }
        }
        return null;
    }
    void Start()
    {
        //创建子探测器列表, subDetectorList; 按优先级排序
        ArrayList lDetectorList = new ArrayList();
        int i = 0;
        foreach (Transform lTransform in transform)
        {
            zzDetectorBase lDetector = lTransform.GetComponent<zzDetectorBase>();
            if (lDetector)
            {
                //按优先级排序,大的排在前面.先检测
                for (i = 0; i < lDetectorList.Count; ++i)
                {
                    zzDetectorBase lDetectorTemp = (zzDetectorBase)lDetectorList[i];
                    if (lDetector.getPriority() > lDetectorTemp.getPriority())
                    {
                        lDetectorList.Insert(i, lDetector);
                        lDetector = null;//来说明已添加
                        break;
                    }
                }
                if (lDetector)
                    lDetectorList.Add(lDetector);
            }
        }

        subDetectorList = new zzDetectorBase[lDetectorList.Count];
        for (i = 0; i < lDetectorList.Count; ++i)
        {
            subDetectorList[i] = (zzDetectorBase)lDetectorList[i];
        }
    }
Example #3
0
        static void playWithArrayList()
        {
            ArrayList lst = new ArrayList() {1,2,3};
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            int a = 0;
            lst.Add(a = 15);
            lst.Add(null);
            lst.Add(new Car("diesel", 150, 200));
            lst.Add(10.25f);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.Insert(2, "insert");
            lst.Add(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            lst.RemoveAt(1);
            lst.Add(a);
            lst.Remove(a);
            lst.Remove(15);
            Debug.WriteLine("capacity {0}", lst.Capacity);
            Debug.WriteLine("count {0}", lst.Count);
            Console.WriteLine(lst.IndexOf(15));

            foreach (Object obj in lst)
                Console.WriteLine(obj);
        }
 public void AddText( string pText, int pIndex )
 {
     ArrayList list = new ArrayList();
     list.AddRange( mContents);
     list.Insert( pIndex, new GUIContent( pText));
     mContents = list.ToArray( typeof(GUIContent)) as GUIContent[];
 }
 [TestMethod] // Тест заполнения с использованием Insert
 public void InsertTest()
 {
     int n = 2;
     ArrayList<object> data = new ArrayList<object>(n);
     data.Append(8);
     data.Insert(4, 1);
 }
Example #6
0
    public static void Main()
    {
        // Create a list of strings.
        var salmons = new List<string>();
        salmons.Add("chinook");
        salmons.Add("coho");
        salmons.Add("pink");
        salmons.Add("sockeye");

        // Iterate through the list.
        foreach (var fish in salmons) {
            Console.Write(fish + " ");
        }
        Console.WriteLine();
        // Output: chinook coho pink sockeye

        var map = new Dictionary<string, string>();
        map.Add("txt", "notepad.exe");
        map.Add("bmp", "paint.exe");
        map.Add("dib", "paint.exe");
        map.Add("rtf", "wordpad.exe");

        foreach(var kvp in map) {
            Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
        }
        Console.WriteLine();

        var al = new ArrayList();
        // Add puts it at the end
        // Insert(0, xxx); puts at beginning
        al.Add(45);
        al.Add(78);
        al.Add(33);
        al.Add(56);
        al.Add(12);
        al.Add(23);
        al.Add(9);
        al.Insert(0, 9); // puts it at front

        // array list is similar to C++ vector
        for (int i = 0; i < al.Count; i++) {
            Console.Write(al[i] + " ");
        }
        Console.WriteLine();

        foreach (var i in al)
        {
            Console.Write(i + " ");
        }
        Console.WriteLine();

        // Linq query over ints
        int[] numbers = { 10, 20, 30, 40, 1, 2, 3, 8 };
        var subset = from i in numbers where i < 10 select i;
        Console.WriteLine("values in linq subset");
        foreach (var i in subset) {
            Console.WriteLine("{0}", i);
        }
    }
Example #7
0
    public static ArrayList getBlob(int [,,] mapData, int stopCode, IntVector3 point)
    {
        /*
        returns a list of IntVector3 voxels that are all connected to i,j,k

        returns an empty list if it finds a voxelCode=hullBase

        prioritize search on neighbors going down, then neighbors at same level, then up
        */
        ArrayList visitedVoxels = new ArrayList ();
        allVisitedVoxels.Add (point);
        visitedVoxels.Add (point);

        frontier = new ArrayList ();
        frontier.Add (point);

        //print ("getBlob " + i + " " + j + " " + k);

        while (frontier.Count>0) {
            IntVector3 seedPoint = (IntVector3)frontier [0];
            frontier.RemoveAt (0);

            foreach (IntVector3 neighbor in MDView.getNeighbors(mapData,seedPoint)) {
                if (! visitedVoxels.Contains (neighbor)) {
                    allVisitedVoxels.Add (neighbor);
                    visitedVoxels.Add (neighbor);

                    //print ("adding to visitedVoxels " + neighbor.i + " " + neighbor.j + " " + neighbor.k);

                    if (neighbor.y < point.y) {
                        frontier.Insert (0, neighbor);
                    } else if (neighbor.y == point.y) {
                        frontier.Insert (frontier.Count / 2, neighbor);
                    } else if (neighbor.y > point.y) {
                        frontier.Insert (frontier.Count, neighbor);
                    }

                    if (mapData [neighbor.x, neighbor.y, neighbor.z] == stopCode) {
                        return new ArrayList ();
                    }
                }
            }
        }

        return visitedVoxels;
    }
    /**
     *
     * Constructs an extended operation object for getting data about any Object
     * and make a call to ld.ExtendedOperation to get the response <br>
     *
     */
    public static ArrayList backup(LdapConnection ld, String objectDN,
        byte[] passwd, String stateInfo)
    {
        int intInfo;
        String strInfo;
        byte[] returnedBuffer; //Actual data blob returned as byte[]
        ArrayList objectBuffer = new ArrayList(4);
        objectBuffer.Insert(0, new Integer32(-1)); //Mark the rc default as failed backup
        try
        {
            LdapExtendedOperation request = new LdapBackupRequest(objectDN,
                    passwd, stateInfo);

            LdapExtendedResponse response = ld.ExtendedOperation(request);

            int result = response.ResultCode;
            objectBuffer.Remove(0);
            objectBuffer.Insert(0, new Integer32(result));

            if ((result == LdapException.SUCCESS) && (response is LdapBackupResponse))
            {
                Console.WriteLine("Backup Info:");

                strInfo = ((LdapBackupResponse) response).getStatusInfo();
                Console.WriteLine("    Status Info: " + strInfo);

                intInfo = ((LdapBackupResponse) response).getBufferLength();
                Console.WriteLine("    Buffer length: " + intInfo);
                objectBuffer.Insert(1, new Integer32(intInfo));

                strInfo = ((LdapBackupResponse) response).getChunkSizesString();
                Console.WriteLine("    Chunk sizes: " + strInfo);
                objectBuffer.Insert(2, strInfo);

                returnedBuffer = ((LdapBackupResponse) response).getReturnedBuffer();
                objectBuffer.Insert(3, returnedBuffer);

                Console.WriteLine("\nInformation backed up successfully\n");

            }
            else
            {
                Console.WriteLine("Could not backup the information.\n");
                throw new LdapException(response.ErrorMessage, response.ResultCode, (String) null);
            }

        }
        catch (LdapException e)
        {
            Console.WriteLine("Error: " + e.ToString());
        }
        catch (System.Exception e)
        {
            Console.WriteLine("Error: " + e.ToString());
        }
        return objectBuffer;
    }
Example #9
0
 public static ArrayList Sekigsae(ArrayList array)
 {
     ArrayList newArray = new ArrayList(array.Count);
     foreach (var n in array)
     {
         var index = Random.Range(0, newArray.Count+1);
         newArray.Insert(index, n);
     }
     return newArray;
 }
Example #10
0
        public void Insert()
        {
            var list = new ArrayList<int>(4);

              Assert.That(() => list.Insert(-1, 0), Throws.Exception);
              Assert.That(() => list.Insert(1, 0), Throws.Exception);

              // Insert into empty list.
              list.Insert(0, 1);
              Assert.AreEqual(1, list.Count);
              Assert.AreEqual(1, list.Array[0]);

              // Insert at begin.
              list.Insert(0, 2);
              Assert.AreEqual(2, list.Count);
              Assert.AreEqual(2, list.Array[0]);
              Assert.AreEqual(1, list.Array[1]);

              // Insert at end.
              list.Insert(2, 3);
              Assert.AreEqual(3, list.Count);
              Assert.AreEqual(2, list.Array[0]);
              Assert.AreEqual(1, list.Array[1]);
              Assert.AreEqual(3, list.Array[2]);

              // Insert in middle.
              list.Insert(1, 4);
              Assert.AreEqual(4, list.Count);
              Assert.AreEqual(2, list.Array[0]);
              Assert.AreEqual(4, list.Array[1]);
              Assert.AreEqual(1, list.Array[2]);
              Assert.AreEqual(3, list.Array[3]);
        }
	// Test insertion into an array list.
	public void TestArrayListInsert()
			{
				int posn;
				ArrayList list = new ArrayList();
		
				for(posn = 0; posn < 100; ++posn)
				{
					AssertEquals(list.Count, posn);
					list.Insert(posn / 2, posn.ToString());
					AssertEquals(list.Count, posn + 1);
					AssertEquals(((String)(list[posn / 2])), posn.ToString());
				}
			}
    static void Main()
    {
        ArrayList ar = new ArrayList(10);
        ar.Add(1);
        ar.Add(2.34);
        ar.Add("string");
        ar.Add(new DateTime(2005, 3, 1));
        ar.Insert(1, 1234);

        foreach (object o in ar)
        {
            Console.WriteLine(o.ToString());
        }
        Console.WriteLine("개수 : " + ar.Count);
        Console.WriteLine("용량 : " + ar.Capacity);
    }
Example #13
0
File: gup.cs Project: timdiels/gup
    static void Main(string[] args)
    {
        string here = Assembly.GetEntryAssembly().Location;
        string dir = Path.GetDirectoryName(here);
        string gup = Path.Combine(dir, "gup");

        ArrayList pythonArgs = new ArrayList(args);
        pythonArgs.Insert(0, gup);

        string argstr = QuoteArguments(pythonArgs);

        // System.Console.WriteLine(argstr);

        var p = Process.Start(new ProcessStartInfo ("python", argstr) { UseShellExecute = false });

        p.WaitForExit();
        Environment.Exit(p.ExitCode);
    }
    /// <summary>
    /// Calls a function on the web page.
    /// </summary>
    /// <param name="functionName">The name of the function to execute.</param>
    /// <param name="args">The arguments to send to the function.</param>
    public static void ExternalCall(string functionName, params object[] args)
    {
        ArrayList parameters = new ArrayList(args);
        parameters.Insert(0, functionName);

        // All function calls pass through a global "DR_clientCall" function
        Application.ExternalCall("DR_clientCall", parameters.ToArray());
    }
Example #15
0
 public void Insert(int index, IMetadataRow value)
 {
     m_items.Insert(index, value);
 }
Example #16
0
        /// <summary>
        /// The extract map button_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        /// <remarks></remarks>
        private void extractMapButton_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            count        = 4 + map.BSP.sbsp.Length;

            // MetaList.Capacity = 10000;
            StatusLabel1.Text = "Processing Map Metas...";
            Application.DoEvents();

            if (treeView1.Nodes[0].Checked)
            {
                RecursivelyCheckMetas(treeView1.Nodes[0]);
            }

            StatusLabel1.Text = "Processing Imported Metas...";
            Application.DoEvents();

            foreach (ListViewItem l in listView2.Items)
            {
                if (l.Checked == false)
                {
                    continue;
                }

                StatusLabel1.Text = "Processing: " + l.Text + "...";
                Application.DoEvents();

                string[] split = l.Text.Split('.');
                if (split[split.Length - 1] != "info")
                {
                    Meta m = new Meta(map);
                    m.LoadMetaFromFile(l.Text);
                    MetaList.Add(m);
                }
                else
                {
                    FileStream   FS    = new FileStream(l.Text, FileMode.Open);
                    StreamReader SR    = new StreamReader(FS);
                    string       temps = string.Empty;
                    do
                    {
                        temps = SR.ReadLine();

                        if (temps == null)
                        {
                            break;
                        }

                        Meta m = new Meta(map);
                        m.LoadMetaFromFile(temps);
                        bool exists = false;
                        for (int x = 0; x < map.IndexHeader.metaCount; x++)
                        {
                            if (map.FileNames.Name[x] == m.name && map.MetaInfo.TagType[x] == m.type)
                            {
                                exists = true;
                                break;
                            }
                        }

                        if (exists == false)
                        {
                            for (int x = 0; x < MetaList.Count; x++)
                            {
                                if (((Meta)MetaList[x]).name == m.name && ((Meta)MetaList[x]).type == m.type)
                                {
                                    exists = true;
                                    break;
                                }
                            }
                        }

                        if (exists == false)
                        {
                            switch (m.type.Trim())
                            {
                            case "matg":
                                matg = m;
                                break;

                            case "sncl":
                                sncl = m;
                                break;

                            case "spk!":
                                spk = m;
                                break;

                            case "scnr":
                                scnr = m;
                                break;

                            case "sky":
                                this.Skies.Add(m);
                                skycount++;
                                break;

                            default:
                                MetaList.Add(m);
                                count++;
                                break;
                            }
                        }
                    }while (temps != null);

                    SR.Close();
                    FS.Close();
                }
            }

            for (int x = skycount - 1; x > -1; x--)
            {
                MetaList.Insert(0, Skies[x]);
            }

            MetaList.Insert(0, scnr);
            MetaList.Insert(0, spk);
            MetaList.Insert(0, sncl);
            MetaList.Insert(0, matg);
            StatusLabel1.Text = "Starting Rebuild....";
            Application.DoEvents();
            MapAnalyzer ma  = new MapAnalyzer();
            MapLayout   lay = ma.ScanMapForLayOut(map, false);

            lay.ReadChunks(map);

            MapRebuilder(ref lay);
            MetaList.Clear();
            StatusLabel1.Text = "Done";
            this.Enabled      = true;
        }
Example #17
0
        static void Main(string[] args)
        {
            int[] arr = new int[5]; /* Fixed in size , but type safe only integer can be stored*/ /*If this need to be resized ,
                                     * need to create new array of different size and copy the existing array values to it */
            /* Inserting/Deleting values from the middle of the Array is not possible*/
            //    Console.WriteLine(arr.Length);
            Array.Resize(ref arr, 10); /*internally creates new array and copies the values and destroys the old array */
            //    Console.WriteLine(arr.Length);
            /*Collections - available in System.Collections */
            /* Are of Non Generic type but auto resizable */
            /* ArrayList , Stack, Queue, HashList , LinkedList,SortedList Classes*/
            ArrayList AL = new ArrayList();

            Console.WriteLine(AL.Capacity);
            AL.Add(5); AL.Add("gowtham"); AL.Add(23.0000);
            // AL.Add(5); AL.Add("gowtham"); AL.Add(23.0000);
            AL.Insert(1, 100000); /* insert method to insert at any place in the list */
            AL.Remove(10000);     /* remove method to remove any value from the list*/
            AL.RemoveAt(1);       /* remove method to remove any value at specified index from the list*/
            Console.WriteLine(AL.Capacity);
            foreach (var item in AL)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine();
            Hashtable HT = new Hashtable(); /* Stores the values in a UserDefined Key/Values pairs */

            /*Even Array/ArrayList stores the values in Key (Index)/Value Pairs, but these keys(index values) are
             * predefined (0,1...,n-1) */

            Console.WriteLine("Hashtable Starts");
            HT.Add("EmpName", "Gowthaman");
            HT.Add("EmpId", 402994);
            HT.Add(1234, "30 / 10 / 1991");
            foreach (var keys in HT.Keys) /* Ht.Values diretly accesses and print values  */
            /* Ht.Keys gets the keys (just like index values but userdefined ) and can print associated values with it */

            /* HT has one more value associated with Keys we enter i.e., HashCode (an int value) which we dont have control over and
             * based on that order only we will get the output displayed*/
            {
                Console.WriteLine(keys + ": " + HT[keys] + " ");
                Console.WriteLine(keys.GetHashCode());
                Console.WriteLine(HT[keys].GetHashCode());
            }

            /* To overcome the Type safety constraints(it accepts any type of value you try to add) in Collections, C# 2.0 MS
             * Introduced Generics Concept - System.Collections.Generic*/
            /*Whenever you try to declare List- it asks for 'T' which is the type of the List (strongly typed list of objects) */
            List <int> Li = new List <int>(); /*It can add only integer values, throws error if we try to add other types*/

            //Li.Add("int");
            Li.Add(10);
            /*Other than this all the features available in Collections will be available in this Generic List as well */
            //Hashtable<int, string> Ht = new Hashtable<int, string>(); need to see equiv for Hashtable in Generic Collection*/ equivalent is Dictionary<TKey,TValue>

            //Genrics<int> genobj = new Genrics<int>();  /*Generics is introduced in C# 2.0*/
            Genrics genobj = new Genrics();

            Console.WriteLine(genobj.Add(10, 100));
            Console.WriteLine(genobj.Add <string>("string A", "string B"));
            Console.WriteLine(genobj.Subtract(99, 100));
            Console.WriteLine(genobj.Add(1000, 11000));

            //Genrics<string> genobj1 = new Genrics<string>();
            //Console.WriteLine(genobj1.Add("Name +", "Gowtham"));
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("Equal", "similar");
            //dict.Add("Equal", "same");

            /*dict.Add("Equal", "Absolute"); /*Same Key names throws error , saying already key exists-
             * need to check actual use of dictionary/ why it is named so? */
            Console.WriteLine("Meanings of Equal");
            foreach (string item in dict.Keys)
            {
                if (item.Equals("Equal"))
                {
                    Console.WriteLine(dict[item]);
                }
            }

            Console.ReadLine();
        }
Example #18
0
        static void Main(string[] args)
        {
            ArrayList a = new ArrayList();

            a.Add(12);
            a.Add(32);
            a.Add(21);
            a.Add(45);
            a.Sort();
            Console.WriteLine(a.Capacity);
            Console.WriteLine(a.BinarySearch(32));
            Console.WriteLine(a.SyncRoot);
            object[] o = a.ToArray();
            foreach (object i in o)
            {
                Console.WriteLine(i);
            }
            foreach (object i in a)
            {
                Console.WriteLine(i);
            }

            Array v = a.ToArray();

            foreach (object i in v)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(a.Count);

            Console.WriteLine(a.Contains(21));
            //elements

            foreach (int i in a.GetRange(0, 3))
            {
                Console.WriteLine(i);
            }

            IEnumerator aa  = a.GetEnumerator();
            IEnumerator aaa = a.GetEnumerator(0, 2);

            Console.WriteLine(aaa.MoveNext());
            Console.WriteLine(aaa.Current);
            Console.WriteLine(aa.MoveNext());
            Console.WriteLine(aa.Equals(aaa));

            Console.WriteLine(a.IndexOf(21));
            a.Insert(1, 10);
            a.Reverse();
            foreach (object i in a)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(a.IsFixedSize);
            Console.WriteLine(a.LastIndexOf(45));
            a.Remove(45);
            foreach (object i in a)
            {
                Console.WriteLine(i);
            }



            //sortedList in generic

            Console.WriteLine("sortedList in generic mode");


            SortedList <int, string> s = new SortedList <int, string>();

            s.Add(1, "veera");
            s.Add(2, "madhu");
            s.Add(0, "veerababu");
            foreach (int i in s.Keys)
            {
                Console.WriteLine(s[i]);
            }

            foreach (string i in s.Values)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(s.Count);
            s.RemoveAt(0);
            foreach (string i in s.Values)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine(s.ContainsValue("madhu"));
            Console.WriteLine(s.ContainsKey(1));
            Console.WriteLine(s.ContainsKey(4));
            Console.WriteLine(s.IndexOfValue("veerab"));


            //sortedLIst in Non-generic mode

            Console.WriteLine("sortedList in Non-generic mode");
            SortedList ss = new SortedList();


            //sorted table automatically sorted based on keys.
            ss.Add(1, "veera");
            ss.Add(2, "srinu");
            ss.Add(0, "sai");
            foreach (object i in ss.Keys)
            {
                Console.WriteLine(i);
            }
            foreach (object i in ss.Values)
            {
                Console.WriteLine(i);
            }
            object m = ss.Clone();

            Console.WriteLine(m);
        }
 /// <summary>
 /// Inserts an item to the IList at the specified position.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The Object to insert into the IList. </param>
 public virtual void Insert(int index, object value)
 {
     ValidateElement(value);
     _array.Insert(index, value);
 }
 public void Insert(int index, TraceListener listener)
 {
     InitializeListener(listener);
     listeners.Insert(index, listener);
 }
Example #21
0
 public Person this[int index] {
     get { return((Person)people[index]); }
     set { people.Insert(index, value); }
 }
 public void Insert(int index, ConnectionInfo ci)
 {
     _connections.Insert(index, ci);
 }
Example #23
0
 public void Insert(int index, T item)
 {
     _entityArray.Insert(index, item);
 }
Example #24
0
        string[] arrMark;   // назв. перем. (снач. y, потом все x)

        public Regression(Sample smpY, Sample[] arrSmpX)
        {
            double[] arrY = smpY.CloneArray();
            n = arrY.Length;
            p = arrSmpX.Length;
            double[][] matrX = new double[p + 1][];
            matrX[0] = new double[n];
            for (int j = 0; j < matrX[0].Length; j++)
            {
                matrX[0][j] = 1;
            }
            for (int i = 1; i < p + 1; i++)
            {
                matrX[i] = arrSmpX[i - 1].CloneArray();
            }
            Matrix mX = Matrix.Create(matrX);

            mX.Transpose();
            Matrix mY = Matrix.Create(new double[][] { arrY });

            mY.Transpose();
            Matrix mXTr = mX.Clone();

            mXTr.Transpose();
            Matrix mB = mXTr * mX;

            matrC    = mB.CopyToArray();
            mB       = mB.Inverse();
            matrCInv = mB.CopyToArray();
            Matrix mXTrY = mXTr * mY;

            mB   = mB * mXTrY;
            arrB = new double[mB.RowCount];
            for (int i = 0; i < mB.RowCount; i++)
            {
                arrB[i] = mB[i, 0];
            }

            // матр. коэф. кор.
            int       smpCount = p + 1;
            ArrayList listSmp  = new ArrayList(arrSmpX);

            listSmp.Insert(0, smpY);
            matrR = new double[smpCount, smpCount];
            for (int i = 0; i < smpCount; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    if (i == j)
                    {
                        matrR[i, j] = 1;
                        continue;
                    }
                    Sample smp1 = (Sample)listSmp[i];
                    Sample smp2 = (Sample)listSmp[j];
                    double sum  = 0;
                    for (int k = 0; k < n; k++)
                    {
                        sum += smp1[k] * smp2[k];
                    }
                    matrR[i, j] = (sum / n - smp1.GetAverage() *
                                   smp2.GetAverage()) / (smp1.GetSigma() *
                                                         smp2.GetSigma());
                }
            }
            for (int i = 0; i < smpCount; i++)
            {
                for (int j = i + 1; j < smpCount; j++)
                {
                    matrR[i, j] = matrR[j, i];
                }
            }

            // пров. знач. коэф. кор.
            arrStudRxy  = new double[p];
            arrSigmaRxy = new double[p];
            for (int i = 0; i < arrStudRxy.Length; i++)
            {
                double r = matrR[0, i + 1];
                arrSigmaRxy[i] = (1 - r) / Math.Sqrt(n - 1);
                arrStudRxy[i]  = r / arrSigmaRxy[i];
            }

            // матр. част. коэф. кор.
            matrRPart = new double[smpCount, smpCount];
            Matrix mR      = Matrix.Create(matrR);
            double minor11 = GetMinor(mR, 0, 0);

            for (int i = 0; i < mR.RowCount; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    matrRPart[i, j] = GetMinor(mR, 1, j) /
                                      Math.Sqrt(minor11 * GetMinor(mR, j, j));
                }
            }
            for (int i = 0; i < smpCount; i++)
            {
                for (int j = i + 1; j < smpCount; j++)
                {
                    matrRPart[i, j] = matrRPart[j, i];
                }
            }

            // коэф. множ. кор.
            //R = Math.Sqrt(1 - devEnd / smpY.GetDevStd());
            R      = Math.Sqrt(1 - mR.Determinant() / minor11);
            sigmaR = (1 - R * R) / Math.Sqrt(n - p - 1);
            fishR  = R * R * (n - p - 1) /
                     (1 - R * R) * p;
            studR = R / sigmaR;

            // эмп. знач. y
            arrYMod = new double[n];
            double[] arrX = new double[p];
            for (int i = 0; i < arrYMod.Length; i++)
            {
                for (int j = 0; j < arrX.Length; j++)
                {
                    arrX[j] = arrSmpX[j][i];
                }
                arrYMod[i] = GetRegValue(arrX);
            }

            // ост. дисп.
            devEnd = 0;
            for (int i = 0; i < n; i++)
            {
                devEnd += (arrY[i] - arrYMod[i]) * (arrY[i] - arrYMod[i]);
            }
            devEnd /= n - p - 1;

            // пров. знач. ур. регр. и коэф. ур. регр.
            fishRegr  = smpY.GetDevStd() / devEnd;
            arrSigmaB = new double[p + 1];
            arrStudB  = new double[p + 1];
            for (int i = 0; i < arrSigmaB.Length; i++)
            {
                arrSigmaB[i] = Math.Sqrt(devEnd * matrCInv[i, i]);
                arrStudB[i]  = arrB[i] / arrSigmaB[i];
            }

            // названия переменных
            arrMark    = new string[p + 1];
            arrMark[0] = smpY.GetMark();
            for (int i = 1; i < arrMark.Length; i++)
            {
                arrMark[i] = arrSmpX[i - 1].GetMark();
            }
        }
Example #25
0
 void IList <T> .Insert(int index, T item)
 {
     _InternalList.Insert(index, item);
 }
Example #26
0
        private void button6_Click(object sender, EventArgs e)
        {
            int  i     = -1;
            bool found = false;

            foreach (ToolStripItem b in cc.Items)
            {
                i++;
                if (b.Selected == true)
                {
                    found = true;
                    break;
                }
            }

            if (found == false)
            {
                return;
            }

            if (i < 0 || i >= cc.Items.Count)
            {
                return;
            }

            if (module == null)
            {
                return;
            }

            ToolStripItem c = cc.Items[i] as ToolStripItem;

            string name = c.Text;

            ArrayList GT = module.temp;

            int p = GT.IndexOf(name);

            if (p < 0)
            {
                return;
            }

            string names = "New Item " + cc.Items.Count;

            var d = cc.Items.Add(names);
            ToolStripMenuItem dd = d as ToolStripMenuItem;

            d.Click       += D_Click;
            dd.MouseEnter += Dd_MouseLeave;
            dd.AutoSize    = false;
            d.Width        = panel1.Size.Width;

            GT.Insert(p, names);

            LoadPanel(module);

            cc.Items[p].Select();

            int w = comboBox3.SelectedIndex;

            string s = comboBox3.Items[w].ToString();

            comboBox3.Items.Insert(w, s + " " + "|" + " " + names);
        }
        //
        // Render row values based on field settings
        //
        public void RenderRow()
        {
            // Initialize urls
            // Row Rendering event

            RegistrosVehiculos.Row_Rendering();

            //
            //  Common render codes for all row types
            //
            // IdRegistroVehiculo
            // IdTipoVehiculo
            // Placa
            // FechaIngreso
            // FechaSalida
            // Observaciones
            //
            //  View  Row
            //

            if (RegistrosVehiculos.RowType == EW_ROWTYPE_VIEW) { // View row

            // IdRegistroVehiculo
                RegistrosVehiculos.IdRegistroVehiculo.ViewValue = RegistrosVehiculos.IdRegistroVehiculo.CurrentValue;
            RegistrosVehiculos.IdRegistroVehiculo.ViewCustomAttributes = "";

            // IdTipoVehiculo
            if (ew_NotEmpty(RegistrosVehiculos.IdTipoVehiculo.CurrentValue)) {
                sFilterWrk = "[IdTipoVehiculo] = " + ew_AdjustSql(RegistrosVehiculos.IdTipoVehiculo.CurrentValue) + "";
            sSqlWrk = "SELECT [TipoVehiculo] FROM [dbo].[TiposVehiculos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [TipoVehiculo]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    RegistrosVehiculos.IdTipoVehiculo.ViewValue = drWrk["TipoVehiculo"];
                } else {
                    RegistrosVehiculos.IdTipoVehiculo.ViewValue = RegistrosVehiculos.IdTipoVehiculo.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                RegistrosVehiculos.IdTipoVehiculo.ViewValue = System.DBNull.Value;
            }
            RegistrosVehiculos.IdTipoVehiculo.ViewCustomAttributes = "";

            // Placa
                RegistrosVehiculos.Placa.ViewValue = RegistrosVehiculos.Placa.CurrentValue;
            RegistrosVehiculos.Placa.ViewCustomAttributes = "";

            // FechaIngreso
                RegistrosVehiculos.FechaIngreso.ViewValue = RegistrosVehiculos.FechaIngreso.CurrentValue;
                RegistrosVehiculos.FechaIngreso.ViewValue = ew_FormatDateTime(RegistrosVehiculos.FechaIngreso.ViewValue, 7);
            RegistrosVehiculos.FechaIngreso.ViewCustomAttributes = "";

            // FechaSalida
                RegistrosVehiculos.FechaSalida.ViewValue = RegistrosVehiculos.FechaSalida.CurrentValue;
                RegistrosVehiculos.FechaSalida.ViewValue = ew_FormatDateTime(RegistrosVehiculos.FechaSalida.ViewValue, 7);
            RegistrosVehiculos.FechaSalida.ViewCustomAttributes = "";

            // Observaciones
            RegistrosVehiculos.Observaciones.ViewValue = RegistrosVehiculos.Observaciones.CurrentValue;
            RegistrosVehiculos.Observaciones.ViewCustomAttributes = "";

            // View refer script
            // IdTipoVehiculo

            RegistrosVehiculos.IdTipoVehiculo.LinkCustomAttributes = "";
            RegistrosVehiculos.IdTipoVehiculo.HrefValue = "";
            RegistrosVehiculos.IdTipoVehiculo.TooltipValue = "";

            // Placa
            RegistrosVehiculos.Placa.LinkCustomAttributes = "";
            RegistrosVehiculos.Placa.HrefValue = "";
            RegistrosVehiculos.Placa.TooltipValue = "";

            // Observaciones
            RegistrosVehiculos.Observaciones.LinkCustomAttributes = "";
            RegistrosVehiculos.Observaciones.HrefValue = "";
            RegistrosVehiculos.Observaciones.TooltipValue = "";

            //
            //  Add Row
            //

            } else if (RegistrosVehiculos.RowType == EW_ROWTYPE_ADD) { // Add row

            // IdTipoVehiculo
            RegistrosVehiculos.IdTipoVehiculo.EditCustomAttributes = "";
            sFilterWrk = "";
            sSqlWrk = "SELECT [IdTipoVehiculo], [TipoVehiculo] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[TiposVehiculos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [TipoVehiculo]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            RegistrosVehiculos.IdTipoVehiculo.EditValue = alwrk;

            // Placa
            RegistrosVehiculos.Placa.EditCustomAttributes = "";
            RegistrosVehiculos.Placa.EditValue = ew_HtmlEncode(RegistrosVehiculos.Placa.CurrentValue);

            // Observaciones
            RegistrosVehiculos.Observaciones.EditCustomAttributes = "";
            RegistrosVehiculos.Observaciones.EditValue = ew_HtmlEncode(RegistrosVehiculos.Observaciones.CurrentValue);

            // Edit refer script
            // IdTipoVehiculo

            RegistrosVehiculos.IdTipoVehiculo.HrefValue = "";

            // Placa
            RegistrosVehiculos.Placa.HrefValue = "";

            // Observaciones
            RegistrosVehiculos.Observaciones.HrefValue = "";
            }
            if (RegistrosVehiculos.RowType == EW_ROWTYPE_ADD ||
            RegistrosVehiculos.RowType == EW_ROWTYPE_EDIT ||
            RegistrosVehiculos.RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
            RegistrosVehiculos.SetupFieldTitles();
            }

            // Row Rendered event
            if (RegistrosVehiculos.RowType != EW_ROWTYPE_AGGREGATEINIT)
            RegistrosVehiculos.Row_Rendered();
        }
Example #28
0
        static void Main(string[] args)
        {
            #region Basics

            // Example Single-line Comment

            /* Example
             * Multiline
             * Comment
             */

            //Hello World
            Console.WriteLine("Hello World");

            //Get user input
            Console.Write("What's your name? ");
            string name = Console.ReadLine();
            Console.WriteLine("Hello " + name);

            //Data Types
            bool canVote = true;
            char fumoffu = '%';

            int     maxInt     = int.MaxValue;
            long    maxLong    = long.MaxValue;
            decimal maxDecimal = decimal.MaxValue;
            float   maxFloat   = float.MaxValue;
            double  maxDouble  = double.MaxValue;

            Console.WriteLine("Max Int: " + maxInt);

            //Implicit type variable declaration
            var sampleVar = "SampleString";

            //You can't change its type after declaration though
            //sampleVar = 2;

            Console.WriteLine("sampleVar is a {0}", sampleVar.GetTypeCode());
            Console.WriteLine("-------------------------------------------------------");

            //Arithmetics
            Console.WriteLine("5 + 3 = " + (5 + 3));
            Console.WriteLine("5 - 3 = " + (5 - 3));
            Console.WriteLine("5 * 3 = " + (5 * 3));
            Console.WriteLine("5 / 3 = " + (5 / 3));
            Console.WriteLine("5.2 % 3 = " + (5.2 % 3));

            int i = 0;

            Console.WriteLine("i++ = " + i++);
            Console.WriteLine("++i = " + ++i);
            Console.WriteLine("i-- = " + i--);
            Console.WriteLine("--i = " + --i);

            Console.WriteLine("-------------------------------------------------------");
            //Some Math Static Functions
            //acos, asin, atan, atan2, cos, cosh, exp, log, sin, sinh, tan, tanh
            double num1 = 10.5;
            double num2 = 15;

            Console.WriteLine("Abs(num1): " + Math.Abs(num1));
            Console.WriteLine("Ceiling(num1): " + Math.Ceiling(num1));
            Console.WriteLine("Floor(num1): " + Math.Floor(num1));
            Console.WriteLine("Max(num1, num2): " + Math.Max(num1, num2));
            Console.WriteLine("Min(num1, num2): " + Math.Min(num1, num2));
            Console.WriteLine("Pow(num1): " + Math.Pow(num1, num2));
            Console.WriteLine("Round(num1): " + Math.Round(num1));
            Console.WriteLine("Sqrt(num1): " + Math.Sqrt(num1));

            Console.WriteLine("-------------------------------------------------------");

            //Casting
            const double PI    = 3.14;
            int          intPI = (int)PI;

            //Generating Random Numbers
            Random rand = new Random();
            Console.WriteLine("Random number between 1 and 10: " + rand.Next(1, 11));

            #endregion

            #region Conditionals and Loops

            //Relational Operators: > < >= <= == !=
            //Logical Operators: && (AND) || (OR) ^ (XOR) ! (NOT)

            int age = rand.Next(1, 101);
            Console.WriteLine(age);

            //IF statements
            if (age >= 5 && age <= 7)
            {
                Console.WriteLine("Go to Elementary School");
            }
            else if (age > 7 && age < 13)
            {
                Console.WriteLine("Go to Middle School");
            }
            else
            {
                Console.WriteLine("Go to High School");
            }

            if (age < 14 || age > 67)
            {
                Console.WriteLine("You Shouldn't Work");
            }

            Console.WriteLine("! true: " + !true);

            //Ternary - Condition ? ifTrue : ifFalse
            bool canDrive = age >= 18 ? true : false;

            switch (age)
            {
            case 0:
                Console.WriteLine("Infant");
                break;

            case 1:
            case 2:
                Console.WriteLine("Toddler");
                //Goto jumps to the code block you specify (It's gonna kick you out of the switch statement)
                goto Checkpoint1;

            default:
                Console.WriteLine("Child");
                break;
            }

Checkpoint1:
            Console.WriteLine("I'm printed from outside the switch statement");

            Console.WriteLine("-------------------------------------------------------");

            int j = 0;

            while (j < 10)
            {
                if (j == 7)
                {
                    j++;
                    continue;
                }
                //^^^ Jump back to the while header

                if (j == 9)
                {
                    break;
                }
                //// ^^ Jump out of the loop

                if (j % 2 > 0)
                {
                    Console.WriteLine(j);
                }

                j++;
            }

            Console.WriteLine("-------------------------------------------------------");

            //DO While: The body of do is executed at least one time
            string guess;

            do
            {
                Console.WriteLine("Guess a number");
                guess = Console.ReadLine();
            } while (!guess.Equals("15"));

            Console.WriteLine("-------------------------------------------------------");

            //FOR Loop: All the conditional and counter stuff is in the heading
            for (int k = 0; k < 10; k++)
            {
                if (k % 2 != 0)
                {
                    Console.WriteLine(k);
                }
            }

            Console.WriteLine("-------------------------------------------------------");

            //FOREACH: Used to iterate over list, arrays, maps and collections
            string randString = "Example Random String";

            foreach (char c in randString)
            {
                Console.WriteLine(c);
            }

            Console.WriteLine("-------------------------------------------------------");

            #endregion

            #region Strings & Arrays

            //Strings
            //Escape Sequences: Allow you to enter special chars in strings
            //      \' \" \\ \b \n \t
            string sampleString = "Some random words";

            //Prints wether a string is empty or null
            Console.WriteLine("Is Empty: " + String.IsNullOrEmpty(sampleString));
            //Prints wether a string is null or filled with white space
            Console.WriteLine("Is Empty: " + String.IsNullOrWhiteSpace(sampleString));

            Console.WriteLine("String Length: " + sampleString.Length);
            //Returns the position of a certain string/char inside of another string | returns -1 if it doesn't find it
            Console.WriteLine("Index of 'random': " + sampleString.IndexOf("random"));
            //Returns a substring of the parent string when given the index of the first letter and the length of the word

            Console.WriteLine("2nd word: " + sampleString.Substring(5, 6));
            //Returns true if the parent string is equals to the argument string
            Console.WriteLine("Strings Equal: " + sampleString.Equals(randString));
            //Returns true if the String starts with the argument string

            Console.WriteLine("Starts with \"Example Random\": " + randString.StartsWith("Example Random"));
            //Returns true if the String ends with the argument string
            Console.WriteLine("Ends with \"Example String\": " + randString.EndsWith("Example String"));

            //Removes white space at the beginning or at the end of a string
            sampleString = sampleString.Trim(); //TrimEnd TrimStart

            //Replaces a substring of the parent string with another string
            sampleString = sampleString.Replace("words", "characters");

            //Removes a substring of length equals to the second parameter starting from the passed index (first parameter)
            sampleString = sampleString.Remove(0, 4);

            //Array of strings
            string[] words = new string[6] {
                "I", "Suck", "At", "Drawing", "Textures", ":("
            };
            //Join a string array into one single string
            Console.WriteLine("Joined String Array: " + String.Join(" ", words));

            Console.WriteLine("-------------------------------------------------------");

            //Formatting Strings
            string formatted = String.Format("{0:c} {1:00.00} {2:#.00} {3:0,0}", 4.99, 15.567, .56, 1000);
            Console.WriteLine("Formatted Strings examples: " + formatted);

            Console.WriteLine("-------------------------------------------------------");

            //String Builder
            //Used when you want to edit a string without creating a new one
            StringBuilder sb = new StringBuilder();
            //Append new strings - (AppendLine is the version that appends a \n at the end automatically)
            sb.Append("This is the first Sentence.");
            sb.AppendFormat("My Nick is {0} and I am a {1} developer", "Davoleo", "C#");
            //Empties the whole StringBuilder Buffer
            //sb.Clear();
            //Replaces a string with another one in all the occurrences in the StringBuilder
            sb.Replace("e", "E");
            //Removes chars from index 5 (included) to index 7 (excluded)
            sb.Remove(5, 7);
            //Converts the StringBuilder to a String and writes it on the console
            Console.WriteLine(sb.ToString());

            Console.WriteLine("-------------------------------------------------------");

            //Arrays
            int[] randArray;
            int[] randFixedArray = new int[5];
            int[] literalArray   = { 1, 2, 3, 4, 5 };

            //Returns the number of items in the array
            Console.WriteLine("Array Length: " + literalArray.Length);
            //Returns the first item of an array
            Console.WriteLine("First Item: " + literalArray[0]);

            //Loop through arrays

            //Classic For loop with array length
            for (int k = 0; k < literalArray.Length; k++)
            {
                Console.WriteLine("{0} : {1}", k, literalArray[k]);
            }
            //For Each
            foreach (int num in literalArray)
            {
                Console.WriteLine(num);
            }

            //Returns the index of a specific array element
            Console.WriteLine("Index of 3: " + Array.IndexOf(literalArray, 3));

            string[] names = { "Shana", "Alastor", "Wilhelmina", "Decarabia", "Fecor", "Hecate", "Sydonnay" };
            //Joins all the items of an array dividing them with a custom separator
            string nameCollectionString = string.Join(", ", names);

            names = nameCollectionString.Split(',');

            //Multidimensional Arrays
            //Two dimensional empty array of length 5*3
            int[,] multArray = new int[5, 3];

            //Literal Init
            int[,] multArray2 = { { 0, 1 }, { 2, 3 }, { 4, 5 } };

            foreach (int num in multArray2)
            {
                Console.WriteLine(num);
            }

            Console.WriteLine("-------------------------------------------------------");

            //Lists: Dynamic Arrays
            List <int> numList = new List <int>();

            //Adds a Single item to the list
            numList.Add(5);
            numList.Add(15);
            numList.Add(25);

            //Adds a range of items to the list (in some kind of collection form)
            int[] numArray = { 1, 2, 3, 4 };
            numList.AddRange(numArray);

            //Removes All the items in the list
            //numList.Clear();

            //Init a list with an array (aka create a list from an array)
            List <int> numList2 = new List <int>(numArray);

            //Insert an item in a specific index
            numList.Insert(1, 10);

            //Removes the first occurance of the argument in the list, from the list
            numList.Remove(5);
            //Removes the item at the index 2
            numList.RemoveAt(2);

            for (var l = 0; l < numList.Count; l++)
            {
                Console.WriteLine(numList[l]);
            }

            //Returns the index of the first occurance of the passed item (returns -1 if it doesn't find any)
            Console.WriteLine("4 is in index " + numList2.IndexOf(4));

            Console.WriteLine("is 5 in the list " + numList.Contains(5));

            List <string> stringList = new List <string>(new string[] { "Davoleo", "Matpac", "Pierknight" });
            //case insensitive String comparison
            Console.WriteLine("Davoleo in list " + stringList.Contains("davoleo", StringComparer.OrdinalIgnoreCase));

            //Sorts the list alphabetically or numerically depending on the contents
            numList.Sort();

            Console.WriteLine("-------------------------------------------------------");

            #endregion

            #region Exceptions

            //Exception Handling
            //Try and Catch Structure
            try
            {
                Console.Write("Divide 10 by ");
                int num = int.Parse(Console.ReadLine());
                Console.WriteLine("10/{0} = {1}", num, 10 / num);
            }
            catch (DivideByZeroException e)
            {
                Console.WriteLine("Can't divide by 0");
                //Prints the name of the exception
                Console.WriteLine(e.GetType().Name);
                //Prints a small description of the exception
                Console.WriteLine(e.Message);
                //Throws the same exception again
                //throw e;
                //Throws another new Exception
                throw new InvalidOperationException("Operation Failed", e);
            }
            catch (Exception e)
            {
                //This Catches all the exceptions
                Console.WriteLine(e.GetType().Name);
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("-------------------------------------------------------");

            #endregion

            #region OOP

            //Classes and Objects
            Animal botolo = new Animal(0.5, 6, "Meeer", "Botolo");

            Console.WriteLine("{0} says {1}", botolo.Name, botolo.Sound);
            Console.WriteLine(botolo.ToString());
            Console.WriteLine(Animal.GetCount());

            Console.WriteLine("-------------------------------------------------------");

            //Method Overloading test
            //This Calls the int version
            Console.WriteLine("1 + 25 = " + GetSum(1, 25));
            //This Calls the double version
            //Passing parameters in another order
            Console.WriteLine("7.64 + 9.24 = " + GetSum(num2: 7.64, num1: 9.24));

            Console.WriteLine("-------------------------------------------------------");

            //Object Initializer - Assigning values to the fields manually
            Animal epicAnimal = new Animal()
            {
                Name   = "Grover",
                Height = 13,
                Weight = 11,
                Sound  = "GRRR"
            };
            Console.WriteLine(epicAnimal.ToString());

            Console.WriteLine("-------------------------------------------------------");
            //Polymorphism
            Shape rect   = new Rectangle(5, 8);
            Shape tri    = new Triangle(8, 3);
            Shape circle = new Circle(5);

            //Array of different kinds of shapes
            Shape[] shapeArray = { rect, tri, circle };

            foreach (var shape in shapeArray)
            {
                shape.LogShapeInfo();
            }
            Console.WriteLine("***");

            Console.WriteLine("Rect Area: " + rect.Area());
            Console.WriteLine("Tri Area: " + tri.Area());
            Console.WriteLine("Circle Area: " + circle.Area());
            Console.WriteLine("tri is a Triangle: " + (tri is Triangle));
            Console.WriteLine("rect is a Rectangle: " + ((rect as Rectangle) != null));
            Console.WriteLine("-------------------------------------------------------");

            //Operator Overloading for objects
            Rectangle combinedRectangle = new Rectangle(6, 10) + (Rectangle)rect;
            Console.WriteLine("combinedRectangle Area: " + combinedRectangle.Area());

            Console.WriteLine("-------------------------------------------------------");

            //Interfaces
            IElettronicDevice TV          = TVRemote.GetDevice();
            PowerButton       powerButton = new PowerButton(TV);
            powerButton.Execute();
            powerButton.Undo();

            Console.WriteLine("-------------------------------------------------------");

            //Generics - Classes that can be used with any kind of object
            SimpleMapEntry <int, string> davPass = new SimpleMapEntry <int, string>(333, "Davoleo");

            davPass.ShowData();

            //Generics work with multiple data types
            int firstInt = 5, secondInt = 4;
            GetSum(ref firstInt, ref secondInt);
            string firstString  = firstInt.ToString();
            string secondString = secondInt.ToString();
            GetSum(ref firstString, ref secondString);

            Rectangle <int> rect1 = new Rectangle <int>(20, 50);
            Console.WriteLine(rect1.GetArea());
            Rectangle <string> rect2 = new Rectangle <string>("20", "50");
            Console.WriteLine(rect2.GetArea());

            Console.WriteLine("-------------------------------------------------------");

            Temperature waveTemp = Temperature.WARM;

            switch (waveTemp)
            {
            case Temperature.FREEZE:
                Console.WriteLine("Freezing Temperature");
                break;

            case Temperature.LOW:
                Console.WriteLine("Low Temperature");
                break;

            case Temperature.WARM:
                Console.WriteLine("Warm Temperature");
                break;

            case Temperature.HOT:
                Console.WriteLine("Hot Temperature");
                break;

            case Temperature.SEARING:
                Console.WriteLine("EPIC Temperature, everything Sublimates");
                break;

            default:
                Console.WriteLine("Invalid Temperature");
                break;
            }

            Console.WriteLine("-------------------------------------------------------");

            //STRUCTS
            Customer davoleo = new Customer();
            davoleo.createCustomer("Davoleo", 55.80, 111);
            davoleo.printInfo();

            Console.WriteLine("-------------------------------------------------------");
            //DELEGATES - Passing methods to other methods as parameters

            //Anonymous method of type EvaluateExpression
            EvaluateExpression add = delegate(double n1, double n2) { return(n1 + n2); };
            //Direct Delegate Assignment
            EvaluateExpression substract = (n1, n2) => { return(n1 + n2); };
            EvaluateExpression multiply  = delegate(double n1, double n2) { return(n1 * n2); };

            //Calls both the delegates
            EvaluateExpression subtractMultuply = substract + multiply;

            Console.WriteLine("5 + 10 = " + add(5, 10));
            Console.WriteLine("5 * 10 = " + multiply(5, 10));
            Console.WriteLine("Subtract & Multiply 10 & 4: " + subtractMultuply(10, 4));

            //Lamda expressions - Anonymous functions
            Func <int, int, int> subtract = (x, y) => x - y;
            Console.WriteLine("5 - 10 = " + subtract.Invoke(5, 10));

            List <int> nums = new List <int> {
                3, 6, 9, 12, 15, 18, 21, 24, 27, 30
            };
            List <int> oddNumbers = nums.Where((n) => n % 2 == 1).ToList();

            foreach (var oddNumber in oddNumbers)
            {
                Console.Write(oddNumber + ", ");
            }
            Console.WriteLine();
            Console.WriteLine("-------------------------------------------------------");

            #endregion


            #region File IO

            //File I/O
            //Access the current directory
            DirectoryInfo dir    = new DirectoryInfo(".");
            DirectoryInfo davDir = new DirectoryInfo(@"C:\Users\Davoleo");

            Console.WriteLine("Davoleo path: " + davDir.FullName);
            Console.WriteLine("Davoleo dir name " + davDir.Name);
            Console.WriteLine(davDir.Parent);
            Console.WriteLine(davDir.Attributes);
            Console.WriteLine(davDir.CreationTime);

            //Creates a directory
            Directory.CreateDirectory(@"D:\C#Data");
            DirectoryInfo dataDir = new DirectoryInfo(@"D:\C#Data");
            //Directory.Delete(@"D:\C#Data");
            string dataPath = @"D:\C#Data";
            Console.WriteLine("-------------------------------------------------------");

            string[] nicks = { "Davoleo", "Matpac", "Pierknight", "gesudio" };

            using (StreamWriter writer = new StreamWriter("nicknames.txt"))
            {
                foreach (var nick in nicks)
                {
                    writer.WriteLine(nick);
                }
            }

            using (StreamReader reader = new StreamReader("nicknames.txt"))
            {
                string user;
                while ((user = reader.ReadLine()) != null)
                {
                    Console.WriteLine(user);
                }
            }

            //Another Way of writing and reading
            File.WriteAllLines(dataPath + "\\nicknames.txt", nicks);
            Console.WriteLine(File.ReadAllBytes(dataPath + "\\nicknames.txt").ToString());

            FileInfo[] textFiles = dataDir.GetFiles("*.txt", SearchOption.AllDirectories);
            Console.WriteLine("Matches: {0}" + textFiles.Length);

            Console.WriteLine(textFiles[0].Name + ", " + textFiles[0].Length);

            string     fileStreamPath   = @"D:\C#Data\streamtest.txt";
            FileStream stream           = File.Open(fileStreamPath, FileMode.Create);
            string     randomString     = "This is a random String";
            byte[]     randomStringByte = Encoding.Default.GetBytes(randString);
            stream.Write(randomStringByte, 0, randomStringByte.Length);
            stream.Position = 0;
            stream.Close();

            string       binaryPath   = @"D:\C#Data\file.dat";
            FileInfo     datFile      = new FileInfo(binaryPath);
            BinaryWriter binaryWriter = new BinaryWriter(datFile.OpenWrite());
            string       text         = "Random Text";
            age = 18;
            double height = 12398;

            binaryWriter.Write(text);
            binaryWriter.Write(age);
            binaryWriter.Write(height);

            binaryWriter.Close();

            BinaryReader binaryReader = new BinaryReader(datFile.OpenRead());
            Console.WriteLine(binaryReader.ReadString());
            Console.WriteLine(binaryReader.ReadInt32());
            Console.WriteLine(binaryReader.ReadDouble());

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            //OOP Game test
            Warrior maximus = new Warrior("Maximus", 1000, 120, 40);
            Warrior bob     = new Warrior("Bob", 1000, 120, 40);

            Console.WriteLine("Disabled");
            //Battle.StartFight(maximus, bob);

            Console.WriteLine("-------------------------------------------------------");

            //Collections ----

            #region ArrayList

            //You can add different kind of objects ArrayLists
            ArrayList arrayList = new ArrayList();
            arrayList.Add("Bob");
            arrayList.Add(43);

            //Number of items in the arraylist
            Console.WriteLine("ArrayList Count: " + arrayList.Count);
            //Capacity is always double the count (?)
            Console.WriteLine("ArrayList Capacity: " + arrayList.Capacity);

            ArrayList arrayList2 = new ArrayList();
            //Add an array to the ArrayList
            arrayList2.AddRange(new object[] { "Jeff", "Dave", "Egg", "Edge" });

            arrayList.AddRange(arrayList2);

            //Sort items in natural order
            arrayList2.Sort();
            //Reverse the order of items
            arrayList2.Reverse();

            //Insert some item at a specific index
            arrayList2.Insert(1, "PI");

            //Sub-Arraylist made of some of the items in the original arraylist
            ArrayList range = arrayList2.GetRange(0, 2);

            Console.WriteLine("arrayList object ---");
            foreach (object o in arrayList)
            {
                Console.Write(o + "\t");
            }
            Console.WriteLine();

            Console.WriteLine("arrayList2 object ---");
            foreach (object o in arrayList2)
            {
                Console.Write(o + "\t");
            }
            Console.WriteLine();

            Console.WriteLine("range object ----");
            foreach (object o in range)
            {
                Console.Write(o + "\t");
            }
            Console.WriteLine();

            //Remove the item at the 0 index
            //arrayList2.RemoveAt(0);

            //Removes the first 2 items starting from index 0
            //arrayList2.RemoveRange(0, 2);

            //Return the index of a specific object - if it doesn't find any it returns -1
            Console.WriteLine("Index of Edge: " + arrayList2.IndexOf("Edge"));

            //Converting ArrayLists to arrays
            string[] array = (string[])arrayList2.ToArray(typeof(string));

            //Converting back to Arraylist
            ArrayList listFromArray = new ArrayList(array);

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Dictionary

            //Stores a list of key-value pairs
            Dictionary <string, string> langsProjs = new Dictionary <string, string>();

            //Add A Key-Value Pair
            langsProjs.Add("C#", "CSharp-Test");
            langsProjs.Add("Java", "Metallurgy 4: Reforged");
            langsProjs.Add("Dart", "sample_flutter_app");

            //Removes a Pair from a given key
            langsProjs.Remove("Dart");

            //Number of pairs in the list
            Console.WriteLine("Count: " + langsProjs.Count);

            //Returns wether a key is present
            Console.WriteLine("C# is present: " + langsProjs.ContainsKey("C#"));

            //Gets the value of Java and outputs into a new string called test
            langsProjs.TryGetValue("Java", out string test);
            Console.WriteLine("Java: " + test);

            //Loop over all the pairs in the list
            Console.WriteLine("LOOP:");
            foreach (KeyValuePair <string, string> pair in langsProjs)
            {
                Console.WriteLine($"{pair.Key} - {pair.Value}");
            }

            //Empties the dictionary Completely
            langsProjs.Clear();

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Queue

            //Creates a new Empty Queue
            Queue queue = new Queue();

            //Adds an item to the queue
            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);

            //Loop over a queue
            foreach (object num in queue)
            {
                Console.Write(num + "\t");
            }
            Console.WriteLine();

            Console.WriteLine("is 3 in the queue: " + queue.Contains(3));

            //Removes the first item and return it to you
            Console.WriteLine("Removes 1: " + queue.Dequeue());

            //Returns the first item in the queue without removing it
            Console.WriteLine("Peek the firs num: " + queue.Peek());

            //Empties the queue
            queue.Clear();

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Stack

            Stack stack = new Stack();

            //Adds an item to the stack
            stack.Push(1);
            stack.Push(2);
            stack.Push(3);
            stack.Push(4);

            //Loop over a stack - items are returned in the opposite order
            foreach (var item in stack)
            {
                Console.WriteLine($"Item: {item}");
            }

            //Returns the last item in the stack without removing it
            Console.WriteLine(stack.Peek());

            //Returns the last item in the stack removing it
            Console.WriteLine(stack.Pop());

            //Returns wether the stack contains an item or not
            Console.WriteLine(stack.Contains(3));

            //Convert to an array and print it with the Join function
            Console.WriteLine(string.Join(", ", stack.ToArray()));

            //Empties the stack
            stack.Clear();

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region LINQ EXTENSION METHODS
            //LINQ EXTENSION METHODS

            //Lamdas with Delegates
            Console.WriteLine("-- Lambda Expressions --");
            doubleIt doubleIt = x => x * 2;
            Console.WriteLine($"5 * 2 = {doubleIt(5)}");

            List <int> numberList = new List <int> {
                1, 9, 2, 6, 3
            };

            //.Where() METHOD
            var evenList = numberList.Where(a => a % 2 == 0).ToList();
            foreach (var k in evenList)
            {
                Console.Write(k + ", ");
            }
            Console.WriteLine();

            //2nd Example of .Where()
            var rangeList = numberList.Where(x => x > 2 && x < 9).ToList();
            foreach (var k in rangeList)
            {
                Console.Write(k + ", ");
            }
            Console.WriteLine();

            //Coin flips (T = 0 or C = 1)
            List <int> coinFlips = new List <int>();
            int        flips     = 0;
            while (flips < 100)
            {
                coinFlips.Add(rand.Next(0, 2));
                flips++;
            }
            //Count method with predicate
            Console.WriteLine($"Testa Count: {coinFlips.Count(a => a == 0)}");
            Console.WriteLine($"Croce Count: {coinFlips.Count(a => a == 1)}");

            //.Select() METHOD
            var oneToTen = new List <int>();
            oneToTen.AddRange(Enumerable.Range(1, 10));
            var squares = oneToTen.Select(x => x * x);

            foreach (var k in squares)
            {
                Console.Write(k + ", ");
            }
            Console.WriteLine();

            //.Zip() METHOD
            var listOne = new List <int> {
                1, 3, 4
            };
            var listTwo = new List <int> {
                4, 6, 8
            };
            var sumList = listOne.Zip(listTwo, (l1Value, l2Value) => l1Value + l2Value);
            foreach (var k in sumList)
            {
                Console.Write(k + ", ");
            }
            Console.WriteLine();

            //.Aggregate() METHOD
            var nums1to5 = new List <int> {
                1, 2, 3, 4, 5
            };
            Console.WriteLine("Sum of elements {0}", nums1to5.Aggregate((a, b) => a + b));

            //.AsQueryable.Average() Method
            Console.WriteLine($"Average: {nums1to5.AsQueryable().Average()}");
            //.All()
            Console.WriteLine($"All > 3 nums? {nums1to5.All(x => x > 3)}");
            //.Any()
            Console.WriteLine($"Any num > 3? {nums1to5.Any(x => x > 3)}");

            //.Distinct()
            var listWithDupes = new List <int> {
                1, 2, 3, 2, 3
            };
            Console.WriteLine($"Distinct: {string.Join(", ", listWithDupes.Distinct())}");

            //.Except() - Prints all the values that don't exist in the second list
            Console.WriteLine($"Except: {string.Join(", ", nums1to5.Except(listWithDupes))}");

            //.Intersect() - Returns a list with common values between two lists
            Console.WriteLine($"Intersect: {string.Join(", ", nums1to5.Intersect(listWithDupes))}");

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Custom Collection Class

            AnimalFarm animals = new AnimalFarm();
            animals[0] = new Animal("Wilbur");
            animals[1] = new Animal("Templeton");
            animals[2] = new Animal("Wally");
            animals[3] = new Animal("ooooooooooooooooooooooooeuf");

            foreach (Animal animal in animals)
            {
                Console.WriteLine(animal.Name);
            }

            Box box1 = new Box(2, 3, 4);
            Box box2 = new Box(5, 6, 7);


            Box boxSum = box1 + box2;
            Console.WriteLine($"Box Sum: {boxSum}");

            Console.WriteLine($"Box -> Int: {(int) box1}");
            Console.WriteLine($"Int -> Box: {(Box) 4}");

            //Anonymous type object
            var anonymous = new
            {
                Name   = "Mr Unknown",
                Status = 312
            };

            Console.WriteLine("{0} status is {1}", anonymous.Name, anonymous.Status);

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region LINQ

            //Stands for Launguage Integrated Query - Provides tools to work with data
            QueryStringArray();

            QueryIntArray();

            QueryArrayList();

            QueryCollection();

            QueryAnimalData();

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Threads

            //Threading allows to execute operation on a different workflow instead of the Main one
            //The workflow continuously and quickly changes thread to

            Thread thread = new Thread(Print1);
            thread.Start();

            for (int k = 0; k < 1000; k++)
            {
                Console.Write(0);
            }
            Console.WriteLine();

            int counter = 1;
            for (int k = 0; k < 10; k++)
            {
                Console.WriteLine(counter);
                //Slow down the current thread of some time in ms
                Thread.Sleep(500);
                counter++;
            }
            Console.WriteLine("Thread Ended");

            BankAccount account = new BankAccount(10);
            Thread[]    threads = new Thread[15];

            Thread.CurrentThread.Name = "main";

            for (int k = 0; k < threads.Length; k++)
            {
                Thread smolThread = new Thread(account.IssueWidthDraw);
                smolThread.Name = k.ToString();
                threads[k]      = smolThread;
            }

            foreach (var smolThread in threads)
            {
                Console.WriteLine("Thread {0} Alive: {1}", smolThread.Name, smolThread.IsAlive);
                smolThread.Start();
                Console.WriteLine("Thread {0} Alive: {1}", smolThread.Name, smolThread.IsAlive);
            }

            Console.WriteLine("Current Priority: " + Thread.CurrentThread.Priority);
            Console.WriteLine($"Thread {Thread.CurrentThread.Name} Ending");

            // Passing data to threads through lambda expressions
            new Thread(() =>
            {
                countTo(5);
                countTo(8);
            }).Start();

            #endregion

            Console.WriteLine("-------------------------------------------------------");

            #region Serialization

            Animal dummyDum    = new Animal(45, 25, "Roar", "Dum");
            Stream dummyStream = File.Open("AnimalData.dat", FileMode.Create);

            BinaryFormatter binaryFormatter = new BinaryFormatter();
            binaryFormatter.Serialize(dummyStream, dummyDum);
            dummyStream.Close();

            dummyDum = null;

            dummyStream     = File.Open("AnimalData.dat", FileMode.Open);
            binaryFormatter = new BinaryFormatter();

            dummyDum = (Animal)binaryFormatter.Deserialize(dummyStream);
            dummyStream.Close();

            Console.WriteLine("Dummy Dum from binary: " + dummyDum.ToString());

            dummyDum.Weight = 33;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Animal));

            using (TextWriter tw = new StreamWriter(@"D:\C#Data\dummy-dum.xml"))
            {
                xmlSerializer.Serialize(tw, dummyDum);
            }

            dummyDum = null;

            XmlSerializer xmlDeserializer = new XmlSerializer(typeof(Animal));
            TextReader    txtReader       = new StreamReader(@"D:\C#Data\dummy-dum.xml");
            object        obj             = xmlDeserializer.Deserialize(txtReader);
            dummyDum = (Animal)obj;
            txtReader.Close();

            Console.WriteLine("Dummy Dum from XML: " + dummyDum.ToString());

            #endregion
        }
Example #29
0
    /// <summary>
    /// Resume all iTweens in scene of a particular type.
    /// </summary>
    /// <param name="type">
    /// A <see cref="System.String"/> name of the type of iTween you would like to resume.  Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
    /// </param> 
    public static void Resume(string type)
    {
        ArrayList resumeArray = new ArrayList();

        for (int i = 0; i < tweens.Count; i++) {
            Hashtable currentTween = (Hashtable)tweens[i];
            GameObject target = (GameObject)currentTween["target"];
            resumeArray.Insert(resumeArray.Count,target);
        }

        for (int i = 0; i < resumeArray.Count; i++) {
            Resume((GameObject)resumeArray[i],type);
        }
    }
 public virtual bool runTest()
 {
     int iCountErrors = 0;
     int iCountTestcases = 0;
     Console.Error.WriteLine( strName + ": " + strTest + " runTest started..." );
     ArrayList arrList = null;
     int start = 3;
     int count = 15;
     String [] strHeroes =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Black Canary",
             "Captain America",
             "Captain Atom",
             "Catwoman",
             "Cyborg",
             "Flash",
             "Green Arrow",
             "Green Lantern",
             "Hawkman",
             "Huntress",
             "Ironman",
             "Nightwing",
             "Robin",
             "SpiderMan",
             "Steel",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     String [] strResult =
         {
             "Aquaman",
             "Atom",
             "Batman",
             "Superman",
             "Thor",
             "Wildcat",
             "Wonder Woman",
     };
     do
     {
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Construct ArrayList" );
         try
         {
             arrList = new ArrayList( (ICollection) strHeroes );
             if ( arrList == null )
             {
                 Console.WriteLine( strTest+ "E_101: Failed to construct new ArrayList" );
                 ++iCountErrors;
                 break;
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10001: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Remove range of items from array list" );
         try
         {
             arrList.RemoveRange( start, count );
             for ( int ii = 0; ii < strResult.Length; ++ii )
             {
                 if ( strResult[ii].CompareTo( (String)arrList[ii] ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected hero <"+ strResult[ii] + "> ";
                     strInfo = strInfo + "Returned hero <"+ (String)arrList[ii] + "> ";
                     Console.WriteLine( strTest+ "E_202: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10002: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt remove range using zero count" );
         try
         {
             arrList.RemoveRange( start, 0 );
             if ( arrList.Count != strResult.Length )
             {
                 String strInfo = strTest + " error: ";
                 strInfo = strInfo + "Expected size <"+ strResult.Length + "> ";
                 strInfo = strInfo + "Returned size <"+ arrList.Count + "> ";
                 Console.WriteLine( strTest+ "E_303: " + strInfo );
                 ++iCountErrors;
                 break;
             }
             for ( int ii = 0; ii < strResult.Length; ++ii )
             {
                 if ( strResult[ii].CompareTo( (String)arrList[ii] ) != 0 )
                 {
                     String strInfo = strTest + " error: ";
                     strInfo = strInfo + "Expected hero <"+ strResult[ii] + "> ";
                     strInfo = strInfo + "Returned hero <"+ (String)arrList[ii] + "> ";
                     Console.WriteLine( strTest+ "E_404: " + strInfo );
                     ++iCountErrors;
                     break;
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10003: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt bogus RemoveRange using very large count" );
         try
         {
             arrList.RemoveRange( start, 10005 );
             Console.WriteLine( strTest+ "E_303: Expected ArgumentException" );
             ++iCountErrors;
             break;
         }
         catch (ArgumentException ex)
         {
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10003: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt bogus RemoveRange using negative index" );
         try
         {
             arrList.Insert( -1000, 5 );
             Console.WriteLine( strTest+ "E_404: Expected ArgumentException" );
             ++iCountErrors;
             break;
         }
         catch (ArgumentException ex)
         {
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10004: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
         ++iCountTestcases;
         Console.Error.WriteLine( "[]  Attempt bogus RemoveRange using out of range index" );
         try
         {
             arrList.Insert( 1000, 5 );
             Console.WriteLine( strTest+ "E_505: Expected ArgumentException" );
             ++iCountErrors;
             break;
         }
         catch (ArgumentException ex)
         {
         }
         catch (Exception ex)
         {
             Console.WriteLine( strTest+ "E_10005: Unexpected Exception: " + ex.ToString() );
             ++iCountErrors;
             break;
         }
     }
     while ( false );
     Console.Error.Write( strName );
     Console.Error.Write( ": " );
     if ( iCountErrors == 0 )
     {
         Console.Error.WriteLine( strTest + " iCountTestcases==" + iCountTestcases + " paSs" );
         return true;
     }
     else
     {
         System.String strFailMsg = null;
         Console.WriteLine( strTest+ strPath );
         Console.WriteLine( strTest+ "FAiL" );
         Console.Error.WriteLine( strTest + " iCountErrors==" + iCountErrors );
         return false;
     }
 }
 public object this[int index]
 {
     get { return(_items[index]); }
     set { _items.Insert(index, value); }
 }
Example #32
0
        public static void Display()
        {
            // (1) - ArrayList
            // ArrayList are resizable arrays, standard arrays cannot change size once declared
            ArrayList list = new ArrayList();

            list.Add("Bob");
            list.Add(40);

            Console.WriteLine($"list count: {list.Count}");
            Console.WriteLine($"capacity: {list.Capacity}");

            // add ArrayList to another ArrayList
            ArrayList list2 = new ArrayList(new object[] { "Spencer", "Joseph", "Savannah" });

            list.AddRange(list2);

            Console.Write("list + list2: ");
            foreach (var item in list)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            // sort ArrayList that contains like types
            list2.Sort();
            Console.Write("sort: ");
            foreach (var item in list2)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            list2.Reverse();
            Console.Write("reverse: ");
            foreach (var item in list2)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            // insert at index of ArrayList
            list2.Insert(2, "Ed");
            Console.Write("insert: ");
            foreach (var item in list2)
            {
                Console.Write($"{item} ");
            }
            Console.WriteLine();

            // get range from list (index, length)
            ArrayList list3 = list2.GetRange(0, 2);

            Console.WriteLine("contains Spencer: {0}", list2.Contains("Spencer"));

            Console.WriteLine("index of Savannah: {0}", list2.IndexOf("Savannah", 0));

            // (2) - dictionary
            // dictionary is a key <-> value container
            // use the key to retrieve the value associated with it
            Dictionary <string, string> chairs = new Dictionary <string, string>();

            chairs.Add("BSIS", "Rich");
            chairs.Add("BSWD", "Beatty");
            chairs["BSGD"] = "Maple";

            // number of keys
            Console.WriteLine("dictionary count: {0}", chairs.Count);

            // check if key is present
            Console.WriteLine("contains BSGD: {0}", chairs.ContainsKey("BSGD"));

            // get value from key, returns true or false if it exists
            chairs.TryGetValue("BSIS", out string bsis);
            Console.WriteLine($"get value BSIS: {bsis}");

            // cycle through key value pairs
            foreach (KeyValuePair <string, string> item in chairs)
            {
                Console.WriteLine("{0} : {1}", item.Key, item.Value);
            }

            // remove a key / value
            chairs.Remove("BSGD");

            // clear out dictionary
            chairs.Clear();

            // (3) - queue
            // FIFO - first in first out container
            // 3 -> 2 -> 1
            Queue queue = new Queue();

            // add to queue
            queue.Enqueue(1);
            queue.Enqueue(2);
            queue.Enqueue(3);

            foreach (object o in queue)
            {
                Console.WriteLine($"queue : {o}");
            }

            // peek but don't remove
            Console.WriteLine("queue peek: {0}", queue.Peek());
            // dequeue (remove) from the front of the queue
            Console.WriteLine("queue dequeue: {0}", queue.Dequeue());
            Console.WriteLine("queue peek: {0}", queue.Peek());

            // check if queue contains a value
            Console.WriteLine("queue contains 1: {0}", queue.Contains(1));

            // convert to array
            object[] queueArray = queue.ToArray();

            // convenient way to display array
            Console.WriteLine(string.Join(",", queueArray));

            // remove all elements from the queue
            queue.Clear();

            // (4) - stack
            // FILO - first in last out
            // 3
            // v
            // 2
            // v
            // 1
            Stack stack = new Stack();

            // add to stack
            stack.Push(1);
            stack.Push(2);
            stack.Push(3);

            foreach (object o in stack)
            {
                Console.WriteLine($"stack : {o}");
            }

            // peek but don't remove
            Console.WriteLine("stack peek: {0}", stack.Peek());
            // pop off the top of the stack
            Console.WriteLine("stack pop: {0}", stack.Pop());
            Console.WriteLine("stack peek: {0}", stack.Peek());

            // check if stack contains a value
            Console.WriteLine("contains 1: {0}", stack.Contains(1));

            // convert to array
            object[] stackArray = stack.ToArray();

            // convenient way to display array
            Console.WriteLine(string.Join(",", stackArray));

            // remove all elements from the stack
            stack.Clear();
        }
 /// <summary>
 /// Inserts a PropertySpec object into the PropertySpecCollection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="value">The PropertySpec to insert.</param>
 public void Insert(int index, PropertySpec value)
 {
     _innerArray.Insert(index, value);
 }
Example #34
0
 public void AddChild(TreeNode child, int position)
 {
     children.Insert(position, child);
     child.SetParent(this);
     OnChildAdded(child);
 }
        //
        // Render row values based on field settings
        //
        public void RenderRow()
        {
            // Initialize urls
            // Row Rendering event

            Usuarios.Row_Rendering();

            //
            //  Common render codes for all row types
            //
            // IdUsuario
            // Usuario
            // NombreUsuario
            // Password
            // Correo
            // IdUsuarioNivel
            // Activo
            //
            //  View  Row
            //

            if (Usuarios.RowType == EW_ROWTYPE_VIEW) { // View row

            // IdUsuario
                Usuarios.IdUsuario.ViewValue = Usuarios.IdUsuario.CurrentValue;
            Usuarios.IdUsuario.ViewCustomAttributes = "";

            // Usuario
                Usuarios.Usuario.ViewValue = Usuarios.Usuario.CurrentValue;
            Usuarios.Usuario.ViewCustomAttributes = "";

            // NombreUsuario
                Usuarios.NombreUsuario.ViewValue = Usuarios.NombreUsuario.CurrentValue;
            Usuarios.NombreUsuario.ViewCustomAttributes = "";

            // Password
                Usuarios.Password.ViewValue = "********";
            Usuarios.Password.ViewCustomAttributes = "";

            // Correo
                Usuarios.Correo.ViewValue = Usuarios.Correo.CurrentValue;
            Usuarios.Correo.ViewCustomAttributes = "";

            // IdUsuarioNivel
            if ((Security.CurrentUserLevel & EW_ALLOW_ADMIN) == EW_ALLOW_ADMIN) { // System admin
            if (ew_NotEmpty(Usuarios.IdUsuarioNivel.CurrentValue)) {
                sFilterWrk = "[UserLevelID] = " + ew_AdjustSql(Usuarios.IdUsuarioNivel.CurrentValue) + "";
            sSqlWrk = "SELECT [UserLevelName] FROM [dbo].[UserLevels]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    Usuarios.IdUsuarioNivel.ViewValue = drWrk["UserLevelName"];
                } else {
                    Usuarios.IdUsuarioNivel.ViewValue = Usuarios.IdUsuarioNivel.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                Usuarios.IdUsuarioNivel.ViewValue = System.DBNull.Value;
            }
            } else {
                Usuarios.IdUsuarioNivel.ViewValue = "********";
            }
            Usuarios.IdUsuarioNivel.ViewCustomAttributes = "";

            // Activo
            if (Convert.ToString(Usuarios.Activo.CurrentValue) == "1") {
                Usuarios.Activo.ViewValue = (Usuarios.Activo.FldTagCaption(1) != "") ? Usuarios.Activo.FldTagCaption(1) : "Y";
            } else {
                Usuarios.Activo.ViewValue = (Usuarios.Activo.FldTagCaption(2) != "") ? Usuarios.Activo.FldTagCaption(2) : "N";
            }
            Usuarios.Activo.ViewCustomAttributes = "";

            // View refer script
            // Usuario

            Usuarios.Usuario.LinkCustomAttributes = "";
            Usuarios.Usuario.HrefValue = "";
            Usuarios.Usuario.TooltipValue = "";

            // NombreUsuario
            Usuarios.NombreUsuario.LinkCustomAttributes = "";
            Usuarios.NombreUsuario.HrefValue = "";
            Usuarios.NombreUsuario.TooltipValue = "";

            // Password
            Usuarios.Password.LinkCustomAttributes = "";
            Usuarios.Password.HrefValue = "";
            Usuarios.Password.TooltipValue = "";

            // Correo
            Usuarios.Correo.LinkCustomAttributes = "";
            Usuarios.Correo.HrefValue = "";
            Usuarios.Correo.TooltipValue = "";

            // IdUsuarioNivel
            Usuarios.IdUsuarioNivel.LinkCustomAttributes = "";
            Usuarios.IdUsuarioNivel.HrefValue = "";
            Usuarios.IdUsuarioNivel.TooltipValue = "";

            // Activo
            Usuarios.Activo.LinkCustomAttributes = "";
            Usuarios.Activo.HrefValue = "";
            Usuarios.Activo.TooltipValue = "";

            //
            //  Add Row
            //

            } else if (Usuarios.RowType == EW_ROWTYPE_ADD) { // Add row

            // Usuario
            Usuarios.Usuario.EditCustomAttributes = "";
            Usuarios.Usuario.EditValue = ew_HtmlEncode(Usuarios.Usuario.CurrentValue);

            // NombreUsuario
            Usuarios.NombreUsuario.EditCustomAttributes = "";
            Usuarios.NombreUsuario.EditValue = ew_HtmlEncode(Usuarios.NombreUsuario.CurrentValue);

            // Password
            Usuarios.Password.EditCustomAttributes = "";
            Usuarios.Password.EditValue = ew_HtmlEncode(Usuarios.Password.CurrentValue);

            // Correo
            Usuarios.Correo.EditCustomAttributes = "";
            Usuarios.Correo.EditValue = ew_HtmlEncode(Usuarios.Correo.CurrentValue);

            // IdUsuarioNivel
            Usuarios.IdUsuarioNivel.EditCustomAttributes = "";
            if (!Security.CanAdmin) { // System admin
                Usuarios.IdUsuarioNivel.EditValue = "********";
            } else {
            sFilterWrk = "";
            sSqlWrk = "SELECT [UserLevelID], [UserLevelName] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[UserLevels]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            Usuarios.IdUsuarioNivel.EditValue = alwrk;
            }

            // Activo
            Usuarios.Activo.EditCustomAttributes = "";
            alwrk = new ArrayList();
            odwrk = new OrderedDictionary();
            odwrk.Add("0", "1");
            odwrk.Add("1", (ew_NotEmpty(Usuarios.Activo.FldTagCaption(1))) ? Usuarios.Activo.FldTagCaption(1) : "Si");
            alwrk.Add(odwrk);
            odwrk = new OrderedDictionary();
            odwrk.Add("0", "0");
            odwrk.Add("1", (ew_NotEmpty(Usuarios.Activo.FldTagCaption(2))) ? Usuarios.Activo.FldTagCaption(2) : "No");
            alwrk.Add(odwrk);
            Usuarios.Activo.EditValue = alwrk;

            // Edit refer script
            // Usuario

            Usuarios.Usuario.HrefValue = "";

            // NombreUsuario
            Usuarios.NombreUsuario.HrefValue = "";

            // Password
            Usuarios.Password.HrefValue = "";

            // Correo
            Usuarios.Correo.HrefValue = "";

            // IdUsuarioNivel
            Usuarios.IdUsuarioNivel.HrefValue = "";

            // Activo
            Usuarios.Activo.HrefValue = "";
            }
            if (Usuarios.RowType == EW_ROWTYPE_ADD ||
            Usuarios.RowType == EW_ROWTYPE_EDIT ||
            Usuarios.RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
            Usuarios.SetupFieldTitles();
            }

            // Row Rendered event
            if (Usuarios.RowType != EW_ROWTYPE_AGGREGATEINIT)
            Usuarios.Row_Rendered();
        }
Example #36
0
 public void Insert(int index, object o)
 {
     list.Insert(index, (MetaProcedureArgument)o);
 }
Example #37
0
 public void Insert(int index, object value)
 {
     _arrLogs.Insert(index, value);
 }
Example #38
0
        public void TestArrayListWrappers()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int ii = 0;
            int start = 3;

            string[] strHeroes =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Huntress",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Superman",
                "Thor",
                "Wildcat",
                "Wonder Woman",
            };

            string[] strInsert =
            {
                "Dr. Fate",
                "Dr. Light",
                "Dr. Manhattan",
                "Hardware",
                "Hawkeye",
                "Icon",
                "Spawn",
                "Spectre",
                "Supergirl",
            };

            string[] strResult =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Dr. Fate",
                "Dr. Light",
                "Dr. Manhattan",
                "Hardware",
                "Hawkeye",
                "Icon",
                "Spawn",
                "Spectre",
                "Supergirl",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Huntress",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Superman",
                "Thor",
                "Wildcat",
                "Wonder Woman",
            };

            //
            // Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of 
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes = {
                                    (ArrayList)arrList.Clone(),
                                    (ArrayList)ArrayList.Adapter(arrList).Clone(),
                                    (ArrayList)arrList.GetRange(0, arrList.Count).Clone(),
                                    (ArrayList)ArrayList.Synchronized(arrList).Clone()};

            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;

                //
                // []  Insert values into array list.
                //
                // Insert values.
                for (ii = 0; ii < strInsert.Length; ++ii)
                {
                    arrList.Insert(start + ii, strInsert[ii]);
                }

                // Verify insert.
                for (ii = 0; ii < strResult.Length; ++ii)
                {
                    Assert.Equal(0, strResult[ii].CompareTo((String)arrList[ii]));
                }

                //
                //  []  Attempt invalid Insert using negative index
                //
                Assert.Throws<ArgumentOutOfRangeException>(() => arrList.Insert(-1000, "Batman"));

                //
                //  []  Attempt invalid Insert using out of range index
                //
                Assert.Throws<ArgumentOutOfRangeException>(() => arrList.Insert(1000, "Batman"));
            }
        }
Example #39
0
 protected virtual void list_insert(int i, object item)
 {
     list.Insert(i - 1, item);
 }
        //
        // Render row values based on field settings
        //
        public void RenderRow()
        {
            // Initialize urls
            // Row Rendering event

            RegistrosPeatones.Row_Rendering();

            //
            //  Common render codes for all row types
            //
            // IdRegistroPeaton
            // IdTipoDocumento
            // Documento
            // Nombre
            // Apellidos
            // IdArea
            // IdPersona
            // FechaIngreso
            // FechaSalida
            // Observacion
            //
            //  View  Row
            //

            if (RegistrosPeatones.RowType == EW_ROWTYPE_VIEW) { // View row

            // IdRegistroPeaton
                RegistrosPeatones.IdRegistroPeaton.ViewValue = RegistrosPeatones.IdRegistroPeaton.CurrentValue;
            RegistrosPeatones.IdRegistroPeaton.ViewCustomAttributes = "";

            // IdTipoDocumento
            if (ew_NotEmpty(RegistrosPeatones.IdTipoDocumento.CurrentValue)) {
                sFilterWrk = "[IdTipoDocumento] = " + ew_AdjustSql(RegistrosPeatones.IdTipoDocumento.CurrentValue) + "";
            sSqlWrk = "SELECT [TipoDocumento] FROM [dbo].[TiposDocumentos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [TipoDocumento]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    RegistrosPeatones.IdTipoDocumento.ViewValue = drWrk["TipoDocumento"];
                } else {
                    RegistrosPeatones.IdTipoDocumento.ViewValue = RegistrosPeatones.IdTipoDocumento.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                RegistrosPeatones.IdTipoDocumento.ViewValue = System.DBNull.Value;
            }
            RegistrosPeatones.IdTipoDocumento.ViewCustomAttributes = "";

            // Documento
                RegistrosPeatones.Documento.ViewValue = RegistrosPeatones.Documento.CurrentValue;
            RegistrosPeatones.Documento.ViewCustomAttributes = "";

            // Nombre
                RegistrosPeatones.Nombre.ViewValue = RegistrosPeatones.Nombre.CurrentValue;
            RegistrosPeatones.Nombre.ViewCustomAttributes = "";

            // Apellidos
                RegistrosPeatones.Apellidos.ViewValue = RegistrosPeatones.Apellidos.CurrentValue;
            RegistrosPeatones.Apellidos.ViewCustomAttributes = "";

            // IdArea
            if (ew_NotEmpty(RegistrosPeatones.IdArea.CurrentValue)) {
                sFilterWrk = "[IdArea] = " + ew_AdjustSql(RegistrosPeatones.IdArea.CurrentValue) + "";
            sSqlWrk = "SELECT [Area], [Codigo] FROM [dbo].[Areas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Area]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    RegistrosPeatones.IdArea.ViewValue = drWrk["Area"];
                    RegistrosPeatones.IdArea.ViewValue = String.Concat(RegistrosPeatones.IdArea.ViewValue, ew_ValueSeparator(0, 1, RegistrosPeatones.IdArea), drWrk["Codigo"]);
                } else {
                    RegistrosPeatones.IdArea.ViewValue = RegistrosPeatones.IdArea.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                RegistrosPeatones.IdArea.ViewValue = System.DBNull.Value;
            }
            RegistrosPeatones.IdArea.ViewCustomAttributes = "";

            // IdPersona
            if (ew_NotEmpty(RegistrosPeatones.IdPersona.VirtualValue)) {
                RegistrosPeatones.IdPersona.ViewValue = RegistrosPeatones.IdPersona.VirtualValue;
            } else {
            if (ew_NotEmpty(RegistrosPeatones.IdPersona.CurrentValue)) {
                sFilterWrk = "[IdPersona] = " + ew_AdjustSql(RegistrosPeatones.IdPersona.CurrentValue) + "";
            sSqlWrk = "SELECT [IdPersona], [Persona], [Documento], [Activa] FROM [dbo].[Personas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Persona]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    RegistrosPeatones.IdPersona.ViewValue = drWrk["IdPersona"];
                    RegistrosPeatones.IdPersona.ViewValue = String.Concat(RegistrosPeatones.IdPersona.ViewValue, ew_ValueSeparator(0, 1, RegistrosPeatones.IdPersona), drWrk["Persona"]);
                    RegistrosPeatones.IdPersona.ViewValue = String.Concat(RegistrosPeatones.IdPersona.ViewValue, ew_ValueSeparator(0, 2, RegistrosPeatones.IdPersona), drWrk["Documento"]);
                    RegistrosPeatones.IdPersona.ViewValue = String.Concat(RegistrosPeatones.IdPersona.ViewValue, ew_ValueSeparator(0, 3, RegistrosPeatones.IdPersona), drWrk["Activa"]);
                } else {
                    RegistrosPeatones.IdPersona.ViewValue = RegistrosPeatones.IdPersona.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                RegistrosPeatones.IdPersona.ViewValue = System.DBNull.Value;
            }
            }
            RegistrosPeatones.IdPersona.ViewCustomAttributes = "";

            // FechaIngreso
                RegistrosPeatones.FechaIngreso.ViewValue = RegistrosPeatones.FechaIngreso.CurrentValue;
                RegistrosPeatones.FechaIngreso.ViewValue = ew_FormatDateTime(RegistrosPeatones.FechaIngreso.ViewValue, 7);
            RegistrosPeatones.FechaIngreso.ViewCustomAttributes = "";

            // FechaSalida
                RegistrosPeatones.FechaSalida.ViewValue = RegistrosPeatones.FechaSalida.CurrentValue;
                RegistrosPeatones.FechaSalida.ViewValue = ew_FormatDateTime(RegistrosPeatones.FechaSalida.ViewValue, 7);
            RegistrosPeatones.FechaSalida.ViewCustomAttributes = "";

            // Observacion
            RegistrosPeatones.Observacion.ViewValue = RegistrosPeatones.Observacion.CurrentValue;
            RegistrosPeatones.Observacion.ViewCustomAttributes = "";

            // View refer script
            // IdTipoDocumento

            RegistrosPeatones.IdTipoDocumento.LinkCustomAttributes = "";
            RegistrosPeatones.IdTipoDocumento.HrefValue = "";
            RegistrosPeatones.IdTipoDocumento.TooltipValue = "";

            // Documento
            RegistrosPeatones.Documento.LinkCustomAttributes = "";
            RegistrosPeatones.Documento.HrefValue = "";
            RegistrosPeatones.Documento.TooltipValue = "";

            // Nombre
            RegistrosPeatones.Nombre.LinkCustomAttributes = "";
            RegistrosPeatones.Nombre.HrefValue = "";
            RegistrosPeatones.Nombre.TooltipValue = "";

            // Apellidos
            RegistrosPeatones.Apellidos.LinkCustomAttributes = "";
            RegistrosPeatones.Apellidos.HrefValue = "";
            RegistrosPeatones.Apellidos.TooltipValue = "";

            // IdArea
            RegistrosPeatones.IdArea.LinkCustomAttributes = "";
            RegistrosPeatones.IdArea.HrefValue = "";
            RegistrosPeatones.IdArea.TooltipValue = "";

            // IdPersona
            RegistrosPeatones.IdPersona.LinkCustomAttributes = "";
            RegistrosPeatones.IdPersona.HrefValue = "";
            RegistrosPeatones.IdPersona.TooltipValue = "";

            // Observacion
            RegistrosPeatones.Observacion.LinkCustomAttributes = "";
            RegistrosPeatones.Observacion.HrefValue = "";
            RegistrosPeatones.Observacion.TooltipValue = "";

            //
            //  Add Row
            //

            } else if (RegistrosPeatones.RowType == EW_ROWTYPE_ADD) { // Add row

            // IdTipoDocumento
            RegistrosPeatones.IdTipoDocumento.EditCustomAttributes = "";
            sFilterWrk = "";
            sSqlWrk = "SELECT [IdTipoDocumento], [TipoDocumento] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[TiposDocumentos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [TipoDocumento]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            RegistrosPeatones.IdTipoDocumento.EditValue = alwrk;

            // Documento
            RegistrosPeatones.Documento.EditCustomAttributes = "";
            RegistrosPeatones.Documento.EditValue = ew_HtmlEncode(RegistrosPeatones.Documento.CurrentValue);

            // Nombre
            RegistrosPeatones.Nombre.EditCustomAttributes = "";
            RegistrosPeatones.Nombre.EditValue = ew_HtmlEncode(RegistrosPeatones.Nombre.CurrentValue);

            // Apellidos
            RegistrosPeatones.Apellidos.EditCustomAttributes = "";
            RegistrosPeatones.Apellidos.EditValue = ew_HtmlEncode(RegistrosPeatones.Apellidos.CurrentValue);

            // IdArea
            RegistrosPeatones.IdArea.EditCustomAttributes = "";
            sFilterWrk = "";
            sSqlWrk = "SELECT [IdArea], [Area] AS [DispFld], [Codigo] AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[Areas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Area]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            ((OrderedDictionary)alwrk[0]).Add("2", "");
            RegistrosPeatones.IdArea.EditValue = alwrk;

            // IdPersona
            RegistrosPeatones.IdPersona.EditCustomAttributes = "";
            if (Convert.ToString(RegistrosPeatones.IdPersona.CurrentValue) == "") {
                sFilterWrk = "0=1";
            } else {
                sFilterWrk = "[IdPersona] = " + ew_AdjustSql(RegistrosPeatones.IdPersona.CurrentValue) + "";
            }
            sSqlWrk = "SELECT [IdPersona], [IdPersona] AS [DispFld], [Persona] AS [Disp2Fld], [Documento] AS [Disp3Fld], [Activa] AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[Personas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Persona]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            ((OrderedDictionary)alwrk[0]).Add("2", "");
            ((OrderedDictionary)alwrk[0]).Add("3",  "");
            ((OrderedDictionary)alwrk[0]).Add("4",  "");
            RegistrosPeatones.IdPersona.EditValue = alwrk;

            // Observacion
            RegistrosPeatones.Observacion.EditCustomAttributes = "";
            RegistrosPeatones.Observacion.EditValue = ew_HtmlEncode(RegistrosPeatones.Observacion.CurrentValue);

            // Edit refer script
            // IdTipoDocumento

            RegistrosPeatones.IdTipoDocumento.HrefValue = "";

            // Documento
            RegistrosPeatones.Documento.HrefValue = "";

            // Nombre
            RegistrosPeatones.Nombre.HrefValue = "";

            // Apellidos
            RegistrosPeatones.Apellidos.HrefValue = "";

            // IdArea
            RegistrosPeatones.IdArea.HrefValue = "";

            // IdPersona
            RegistrosPeatones.IdPersona.HrefValue = "";

            // Observacion
            RegistrosPeatones.Observacion.HrefValue = "";
            }
            if (RegistrosPeatones.RowType == EW_ROWTYPE_ADD ||
            RegistrosPeatones.RowType == EW_ROWTYPE_EDIT ||
            RegistrosPeatones.RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
            RegistrosPeatones.SetupFieldTitles();
            }

            // Row Rendered event
            if (RegistrosPeatones.RowType != EW_ROWTYPE_AGGREGATEINIT)
            RegistrosPeatones.Row_Rendered();
        }
    private static ArrayList FindKickers(Card[][] cardArray, 
			ArrayList reservedCards)
    {
        int numberOfKickers = 5 - reservedCards.Count;
        ArrayList kickers = new ArrayList();
        for (int i = cardArray[0].Length - 1; i >= 0; i--){
            for (int j = 0; j < cardArray.Length; j++){
                Card card = cardArray[j][i];
                if (card != null && !reservedCards.Contains(card)){
                    for (int k = 0; k < numberOfKickers; k++){
                        if (k == kickers.Count || card.CompareTo((Card)kickers[k]) > 0){
                            kickers.Insert(k, card);
                            break;
                        }
                    }
                    if (kickers.Count > numberOfKickers){
                        kickers.RemoveAt(kickers.Count - 1);
                    }
                }
            }
        }
        if (kickers.Count + reservedCards.Count != 5){
            Debug.LogError("Too few kickers!");
        }
        return kickers;
    }
Example #42
0
    public static void Optimize(ArrayList list)
    {
        for (int i = 1; i < list.Count; i++)
        {
            X86Code x0 = list[i] as X86Code;
            if (x0 == null || x0.ignore || x0.IsBrTarget) continue;

            ArrayList listx = new ArrayList();
            listx.Add(x0);
            for (int j = 1;; j++)
            {
                X86Code xx = GetPrevious(list, i, j);
                if (xx == null) break;
                listx.Add(xx);
            }
            if (listx.Count < 2) continue;

            X86Code[] x = listx.ToArray(typeof(X86Code)) as X86Code[];
            if (IsMovEtc(x[0].Mnemonic) && !IsXS(x[0].Operand1) && IsXX(x[0].Operand2) && x[0].Operand1 != x[0].Operand2)
            {
                for (int j = 1; j < x.Length; j++)
                {
                    if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand2 && !IsXS(x[j].Operand2)
                        && !(IsAddr(x[0].Operand1) && IsAddr(x[j].Operand2)))
                    {
                        if (x[0].Operand1 != x[j].Operand2 && (IsXX(x[0].Operand1) || IsXX(x[j].Operand2)))
                        {
                            x[j].Ignore();
                            x[0].Ignore();
                            X86Code xx = new X86Code(x[0].Mnemonic, x[0].Operand1, x[j].Operand2);
                            xx.Notes = "[optimize] add";
                            list.Insert(i + 1, xx);
                        }
                    }
                    else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[0].Operand2)
                    {
                        continue;
                    }
                    break;
                }
                if (x[0].ignore) continue;
            }
            switch (x[0].Mnemonic)
            {
                case "pop":
                {
                    Hashtable t = new Hashtable();
                    for (int j = 1; j < x.Length; j++)
                    {
                        if (x[j].Mnemonic == "push")
                        {
                            if (!t.Contains(x[j].Operand1))
                            {
                                if (x[j].Operand1 == x[0].Operand1)
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                }
                                else if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1))
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                    X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1);
                                    xx.Notes = "[optimize] add";
                                    list.Insert(i + 1, xx);
                                }
                            }
                            else if (!t.Contains(x[0].Operand1))
                            {
                                if (IsXX(x[j].Operand1) || IsXX(x[0].Operand1))
                                {
                                    x[j].Ignore();
                                    x[0].Ignore();
                                    X86Code xx = new X86Code("mov", x[0].Operand1, x[j].Operand1);
                                    xx.Notes = "[optimize] add";
                                    i = list.IndexOf(x[j]);
                                    list.Insert(i + 1, xx);
                                }
                            }
                        }
                        else if (IsMovEtc(x[j].Mnemonic))
                        {
                            t[x[j].Operand1] = true;
                            continue;
                        }
                        break;
                    }
                    break;
                }
                case "cmp":
                    if (IsXX(x[0].Operand1) && IsDigit(x[0].Operand2))
                    {
                        for (int j = 1; j < x.Length; j++)
                        {
                            if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[0].Operand1)
                            {
                                x[j].Ignore();
                                x[0].Ignore();
                                X86Code xx = new X86Code("cmp", x[j].Operand2, x[0].Operand2);
                                xx.Notes = "[optimize] add";
                                list.Insert(i + 1, xx);
                            }
                            else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[0].Operand1)
                            {
                                continue;
                            }
                            break;
                        }
                    }
                    break;
                case "je":
                case "jne":
                case "jz":
                case "jnz":
                    if (x[1].Mnemonic == "cmp" && IsXX(x[1].Operand1) && !IsDigit(x[1].Operand2))
                    {
                        for (int j = 2; j < x.Length; j++)
                        {
                            if (x[j].Mnemonic == "mov" && x[j].Operand1 == x[1].Operand1)
                            {
                                x[j].Ignore();
                                x[1].Ignore();
                                X86Code xx = new X86Code("cmp", x[1].Operand2, x[j].Operand2);
                                xx.Notes = "[optimize] add";
                                i = list.IndexOf(x[1]);
                                list.Insert(i + 1, xx);
                            }
                            else if (IsMovEtc(x[j].Mnemonic) && x[j].Operand1 != x[1].Operand1)
                            {
                                continue;
                            }
                            break;
                        }
                    }
                    break;
                case "mov":
                    if (x.Length > 2 && IsAddEtc(x[1].Mnemonic) && x[2].Mnemonic == "mov"
                        && x[0].Operand2 == x[1].Operand1 && x[1].Operand1 == x[2].Operand1)
                    {
                        if (x[1].Mnemonic == "inc" || x[1].Mnemonic == "dec")
                        {
                            x[2].Ignore();
                            x[1].Ignore();
                            x[0].Ignore();
                            X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1);
                            xx.Notes = "[optimize] add";
                            list.Insert(i + 1, xx);
                        }
                        else if (x[0].Operand1 == x[1].Operand2 && !IsAddr(x[2].Operand2))
                        {
                            x[2].Ignore();
                            x[1].Ignore();
                            x[0].Ignore();
                            X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1, x[2].Operand2);
                            xx.Notes = "[optimize] add";
                            list.Insert(i + 1, xx);
                        }
                        else if (x[0].Operand1 == x[2].Operand2 && !IsAddr(x[1].Operand2))
                        {
                            x[2].Ignore();
                            x[1].Ignore();
                            x[0].Ignore();
                            X86Code xx = new X86Code(x[1].Mnemonic, x[0].Operand1, x[1].Operand2);
                            xx.Notes = "[optimize] add";
                            list.Insert(i + 1, xx);
                        }
                    }
                    break;
                case "add":
                    if (x[0].Operand2 == "1")
                    {
                        x[0].Ignore();
                        X86Code xx = new X86Code("inc", x[0].Operand1);
                        xx.Notes = "[Optimize] add";
                        list.Insert(i + 1, xx);
                    }
                    break;
                case "sub":
                    if (x[0].Operand2 == "1")
                    {
                        x[0].Ignore();
                        X86Code xx = new X86Code("dec", x[0].Operand1);
                        xx.Notes = "[Optimize] add";
                        list.Insert(i + 1, xx);
                    }
                    break;
            }
        }

        StringCollection jmp = new StringCollection();
        for (int i = 0; i < list.Count; i++)
        {
            X86Code x = list[i] as X86Code;
            if (x == null || x.ignore) continue;

            if (x.Mnemonic == "mov" && X86Code.IsXX(x.Operand1) && x.Operand2 == "0")
            {
                x.Ignore();
                X86Code xx = new X86Code("xor", x.Operand1, x.Operand1);
                xx.Notes = "[optimize] add";
                list.Insert(i + 1, xx);
            }
            else if (x.Mnemonic == "mov" && x.Operand1 == x.Operand2)
            {
                x.Ignore();
            }
            else if (x.Mnemonic.StartsWith("j"))
            {
                jmp.Add(x.Operand1);
            }
        }
        for (int i = 0; i < list.Count; i++)
        {
            X86Code x = list[i] as X86Code;
            if (x == null) continue;

            if (x.IsBrTarget && !jmp.Contains(x.Label)) x.IsBrTarget = false;
        }
    }
Example #43
0
 /// <include file='doc\StringCollection.uex' path='docs/doc[@for="StringCollection.Insert"]/*' />
 /// <devdoc>
 /// <para>Inserts a string into the <see cref='System.Collections.Specialized.StringCollection'/> at the specified
 ///    index.</para>
 /// </devdoc>
 public void Insert(int index, string value)
 {
     data.Insert(index, value);
 }
Example #44
0
        static void Main(string[] args)
        {
            ArrayList List = new ArrayList();

            List.Add(23);

            List.Add("Hello");

            List.Add("!");

            foreach (object o in List)
            {
                Console.Write(o + "  ");
            }

            Console.WriteLine("\n" + List.Count);

            Console.WriteLine(new string('-', 30));

            List.AddRange(new double[] { 2.4, 1.98, 6.45 });

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.Insert(2, "world");

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            ArrayList sList = new ArrayList
            {
                'l', 'o', 'v', 'e', ' ', 'c', '#'
            };

            List.InsertRange(List.Count - 1, sList);

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.Add("Hello");

            Console.WriteLine(List.IndexOf("Hello") + " Место");

            Console.WriteLine(List.LastIndexOf("Hello") + " Место");

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.Remove("Hello");

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.RemoveAt(List.IndexOf("Hello"));

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.RemoveRange(3, 2);

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            List.Add(90);

            List.Insert(3, 90);

            List.Insert(6, 90);

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine();

            while (List.Contains(90))
            {
                List.Remove(90);
            }

            for (int i = 0; i < List.Count; i++)
            {
                Console.Write(List[i] + "  ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            IEnumerator en = List.GetEnumerator();

            while (en.MoveNext())
            {
                Console.Write(en.Current + ", ");
            }

            Console.WriteLine("\n" + new string('-', 30));

            Console.ReadKey();
        }
Example #45
0
			/// <summary>
			/// Get a list of active counts of different callbacks
			/// </summary>
			/// <returns></returns>
			public IList GetUsedCallbacks()
			{
				Hashtable table;
				lock (m_timerCallbackStatistic) {
					table = (Hashtable)m_timerCallbackStatistic.Clone();
				}

				// sort it
				ArrayList sorted = new ArrayList();
				foreach (DictionaryEntry entry in table) {
					int count = (int)entry.Value;
					int i;
					for (i=0; i<sorted.Count; i++) {
						if ( ((int)((DictionaryEntry)sorted[i]).Value) < count ) break;
					}
					sorted.Insert(i, entry);
				}

				// make strings
				for (int i=0; i<sorted.Count; i++) {
					DictionaryEntry entry = (DictionaryEntry)sorted[i];
					sorted[i] = entry.Value+": "+entry.Key;
				}
				return sorted;
			}
Example #46
0
        protected void PreProcessControlsCollection(ArrayList topList, ArrayList leftList, ArrayList rightList, ArrayList bottomList, ArrayList fillList, int outerIndex)
        {
            // Find space left after all docking windows has been positioned
            _insideRect  = _container.ClientRectangle;
            _outsideRect = _insideRect;

            // We want lists of docked controls grouped by docking style
            foreach (Control item in _container.Controls)
            {
                bool ignoreType = (item is AutoHidePanel);

                int controlIndex = _container.Controls.IndexOf(item);

                bool outer = (controlIndex >= outerIndex);

                if (item.Visible)
                {
                    if (item.Dock == DockStyle.Top)
                    {
                        topList.Insert(0, item);

                        if (_insideRect.Y < item.Bottom)
                        {
                            _insideRect.Height -= item.Bottom - _insideRect.Y;
                            _insideRect.Y       = item.Bottom;
                        }

                        if (outer || ignoreType)
                        {
                            if (_outsideRect.Y < item.Bottom)
                            {
                                _outsideRect.Height -= item.Bottom - _outsideRect.Y;
                                _outsideRect.Y       = item.Bottom;
                            }
                        }
                    }

                    if (item.Dock == DockStyle.Left)
                    {
                        leftList.Insert(0, item);

                        if (_insideRect.X < item.Right)
                        {
                            _insideRect.Width -= item.Right - _insideRect.X;
                            _insideRect.X      = item.Right;
                        }

                        if (outer || ignoreType)
                        {
                            if (_outsideRect.X < item.Right)
                            {
                                _outsideRect.Width -= item.Right - _outsideRect.X;
                                _outsideRect.X      = item.Right;
                            }
                        }
                    }

                    if (item.Dock == DockStyle.Bottom)
                    {
                        bottomList.Insert(0, item);

                        if (_insideRect.Bottom > item.Top)
                        {
                            _insideRect.Height -= _insideRect.Bottom - item.Top;
                        }

                        if (outer || ignoreType)
                        {
                            if (_outsideRect.Bottom > item.Top)
                            {
                                _outsideRect.Height -= _outsideRect.Bottom - item.Top;
                            }
                        }
                    }

                    if (item.Dock == DockStyle.Right)
                    {
                        rightList.Insert(0, item);

                        if (_insideRect.Right > item.Left)
                        {
                            _insideRect.Width -= _insideRect.Right - item.Left;
                        }

                        if (outer || ignoreType)
                        {
                            if (_outsideRect.Right > item.Left)
                            {
                                _outsideRect.Width -= _outsideRect.Right - item.Left;
                            }
                        }
                    }

                    if (item.Dock == DockStyle.Fill)
                    {
                        fillList.Insert(0, item);
                    }
                }
            }

            // Convert to screen coordinates
            _insideRect  = _container.RectangleToScreen(_insideRect);
            _outsideRect = _container.RectangleToScreen(_outsideRect);
        }
Example #47
0
 public static void StopByName(string name)
 {
     ArrayList arrayList = new ArrayList();
     for (int i = 0; i < iTween.tweens.Count; i++)
     {
         Hashtable hashtable = (Hashtable)iTween.tweens[i];
         GameObject value = (GameObject)hashtable["target"];
         arrayList.Insert(arrayList.Count, value);
     }
     for (int j = 0; j < arrayList.Count; j++)
     {
         iTween.StopByName((GameObject)arrayList[j], name);
     }
 }
Example #48
0
        public void TestArrayListWrappers()
        {
            //--------------------------------------------------------------------------
            // Variable definitions.
            //--------------------------------------------------------------------------
            ArrayList arrList = null;
            int       ii      = 0;
            int       start   = 3;

            string[] strHeroes =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Huntress",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Superman",
                "Thor",
                "Wildcat",
                "Wonder Woman",
            };

            string[] strInsert =
            {
                "Dr. Fate",
                "Dr. Light",
                "Dr. Manhattan",
                "Hardware",
                "Hawkeye",
                "Icon",
                "Spawn",
                "Spectre",
                "Supergirl",
            };

            string[] strResult =
            {
                "Aquaman",
                "Atom",
                "Batman",
                "Dr. Fate",
                "Dr. Light",
                "Dr. Manhattan",
                "Hardware",
                "Hawkeye",
                "Icon",
                "Spawn",
                "Spectre",
                "Supergirl",
                "Black Canary",
                "Captain America",
                "Captain Atom",
                "Catwoman",
                "Cyborg",
                "Flash",
                "Green Arrow",
                "Green Lantern",
                "Hawkman",
                "Huntress",
                "Ironman",
                "Nightwing",
                "Robin",
                "SpiderMan",
                "Steel",
                "Superman",
                "Thor",
                "Wildcat",
                "Wonder Woman",
            };

            //
            // Construct array lists.
            //
            arrList = new ArrayList((ICollection)strHeroes);

            //Adapter, GetRange, Synchronized, ReadOnly returns a slightly different version of
            //BinarySearch, Following variable cotains each one of these types of array lists

            ArrayList[] arrayListTypes =
            {
                (ArrayList)arrList.Clone(),
                (ArrayList)ArrayList.Adapter(arrList).Clone(),
                (ArrayList)arrList.GetRange(0,                arrList.Count).Clone(),
                (ArrayList)ArrayList.Synchronized(arrList).Clone()
            };

            foreach (ArrayList arrayListType in arrayListTypes)
            {
                arrList = arrayListType;

                //
                // []  Insert values into array list.
                //
                // Insert values.
                for (ii = 0; ii < strInsert.Length; ++ii)
                {
                    arrList.Insert(start + ii, strInsert[ii]);
                }

                // Verify insert.
                for (ii = 0; ii < strResult.Length; ++ii)
                {
                    Assert.Equal(0, strResult[ii].CompareTo((String)arrList[ii]));
                }

                //
                //  []  Attempt invalid Insert using negative index
                //
                Assert.Throws <ArgumentOutOfRangeException>(() => arrList.Insert(-1000, "Batman"));

                //
                //  []  Attempt invalid Insert using out of range index
                //
                Assert.Throws <ArgumentOutOfRangeException>(() => arrList.Insert(1000, "Batman"));
            }
        }
    void InitTableViewImp(ArrayList inDataList, List<int> inSectionsIndices, int inStartIndex)
    {
        RefreshPool();
        startIndex = inStartIndex;
        scrollCursor = inStartIndex;
        dataTracker.Clear();
        originalData = new ArrayList(inDataList);
        dataList = new ArrayList(inDataList);
        if(inSectionsIndices!=null)
        {
            numberOfSections = inSectionsIndices.Count;
            sectionsIndices = inSectionsIndices;
        }
        else
        {
            numberOfSections = 0;
            sectionsIndices = new List<int>();
        }
        // do we have a section? then inject 'special' data inside the date list
        if(numberOfSections > 0)
        {

            for(int i = 0; i< numberOfSections; i++)
            {
                sectionsIndices[i] +=i;
                if(sectionsIndices[i]<dataList.Count)
                    dataList.Insert(sectionsIndices[i],null);// testing with null data
                else
                {
                    if(enableLog)
                    {
                        Debug.LogWarning("InfiniteListPopulator.InitTableView() section index "+(sectionsIndices[i] - i)+" value is larger than last data index and is ignored");
                    }
                    sectionsIndices.RemoveAt(i);
                    numberOfSections--;
                }
            }
        }

        int j = 0;
        for(int i=startIndex; i<dataList.Count; i++)
        {
            Transform item = GetItemFromPool(j);
            if(item!=null)
            {
                // is it a section index?
                if(sectionsIndices.Contains(i) && item.tag.Equals(listItemTag))
                {
                    // change item to section
                    InitSection(item,i,j);
                }
                else
                {
                    InitListItemWithIndex(item,i,j);
                }
                if(enableLog)
                {
                    Debug.Log(item.name+"::"+item.tag);
                }
                j++;

            }
            else // end of pool
            {

                break;
            }
        }

        // at the moment we are repositioning the list after a delay... repositioning immediatly messes up the table when refreshing... no clue why...
        Invoke("RepositionList",0.1f);
    }
Example #50
0
    void UpdateInsertion()
    {
        // Move chain and Add bullet to chain
        int dequeSize = 0;

        foreach (MovementRegistrationEntry entry in insertionQueue)
        {
            if (Time.frameCount > entry.registerFrame)
            {
                // move all the leading balls
                foreach (GameObject ball in balls)
                {
                    float deltaTime = Time.deltaTime;
                    if (entry.proceedTime + deltaTime > insetionSmoothTime)
                    {
                        deltaTime = insetionSmoothTime - entry.proceedTime;
                    }
                    ball.GetComponent <BallChainMovement>()
                    .PushFoward(diameterPercentPerSecond * deltaTime);
                    if (ball == entry.chainBall)
                    {
                        break;
                    }
                }

                entry.proceedTime += Time.deltaTime;

                // TODO: Fix the bug of position mismatch when multiple bullets
                // hit same chainBall
                if (entry.proceedTime > insetionSmoothTime)
                {
                    dequeSize++;
                    int idx = balls.IndexOf(entry.chainBall);
                    if (entry.repeatChainBall > 1)
                    {
                        Debug.Log("Same Time");
                    }
                    if (idx + entry.repeatChainBall >= balls.Count)
                    {
                        Debug.LogWarning("Insertion idx Larger than chain size");
                    }
                    balls.Insert(idx + entry.repeatChainBall, entry.bulletBall);
                    // Synchronizing the remove
                    CheckColorTableEntry setEntry = new CheckColorTableEntry();
                    setEntry.indexReference = idx + entry.repeatChainBall;
                    setEntry.covered        = false;
                    if (!checkColorTable.ContainsKey(entry.bulletBall))
                    {
                        checkColorTable.Add(entry.bulletBall, setEntry);
                    }
                    else
                    {
                        Debug.LogError("Same bulletBall registered twice " + entry.bulletBall);
                    }
                    combo = 0;
                    checkColorRegisterTime = Time.time;
                    //Debug.Log (entry.bulletBall.name + " " + entry.chainBall.name + " " + (idx));
                    entry.bulletBall.GetComponent <Rigidbody> ().isKinematic = false;
                    entry.bulletBall.transform.parent = ballsObject.transform;
                    BallChainMovement ballScript = entry.bulletBall
                                                   .AddComponent <BallChainMovement>();
                    ballScript.currPathPercent = entry.chainBall.GetComponent <BallChainMovement> ().currPathPercent
                                                 - (entry.repeatChainBall) * diameterPercent;
                    spawn.SetPPSForBallScript(ballScript);
                }
            }
            else
            {
                // as it is enqued in time order
                break;
            }
        }

        DequeHeadElements(dequeSize);

        // Move bullet
    }
Example #51
0
		public bool Build (X509Certificate2 certificate)
		{
			if (certificate == null)
				throw new ArgumentException ("certificate");

			Reset ();
			X509ChainStatusFlags flag;
			try {
				flag = BuildChainFrom (certificate);
				ValidateChain (flag);
			}
			catch (CryptographicException ce) {
				throw new ArgumentException ("certificate", ce);
			}

			X509ChainStatusFlags total = X509ChainStatusFlags.NoError;
			ArrayList list = new ArrayList ();
			// build "global" ChainStatus from the ChainStatus of every ChainElements
			foreach (X509ChainElement ce in elements) {
				foreach (X509ChainStatus cs in ce.ChainElementStatus) {
					// we MUST avoid duplicates in the "global" list
					if ((total & cs.Status) != cs.Status) {
						list.Add (cs);
						total |= cs.Status;
					}
				}
			}
			// and if required add some
			if (flag != X509ChainStatusFlags.NoError) {
				list.Insert (0, new X509ChainStatus (flag));
			}
			status = (X509ChainStatus[]) list.ToArray (typeof (X509ChainStatus));

			// (fast path) this ignore everything we have checked
			if ((status.Length == 0) || (ChainPolicy.VerificationFlags == X509VerificationFlags.AllFlags))
				return true;

			bool result = true;
			// now check if exclude some verification for the "end result" (boolean)
			foreach (X509ChainStatus cs in status) {
				switch (cs.Status) {
				case X509ChainStatusFlags.UntrustedRoot:
				case X509ChainStatusFlags.PartialChain:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.AllowUnknownCertificateAuthority) != 0);
					break;
				case X509ChainStatusFlags.NotTimeValid:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreNotTimeValid) != 0);
					break;
				// FIXME - from here we needs new test cases for all cases
				case X509ChainStatusFlags.NotTimeNested:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreNotTimeNested) != 0);
					break;
				case X509ChainStatusFlags.InvalidBasicConstraints:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreInvalidBasicConstraints) != 0);
					break;
				case X509ChainStatusFlags.InvalidPolicyConstraints:
				case X509ChainStatusFlags.NoIssuanceChainPolicy:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreInvalidPolicy) != 0);
					break;
				case X509ChainStatusFlags.InvalidNameConstraints:
				case X509ChainStatusFlags.HasNotSupportedNameConstraint:
				case X509ChainStatusFlags.HasNotPermittedNameConstraint:
				case X509ChainStatusFlags.HasExcludedNameConstraint:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreInvalidName) != 0);
					break;
				case X509ChainStatusFlags.InvalidExtension:
					// not sure ?!?
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreWrongUsage) != 0);
					break;
				//
				//	((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreRootRevocationUnknown) != 0)
				//	((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreEndRevocationUnknown) != 0)
				case X509ChainStatusFlags.CtlNotTimeValid:
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreCtlNotTimeValid) != 0);
					break;
				case X509ChainStatusFlags.CtlNotSignatureValid:
					// ?
					break;
				//	((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreCtlSignerRevocationUnknown) != 0);
				case X509ChainStatusFlags.CtlNotValidForUsage:
					// FIXME - does IgnoreWrongUsage apply to CTL (it doesn't have Ctl in it's name like the others)
					result &= ((ChainPolicy.VerificationFlags & X509VerificationFlags.IgnoreWrongUsage) != 0);
					break;
				default:
					result = false;
					break;
				}
				// once we have one failure there's no need to check further
				if (!result)
					return false;
			}

			// every "problem" was excluded
			return true;
		}
Example #52
0
        /// <summary>
        /// The on text changed overrided. Here we parse the text into RTF for the highlighting.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTextChanged(EventArgs e)
        {
            if (mParsing)
            {
                return;
            }
            mParsing = true;
            Win32.LockWindowUpdate(Handle);
            base.OnTextChanged(e);

            if (!mIsUndo)
            {
                mRedoStack.Clear();
                mUndoList.Insert(0, mLastInfo);
                this.LimitUndo();
                mLastInfo = new UndoRedoInfo(Text, GetScrollPos(), SelectionStart);
            }

            //Save scroll bar an cursor position, changeing the RTF moves the cursor and scrollbars to top positin
            Win32.POINT scrollPos = GetScrollPos();
            int         cursorLoc = SelectionStart;

            //Created with an estimate of how big the stringbuilder has to be...
            StringBuilder sb = new
                               StringBuilder((int)(Text.Length * 1.5 + 150));

            //Adding RTF header
            sb.Append(@"{\rtf1\fbidis\ansi\ansicpg1255\deff0\deflang1037{\fonttbl{");

            //Font table creation
            int       fontCounter = 0;
            Hashtable fonts       = new Hashtable();

            AddFontToTable(sb, Font, ref fontCounter, fonts);
            foreach (HighlightDescriptor hd in mHighlightDescriptors)
            {
                if ((hd.Font != null) && !fonts.ContainsKey(hd.Font.Name))
                {
                    AddFontToTable(sb, hd.Font, ref fontCounter, fonts);
                }
            }
            sb.Append("}\n");

            //ColorTable

            sb.Append(@"{\colortbl ;");
            Hashtable colors       = new Hashtable();
            int       colorCounter = 1;

            AddColorToTable(sb, ForeColor, ref colorCounter, colors);
            AddColorToTable(sb, BackColor, ref colorCounter, colors);

            foreach (HighlightDescriptor hd in mHighlightDescriptors)
            {
                if (!colors.ContainsKey(hd.Color))
                {
                    AddColorToTable(sb, hd.Color, ref colorCounter, colors);
                }
            }

            //Parsing text

            sb.Append("}\n").Append(@"\viewkind4\uc1\pard\ltrpar");
            SetDefaultSettings(sb, colors, fonts);

            char[] seperators = mSeperators.GetAsCharArray();

            //Replacing "\" to "\\" for RTF...
            string[] lines = Text.Replace("\\", "\\\\").Replace("{", "\\{").Replace("}", "\\}").Split('\n');
            for (int lineCounter = 0; lineCounter < lines.Length; lineCounter++)
            {
                if (lineCounter != 0)
                {
                    AddNewLine(sb);
                }
                string   line   = lines[lineCounter];
                string[] tokens = mCaseSensitive ? line.Split(seperators) : line.ToUpper().Split(seperators);
                if (tokens.Length == 0)
                {
                    sb.Append(line);
                    AddNewLine(sb);
                    continue;
                }

                int tokenCounter = 0;
                for (int i = 0; i < line.Length;)
                {
                    char curChar = line[i];
                    if (mSeperators.Contains(curChar))
                    {
                        sb.Append(curChar);
                        i++;
                    }
                    else
                    {
                        string curToken  = tokens[tokenCounter++];
                        bool   bAddToken = true;
                        foreach (HighlightDescriptor hd in mHighlightDescriptors)
                        {
                            string compareStr = mCaseSensitive ? hd.Token : hd.Token.ToUpper();
                            bool   match      = false;

                            //Check if the highlight descriptor matches the current toker according to the DescriptoRecognision property.
                            switch (hd.DescriptorRecognition)
                            {
                            case DescriptorRecognition.WholeWord:
                                if (curToken == compareStr)
                                {
                                    match = true;
                                }
                                break;

                            case DescriptorRecognition.StartsWith:
                                if (curToken.StartsWith(compareStr))
                                {
                                    match = true;
                                }
                                break;

                            case DescriptorRecognition.Contains:
                                if (curToken.IndexOf(compareStr) != -1)
                                {
                                    match = true;
                                }
                                break;
                            }
                            if (!match)
                            {
                                //If this token doesn't match chech the next one.
                                continue;
                            }

                            //printing this token will be handled by the inner code, don't apply default settings...
                            bAddToken = false;

                            //Set colors to current descriptor settings.
                            SetDescriptorSettings(sb, hd, colors, fonts);

                            //Print text affected by this descriptor.
                            switch (hd.DescriptorType)
                            {
                            case DescriptorType.Word:
                                sb.Append(line.Substring(i, curToken.Length));
                                SetDefaultSettings(sb, colors, fonts);
                                i += curToken.Length;
                                break;

                            case DescriptorType.ToEOL:
                                sb.Append(line.Remove(0, i));
                                i = line.Length;
                                SetDefaultSettings(sb, colors, fonts);
                                break;

                            case DescriptorType.ToCloseToken:
                                while ((line.IndexOf(hd.CloseToken, i) == -1) && (lineCounter < lines.Length))
                                {
                                    sb.Append(line.Remove(0, i));
                                    lineCounter++;
                                    if (lineCounter < lines.Length)
                                    {
                                        AddNewLine(sb);
                                        line = lines[lineCounter];
                                        i    = 0;
                                    }
                                    else
                                    {
                                        i = line.Length;
                                    }
                                }
                                if (line.IndexOf(hd.CloseToken, i) != -1)
                                {
                                    sb.Append(line.Substring(i, line.IndexOf(hd.CloseToken, i) + hd.CloseToken.Length - i));
                                    line         = line.Remove(0, line.IndexOf(hd.CloseToken, i) + hd.CloseToken.Length);
                                    tokenCounter = 0;
                                    tokens       = mCaseSensitive ? line.Split(seperators) : line.ToUpper().Split(seperators);
                                    SetDefaultSettings(sb, colors, fonts);
                                    i = 0;
                                }
                                break;
                            }
                            break;
                        }
                        if (bAddToken)
                        {
                            //Print text with default settings...
                            sb.Append(line.Substring(i, curToken.Length));
                            i += curToken.Length;
                        }
                    }
                }
            }
            Rtf = sb.ToString();

            //Restore cursor and scrollbars location.
            SelectionStart = cursorLoc;

            mParsing = false;

            SetScrollPos(scrollPos);
            Win32.LockWindowUpdate((IntPtr)0);
            Invalidate();

            if (mAutoCompleteShown)
            {
                if (mFilterAutoComplete)
                {
                    SetAutoCompleteItems();
                    SetAutoCompleteSize();
                    SetAutoCompleteLocation(false);
                }
                SetBestSelectedAutoCompleteItem();
            }
        }
Example #53
0
 internal Parser(DirectoryPrx root)
 {
     _dirs = new ArrayList();
     _dirs.Insert(0, root);
 }
Example #54
0
 public void Insert(int index, PdfObject value)
 {
     elements.Insert(index, value);
 }
        //
        // Render row values based on field settings
        //
        public void RenderRow()
        {
            // Initialize urls
            // Row Rendering event

            Personas.Row_Rendering();

            //
            //  Common render codes for all row types
            //
            // IdPersona
            // IdArea
            // IdCargo
            // Documento
            // Persona
            // Activa
            //
            //  View  Row
            //

            if (Personas.RowType == EW_ROWTYPE_VIEW) { // View row

            // IdPersona
                Personas.IdPersona.ViewValue = Personas.IdPersona.CurrentValue;
            Personas.IdPersona.ViewCustomAttributes = "";

            // IdArea
            if (ew_NotEmpty(Personas.IdArea.CurrentValue)) {
                sFilterWrk = "[IdArea] = " + ew_AdjustSql(Personas.IdArea.CurrentValue) + "";
            sSqlWrk = "SELECT [Area], [Codigo] FROM [dbo].[Areas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Area]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    Personas.IdArea.ViewValue = drWrk["Area"];
                    Personas.IdArea.ViewValue = String.Concat(Personas.IdArea.ViewValue, ew_ValueSeparator(0, 1, Personas.IdArea), drWrk["Codigo"]);
                } else {
                    Personas.IdArea.ViewValue = Personas.IdArea.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                Personas.IdArea.ViewValue = System.DBNull.Value;
            }
            Personas.IdArea.ViewCustomAttributes = "";

            // IdCargo
            if (ew_NotEmpty(Personas.IdCargo.CurrentValue)) {
                sFilterWrk = "[IdCargo] = " + ew_AdjustSql(Personas.IdCargo.CurrentValue) + "";
            sSqlWrk = "SELECT [Cargo] FROM [dbo].[Cargos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Cargo]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    Personas.IdCargo.ViewValue = drWrk["Cargo"];
                } else {
                    Personas.IdCargo.ViewValue = Personas.IdCargo.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                Personas.IdCargo.ViewValue = System.DBNull.Value;
            }
            Personas.IdCargo.ViewCustomAttributes = "";

            // Documento
                Personas.Documento.ViewValue = Personas.Documento.CurrentValue;
            Personas.Documento.ViewCustomAttributes = "";

            // Persona
                Personas.Persona.ViewValue = Personas.Persona.CurrentValue;
            Personas.Persona.ViewCustomAttributes = "";

            // Activa
            if (Convert.ToString(Personas.Activa.CurrentValue) == "1") {
                Personas.Activa.ViewValue = (Personas.Activa.FldTagCaption(1) != "") ? Personas.Activa.FldTagCaption(1) : "Y";
            } else {
                Personas.Activa.ViewValue = (Personas.Activa.FldTagCaption(2) != "") ? Personas.Activa.FldTagCaption(2) : "N";
            }
            Personas.Activa.ViewCustomAttributes = "";

            // View refer script
            // IdArea

            Personas.IdArea.LinkCustomAttributes = "";
            Personas.IdArea.HrefValue = "";
            Personas.IdArea.TooltipValue = "";

            // IdCargo
            Personas.IdCargo.LinkCustomAttributes = "";
            Personas.IdCargo.HrefValue = "";
            Personas.IdCargo.TooltipValue = "";

            // Documento
            Personas.Documento.LinkCustomAttributes = "";
            Personas.Documento.HrefValue = "";
            Personas.Documento.TooltipValue = "";

            // Persona
            Personas.Persona.LinkCustomAttributes = "";
            Personas.Persona.HrefValue = "";
            Personas.Persona.TooltipValue = "";

            // Activa
            Personas.Activa.LinkCustomAttributes = "";
            Personas.Activa.HrefValue = "";
            Personas.Activa.TooltipValue = "";

            //
            //  Add Row
            //

            } else if (Personas.RowType == EW_ROWTYPE_ADD) { // Add row

            // IdArea
            Personas.IdArea.EditCustomAttributes = "";
            if (ew_NotEmpty(Personas.IdArea.SessionValue)) {
                Personas.IdArea.CurrentValue = Personas.IdArea.SessionValue;
            if (ew_NotEmpty(Personas.IdArea.CurrentValue)) {
                sFilterWrk = "[IdArea] = " + ew_AdjustSql(Personas.IdArea.CurrentValue) + "";
            sSqlWrk = "SELECT [Area], [Codigo] FROM [dbo].[Areas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Area]";
                drWrk = Conn.GetTempDataReader(sSqlWrk);
                if (drWrk.Read()) {
                    Personas.IdArea.ViewValue = drWrk["Area"];
                    Personas.IdArea.ViewValue = String.Concat(Personas.IdArea.ViewValue, ew_ValueSeparator(0, 1, Personas.IdArea), drWrk["Codigo"]);
                } else {
                    Personas.IdArea.ViewValue = Personas.IdArea.CurrentValue;
                }
                Conn.CloseTempDataReader();
            } else {
                Personas.IdArea.ViewValue = System.DBNull.Value;
            }
            Personas.IdArea.ViewCustomAttributes = "";
            } else {
            sFilterWrk = "";
            sSqlWrk = "SELECT [IdArea], [Area] AS [DispFld], [Codigo] AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[Areas]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Area]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            ((OrderedDictionary)alwrk[0]).Add("2", "");
            Personas.IdArea.EditValue = alwrk;
            }

            // IdCargo
            Personas.IdCargo.EditCustomAttributes = "";
            sFilterWrk = "";
            sSqlWrk = "SELECT [IdCargo], [Cargo] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld] FROM [dbo].[Cargos]";
            sWhereWrk = "";
            if (sFilterWrk != "") {
                if (sWhereWrk != "") sWhereWrk += " AND ";
                sWhereWrk += "(" + sFilterWrk + ")";
            }
            if (sWhereWrk != "") sSqlWrk += " WHERE " + sWhereWrk;
            sSqlWrk += " ORDER BY [Cargo]";
            alwrk = Conn.GetRows(sSqlWrk);
            alwrk.Insert(0, new OrderedDictionary());
            ((OrderedDictionary)alwrk[0]).Add("0", "");
            ((OrderedDictionary)alwrk[0]).Add("1",  Language.Phrase("PleaseSelect"));
            Personas.IdCargo.EditValue = alwrk;

            // Documento
            Personas.Documento.EditCustomAttributes = "";
            Personas.Documento.EditValue = ew_HtmlEncode(Personas.Documento.CurrentValue);

            // Persona
            Personas.Persona.EditCustomAttributes = "";
            Personas.Persona.EditValue = ew_HtmlEncode(Personas.Persona.CurrentValue);

            // Activa
            Personas.Activa.EditCustomAttributes = "";
            alwrk = new ArrayList();
            odwrk = new OrderedDictionary();
            odwrk.Add("0", "1");
            odwrk.Add("1", (ew_NotEmpty(Personas.Activa.FldTagCaption(1))) ? Personas.Activa.FldTagCaption(1) : "Si");
            alwrk.Add(odwrk);
            odwrk = new OrderedDictionary();
            odwrk.Add("0", "0");
            odwrk.Add("1", (ew_NotEmpty(Personas.Activa.FldTagCaption(2))) ? Personas.Activa.FldTagCaption(2) : "No");
            alwrk.Add(odwrk);
            Personas.Activa.EditValue = alwrk;

            // Edit refer script
            // IdArea

            Personas.IdArea.HrefValue = "";

            // IdCargo
            Personas.IdCargo.HrefValue = "";

            // Documento
            Personas.Documento.HrefValue = "";

            // Persona
            Personas.Persona.HrefValue = "";

            // Activa
            Personas.Activa.HrefValue = "";
            }
            if (Personas.RowType == EW_ROWTYPE_ADD ||
            Personas.RowType == EW_ROWTYPE_EDIT ||
            Personas.RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
            Personas.SetupFieldTitles();
            }

            // Row Rendered event
            if (Personas.RowType != EW_ROWTYPE_AGGREGATEINIT)
            Personas.Row_Rendered();
        }
 /// <summary>
 /// Inserts an object into the chain at a specific index.
 ///
 /// Warning: object must be a NeoPixel instance
 /// </summary>
 /// <param name="index">index of the insertion</param>
 /// <param name="value">object to be inserted</param>
 public void Insert(int index, object value)
 {
     pixels.Insert(index, value);
 }
Example #57
0
	/// <summary>
	/// Pause all iTweens in scene of a particular type.
	/// </summary>
	/// <param name="type">
	/// A <see cref="System.String"/> name of the type of iTween you would like to pause.  Can be written as part of a name such as "mov" for all "MoveTo" iTweens.
	/// </param> 
	public static void Pause(string type){
		ArrayList pauseArray = new ArrayList();
		
		for (int i = 0; i < tweens.Count; i++) {
			Hashtable currentTween = tweens[i];
			GameObject target = (GameObject)currentTween["target"];
			pauseArray.Insert(pauseArray.Count,target);
		}
		
		for (int i = 0; i < pauseArray.Count; i++) {
			Pause((GameObject)pauseArray[i],type);
		}
	}		
Example #58
0
 public void Insert(int index, object value)
 {
     list.Insert(index, value);
 }
Example #59
0
    /* GFX47 MOD START */
    /// <summary>
    /// Stop and destroy all iTweens in current scene of a particular name.
    /// </summary>
    /// <param name="name">
    /// The <see cref="System.String"/> name of iTween you would like to stop.
    /// </param> 
    public static void StopByName(string name)
    {
        ArrayList stopArray = new ArrayList();

        for (int i = 0; i < tweens.Count; i++) {
            Hashtable currentTween = (Hashtable)tweens[i];
            GameObject target = (GameObject)currentTween["target"];
            stopArray.Insert(stopArray.Count,target);
        }

        for (int i = 0; i < stopArray.Count; i++) {
            StopByName((GameObject)stopArray[i],name);
        }
    }
Example #60
0
        static void Main(string[] args)
        {
            ICollection coll = new int[] { 6, 7, 8, 9 };

            ArrayList arr = new ArrayList();

            arr.Add(5); //boxing is happening
            arr.AddRange(coll);
            arr.Insert(0, 4);
            Console.WriteLine("Element fof Array");
            foreach (var a in arr)
            {
                Console.WriteLine(a);
            }

            Console.WriteLine("Capavcity :{0}", arr.Capacity);
            ArrayList objClone = (ArrayList)arr.Clone();  //Creates a shallow copy of object

            Console.WriteLine("After Cloni9ng");
            foreach (var v in objClone)
            {
                Console.WriteLine(v);
            }


            Console.WriteLine("It contains after using contains : {0}", arr.Contains(5));


            Console.WriteLine("It counts : {0}", arr.Count);

            Console.WriteLine("Index of arr elemnet : {0}", arr.IndexOf(7));

            Console.WriteLine("Inserting an elemnt in arr : ");
            arr.Insert(2, 5);

            Console.WriteLine("Removing an element of arr : ");
            arr.Remove(6);


            arr.InsertRange(1, new int[] { 12, 99, 98, 97, 34, 4 });
            foreach (var z in arr)
            {
                Console.WriteLine(z);
            }

            Console.WriteLine("remove range");
            arr.RemoveRange(2, 3);
            foreach (var a in arr)
            {
                Console.WriteLine(a);
            }
            Console.WriteLine("-------------------------");
            arr.GetRange(2, 5);



            Array a1 = new int[arr.Count];

            Console.WriteLine("copying element");
            arr.CopyTo(a1);
            foreach (var v in a1)
            {
                Console.WriteLine(v);
            }


            Console.WriteLine("=======================");
            Console.WriteLine("Viewing the contents of the Arraylist using GetEnumerator......");
            IEnumerator en = arr.GetEnumerator();

            while (en.MoveNext())
            {
                Console.WriteLine(en.Current);
            }

            ArrayList myList = new ArrayList();

            myList.Add(23);
            myList.Add(45);
            myList.Add(12);
            myList.Add(5);
            myList.Add(43);
            myList.Add(78);

            foreach (int res in myList)
            {
                Console.WriteLine(res);
            }

            ArrayList newArr = new ArrayList();

            newArr.Add(45);
            newArr.Add("hello");
            newArr.Add('s');
            newArr.Add(3444.45);
            newArr.Add(true);
            foreach (var item in newArr)
            {
                Console.WriteLine(item);
            }
            //newArr.Sort();//runtime error


            Console.WriteLine("Using a generic Collection List Similar to ArrayList");

            List <int> list = new List <int>();

            list.Add(56);
            list.Add(21);
            list.Add(7);
            list.Add(14);
            list.Add(21);
            list.Add(28);
            list.Add(35);
            int findRes = list.Find(x => x.Equals(21));

            foreach (int i in list)
            {
                Console.WriteLine(i);
            }

            List <string> slist = new List <string>();

            Console.WriteLine("Finding 21 in the list:{0} ", findRes);
            slist.Add("break now?");

            //slist.


            Console.Read();
        }