Example #1
0
        void BtnCalcClick(object sender, EventArgs e)
        {
            CalcForm calc_form = new CalcForm();

            calc_form.btnDoCalc.Click += (fSender, eSender) => {
                //alert("test");
                calc_form.listBox_calc.Items.Clear();
                //строим список элементов, которые не учитываем
                Dictionary <EntryType, bool> exclude_types = new Dictionary <EntryType, bool>();
                //TOQ: вынести что-то вроде этого в отдельный метод EnumsExtender
                exclude_types.Add(EntryType.Target, calc_form.checkBox_targets.Checked);
                exclude_types.Add(EntryType.Payment, calc_form.checkBox_payments.Checked);
                exclude_types.Add(EntryType.Investment, calc_form.checkBox_investments.Checked);
                //Debug.Print(exclude_types.ToString());
                List <BalanceData> bdata_list = logic.buildFinanceList(exclude_types);
                decimal            bdata_sum  = 0;
                for (int i = 0; i < bdata_list.Count; i++)
                {
                    bdata_sum += bdata_list[i].amount;
                    calc_form.listBox_calc.Items.Add(bdata_list[i].comment);
                }
                //calc_form.listBox_calc.Items.AddRange(
                //получаем число свободных средств
                decimal free_value = calc_form.entry_amount.Value - bdata_sum;
                calc_form.label_result.Text = Math.Round(free_value, 2).ToString();
            };
            calc_form.ShowDialog();
        }
Example #2
0
    static void Main()
    {
        bool bContinue = false;

        do
        {
            try
            {
                bContinue = false;
                Form form = new CalcForm();
                Program.Prepare();
                Application.Run(form);
            }
            catch (Exception xcp)
            {
                DEBUG.DUMP_EXCEPTION(xcp);
                DialogResult r = MessageBox.Show(
                    "Programm was wondered by underestimated but handled exception."
                    + "\nWTF are you doing there?\n\n- Restart the programm?" + xcp.ToString()
                    , "What a wonderful world :)"
                    , MessageBoxButtons.RetryCancel, MessageBoxIcon.Question
                    , MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                bContinue = (r == DialogResult.Retry);
            }
        } while (bContinue);
    }
Example #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CalcForm          calcForm          = new CalcForm();
            CalcFormPresenter calcFormPresenter = new CalcFormPresenter(calcForm);

            Application.Run(calcForm);
        }
Example #4
0
    void OnOpen(object sender, EventArgs e)
    {
        // create the dialog
        MyDialog dlg = new MyDialog();

        // initialize the input box with a sample string
        dlg.UserFile = "Math.dll";

        if (dlg.ShowDialog(this) == DialogResult.OK)
        {
            // If the dialog was dismissed with the OK button,
            // extract the user input and open the .dll file
            dllFileName = dlg.UserFile;
            dllLoaded   = true; // set the flag to change the form

            #region Reflection Stuff
            Assembly a    = Assembly.LoadFrom(dllFileName);
            Type     type = a.GetType(dllFileName);
            Console.WriteLine(a);
            Console.WriteLine(type);

            foreach (Type className in a.GetExportedTypes())
            {
                // we use a dynamic object to get the classes inside the .dll
                dynamic c = Activator.CreateInstance(className);
                Console.WriteLine(c);
                classCount++;
                classList[classCount] = c.ToString();

                // we're looking for these exact methods
                // maybe later on, look into dynamically listing all methods
                Console.WriteLine(className.GetMethod("addition"));
                Console.WriteLine(className.GetMethod("subtraction"));
                Console.WriteLine(className.GetMethod("multiplication"));
                Console.WriteLine(className.GetMethod("division"));
                //Console.WriteLine(myMethodInfo);
            }
            #endregion

            Invalidate();
            CalcForm calc = new CalcForm();
            //Invalidate();
        }
    }
Example #5
0
    void OnOpen(object sender, EventArgs e)
    {
        // create the dialog
        MyDialog dlg = new MyDialog();

        // initialize the input box with a sample string
        dlg.UserFile = "Math.dll";

        if (dlg.ShowDialog(this) == DialogResult.OK)
        {
            // If the dialog was dismissed with the OK button,
            // extract the user input and open the .dll file
            dllFileName = dlg.UserFile;
            dllLoaded = true; // set the flag to change the form

            #region Reflection Stuff
            Assembly a = Assembly.LoadFrom(dllFileName);
            Type type = a.GetType(dllFileName);
            Console.WriteLine(a);
            Console.WriteLine(type);

            foreach(Type className in a.GetExportedTypes())
            {
                // we use a dynamic object to get the classes inside the .dll
                dynamic c = Activator.CreateInstance(className);
                Console.WriteLine(c);
                classCount++;
                classList[classCount] = c.ToString();

                // we're looking for these exact methods
                // maybe later on, look into dynamically listing all methods
                Console.WriteLine(className.GetMethod("addition"));
                Console.WriteLine(className.GetMethod("subtraction"));
                Console.WriteLine(className.GetMethod("multiplication"));
                Console.WriteLine(className.GetMethod("division"));
                //Console.WriteLine(myMethodInfo);
            }
            #endregion

            Invalidate();
            CalcForm calc = new CalcForm();
            //Invalidate();
        }
    }