Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var myList = new MyList<int>();

            int cnt = 11;
            for (int i = 0; i < cnt; i++)
            {
                myList.Add(i);
            }

            Console.WriteLine("List of elements: ");
            foreach (var item in myList)
            {
                Console.Write("{0}  ", item);
            }
            Console.WriteLine("| Count = {0}", myList.Count);

            myList.RemoveAt(5);
            myList.RemoveAt(5);
            myList.RemoveAt(5);

            Console.WriteLine("\nList of elements with removed elements: ");
            foreach (var item in myList)
            {
                Console.Write("{0}  ", item);
            }
            Console.WriteLine("| Count = {0}", myList.Count);

            Console.WriteLine("\nElement with index = 3:  {0}", myList[3]);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MyList<int> generic_int = new MyList<int>();
            generic_int.Add(-1);
            generic_int.Add(2);
            generic_int.Add(3);

            MyList<float> genfloat = new MyList<float>();
            genfloat.Add(2.45f);
            genfloat.Add(2.46f);
            genfloat.Add(2.47f);
            genfloat.Add(2.48f);
            genfloat.Add(2.49f);
            Console.WriteLine("Друкуемо раз:");
            foreach (var item in generic_int)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine("Друкуемо два:");
            foreach (var item in genfloat)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine(generic_int.IndexOf(2));
            generic_int.Remove(2);
            Console.WriteLine(generic_int.IndexOf(2));
            Console.WriteLine("Писля удаления:");
            foreach (var item in generic_int)
            {
                Console.WriteLine(item);
            }

        }
Ejemplo n.º 3
0
  public static void Main(String[] args) 
  {
    Console.WriteLine ("Fill MyList object with content\n");
    MyList l = new MyList();
    for (int x=0; x< 10; x++) 
    {
      Console.WriteLine (x);
      l.Add (x);
    } // end for
    Console.WriteLine("\nSerializing object graph to file {0}", FILENAME);
    Stream outFile = File.Open(FILENAME, FileMode.Create, FileAccess.ReadWrite);
    BinaryFormatter outFormat = new BinaryFormatter();
    outFormat.Serialize(outFile, l);
    outFile.Close();
    Console.WriteLine("Finished\n");

    Console.WriteLine("Deserializing object graph from file {0}", FILENAME);
    Stream inFile = File.Open(FILENAME, FileMode.Open, FileAccess.Read);
    BinaryFormatter inFormat = new BinaryFormatter();
    MyList templist = (MyList)inFormat.Deserialize(inFile);
    Console.WriteLine ("Finished\n");
    
    foreach (MyListItem mli in templist) 
    {
      Console.WriteLine ("List item number {0}, square root {1}", mli.Number, mli.Sqrt);
    } //foreach

    inFile.Close();
  } // end main
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            MyList<string> test = new MyList<string>(7);
            test.Add("lol0");
            test.Add("lol2");
            test.Add("lol1");
            Console.WriteLine("lol0 "+test.GetElementByIndex(0));
            Console.WriteLine("lol2 " + test.GetElementByIndex(1));
            Console.WriteLine("lol1 " + test.GetElementByIndex(2));
            Console.WriteLine("lol1 " + test.GetLastElement());
            test.RemoveLastElement();
            Console.WriteLine("lol2 " + test.GetLastElement());
            Console.WriteLine("2 "+test.getCount());
            test.RemoveFirstElement();
            Console.WriteLine("lol2 "+test.GetLastElement());
            Console.WriteLine("1 "+test.getCount());
            test.InsertElementAt(0, "lol2");
            Console.WriteLine("lol2 " + test.GetLastElement());
            test.InsertElementAt(1, "lol3");
            test.InsertElementAt(1, "lol4");
            Console.WriteLine("4 " +test.getCount());
            test.RemoveLastElement();
            Console.WriteLine("lol3 "+test.GetLastElement());
            test.RemoveLastElement();
            Console.WriteLine("lol4 " + test.GetLastElement());

            foreach (var item in test)
            {
                Console.WriteLine(item);
            }

            Console.Read();
        }
Ejemplo n.º 5
0
 public void testAs4()
 {
     var x = new MyList();
     AssertNotNull(AsIEnumerable(x));
     AssertNotNull(AsICollection(x));
     AssertNotNull(AsIList(x));
 }
Ejemplo n.º 6
0
 static void Main(string[] args)
 {
     MyList<int> List = new MyList<int>();
     List.AddElem(10);
     List.AddElem(15);
     List.AddElem(20);
 }
