Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            MouseEventArgs eventargs = e as MouseEventArgs;
            Button         button1   = sender as Button;

            // displays which mouse button I used
            //MessageBox.Show(eventargs.Button.ToString());
            // displays the name of the button I clicked
            //MessageBox.Show(button1.Name.ToString());
            // changes the text of the button
            //if (button1.Text == "I've changed")
            //{
            //    button1.Text = "Hey, I'm old right now!";
            //} else
            //button1.Text = "I've changed";

            try
            {
                Tranche tranche = readTranche();

                InvestmentPlan plan = EasySolve.solve(tranche);

                //var plan = tranche.assets[0].profit.ToString() + " " + tranche.assets[0].prob.ToString();

                this.answerBox.Text = plan.GetFinalProfit().ToString(ci);


                /*
                 * foreach (var asset in tranche.assets)
                 *  {
                 *      assetsGrid.Rows.Add(
                 * asset.profit.ToString(ci), asset.prob.ToString(ci));
                 * }
                 * assetsGrid.Visible = true;
                 */
                this.answerGridView.Rows.Clear();
                foreach (var x in plan.Plan)
                {
                    this.answerGridView.Rows.Add(x.Item1.ToString(ci), x.Item2.ToString());
                }
                setRowNumber(this.answerGridView);
                this.answerGridView.Visible = true;

                this.answerBox.TabStop       = false;
                this.tabControl1.SelectedTab = this.tabPage2;
                this.tabPage2.Visible        = true;
            }
            catch (Exception ex)
            {
            }
        }
        public static InvestmentPlan planFromThread(Tranche tranche)
        {
            object t      = null;
            var    thread = new Thread(
                () =>
            {
                t = EasySolve.solve(tranche);
            }
                );

            thread.Start();
            thread.Join();

            return((InvestmentPlan)t);
        }
        static void Main(string[] args)
        {
            CultureInfo ci = CultureInfo.CreateSpecificCulture("en-US");

            if (args.Length > 0 && args[0] != "")
            {
                string filename = args[0]; //"another_sample.txt";
                                           //args[0];

                Tranche tranche = ReadWriteTools.ReadConditionFromTextFile(filename);

                InvestmentPlan plan = EasySolve.solve(tranche);

                //Console.WriteLine(answerToString(plan, ci));

                String s = answerToString(plan, ci);//.Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries);

                /*foreach (String t in s)
                 * {
                 *  Console.WriteLine(t);
                 * }*/

                //Console.WriteLine(s.Count());

                Console.WriteLine(s);

                /*ReadWriteTools.WriteConditionToFile(
                 *  "sample",
                 *  ReadWriteTools.MakeSimpleTranche()
                 *  );
                 *
                 * Tranche tranche = ReadWriteTools.ReadConditionFromFile("sample");
                 *
                 *
                 * Investor investor = new Investor(tranche.period, tranche.capital, tranche.assets);
                 *
                 * InvestmentsSolver solver = new InvestmentsSolver(investor);
                 *
                 * InvestmentPlan plan = solver.TheoreticalProfitPlan();
                 *
                 * foreach (Tuple<decimal, decimal> x in plan.Plan)
                 * {
                 *  System.Console.WriteLine(x);
                 * }
                 *
                 * System.Console.WriteLine(plan.GetFinalProfit());*/
            }
        }