Ejemplo n.º 7
0
        private void A43_Load(object sender, EventArgs e)
        {
            if (this.DesignMode)
            {
                return;
            }

            MyList<string> list = new MyList<string>();
            list.Add(isPT() ? "Gasolina" : "Nafta");
            list.Add(isPT() ? "Diesel" : "Diesel");
            list.Add(isPT() ? "GLP/ Gas Licuado de Petróleo más nafta" : "GLP/Gás de petróleo liquefeito mais gasolina");
            list.Add(isPT() ? "GNV/Gás Natural Veicular mais gasolina" : "GNC/ Gas Natural Comprimido más nafta");
            list.Add(isPT() ? "GNV/Gás Natural Veicular" : "GNC/ Gas natural Comprimido");
            list.Add(isPT() ? "GNV/Gás Natural Veicular mais diesel" : "GNC/ Gas Natural Comprimido másdiesel");
            list.Add(isPT() ? "Flex-fuel total flex: etanol e gasolina ou uma mistura dos dois" : "Combustible flexible (Flex Fuel)/vehículo totalflex: etanol y nafta ouna mezcla delas anteriores");
            list.Add(isPT() ? "Biodiesel" : "Biodiesel");
            list.Add(isPT() ? "Bioetanol" : "Bioetanol");

            list.Add(isPT() ? "Motor totalmente elétrico" : "Transmisióntotalmente eléctrica");
            list.Add(isPT() ? "Motor híbrido combinado com diesel" : "Motor híbrido combinado con diesel");
            list.Add(isPT() ? "Motor híbrido combinado com gasolina" : "Motor híbrido combinado con nafta");
            list.Add(isPT() ? "Célula de combustível" : "Pila de combustible");

            MyList<string> listVisiveis = new MyList<string>();

            listVisiveis.AddRange(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14" });

            class_A.Lista = list;
            class_A.Visiveis = listVisiveis;
        }
Ejemplo n.º 8
0
 public void testIs4()
 {
     var x = new MyList();
     AssertTrue(IsIEnumerable(x));
     AssertTrue(IsICollection(x));
     AssertTrue(IsIList(x));
 }
Ejemplo n.º 9
0
        private void A37_Load(object sender, EventArgs e)
        {
            if (this.DesignMode)
            {
                return;
            }
            string msg = isPT() ? String.Format("Com que tipo de gasolina o(a) Sr(a). geralmente abastece seu {0}?", rowCurrent["A4_A_NOME"]) : String.Format("¿Con qué tipo de nafta reabastece normalmente su {0}?", rowCurrent["A4_A_NOME"]);
            Label3.Text = msg;

            MyList<string> list = new MyList<string>();
            list.Add(isPT() ? "Petrobras: 101.5 octanas" : "Petrobras: 101.5 octanos");
            list.Add(isPT() ? "YPF fangio XXI: 98 octanas" : "YPF fangio XXI: 98 octanos");
            list.Add(isPT() ? "SHELL V-Power: 97,5 octanas" : "SHELL V-Power: 97.5 octanos");
            list.Add(isPT() ? "SUPER: 93,5 a 95 octanas" : "SUPER: 93.5 a 95 octanos");
            list.Add(isPT() ? "Comum: 83 a 85 octanas" : "Común: 83 a85 octanos");
            list.Add(isPT() ? "Gasolina comum: 87 octanas" : "Nafta común: 87 octanos");
            list.Add(isPT() ? "Gasolina Aditiva Supra: 87 octanas (+ aditivos)" : "Nafta Aditiva Supra: 87 octanos (+ aditivitos)");
            list.Add(isPT() ? "Gasolina Premium: 91 octanas" : "Nafta Premium: 91 octanos");
            list.Add(isPT() ? "Gasolina Podium: 95 octanas" : "NaftaPodium: 95 octanos");

            MyList<string> listVisiveis = new MyList<string>();

            if (isPT())
            {
                listVisiveis.AddRange(new string[] { "6", "7", "8", "9"});
            }
            else
            {
                listVisiveis.AddRange(new string[] { "1", "2", "3", "4", "5"});
            }

            //listVisiveis.Shuffle();
            class_A.Lista = list;
            class_A.Visiveis = listVisiveis;
        }
Ejemplo n.º 10
0
 public void should_Add_Single_Item_To_MyList_Instance()
 {
     var myList = new MyList();
     myList.Add(1);
     Assert.AreEqual(1,myList.Count);
     Assert.AreEqual(1,myList.Capacity);
 }
Ejemplo n.º 11
0
        //public void OutputResults(ResultCollection res)
        //{
        //    int count = 0;
        //    foreach (Results r in res.ResultSet)
        //    {
        //        Console.WriteLine("Result set {0}", ++count);
        //        Console.WriteLine("Permutuations: {0}", r.Permutations);
        //        foreach (Line l in r.Lines)
        //        {
        //            Console.Write("Line: ");
        //            foreach (MyPoint p in l.Points)
        //            {
        //                Console.Write("({0}, {1}) ", p.X, p.Y);
        //            }
        //            Console.WriteLine();
        //        }
        //        Console.WriteLine();
        //    }
        //    Console.Read();
        //}
        public void OutputResults2(MyList<MyPoint> set1, ResultCollection2 res)
        {
            int count = 0;
            for (int k = 0; k < res.ResultSet.Count; k++)
            {
                Results2 r = res.ResultSet[k];
                Console.WriteLine("Result set {0}", ++count);
                Console.WriteLine("Permutuations: {0}", r.Permutations);
                int c = r.Count;
                for (int j = 0; j < c; j++)
                {
                    ItemSet l = r.GetLine(j);
                    if (r.Count == 1)
                    {
                        Console.WriteLine("Emergency");
                    }
                    Console.Write("Line: ");

                    for (int i = 0; i < l.Count; i++)
                    {
                        Console.Write("({0}, {1}) ", l.GetItem(set1, i).X, l.GetItem(set1, i).Y);
                    }

                    Console.WriteLine();
                }
                Console.WriteLine();
            }
            Console.Read();
        }
Ejemplo n.º 12
0
        private void A36_Load(object sender, EventArgs e)
        {
            if (this.DesignMode)
            {
                return;
            }
            string msg = isPT() ? String.Format("Seu {0} é movido a que combustível?", rowCurrent["A4_A_NOME"]) : String.Format("¿Qué de combustible usa el motor de su {0}?", rowCurrent["A4_A_NOME"]);
            Label3.Text = msg;

            MyList<string> list = new MyList<string>();
            list.Add(isPT() ? "Gasolina" : "Nafta");
            list.Add(isPT() ? "Diesel" : "Diesel");
            list.Add(isPT() ? "GLP/ Gás de petróleo liquefeito mais gasolina " : "GLP/Gas Licuado de Petróleo más nafta");
            list.Add(isPT() ? "GNV ou Gás Natural Veicular mais gasolina" : "GNC/Gas Natural Comprimido más nafta");
            list.Add(isPT() ? "GNV ou Gás Natural Veicular" : "GNC/Gas Natural Comprimido");
            list.Add(isPT() ? "CNG/Compressed Natural Gasplus diesel" : "GNC/Gas Natural Comprimido");
            list.Add(isPT() ? "Flex / total flex: etanol e gasolina ou uma mistura dos dois" : "Combustible flexible (Flex fuel)/vehículo total flex: etanoly nafta o una mezcla de los mismos");
            list.Add(isPT() ? "Triflex/ Multiflex/ Nafta, gas más alcohol" : "Triflex/ Multiflex/ Nafta, gas más alcohol");

            MyList<string> listVisiveis = new MyList<string>();

            if (isPT())
            {
                listVisiveis.AddRange(new string[] { "1", "2", "4", "5", "7", "8", "9", "10", "11"});
            }
            else {
                listVisiveis.AddRange(new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" });
            }

            //listVisiveis.Shuffle();
            class_A.Lista = list;
            class_A.Visiveis = listVisiveis;
        }
Ejemplo n.º 13
0
        public void Test13Second()
        {
            MyList<MyPoint> set1 = new MyList<MyPoint>();
            set1.Add(new MyPoint(8, 4));
            set1.Add(new MyPoint(9, 6));
            set1.Add(new MyPoint(1, 6));
            set1.Add(new MyPoint(2, 6));
            set1.Add(new MyPoint(5, 6));
            set1.Add(new MyPoint(3, 6));
            set1.Add(new MyPoint(6, 6));
            set1.Add(new MyPoint(7, 5));
            set1.Add(new MyPoint(8, 5));
            set1.Add(new MyPoint(3, 7));
            set1.Add(new MyPoint(6, 4));
            set1.Add(new MyPoint(6, 5));
            set1.Add(new MyPoint(2, 5));

            ResultCollection2 res = Solution.CalculatePoints(set1).GetBestSet(4);
            int val = res.ResultSet.Count;
            int permute = 0;
            Assert.IsTrue(val > 0);
            int c = res.ResultSet[0].Count;
            for (int i = 0; i < val; ++i)
            {
                Assert.AreEqual(c, res.ResultSet[i].Count, "Result sets are not all the same size");
                permute += res.ResultSet[i].Permutations;
            }

            Assert.AreEqual(36, val);
            Assert.AreEqual(864, permute);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Вернет список бьющихся фигур на проходе
        /// </summary>
        /// <returns></returns>
        public MyList<Position> GetInMoveAttacks()
        {
            int delta = (Side == Side.Black) ? +1 : -1;
            Position pos;
            Side oppside = GetEnemySide();
            Figure fig;
            MyList<Position> moves = new MyList<Position>();
            foreach (Position attack in GetAttacks())
            {
                try{
                    pos = new Position(attack.GetX(), attack.GetY() + delta);
                    fig = chessfield.GetFigureAt(pos);
                    if (fig != null && fig.GetFigureType() == FigureTypes.Pawn &&
                        fig.Side == oppside &&
                        chessfield.GetlastMoved(oppside) == fig)
                        moves.Add(pos);
                    {

                    }

                }
                catch {}

            }
            return moves;
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            MyList<int> mylist = new MyList<int>();
            mylist.Add(213);
            mylist.Add(13);
            mylist.Add(1);
            mylist.Add(23);
            mylist.Insert(1,2);
            mylist.RemoveAt(4);
            mylist[0] = 100;
            for (int i = 0; i < mylist.Count; i++)
            {
                //Console.WriteLine(mylist.GetItem(i));
                Console.WriteLine(mylist[i]);
            }
            Console.WriteLine(mylist.IndexOf(13));
            Console.WriteLine(mylist.LastIndexOf(2));
            mylist.Sort();
            for (int i = 0; i < mylist.Count; i++)
            {
                //Console.WriteLine(mylist.GetItem(i));
                Console.WriteLine(mylist[i]);
            }

            Console.ReadKey();
        }
Ejemplo n.º 16
0
        public void Test16First()
        {
            MyList<MyPoint> set1 = new MyList<MyPoint>();
            set1.Add(new MyPoint(1, 6));
            set1.Add(new MyPoint(2, 6));
            set1.Add(new MyPoint(5, 6));
            set1.Add(new MyPoint(3, 6));
            set1.Add(new MyPoint(2, 5));
            set1.Add(new MyPoint(3, 5));
            set1.Add(new MyPoint(5, 5));
            set1.Add(new MyPoint(3, 4));
            set1.Add(new MyPoint(3, 7));
            set1.Add(new MyPoint(6, 4));
            set1.Add(new MyPoint(6, 5));
            set1.Add(new MyPoint(6, 6));
            set1.Add(new MyPoint(7, 5));
            set1.Add(new MyPoint(8, 5));
            set1.Add(new MyPoint(8, 4));
            set1.Add(new MyPoint(9, 6));

            ResultCollection2 res = Solution.CalculatePoints(set1);
            int val = res.ResultSet.Count;
            int permute = 0;
            Assert.IsTrue(val > 0);
            int c = res.ResultSet[0].Count;
            for (int i = 0; i < val; ++i)
            {
                Assert.AreEqual(c, res.ResultSet[i].Count);
                permute += res.ResultSet[i].Permutations;
            }

            Assert.AreEqual(8, val);
            Assert.AreEqual(192, permute);
        }
Ejemplo n.º 17
0
 public void DeleteBadTest()
 {
     MyList<int> list = new MyList<int>();
     list.AddToHead(10);
     list.AddToHead(9);
     list.Delete(4);
 }
Ejemplo n.º 18
0
 public void ClearTest()
 {
     MyList<int> list = new MyList<int>();
     list.AddToHead(10);
     list.Clear();
     Assert.IsTrue(list.Size() == 0);
 }
Ejemplo n.º 19
0
 private void SetUpList()
 {
     List = new MyList
     {
         CreateModel()
     };
 }
Ejemplo n.º 20
0
 public override MyList<Position> GetAttacks()
 {
     MyList<Position> l = new MyList<Position>();
     foreach (MovePolitics mp in attackpolitics)
             l.AddRange(mp.GetMoves(this, chessfield));
     return l;
 }
Ejemplo n.º 21
0
        public MyList<Position> GetCastling()
        {
            MyList<Position> castling = new MyList<Position>();
            Figure fig;
            int x = Position.GetX();
            if (ismoved())
                return castling;
            Side oppside = GetEnemySide();
            int ypos = (this.Side == Side.White) ? 1 : 8;
            if (chessfield.isDangerPosition(oppside, Position))
                return castling;

            fig = chessfield.GetFigureAt(new Position(1, ypos));
            if (fig != null &&
                !chessfield.isDangerPosition(oppside, new Position(x-1,ypos))    &&
                !chessfield.isDangerPosition(oppside, new Position(x - 2, ypos)) &&
                !chessfield.isDangerPosition(oppside, new Position(x - 3, ypos)) &&
                !chessfield.isDangerPosition(oppside, new Position(x, ypos)) &&
                !fig.ismoved() &&
                chessfield.GetFigureAt(new Position(2, ypos)) == null &&
                chessfield.GetFigureAt(new Position(3, ypos)) == null &&
                chessfield.GetFigureAt(new Position(4, ypos)) == null)
                                castling.Add(fig.Position);

             fig = chessfield.GetFigureAt(new Position(8, ypos));
             if (fig != null &&
                 !chessfield.isDangerPosition(oppside, new Position(x + 1, ypos)) &&
                 !chessfield.isDangerPosition(oppside, new Position(x + 2, ypos)) &&
                 !chessfield.isDangerPosition(oppside, new Position(x, ypos)) &&
                 !fig.ismoved() &&
                 chessfield.GetFigureAt(new Position(7, ypos)) == null &&
                 chessfield.GetFigureAt(new Position(6, ypos)) == null)
                    castling.Add(fig.Position);
            return castling;
        }
Ejemplo n.º 22
0
 public void AddTest()
 {
     var controlList = new System.Collections.Generic.List<int>();
     var testList = new MyList<int>();
     controlList.Add(1);
     testList.Add(1);
     Assert.AreEqual(controlList.Count, testList.Count);
 }
Ejemplo n.º 23
0
 public void DeleteGoodTest()
 {
     MyList<int> list = new MyList<int>();
     list.AddToHead(10);
     list.AddToHead(9);
     list.Delete(0);
     Assert.IsTrue(list.ReturnByIndex(0) == 10);
 }
Ejemplo n.º 24
0
        static void Main(string[] args)
        {
            var list = new List<int> { 5, 6, 7, 22 };
            Print(list);

            var MyList = new MyList<int>();
               // Print(MyList);
        }
 public static void TestClear(MyList<int> Inlist)
 {
     Inlist.Add(1);
     Inlist.Add(2);
     Inlist.Add(3);
     Inlist.Clear();
     Debug.Assert(Inlist.numItems == 0);
 }
Ejemplo n.º 26
0
        public void ListRNDTest()
        {
            var controlList = new System.Collections.Generic.List<int>();
            var testList = new MyList<int>();

            var r = new System.Random();
            for (int i = 0; i < 1000; i++)
            {
                var next = r.Next();
                controlList.Add(next);
                testList.Add(next);
                Assert.AreEqual(controlList.Count, testList.Count);
            }
            for (int i = 0; i < 1000; i++)
            {
                Assert.IsTrue(testList.IndexOf(controlList[i]) == i);
            }
            for (int i = 0; i < controlList.Count; i++)
            {
                if (r.Next() < int.MaxValue / 2)
                {
                    testList.RemoveAt(i);
                    controlList.RemoveAt(i);
                }
                else
                {
                    var newItem = r.Next();
                    testList.Insert(i, newItem);
                    controlList.Insert(i, newItem);
                }
            }
            Assert.AreEqual(controlList.Count, testList.Count);

            foreach (var itm in controlList){
                Assert.IsTrue(testList.Contains(itm));
            }
            for (int i = 0; i < controlList.Count / 2; i++ )
            {
                var e = controlList[i];
                controlList.Remove(e);
                testList.Remove(e);
            }
            int[] controllarray = new int[controlList.Count+1];
            int[] testArray = new int[testList.Count+1];
            controllarray[0] = r.Next();
            testArray[0] = controllarray[0];
            controlList.CopyTo(controllarray, 1);
            testList.CopyTo(testArray, 1);

            var q = from a in testArray
                    join b in controllarray on a equals b
                    select a;

            Assert.IsTrue(testArray.Length == controllarray.Length && q.Count() == controllarray.Length);
            controlList.Clear();
            testList.Clear();
            Assert.AreEqual(controlList.Count,testList.Count);
        }
Ejemplo n.º 27
0
        public void InsertAfterTest()
        {
            MyList<int> list1 = new MyList<int>();
            list1.InsertAsLast(10);
            list1.InsertAfter(list1.First(), 11);

            Assert.IsTrue(list1.Size() == 2);
            Assert.IsTrue(list1.Last().Data == 11);
        }
Ejemplo n.º 28
0
 public void B001TestMethod1()
 {
     var s = new XSerializer(typeof(MyList));
     var list = new MyList { 1, 2, 3 };
     var doc = s.GetSerializedDocument(list);
     Trace.WriteLine(doc);
     var list1 = (MyList)s.Deserialize(doc, null);
     Assert.AreEqual(list1.Count, list.Count);
 }
Ejemplo n.º 29
0
        public void DisorderedTest()
        {
            MyList<int> list1 = new MyList<int>();
            list1.InsertAsFirst(10);
            list1.InsertAsFirst(11);
            list1.InsertAsFirst(12);

            Assert.IsFalse(list1.Disordered());
        }
Ejemplo n.º 30
0
        public void FirstTest()
        {
            MyList<int> list1 = new MyList<int>();
            list1.InsertAsLast(10);
            list1.InsertAsLast(11);
            list1.InsertAsLast(12);

            Assert.IsTrue(list1.First().Data == 10);
        }
    public static void Main()
    {
        MyList <string> names = new MyList <string> ();

        names.AddAll <string> ();
    }
Ejemplo n.º 32
0
 public Wrapper(MyList list)
 {
     this.list = list;
 }
    static void Main(string[] args)
    {
        bool b;

        /////////
        // Arrays

        // NOT OK: always true
        b = args.Length >= 0;

        // NOT OK: always true
        b = 0 <= args.Length;

        // NOT OK: always false
        b = args.Length < 0;

        // NOT OK: always false
        b = 0 > args.Length;

        // OK: sometimes could be false
        b = args.Length > 0;

        // OK: sometimes could be false
        b = 0 < args.Length;

        // OK: sometimes could be true
        b = args.Length <= 0;

        // OK: sometimes could be true
        b = 0 >= args.Length;

        /////////
        // Containers
        var xs = new MyList2 <int>();
        var ys = new Stack <string>();

        // NOT OK
        b = xs.Count >= 0;
        b = 0 <= xs.Count;
        b = 0 <= ys.Count;

        b = xs.Count < 0;
        b = 0 > ys.Count;

        // OK
        b = xs.Count >= -1;

        // OK
        b = 0 < xs.Count;

        /////////
        // missed in java, but not here

        b = xs.Count >= (short)0;
        b = xs.Count >= (byte)0;

        /////////
        // missed cases

        // NOT OK
        b = xs.Count >= 0 + 0;
        b = xs.Count >= 0 - 0;

        b = args.LongLength >= 0L;

        /////////
        // Nested Containers
        var zs = new MyList <List <string> >();

        // NOT OK
        b = zs.Count >= 0;
        b = zs.Count < 0;

        // NOT OK
        b = zs[0].Count >= 0;

        // NOT OK
        b = zs[0][0].Length >= 0;

        /////////
        // Dictionaries
        var ws = new Dictionary <int, string>();

        // NOT OK: Always true
        b = ws.Count >= 0;

        // NOT OK: Always true
        b = 0 <= ws.Count;

        // OK: can be false
        b = ws.Count >= -1;

        // OK: can be false
        b = 0 < ws.Count;

        /////////
        // Non-generic containers/dictionaries

        var us = new System.Collections.Hashtable();
        var vs = new System.Collections.BitArray(1);

        // NOT OK: Always true
        b = us.Count >= 0;
        b = 0 > vs.Count;

        // NOT OK: Always true
        b = 0 <= us.Count;
        b = vs.Count < 0;

        // OK: can be false
        b = us.Count >= -1;
        b = vs.Count >= -1;

        // OK: can be false
        b = 0 < us.Count;
        b = 0 < vs.Count;
    }
 private void AddEmpty_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     MyList.Add(new MyClass("", DateTime.Now));
 }
        private async Task <string> postUserImage(MyFile imageFile)
        {
            MyList <string>    fileKey;
            MyList <MyFile>    files;
            ApiClient          client = ApiUtil.Instance.vClient;
            ApiRequestBuilder  requestBuilder;
            ApiRequestBundle   requestBundle;
            HttpResponseBundle responseBundle = null;

            if (imageFile == null)
            {
                return(null);
            }

            fileKey = new MyList <string>()
            {
                "image"
            };
            files = new MyList <MyFile>()
            {
                imageFile
            };
            requestBuilder = new ApiRequestBuilder()
                             .buildMultipartRequest(new MultiPartContent(files, fileKey))
                             .setRequestMethod(HttpMethod.Post)
                             .setEndpoint("users/image");
            requestBundle = requestBuilder.getApiRequestBundle();
            client.setAuthorizationToken(StorageUtil.Instance.token);
            client.setOnSuccessRequest(null);
            client.setOnFailedRequest(null);
            try
            {
                responseBundle = await client.sendRequest(requestBundle);
            }
            catch (Exception e)
            {
                getView().callMethod("showErrorMessage",
                                     "Failed uploading image. " + e.Message);
            }

            if (responseBundle != null)
            {
                Trace.WriteLine("Response: \n" + responseBundle.getJObject().ToString());
                if (responseBundle.getHttpResponseMessage().IsSuccessStatusCode)
                {
                    if (responseBundle.getHttpResponseMessage().Content != null)
                    {
                        JObject responseJSON = responseBundle.getJObject();
                        JObject dataJSON     = (JObject)responseJSON["data"];
                        string  imagePath    = (string)dataJSON["path"];

                        return(imagePath);
                    }
                }
                else
                {
                    string reasonPhrase = responseBundle.getHttpResponseMessage().ReasonPhrase;

                    getView().callMethod("showErrorMessage",
                                         "Failed uploading image. Reason Phrase: " + reasonPhrase);
                }
            }

            return(null);
        }
 protected async override void OnAppearing()
 {
     base.OnAppearing();
     await MyList.ScaleTo(1, 250, Easing.Linear);
 }
Ejemplo n.º 37
0
        private void WriteJson()
        {
            string json = JsonConvert.SerializeObject(MyList.ToArray());

            File.WriteAllText(@"D:\AzurLaneAPIList.json", json);
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Add items to ComboBox.
 /// </summary>
 /// <param name="_item">A list of generic data type param.</param>
 /// <typeparam name="T"></typeparam>
 /// <returns>IMyComboBox</returns>
 public IMyComboBox addItems <T>(MyList <T> _item)
 {
     myComboBox_cbo.Items.Add(_item);
     myComboBox_cbo.SelectedIndex = 0;
     return(this);
 }
Ejemplo n.º 39
0
 private Engine()
 {
     this.addCollection       = new AddCollection();
     this.addRemoveCollection = new AddRemoveCollection();
     this.list = new MyList();
 }
 public void Setup()
 {
     myList = new MyList();
 }
Ejemplo n.º 41
0
        private void Pier_Process_Design_IS()
        {
            string file_path = Path.Combine(iApp.LastDesignWorkingFolder, Title);

            if (iApp.user_path != "")
            {
                file_path = Path.Combine(iApp.user_path, Title);
            }

            if (!Directory.Exists(file_path))
            {
                Directory.CreateDirectory(file_path);
            }

            //file_path = Path.Combine(file_path, "RCC Cantilever Abutment Design");

            //if (!Directory.Exists(file_path)) Directory.CreateDirectory(file_path);

            file_path = Path.Combine(file_path, "Pier with Pile Foundation IS.xlsm");

            //file_path = Path.Combine(file_path, "BoQ_Flyover_ROB_RUBs.xlsx");
            //file_path = Path.Combine(file_path, "BoQ for " + cmb_boq_item.Text + ".xlsx");

            string copy_path = file_path;

            file_path = Path.Combine(Application.StartupPath, @"DESIGN\Pier\Pier Design Limit State\Pier with Pile Foundation IS.xlsm");

            if (File.Exists(file_path))
            {
                File.Copy(file_path, copy_path, true);
            }
            else
            {
                MessageBox.Show(file_path + " file not found.");
                return;
            }


            //iApp.Excel_Open_Message();

            Excel.Application myExcelApp;
            Excel.Workbooks   myExcelWorkbooks;
            Excel.Workbook    myExcelWorkbook;

            object misValue = System.Reflection.Missing.Value;

            myExcelApp         = new Excel.ApplicationClass();
            myExcelApp.Visible = true;
            //myExcelApp.Visible = false;
            myExcelWorkbooks = myExcelApp.Workbooks;

            //myExcelWorkbook = myExcelWorkbooks.Open(fileName, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);

            myExcelWorkbook = myExcelWorkbooks.Open(copy_path, 0, false, 5, "2011ap", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

            //Excel.Worksheet myExcelWorksheet = (Excel.Worksheet)myExcelWorkbook.ActiveSheet;
            Excel.Worksheet EXL_INP = (Excel.Worksheet)myExcelWorkbook.Sheets["1. Lvl & Dim."];
            Excel.Worksheet EXL_DES = (Excel.Worksheet)myExcelWorkbook.Sheets["2.Design Paramters"];


            //List<TextBox> All_Data = Get_TextBoxes();

            List <TextBox> All_Data = MyList.Get_TextBoxes(this);

            //Excel.Range formatRange;
            //formatRange = myExcelWorksheet.get_Range("b" + (dgv.RowCount + after_indx), "L" + (dgv.RowCount + after_indx));
            //formatRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGreen);


            List <double> data = new List <double>();

            try
            {
                string kStr = "";
                foreach (var item in All_Data)
                {
                    if (item.Name.ToLower().StartsWith("txt_xls_inp_"))
                    {
                        kStr = item.Name.Replace("txt_xls_inp_", "");

                        //myExcelWorksheet.get_Range("E53").Formula = data[rindx++].ToString();
                        EXL_INP.get_Range(kStr).Formula = item.Text;
                    }

                    #region Input 2

                    else if (item.Name.ToLower().StartsWith("txt_xls_des_"))
                    {
                        kStr = item.Name.Replace("txt_xls_des_", "");
                        //myExcelWorksheet.get_Range("E53").Formula = data[rindx++].ToString();
                        EXL_DES.get_Range(kStr).Formula = item.Text;
                    }

                    #endregion Input 2
                }
            }
            catch (Exception exx) { }

            myExcelWorkbook.Save();

            releaseObject(myExcelWorkbook);

            //iApp.Excel_Open_Message();
        }
Ejemplo n.º 42
0
        void Load_Default_Data_Single_Cell()
        {
            //DataGridView dgv = dgv_input_data;

            List <string> list  = new List <string>();
            MyList        mlist = null;


            #region Base Pressure
            list.Add(string.Format("Number of cell in culvert$1$"));
            list.Add(string.Format("Clear Span$8.8$m"));
            list.Add(string.Format("Clear Height$7.6$m"));
            list.Add(string.Format("Overall width$12$m"));
            list.Add(string.Format("Carriageway width$11$m"));
            list.Add(string.Format("Crash barrier width$0.5$m"));
            list.Add(string.Format("Footpath width/ Safety kerb$0$m"));
            list.Add(string.Format("Minimum thickness of wearing coat$0.075$m"));
            list.Add(string.Format("Thickness of soil fill over Bottom slab$0$m"));
            list.Add(string.Format("lean concrete thickness over deck$0.000$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Width of Haunch$0.3$m"));
            list.Add(string.Format("Depth of Haunch$0.3$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Top slab thickness$0.70$m"));
            list.Add(string.Format("Bottom slab thickness$0.70$m"));
            list.Add(string.Format("Side wall thickness $0.65$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Safe Bearing Capacity$150$kN/m²"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Density of concrete$25$kN/m³"));
            list.Add(string.Format("unit weight of soil$18$kN/m³"));
            list.Add(string.Format("unit weight of submerged soil$10$kN/m³"));
            list.Add(string.Format("unit weight of wearing coat$22$kN/m³"));
            list.Add(string.Format("Grade of concrete$35$N/mm2"));
            list.Add(string.Format("Grade of reinforcement$500$N/mm2"));
            list.Add(string.Format("Length of the box considered for design$1$m"));
            list.Add(string.Format("Modulus of elasticity of concret$2.96E+04$N/m2"));
            list.Add(string.Format("Modulus of elasticity of Steel$2.00E+05$N/m2"));
            list.Add(string.Format("Permissible stresses$$"));
            list.Add(string.Format("Permissible Compressive stress in Concrete$11.5$Mpa"));
            list.Add(string.Format("Permissible Tensile stress in Steel$240$Mpa"));
            list.Add(string.Format("Modular ratio, m$6.76$"));
            list.Add(string.Format("factor, k$0.245$"));
            list.Add(string.Format("Lever arm factor, j$0.92$"));
            list.Add(string.Format("Moment resistance factor, R$1.29$Mpa"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Grade of shear reinforcement$500$"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Design Levels$$"));
            list.Add(string.Format("Formation road level$812.043$m"));
            list.Add(string.Format("Highest Flood level$810.56$m"));
            list.Add(string.Format("Lowest Water level$803$m"));
            list.Add(string.Format("Maximum Scour level$803$m"));
            list.Add(string.Format("Foundation level$802.899$m"));

            //dgv = dgv_input_data;



            MyList.Fill_List_to_Grid(dgv_design_data_single, list, '$');
            //dgv_base_pressure.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;


            #endregion Base Pressure

            //Modified_Cell(dgv_input_data);

            //if (dgv[2, i].Value == "") dgv[2, i].Value = "";
        }
Ejemplo n.º 43
0
 public T ConvertAll2(MyList <T> arg)
 {
     return(default(T));
 }
Ejemplo n.º 44
0
 /// <summary>
 /// Add many items.
 /// </summary>
 /// <param name="_listOfItem">A MyList of string param.</param>
 /// <returns></returns>
 public IMyListBox setItemsSource <T>(MyList <T> _listOfItem)
 {
     myListBox_lb.ItemsSource = _listOfItem;
     return(this);
 }
Ejemplo n.º 45
0
 public static MyList <A> Cons <A>(this A head, MyList <A> tail)
 {
     return(null);
 }
Ejemplo n.º 46
0
        private void Load_Channel_Sections_details(string name, string code, int opt)
        {
            MyList ml = new MyList(code, 'X');


            double ts = 0.0;

            if (name.EndsWith("A"))
            {
                ts   = ml.GetDouble(2);
                code = ml[0] + "X" + ml[1];
                foreach (var item in tbl_Angles.List_Table)
                {
                    if ((item.SectionName == name) && item.SectionSize == code && item.Thickness == ts)
                    {
                        if (Pro_Grid != null)
                        {
                            Pro_Grid.SelectedObject = item;
                        }

                        Area = item.Area;
                        tw   = item.Thickness;
                        Ixx  = item.Ixx;
                        Iyy  = item.Iyy;

                        break;
                    }
                }
            }



            foreach (var item in tbl_Channels.List_Table)
            {
                if ((item.SectionName == name) && item.SectionCode == code)
                {
                    if (Pro_Grid != null)
                    {
                        Pro_Grid.SelectedObject = item;
                    }

                    D    = item.Depth;
                    tw   = item.WebThickness;
                    Ixx  = item.Ixx;
                    Area = item.Area;
                    Iyy  = item.Iyy;

                    break;
                }
            }
            foreach (var item in tbl_Beams.List_Table)
            {
                if ((item.SectionName == name) && item.SectionCode == code)
                {
                    if (Pro_Grid != null)
                    {
                        Pro_Grid.SelectedObject = item;
                    }

                    D    = item.Depth;
                    tw   = item.WebThickness;
                    Ixx  = item.Ixx;
                    Area = item.Area;
                    Iyy  = item.Iyy;

                    break;
                }
            }
        }
 public MyListPage()
 {
     InitializeComponent();
     MyList.ScaleTo(0);
 }
Ejemplo n.º 48
0
        static void Main(string[] args)
        {
            MyList <string> isimler = new MyList <string>();

            isimler.Add("Engin");
        }
Ejemplo n.º 49
0
 private void a(object A_0, EventArgs A_1)
 {
     try
     {
         MyList <int> list = new MyList <int>(0x58);
         for (int i = 0; i < this.e.Count; i++)
         {
             if (!dh.b(this.e[i]))
             {
                 list.Add(this.e[i]);
                 if (i < this.c)
                 {
                     this.c--;
                 }
             }
         }
         foreach (int num2 in list)
         {
             if (this.e.Contains(num2))
             {
                 this.e.Remove(num2);
             }
             if (this.g.ContainsKey(num2))
             {
                 Dictionary <b0.a, int> dictionary;
                 b0.a a;
                 (dictionary = this.h)[a = this.g[num2]] = dictionary[a] - 1;
                 this.g.Remove(num2);
             }
             this.a(num2, false);
         }
         if (this.e.Count == 0)
         {
             l.i();
             return;
         }
         this.c++;
         if (this.c < 0)
         {
             this.c = 0;
         }
         if (this.c >= this.e.Count)
         {
             this.c = 0;
         }
         int c    = this.c;
         int num4 = 0;
         do
         {
             if (!this.a(this.e[c]))
             {
                 int num5 = this.e[c];
                 PluginCore.cq.ax.get_Actions().RequestId(num5);
                 break;
             }
             c++;
             if (c >= this.e.Count)
             {
                 c = 0;
             }
             num4++;
         }while ((num4 <= this.e.Count) && (c != this.c));
         this.c = c;
     }
     catch (Exception exception)
     {
         ad.a(exception);
     }
     l.i();
 }
Ejemplo n.º 50
0
        public static double Permissible_Shear_Stress(double percent, int con_grade, ref string ref_string)
        {
            int indx = -1;

            percent = Double.Parse(percent.ToString("0.00"));
            string table_file = ASTRA_Table_Path;

            //table_file = Path.Combine(table_file, "Box_Culvert_Table_1.txt");
            table_file = Path.Combine(table_file, "Permissible_Shear_Stress.txt");
            //Permissible_Shear_Stress

            List <string> lst_content = new List <string>(File.ReadAllLines(table_file));
            string        kStr        = "";
            MyList        mList       = null;

            bool find = false;

            double a1, b1, a2, b2, returned_value;

            a1             = 0.0;
            b1             = 0.0;
            a2             = 0.0;
            b2             = 0.0;
            returned_value = 0.0;

            List <MyList> lst_list = new List <MyList>();


            #region Swith Case
            switch (con_grade)
            {
            case 15:
                indx = 1;
                break;

            case 20:
                indx = 2;
                break;

            case  25:
                indx = 3;
                break;

            case  30:
                indx = 4;
                break;

            case  35:
                indx = 5;
                break;

            case  40:
                indx = 6;
                break;

            default:
                indx = 6; con_grade = 40;
                break;
            }
            #endregion


            for (int i = 0; i < lst_content.Count; i++)
            {
                if (i == 0)
                {
                    ref_string = lst_content[0];
                    find       = false;
                }
                kStr = MyList.RemoveAllSpaces(lst_content[i]);
                //find = ((double.TryParse(mList.StringList[0], out a2)) && (mList.Count == 7));
                kStr  = kStr.ToUpper().Replace("AND ABOVE", "").Trim().TrimEnd().TrimStart();
                kStr  = kStr.Replace("<=", "");
                mList = new MyList(MyList.RemoveAllSpaces(kStr), ' ');
                if (kStr.ToLower().Contains("m"))
                {
                    kStr = MyList.RemoveAllSpaces(lst_content[i]).ToUpper();

                    kStr = kStr.Substring(kStr.IndexOf('M'), (kStr.Length - kStr.IndexOf('M')));


                    MyList ml = new MyList(kStr, 'M');
                    indx = ml.StringList.IndexOf(((int)con_grade).ToString());

                    if (DesignStandard == eDesignStandard.BritishStandard)
                    {
                        if (con_grade == 15 || con_grade == 20)
                        {
                            indx = 1;
                        }
                        else if (con_grade == 25)
                        {
                            indx = 2;
                        }
                        else if (con_grade == 30)
                        {
                            indx = 3;
                        }
                        else if (con_grade == 35 || con_grade == 40)
                        {
                            indx = 4;
                        }
                        else
                        {
                            indx = 4;
                        }
                    }

                    if (indx != -1)
                    {
                        find = true; continue;
                    }
                }
                if (find)
                {
                    try
                    {
                        if (mList.GetDouble(0) != 0.0000001111111)
                        {
                            lst_list.Add(mList);
                        }
                    }
                    catch (Exception ex) { }
                }
            }

            for (int i = 0; i < lst_list.Count; i++)
            {
                a1 = lst_list[i].GetDouble(0);
                if (percent < lst_list[0].GetDouble(0))
                {
                    returned_value = lst_list[0].GetDouble(indx);
                    break;
                }
                else if (percent > (lst_list[lst_list.Count - 1].GetDouble(0)))
                {
                    returned_value = lst_list[lst_list.Count - 1].GetDouble(indx);
                    break;
                }

                if (a1 == percent)
                {
                    returned_value = lst_list[i].GetDouble(indx);
                    break;
                }
                else if (a1 > percent)
                {
                    a2 = a1;
                    b2 = lst_list[i].GetDouble(indx);

                    a1 = lst_list[i - 1].GetDouble(0);
                    b1 = lst_list[i - 1].GetDouble(indx);

                    returned_value = b1 + ((b2 - b1) / (a2 - a1)) * (percent - a1);
                    break;
                }
            }

            lst_list.Clear();
            lst_content.Clear();


            returned_value = Double.Parse(returned_value.ToString("0.000"));
            return(returned_value);
        }
Ejemplo n.º 51
0
 public Engine()
 {
     addCollection       = new AddCollection();
     addRemoveCollection = new AddRemoveCollection();
     myList = new MyList();
 }
Ejemplo n.º 52
0
        public static void Terzaghi_Bearing_Capacity_Factors(double phi, ref double Nc, ref double Nq, ref double Nr, ref string ref_string)
        {
            phi = Double.Parse(phi.ToString("0.000"));
            int indx = 0;

            string table_file = ASTRA_Table_Path;

            //table_file = Path.Combine(table_file, "Steel_Plate_Tab_4.txt");
            table_file = Path.Combine(table_file, "Terzaghi_Bearing_Capacity_Factors.txt");

            List <string> lst_content = new List <string>(File.ReadAllLines(table_file));
            string        kStr        = "";
            MyList        mList       = null;

            bool find = false;

            double a1, b1, a2, b2, returned_value;

            a1             = 0.0;
            b1             = 0.0;
            a2             = 0.0;
            b2             = 0.0;
            returned_value = 0.0;

            List <MyList> lst_list = new List <MyList>();

            for (int i = 0; i < lst_content.Count; i++)
            {
                kStr = MyList.RemoveAllSpaces(lst_content[i]);
                kStr = kStr.Replace("<=", "");
                if (i == 0)
                {
                    ref_string = kStr;
                }

                mList = new MyList(MyList.RemoveAllSpaces(kStr), ' ');
                if (mList.Count == 4)
                {
                    try
                    {
                        a1 = mList.GetDouble(0);

                        lst_list.Add(mList);
                    }
                    catch (Exception ex) { }
                }
            }

            for (int i = 0; i < lst_list.Count; i++)
            {
                a1 = lst_list[i].GetDouble(0);
                if (phi < lst_list[0].GetDouble(0))
                {
                    Nc = lst_list[0].GetDouble(1);
                    Nq = lst_list[0].GetDouble(2);
                    Nr = lst_list[0].GetDouble(3);

                    break;
                }
                else if (phi > (lst_list[lst_list.Count - 1].GetDouble(0)))
                {
                    //returned_value = lst_list[lst_list.Count - 1].GetDouble(indx);

                    Nc = lst_list[lst_list.Count - 1].GetDouble(1);
                    Nq = lst_list[lst_list.Count - 1].GetDouble(2);
                    Nr = lst_list[lst_list.Count - 1].GetDouble(3);

                    break;
                }

                if (a1 == phi)
                {
                    //returned_value = lst_list[i].GetDouble(indx);

                    Nc = lst_list[i].GetDouble(1);
                    Nq = lst_list[i].GetDouble(2);
                    Nr = lst_list[i].GetDouble(3);

                    break;
                }
                else if (a1 > phi)
                {
                    //a2 = a1;
                    //b2 = lst_list[i].GetDouble(indx);

                    //a1 = lst_list[i - 1].GetDouble(0);
                    //b1 = lst_list[i - 1].GetDouble(indx);

                    //returned_value = b1 + ((b2 - b1) / (a2 - a1)) * (phi - a1);

                    Nc = lst_list[i].GetDouble(1);
                    Nq = lst_list[i].GetDouble(2);
                    Nr = lst_list[i].GetDouble(3);

                    break;
                }
            }

            lst_list.Clear();
            lst_content.Clear();
        }
Ejemplo n.º 53
0
 public static IEnumerable <MyListItemType> ToIEnumerable(this MyList list)
 {
     return new Wrapper(list)
 }
Ejemplo n.º 54
0
        //Chiranjit [2013 07 18]



        public static void Get_Bending_Moment_Coefficients(out double beta_x, out double beta_y, out double alpha_x, out double alpha_y, double Ly_by_Lx, int case_index)
        {
            beta_x  = 0.084;
            beta_y  = 0.063;
            alpha_x = 0.047;
            alpha_y = 0.035;


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

            List <List <double> > list_1 = new List <List <double> >();

            List <double> list_2 = new List <double>();



            string tab_file = Path.Combine(Application.StartupPath, @"TABLES\Bending_Moment_Coefficients.txt");

            if (File.Exists(tab_file))
            {
                List <string> file_content = new List <string>(File.ReadAllLines(tab_file));

                string kStr  = "";
                MyList mlist = null;

                int    flag = 0;
                double dd   = 0.0;

                int i = 0;
                for (i = 0; i < file_content.Count; i++)
                {
                    kStr = MyList.RemoveAllSpaces(file_content[i].ToUpper().TrimEnd().TrimStart().Trim());

                    if (kStr.StartsWith("------"))
                    {
                        flag++;
                        continue;
                    }

                    if (flag == 1)
                    {
                        mlist = new MyList(kStr, ' ');

                        for (int j = 0; j < mlist.Count; j++)
                        {
                            try
                            {
                                list_2.Add(mlist.GetDouble(j));
                            }
                            catch (Exception ex) { }
                        }
                    }
                    else if (flag == 2)
                    {
                        mlist = new MyList(kStr, ' ');
                        for (int j = mlist.Count - 1; j > 0; j--)
                        {
                            try
                            {
                                list.Add(mlist.GetDouble(j));
                            }
                            catch (Exception ex) { break; }
                        }

                        if (list.Count > 0)
                        {
                            list.Reverse();
                            list_1.Add(list);
                            list = new List <double>();
                        }
                    }
                }

                //Ly_by_Lx = 1.75;
                for (i = 1; i < list_2.Count; i++)
                {
                    if (Ly_by_Lx >= list_2[i - 1] && Ly_by_Lx <= list_2[i])
                    {
                        int indx = case_index;

                        indx = indx * 2;

                        beta_x = list_1[indx][i];
                        beta_y = list_1[indx + 1][i];

                        alpha_x = list_1[indx][list_1[indx].Count - 1];
                        alpha_y = list_1[indx + 1][list_1[indx].Count - 1];
                        break;
                    }
                }
            }
        }
Ejemplo n.º 55
0
        public void TestInit()
        {
            MyList films = new MyList();

            Assert.AreEqual(0, films.Count);
        }
Ejemplo n.º 56
0
        public static void Get_Shear_Force_Coefficients(out double gamma_x1, out double gamma_x2, out double gamma_x3, out double gamma_x4, double Ly_by_Lx, int case_index)
        {
            gamma_x1 = 0.57;
            gamma_x2 = 0.38;

            gamma_x3 = 0.57;
            gamma_x4 = 0.38;


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

            List <List <double> > list_1 = new List <List <double> >();

            List <double> list_2 = new List <double>();



            string tab_file = Path.Combine(Application.StartupPath, @"TABLES\Shear_Force_Coefficients.txt");

            if (File.Exists(tab_file))
            {
                List <string> file_content = new List <string>(File.ReadAllLines(tab_file));

                string kStr  = "";
                MyList mlist = null;

                int    flag = 0;
                double dd   = 0.0;

                int i = 0;
                for (i = 0; i < file_content.Count; i++)
                {
                    kStr = MyList.RemoveAllSpaces(file_content[i].ToUpper().TrimEnd().TrimStart().Trim());

                    if (kStr.StartsWith("------"))
                    {
                        flag++;
                        continue;
                    }

                    if (flag == 1)
                    {
                        mlist = new MyList(kStr, ' ');

                        for (int j = 0; j < mlist.Count; j++)
                        {
                            try
                            {
                                list_2.Add(mlist.GetDouble(j));
                            }
                            catch (Exception ex) { }
                        }
                    }
                    else if (flag == 2)
                    {
                        mlist = new MyList(kStr, ' ');
                        for (int j = mlist.Count - 1; j > 0; j--)
                        {
                            try
                            {
                                list.Add(mlist.GetDouble(j));
                            }
                            catch (Exception ex) { break; }
                        }

                        if (list.Count > 2)
                        {
                            list.Reverse();
                            list_1.Add(list);
                        }
                        list = new List <double>();
                    }
                }

                //Ly_by_Lx = 1.75;
                for (i = 1; i < list_2.Count; i++)
                {
                    if (Ly_by_Lx >= list_2[i - 1] && Ly_by_Lx <= list_2[i])
                    {
                        int indx = case_index;
                        if (indx == 8 || indx == 0 || indx == 1)
                        {
                            indx = 0;
                        }
                        else
                        {
                            indx = indx - 1;
                        }


                        indx = indx * 2;

                        gamma_x1 = list_1[indx][i];
                        gamma_x2 = list_1[indx + 1][i];

                        gamma_x3 = list_1[indx][list_1[indx].Count - 1];
                        gamma_x4 = list_1[indx + 1][list_1[indx].Count - 1];

                        break;
                    }
                }
            }
        }
Ejemplo n.º 57
0
        public void ReadData_from_File(string file_name)
        {
            if (!File.Exists(file_name))
            {
                return;
            }
            string kStr = "";
            //StreamReader sr = new StreamReader(new FileStream(file_name, FileMode.Open));
            List <string> sr = new List <string>(File.ReadAllLines(file_name));

            try
            {
                //Sample Data
                //At Support=   18  For Load Case=   15  Maximum Reaction= 3.642E+002
                //At Support=   18  For Load Case=   36  Maximum +ve Mx= 1.779E+002  For Load Case=   36  Maximum -ve Mx=-1.565E+002
                //At Support=   18  For Load Case=   44  Maximum +ve Mz= 1.402E+002  For Load Case=    1  Maximum -ve Mz=-4.812E+001

                //At Support=   52  For Load Case=   34  Maximum Reaction= 4.549E+002
                //At Support=   52  For Load Case=   36  Maximum +ve Mx= 1.950E+002  For Load Case=   36  Maximum -ve Mx=-2.136E+002
                //At Support=   52  For Load Case=   33  Maximum +ve Mz= 2.471E+002  For Load Case=   14  Maximum -ve Mz=-7.351E+001
                MyList          mlist   = null;
                MyList          mlist_2 = null;
                SupportReaction sup_rc  = null;
                int             ln_no   = 0; // for 3 times Read line nos

                //iApp.Progress_ON("Reading support forces... ");
                int  i    = -1;
                bool flag = false;
                while (i != sr.Count - 1 && i != 0)
                {
                    if (i == -1)
                    {
                        i = sr.Count - 1;
                    }
                    kStr = MyList.RemoveAllSpaces(sr[i]);

                    if (kStr.ToUpper().Contains("SUMMARY OF MAXIMUM SUPPORT FORCES"))
                    {
                        flag = true;
                    }
                    if (!flag)
                    {
                        i--;
                    }
                    else
                    {
                        i++;
                    }

                    if (flag)
                    {
                        //kStr = sr[i];
                        if (kStr == "" || kStr.StartsWith("=====") || kStr.StartsWith("*****"))
                        {
                            continue;
                        }

                        kStr  = MyList.RemoveAllSpaces(kStr.ToUpper());
                        mlist = new MyList(kStr, '=');


                        if (mlist.StringList[0].StartsWith("AT SUPPORT"))
                        {
                            if (mlist.Count == 4)
                            {
                                kStr = kStr.Replace("AT SUPPORT=", " ");
                                kStr = kStr.Replace("FOR LOAD CASE=", " ");
                                kStr = kStr.Replace("MAXIMUM REACTION=", " ");

                                kStr = MyList.RemoveAllSpaces(kStr.ToUpper());

                                mlist = new MyList(kStr, ' ');

                                sup_rc         = new SupportReaction();
                                sup_rc.JointNo = mlist.GetInt(0);
                                sup_rc.Max_Reaction_LoadCase = mlist.GetInt(1);
                                sup_rc.Max_Reaction          = mlist.GetDouble(2);
                                ln_no = 1; continue;
                            }

                            //At Support=   18  For Load Case=   36  Maximum +ve Mx= 1.779E+002  For Load Case=   36  Maximum -ve Mx=-1.565E+002
                            if (ln_no == 1)
                            {
                                kStr = kStr.Replace("AT SUPPORT=", " ");
                                kStr = kStr.Replace("FOR LOAD CASE=", " ");
                                kStr = kStr.Replace("MAXIMUM +VE MX=", " ");
                                kStr = kStr.Replace("MAXIMUM -VE MX=", " ");

                                kStr = MyList.RemoveAllSpaces(kStr.ToUpper());

                                mlist = new MyList(kStr, ' ');

                                //sup_rc = new SupportReaction();
                                //sup_rc.JointNo = mlist.GetInt(0);
                                sup_rc.Max_Positive_Mx_LoadCase = mlist.GetInt(1);
                                sup_rc.Max_Positive_Mx          = mlist.GetDouble(2);

                                sup_rc.Max_Negative_Mx_LoadCase = mlist.GetInt(3);
                                sup_rc.Max_Negative_Mx          = mlist.GetDouble(4);

                                ln_no = 2; continue;
                            }
                            if (ln_no == 2)
                            {
                                kStr = kStr.Replace("AT SUPPORT=", " ");
                                kStr = kStr.Replace("FOR LOAD CASE=", " ");
                                kStr = kStr.Replace("MAXIMUM +VE MZ=", " ");
                                kStr = kStr.Replace("MAXIMUM -VE MZ=", " ");

                                kStr = MyList.RemoveAllSpaces(kStr.ToUpper());

                                mlist = new MyList(kStr, ' ');

                                //sup_rc = new SupportReaction();
                                //sup_rc.JointNo = mlist.GetInt(0);
                                sup_rc.Max_Positive_Mz_LoadCase = mlist.GetInt(1);
                                sup_rc.Max_Positive_Mz          = mlist.GetDouble(2);

                                sup_rc.Max_Negative_Mz_LoadCase = mlist.GetInt(3);
                                sup_rc.Max_Negative_Mz          = mlist.GetDouble(4);
                                ln_no = 0;

                                list.Add(sup_rc);
                            }
                            //iApp.SetProgressValue((double)sr.BaseStream.Position, (double)sr.BaseStream.Length);

                            //Chiranjit [2013 05 15]
                            //if (iApp.Is_Progress_Cancel) break;
                        }
                    }
                }
            }
            catch (Exception ex) { }
            finally
            {
                sr.Clear();
                sr = null;
            }
        }
Ejemplo n.º 58
0
        void Show_and_Save_Data()
        {
            if (!File.Exists(analysis_rep))
            {
                return;
            }
            string        format   = "{0,27} {1,10:f3} {2,10:f3} {3,10:f3}";
            List <string> list_arr = new List <string>(File.ReadAllLines(analysis_rep));

            list_arr.Add("");
            list_arr.Add("                   =====================================");
            list_arr.Add("                     DESIGN FORCES FOR RCC PIER DESIGN");
            list_arr.Add("                   =====================================");
            list_arr.Add("");
            list_arr.Add("");
            list_arr.Add(string.Format(""));
            list_arr.Add(string.Format(format, "JOINT", "VERTICAL", "MAXIMUM", "MAXIMUM"));
            list_arr.Add(string.Format(format, "NOS", "REACTIONS", "MX", "MZ"));
            list_arr.Add(string.Format(format, "   ", "  (Ton)   ", "  (Ton-m)", "  (Ton-m)"));
            list_arr.Add("");
            SupportReaction sr = null;

            MyList mlist = new MyList(MyList.RemoveAllSpaces(Left_support), ' ');

            double tot_left_vert_reac  = 0.0;
            double tot_right_vert_reac = 0.0;

            double tot_left_Mx = 0.0;
            double tot_left_Mz = 0.0;

            double tot_right_Mx = 0.0;
            double tot_right_Mz = 0.0;

            list_arr.Add("LEFT END");
            list_arr.Add("--------");
            for (int i = 0; i < mlist.Count; i++)
            {
                sr = support_reactions.Get_Data(mlist.GetInt(i));
                dgv_left_end_design_forces.Rows.Add(sr.JointNo, sr.Max_Reaction, sr.Max_Mx, sr.Max_Mz);

                tot_left_vert_reac += Math.Abs(sr.Max_Reaction);;
                tot_left_Mx        += sr.Max_Mx;
                tot_left_Mz        += sr.Max_Mz;
                list_arr.Add(string.Format(format, sr.JointNo, Math.Abs(sr.Max_Reaction), sr.Max_Mx, sr.Max_Mz));
            }

            list_arr.Add("");
            txt_left_total_vert_reac.Text = tot_left_vert_reac.ToString("0.000");
            txt_left_total_Mx.Text        = tot_left_Mx.ToString("0.000");
            txt_left_total_Mz.Text        = tot_left_Mz.ToString("0.000");
            list_arr.Add(string.Format(format, "TOTAL", tot_left_vert_reac, tot_left_Mx, tot_left_Mz));
            list_arr.Add("");

            mlist = new MyList(MyList.RemoveAllSpaces(Right_support), ' ');
            list_arr.Add("RIGHT END");
            list_arr.Add("--------");
            for (int i = 0; i < mlist.Count; i++)
            {
                sr = support_reactions.Get_Data(mlist.GetInt(i));
                dgv_right_end_design_forces.Rows.Add(sr.JointNo, Math.Abs(sr.Max_Reaction), sr.Max_Mx, sr.Max_Mz);

                tot_right_vert_reac += Math.Abs(sr.Max_Reaction);
                tot_right_Mx        += sr.Max_Mx;
                tot_right_Mz        += sr.Max_Mz;
                list_arr.Add(string.Format(format, sr.JointNo, Math.Abs(sr.Max_Reaction), sr.Max_Mx, sr.Max_Mz));
            }
            list_arr.Add("");
            txt_right_total_vert_reac.Text = tot_right_vert_reac.ToString("0.000");
            txt_right_total_Mx.Text        = tot_right_Mx.ToString("0.000");
            txt_right_total_Mz.Text        = tot_right_Mz.ToString("0.000");
            list_arr.Add("");


            list_arr.Add(string.Format(format, "TOTAL", tot_right_vert_reac, tot_right_Mx, tot_right_Mz));
            list_arr.Add("");


            txt_both_ends_total.Text = (tot_left_vert_reac + tot_right_vert_reac).ToString("0.000");
            list_arr.Add("");
            list_arr.Add("BOTH ENDS TOTAL VERTICAL REACTION = " + txt_both_ends_total.Text + " Ton");

            txt_final_vert_reac.Text   = (tot_right_vert_reac + tot_left_vert_reac).ToString("0.000");
            txt_final_vert_rec_kN.Text = ((tot_right_vert_reac + tot_left_vert_reac) * 10).ToString("0.000");


            list_arr.Add("");
            list_arr.Add("");
            list_arr.Add("FINAL DESIGN FORCES");
            list_arr.Add("-------------------");
            list_arr.Add("");
            list_arr.Add("TOTAL VERTICAL REACTION = " + txt_final_vert_reac.Text + " Ton" + "    =  " + txt_final_vert_rec_kN.Text + " kN");

            txt_final_Mx.Text  = ((Math.Abs(tot_left_Mx) > Math.Abs(tot_right_Mx)) ? tot_left_Mx : tot_right_Mx).ToString("0.000");
            txt_max_Mx_kN.Text = MyList.StringToDouble(txt_final_Mx.Text, 0.0) * 10.0 + "";


            list_arr.Add("        MAXIMUM  MX     = " + txt_final_Mx.Text + " Ton-M" + "  =  " + txt_max_Mx_kN.Text + " kN-m");
            txt_final_Mz.Text  = ((Math.Abs(tot_left_Mz) > Math.Abs(tot_right_Mz))  ? tot_left_Mz : tot_right_Mz).ToString("0.000");
            txt_max_Mz_kN.Text = MyList.StringToDouble(txt_final_Mz.Text, 0.0) * 10.0 + "";

            list_arr.Add("        MAXIMUM  MZ     = " + txt_final_Mz.Text + " Ton-M" + "  =  " + txt_max_Mz_kN.Text + " kN-m");
            list_arr.Add("");
            list_arr.Add("");
            list_arr.Add("                  ========================================");
            list_arr.Add("                  END OF DESIGN FORCES FOR RCC PIER DESIGN");
            list_arr.Add("                  ========================================");
            list_arr.Add("");



            File.WriteAllLines(analysis_rep, list_arr.ToArray());

            list_arr.Clear();
            list_arr.Add("W1=" + txt_final_vert_rec_kN.Text);
            list_arr.Add("Mx1=" + txt_max_Mx_kN.Text);
            list_arr.Add("Mz1=" + txt_max_Mz_kN.Text);
            string f_path = Path.Combine(Path.GetDirectoryName(analysis_rep), "Forces.fil");

            File.WriteAllLines(f_path, list_arr.ToArray());
            Environment.SetEnvironmentVariable("PIER", f_path);
        }
Ejemplo n.º 59
0
        void Load_Default_Data_Multi_Cell()
        {
            //DataGridView dgv = dgv_input_data;

            List <string> list  = new List <string>();
            MyList        mlist = null;


            #region Base Pressure
            list.Add(string.Format("Design Data$$"));
            list.Add(string.Format("Number of cells in culvert$2$"));
            list.Add(string.Format("Clear Span$11.90$m"));
            list.Add(string.Format("$11.90$m"));
            list.Add(string.Format("$0.00$m"));
            list.Add(string.Format("Effective Span$12.6$m(skew)"));
            list.Add(string.Format("$12.6$m(skew)"));
            list.Add(string.Format("$0$m"));
            list.Add(string.Format("Total span$25.2$m"));
            list.Add(string.Format("Clear Height$4.5$m"));
            list.Add(string.Format("Effective Height$5.35$m"));
            list.Add(string.Format("Overall width$28$m"));
            list.Add(string.Format("Carriageway width$8.5$m"));
            list.Add(string.Format("Crash barrier width$0.50$m"));
            list.Add(string.Format("Crash barrier Height$0.75$m"));
            list.Add(string.Format("Safety kerb$0.00$m"));
            list.Add(string.Format("Ht. of crash barrier$1.00$m"));
            list.Add(string.Format("Ht. of kerb$0.00$m"));
            list.Add(string.Format("Width of railing$0.50$m"));
            list.Add(string.Format("Footpath width$1.50$m"));
            list.Add(string.Format("Minimum thickness of wearing coat$0.065$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Thickness of soil fill over Bottom slab$0.00$m"));
            list.Add(string.Format("lean concrete thickness bot. slab$0.00$m"));
            list.Add(string.Format("Length of the box considered for design$1.00$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Width of Haunch$1.5$m"));
            list.Add(string.Format("Depth of Haunch$0.5$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Top slab thickness$0.80$m"));
            list.Add(string.Format("Bottom slab thickness$0.90$m"));
            list.Add(string.Format("Side wall thickness $0.80$m"));
            list.Add(string.Format("Mid wall thickness$0.60$m"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Safe Bearing Capacity$150.00$kN/m²"));
            list.Add(string.Format("Density of concrete$25.00$kN/m³"));
            list.Add(string.Format("unit weight of soil$18.00$kN/m³"));
            list.Add(string.Format("unit weight of submerged soil$10.00$kN/m³"));
            list.Add(string.Format("unit weight of wearing coat$22.00$kN/m³"));
            list.Add(string.Format("unit weight of water$10.00$kN/m³"));
            list.Add(string.Format("$$"));
            list.Add(string.Format("Grade of concrete$30$N/mm2"));
            list.Add(string.Format("$2.50$N/mm2"));
            list.Add(string.Format("$13.40$N/mm2"));
            list.Add(string.Format("Grade of reinforcement$500$N/mm2"));
            list.Add(string.Format("Grade of shear reinforcement$500$N/mm2"));
            list.Add(string.Format("Modulus of elasticity of concret$3.10E+07$N/m2"));
            list.Add(string.Format("Modulus of elasticity of Steel$200000000$N/m2"));
            list.Add(string.Format("Modulur Ratio$6.451612903$"));
            list.Add(string.Format("Design Levels$$"));
            list.Add(string.Format("Formation road level$263.335$m"));
            list.Add(string.Format("Highest Flood level$260.660$m"));
            list.Add(string.Format("Lowest Water level$256.259$m"));
            list.Add(string.Format("Maximum Scour level$256.259$m"));
            list.Add(string.Format("Foundation level$258.259$m"));
            //dgv = dgv_input_data;



            MyList.Fill_List_to_Grid(dgv_design_data_multi, list, '$');
            //dgv_base_pressure.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;


            #endregion Base Pressure

            //Modified_Cell(dgv_input_data);

            //if (dgv[2, i].Value == "") dgv[2, i].Value = "";
        }
 private void Delete_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
 {
     MyList.Remove((MyClass)AllElementsList.SelectedItem);
 }