예제 #1
0
        private void initGrfFoodsMaterial()
        {
            grfFooM                     = new C1FlexGrid();
            grfFooM.Font                = fEdit;
            grfFooM.Dock                = System.Windows.Forms.DockStyle.Fill;
            grfFooM.Location            = new System.Drawing.Point(0, 0);
            grfFooM.Rows.Count          = 1;
            grfFooM.Cols[colFmId].Width = 60;

            grfFooM.Cols[colFmName].Width   = 200;
            grfFooM.Cols[colFmprice].Width  = 120;
            grfFooM.Cols[colFmWeight].Width = 120;
            grfFooM.Cols[colFmQty].Width    = 70;

            grfFooM.ShowCursor = true;
            //grdFlex.Cols[colID].Caption = "no";
            //grfDept.Cols[colCode].Caption = "รหัส";

            grfFooM.Cols[colFmName].Caption   = "Material";
            grfFooM.Cols[colFmprice].Caption  = "Price";
            grfFooM.Cols[colFmWeight].Caption = "Weight";
            grfFooM.Cols[colFmQty].Caption    = "Qty";
            grfFooM.Cols[colFmTotal].Caption  = "Total";
            //FilterRow fr = new FilterRow(grfPosi);

            grfFooM.CellChanged += GrfFooM_CellChanged;

            pnMaterialAdd.Controls.Add(this.grfFooM);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfFooM, theme);
        }
예제 #2
0
        private void initGrfStfH()
        {
            grfStf          = new C1FlexGrid();
            grfStf.Font     = fEdit;
            grfStf.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfStf.Location = new System.Drawing.Point(0, 0);

            //FilterRow fr = new FilterRow(grfStf);

            grfStf.AfterDataRefresh  += new System.ComponentModel.ListChangedEventHandler(this.StatusBar_AfterDataRefresh);
            grfStf.CellChanged       += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfStf_CellChanged);
            grfStf.LeaveCell         += new System.EventHandler(this.grfStf_LeaveCell);
            grfStf.AfterRowColChange += new C1.Win.C1FlexGrid.RangeEventHandler(this.grfStf_AfterRowColChange);
            //this.grfCus.AfterRowColChange += new C1.Win.C1FlexGrid.RangeEventHandler(this.grfCus_AfterRowColChange);
            //new C1.Win.C1FlexGrid.RangeEventHandler(this.c1FlexGrid1_AfterRowColChange);
            //splitContainer1.Panel1.Controls.Add(this.grfCus);
            panel2.Controls.Add(this.grfStf);
            //grfCus.ShowThemedHeaders = ShowThemedHeadersEnum.None;
            //grfCus.Styles.Clear();
            //Mac(grfCus.Styles);
            //Controls.Add(sB);
            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfStf, theme);
        }
예제 #3
0
        private void initGrfLab()
        {
            grfLab          = new C1FlexGrid();
            grfLab.Font     = fEdit;
            grfLab.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfLab.Location = new System.Drawing.Point(0, 0);

            //FilterRow fr = new FilterRow(grfPosi);
            ContextMenu menuGw = new ContextMenu();

            menuGw.MenuItems.Add("เลือก รายการนี้", new EventHandler(ContextMenu_grflab_select));
            //menuGw.MenuItems.Add("Upload สำเนาบัตรประชาชน ที่มีลายเซ็น", new EventHandler(ContextMenu_grfimg_upload_ptt));
            //menuGw.MenuItems.Add("Upload รูป Passport", new EventHandler(ContextMenu_grfimg_upload_ptt));
            //menuGw.MenuItems.Add("ยกเลิก", new EventHandler(ContextMenu_grfimg_Cancel));
            grfLab.ContextMenu        = menuGw;
            grfLab.AfterRowColChange += GrfLab_AfterRowColChange;
            //grfAgn.CellButtonClick += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellButtonClick);
            //grfAgn.CellChanged += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellChanged);

            panel8.Controls.Add(this.grfLab);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfLab, theme);
        }
예제 #4
0
        // apply theme to the FlexPivot page
        private void cbTheme_SelectedIndexChanged(object sender, EventArgs e)
        {
            C1Theme theme = C1ThemeController.GetThemeByName(cbTheme.Text, false);

            if (theme != null)
            {
                C1ThemeController.ApplyThemeToObject(_c1FlexPivotPage, theme);
            }
        }
예제 #5
0
        private void initGrfInterpret()
        {
            grfInt             = new C1FlexGrid();
            grfInt.Font        = fEdit;
            grfInt.Dock        = System.Windows.Forms.DockStyle.Fill;
            grfInt.Location    = new System.Drawing.Point(0, 0);
            grfInt.ChangeEdit += GrfInt_ChangeEdit;
            //FilterRow fr = new FilterRow(grfPosi);

            gbInterpret.Controls.Add(this.grfInt);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfInt, theme);
        }
예제 #6
0
        private void initGrfDept()
        {
            grfDept.Font     = fEdit;
            grfDept.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfDept.Location = new System.Drawing.Point(0, 0);

            FilterRow fr = new FilterRow(grfDept);

            grfDept.AfterRowColChange += new C1.Win.C1FlexGrid.RangeEventHandler(this.grfDept_AfterRowColChange);
            grfDept.CellButtonClick   += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfDept_CellButtonClick);
            grfDept.CellChanged       += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfDept_CellChanged);
            this.Controls.Add(this.grfDept);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfDept, theme);
        }
예제 #7
0
        private void initGrfContH()
        {
            grfCont          = new C1FlexGrid();
            grfCont.Font     = fEdit;
            grfCont.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfCont.Location = new System.Drawing.Point(0, 0);

            FilterRow fr = new FilterRow(grfCont);

            grfCont.DoubleClick += new System.EventHandler(this.grfCont_DoubleClick);
            //grfBank.CellButtonClick += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfBank_CellButtonClick);

            panel2.Controls.Add(this.grfCont);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfCont, theme);
        }
예제 #8
0
        private void initGrfDiag()
        {
            grfReq          = new C1FlexGrid();
            grfReq.Font     = fEdit;
            grfReq.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfReq.Location = new System.Drawing.Point(0, 0);

            //FilterRow fr = new FilterRow(grfPosi);

            grfReq.AfterRowColChange += new C1.Win.C1FlexGrid.RangeEventHandler(this.grfPosi_AfterRowColChange);
            //grfAgn.CellButtonClick += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellButtonClick);
            //grfAgn.CellChanged += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellChanged);

            panel5.Controls.Add(this.grfReq);

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfReq, theme);
        }
예제 #9
0
        private void initGrfMatr()
        {
            grfMatr          = new C1FlexGrid();
            grfMatr.Font     = fEdit;
            grfMatr.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfMatr.Location = new System.Drawing.Point(0, 0);

            //FilterRow fr = new FilterRow(grfPosi);

            //grfMatr.AfterRowColChange += new C1.Win.C1FlexGrid.RangeEventHandler(this.grfPosi_AfterRowColChange);
            //grfMatr.CellButtonClick += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellButtonClick);
            //grfMatr.CellChanged += GrfMatr_CellChanged;
            grfMatr.AfterEdit    += GrfMatr_AfterEdit;
            grfMatr.ComboCloseUp += GrfMatr_ComboCloseUp;
            panel2.Controls.Add(this.grfMatr);

            setControl();

            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfMatr, theme);
        }
예제 #10
0
        private void initGrfStockDrug()
        {
            grfDrug          = new C1FlexGrid();
            grfDrug.Font     = fEdit;
            grfDrug.Dock     = System.Windows.Forms.DockStyle.Fill;
            grfDrug.Location = new System.Drawing.Point(0, 0);

            //FilterRow fr = new FilterRow(grfPosi);

            grfDrug.AfterRowColChange += GrfPkg_AfterRowColChange;
            //grfAgn.CellButtonClick += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellButtonClick);
            //grfAgn.CellChanged += new C1.Win.C1FlexGrid.RowColEventHandler(this.grfPosi_CellChanged);

            panel1.Controls.Add(this.grfDrug);
            FilterRow fr = new FilterRow(grfDrug);

            grfDrug.AllowFiltering = true;
            grfDrug.AfterFilter   += GrfDrug_AfterFilter;
            C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);

            C1ThemeController.ApplyThemeToObject(grfDrug, theme);
        }
예제 #11
0
        private void BtnCheck2_Click(object sender, EventArgs e)
        {
            int     cnt = 0, cntErr = 0;
            Decimal sum = 0, price1 = 0, net = 0, minus = 0;

            //throw new NotImplementedException();
            pB2.Show();
            pB2.Minimum = 0;
            pB2.Maximum = lItm.Count;
            ConnectDB conn;

            conn         = new ConnectDB(bc.iniC);
            lItmC        = new List <string>();
            lItmE        = new List <string>();
            label11.Text = chkBn1.Checked ? "bangna1" : chkBn2.Checked ? "bangna2" : chkBn5.Checked ? "bangna5" : "";
            label12.Text = cboYear.Text;
            label13.Text = cboMonth.Text;
            label14.Text = cboPeriod.Text;
            Application.DoEvents();
            //foreach (String str in lItm)
            foreach (DataRow str in dtChk.Rows)
            {
                try
                {
                    //String[] itm = str.Split('|');
                    //String[] itm = str.Split('|');
                    String col1 = "", date = "", hn = "", name = "", fntype = "", col6 = "", labname = "", labcode = "", labdate1 = "", labdate = "", labdateOld = "", price = "";
                    //col1 = itm[0];
                    //date = itm[1];
                    //hn = itm[2];
                    //name = itm[3];
                    //fntype = itm[4];
                    //col6 = itm[5];
                    //price = itm[6];
                    //labcode = itm[7];
                    //labname = itm[8];

                    col1    = str["col1"].ToString();
                    date    = str["date"].ToString();
                    hn      = str["hn"].ToString();
                    name    = str["ptt_name"].ToString();
                    fntype  = str["paidtype"].ToString();
                    col6    = str["net_price"].ToString();
                    price   = str["price"].ToString();
                    labcode = str["lab_code"].ToString();
                    labname = str["lab_name"].ToString();

                    labdate1 = (int.Parse(date.Substring(6)) - 543) + "-" + date.Substring(3, 2) + "-" + date.Substring(0, 2);
                    price1   = 0;
                    if (Decimal.TryParse(price, out price1))
                    {
                        sum += price1;
                    }
                    String    sql = "";
                    DataTable dt  = new DataTable();
                    //sql = "select lab_t05.MNC_req_no,LAB_T01.MNC_PRE_NO " +
                    //    "from PATIENT_T01 " +
                    //    "inner join LAB_T01 on LAB_T01.mnc_hn_no = PATIENT_T01.mnc_hn_no " +
                    //    "and LAB_T01.mnc_pre_no = PATIENT_T01.mnc_pre_no " +
                    //    "and LAB_T01.mnc_date = PATIENT_T01.MNC_DATE " +
                    //    "inner join LAB_T05 on lab_t05.MNC_REQ_YR = lab_t01.MNC_REQ_YR " +
                    //    "and lab_t05.MNC_REQ_no = lab_t01.MNC_REQ_no " +
                    //    "and lab_t05.MNC_REQ_dat = lab_t01.MNC_REQ_dat " +
                    //    "where lab_t05.MNC_REQ_DAT >= '" + labdate1 + "' " +
                    //    "and lab_t05.MNC_REQ_DAT <= '" + labdate1 + "' " +
                    //    //"and patient_t01.MNC_STS = 'f' " +
                    //    //"and LAB_T01.MNC_REQ_STS = 'Q' " +
                    //    "and LAB_T01.mnc_hn_no ='" + hn + "' " +
                    //    "and lab_t05.mnc_lb_cd ='" + labcode + "'";
                    sql = "select lab_t02.MNC_req_no,LAB_T01.MNC_PRE_NO " +
                          "from PATIENT_T01 " +
                          "inner join LAB_T01 on LAB_T01.mnc_hn_no = PATIENT_T01.mnc_hn_no " +
                          "and LAB_T01.mnc_pre_no = PATIENT_T01.mnc_pre_no " +
                          "and LAB_T01.mnc_date = PATIENT_T01.MNC_DATE " +
                          "inner join lab_t02 on lab_t02.MNC_REQ_YR = lab_t01.MNC_REQ_YR " +
                          "and lab_t02.MNC_REQ_no = lab_t01.MNC_REQ_no " +
                          "and lab_t02.MNC_REQ_dat = lab_t01.MNC_REQ_dat " +
                          "where lab_t02.MNC_REQ_DAT >= '" + labdate1 + "' " +
                          "and lab_t02.MNC_REQ_DAT <= '" + labdate1 + "' " +
                          //"and patient_t01.MNC_STS = 'f' " +
                          //"and LAB_T01.MNC_REQ_STS = 'Q' " +
                          "and LAB_T01.mnc_hn_no ='" + hn + "' " +
                          "and lab_t02.mnc_lb_cd ='" + labcode + "'";
                    dt = conn.selectData(conn.connMainHIS, sql);
                    if (dt.Rows.Count > 0)
                    {
                        //itm[8] = dt.Rows[0]["MNC_PRE_NO"].ToString();
                        //itm[9] = dt.Rows[0]["MNC_req_no"].ToString();
                        str["status_chk"] = "1";
                        listBox2.Items.Add(date + " " + hn + " " + name + " " + labcode + " " + labname);
                        lItmC.Add(col1 + "|" + date + "|" + hn + "|" + name + "|" + fntype + "|" + col6 + "|" + price + "|" + labcode + "|" + labname + "|" + dt.Rows[0]["MNC_PRE_NO"].ToString() + "|" + dt.Rows[0]["MNC_req_no"].ToString());
                        cnt++;
                        net += price1;
                        if ((cnt % 100) == 0)
                        {
                            Application.DoEvents();
                        }
                    }
                    else
                    {
                        cntErr++;
                        minus += price1;
                        listBox3.Items.Add(date + " " + hn + " " + name + " " + labcode + " " + labname);
                        lItmC.Add(col1 + "|" + date + "|" + hn + "|" + name + "|" + fntype + "|" + col6 + "|" + price + "|" + labcode + "|" + labname + "|0|0|-" + "|-");
                        lItmE.Add(col1 + "|" + date + "|" + hn + "|" + name + "|" + fntype + "|" + col6 + "|" + price + "|" + labcode + "|" + labname + "|0|0|-" + "|-");
                        int cnt1 = 0;
                        foreach (String paid in lPaid)
                        {
                            if (paid.Equals(fntype))
                            {
                                //int cnt2 = 0;
                                lPaidCntErr[cnt1]++;
                                //int.TryParse(lPaidCnt[cnt1],out cnt2);
                            }
                            cnt1++;
                        }
                        //itm[8] = dt.Rows[0]["MNC_PRE_NO"].ToString();
                        //itm[9] = dt.Rows[0]["MNC_req_no"].ToString();
                        //listBox2.Items.Add(itm.ToString());
                    }
                    pB2.Value++;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ex" + ex.Message, "");
                }
            }
            //Control ctn = this.GetControl("listBoxSum3");
            ListBox listsum = new ListBox();

            foreach (Control ctl in this.Controls)
            {
                if ((ctl is C1DockingTab) && (ctl.Name.Equals("tC")))
                {
                    foreach (Control ctl1 in ctl.Controls)
                    {
                        if ((ctl1 is C1DockingTabPage) && (ctl1.Name.Equals("tab3")))
                        {
                            foreach (Control ctl2 in ctl1.Controls)
                            {
                                if ((ctl2 is Panel) && (ctl2.Name.Equals("panel3")))
                                {
                                    foreach (Control ctl3 in ctl2.Controls)
                                    {
                                        if ((ctl3 is C1DockingTab) && (ctl3.Name.Equals("tC3")))
                                        {
                                            foreach (Control ctl4 in ctl3.Controls)
                                            {
                                                if ((ctl4 is C1DockingTabPage) && (ctl4.Name.Equals("tabsum")))
                                                {
                                                    foreach (Control ctl5 in ctl4.Controls)
                                                    {
                                                        if ((ctl5 is ListBox) && (ctl5.Name.Equals("listBoxSum3")))
                                                        {
                                                            listsum = (ListBox)ctl5;
                                                            listsum.Items.Clear();
                                                            int i = 0;
                                                            foreach (String txt in lPaid)
                                                            {
                                                                listsum.Items.Add(txt + "  จำนวน " + lPaidCnt[i] + " ไม่พบ จำนวน " + lPaidCntErr[i]);
                                                                i++;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //listsum.Items.Clear();
            //int i = 0;
            //foreach (String txt in lPaid)
            //{
            //    listsum.Items.Add(txt + "  จำนวน " + lPaidCnt[i]+" ไม่พบ จำนวน "+ lPaidCntErr[i]);
            //    i++;
            //}

            pB1.Hide();
            label18.Text    = lItm.Count.ToString();
            label17.Text    = cnt.ToString();
            label16.Text    = cntErr.ToString();
            label15.Text    = sum.ToString("#,###.00");
            label23.Text    = net.ToString("#,###.00");
            label26.Text    = minus.ToString("#,###.00");
            btnTab3.Enabled = true;
            pB2.Hide();
            tC.SelectedTab = tab3;
            setGrf();
            //DataTable dt11 = new DataTable();
            dtChkGrp = GroupBy("paidtype", "paidtype", dtChk);
            setGrf11(dtChkGrp);
            if (dtChkGrp.Rows.Count > 0)
            {
                foreach (DataRow row in dtChkGrp.Rows)
                {
                    C1DockingTabPage tab1 = new C1DockingTabPage();
                    tab1.Text = row["paidtype"].ToString();
                    tC3.TabPages.Add(tab1);
                    C1FlexGrid grf = new C1FlexGrid();
                    grf.Font     = fEdit;
                    grf.Dock     = System.Windows.Forms.DockStyle.Fill;
                    grf.Location = new System.Drawing.Point(0, 0);
                    tab1.Controls.Add(grf);
                    DataRow[] result = dtChk.Select("paidtype = '" + row["paidtype"].ToString() + "'");
                    DataTable dt1    = new DataTable();
                    addColumn(dt1);
                    foreach (DataRow row1 in result)
                    {
                        DataRow row2 = dt1.NewRow();
                        ///row2 = row1;
                        row2["row1"]       = int.Parse(row1["row1"].ToString()) + 1;
                        row2["lab_code"]   = row1["lab_code"];
                        row2["lab_name"]   = row1["lab_name"];
                        row2["qty"]        = row1["qty"];
                        row2["price"]      = row1["price"];
                        row2["net_price"]  = row1["net_price"];
                        row2["amount"]     = row1["amount"];
                        row2["paidtype"]   = row1["paidtype"];
                        row2["status_chk"] = row1["status_chk"];
                        row2["ptt_name"]   = row1["ptt_name"];
                        row2["date"]       = row1["date"];
                        row2["hn"]         = row1["hn"];
                        row2["col1"]       = row1["col1"];
                        dt1.Rows.Add(row2);
                    }
                    DataTable dt2 = new DataTable();
                    dt2 = GroupBy1("lab_code", "lab_code", dt1);
                    foreach (DataRow row3 in dt2.Rows)
                    {
                        DataRow[] result1 = dtChk.Select("lab_code = '" + row3 ["lab_code"].ToString() + "'");
                        if (result.Length > 0)
                        {
                            row3["lab_name"] = result1[0]["lab_name"].ToString();
                        }
                        Console.WriteLine("{0}, {1}", row[0], row[1]);
                    }
                    //dt1.ad
                    grf.DataSource                = dt2;
                    grf.Cols["price"].Visible     = false;
                    grf.Cols["net_price"].Visible = false;
                    grf.Cols["amount"].Visible    = false;
                    grf.Cols["lab_code"].Width    = 100;
                    grf.Cols["lab_name"].Width    = 300;
                    C1Theme theme = C1ThemeController.GetThemeByName("Office2013Red", false);
                    C1ThemeController.ApplyThemeToObject(grf, theme);
                }
            }
            //pB1.Show();
        }
예제 #12
0
        public ScriptEditorFormEx(
            MainForm mainForm,
            C1FlexReport report,
            string scriptContextName,
            // either this:
            ITypeDescriptorContext typeDescriptorContext,
            // or these two:
            object propertyOwner,
            string propertyName,
            // if non-null, used instead of derived name for display ONLY (does not affect script item key)
            string displayName,
            //
            bool isScript)
            : this()
        {
            System.Diagnostics.Debug.Assert(typeDescriptorContext != null || (propertyOwner != null && !string.IsNullOrEmpty(propertyName)));

            AutoScaleMode       = AutoScaleMode.None;
            Font                = MainForm.DefaultAppFont;
            _mainForm           = mainForm;
            _report             = report;
            _contexts           = new EditorScriptContextCollection(this, report, _mainForm.FlexDesigner);
            _activeScriptEditor = _scriptEditor0;
            //
            rbnMain.BeginUpdate();
            //
            _scriptEditor1.TextBox.Font          = _scriptEditor0.TextBox.Font = _mainForm._scriptEditorFont;
            _scriptEditor1.EditorBackgroundColor = _scriptEditor0.EditorBackgroundColor = _mainForm._scriptEditorBackColor;
            _scriptEditor1.EditorTextColor       = _scriptEditor0.EditorTextColor = _mainForm._scriptEditorForeColor;
            _scriptEditor1.SyntaxAutoCheck       = _scriptEditor0.SyntaxAutoCheck = _mainForm._syntaxCheck;
            _scriptEditor1.AutoSaveCurrentScript = _scriptEditor0.AutoSaveCurrentScript = _mainForm._scriptEditorAutoSave;
            // init options in ribbon UI:
            rbEditorFontName.Text             = _mainForm._scriptEditorFont.Name;
            rbBackgroundColor.Color           = _mainForm._scriptEditorBackColor;
            rbTextColor.Color                 = _mainForm._scriptEditorForeColor;
            rbSyntaxHighlight.Checked         = _mainForm._syntaxColoring;
            rbSyntaxAutoCheck.Checked         = _mainForm._syntaxCheck;
            rbAutoSave.Checked                = _mainForm._scriptEditorAutoSave;
            rbDataSourceFilterWarning.Checked = _mainForm._scriptEditorDataSourceFilterWarning;
            // font size:
            for (int i = c_minFontSize; i <= c_maxFontSize; ++i)
            {
                rbFontSize.Items.Add(i.ToString());
            }
            rbFontSize.Text = ((int)Math.Round(_scriptEditor0.EditorFont.Size)).ToString();

            _scriptEditor0.TextBox.GotFocus         += ScriptEditorGotFocus;
            _scriptEditor0.CurrentScriptItemChanged += CurrentScriptItemChanged;
            _scriptEditor0.CurrentScriptTextChanged += CurrentScriptTextChanged;
            _scriptEditor0.ScriptWritten            += ScriptWritten;
            _scriptEditor0.TextSelectionChanged     += TextSelectionChanged;
            _scriptEditor0.SyntaxCheckNeeded        += SyntaxCheckNeeded;

            _scriptEditor1.TextBox.GotFocus         += ScriptEditorGotFocus;
            _scriptEditor1.CurrentScriptItemChanged += CurrentScriptItemChanged;
            _scriptEditor1.CurrentScriptTextChanged += CurrentScriptTextChanged;
            _scriptEditor1.ScriptWritten            += ScriptWritten;
            _scriptEditor1.TextSelectionChanged     += TextSelectionChanged;
            _scriptEditor1.SyntaxCheckNeeded        += SyntaxCheckNeeded;

            _scriptItems = new EditorScriptItemCollection(_report, _contexts, _mainForm.FlexDesigner);

            // initial mode we start with:
            bool splitWindowMode = _mainForm._scriptEditorSplitWindowDistance > 0;

            // script data context:
            EditorScriptContextBase context = _contexts.GetContext(scriptContextName);

            System.Diagnostics.Debug.Assert(context != null);

            // this is patchy but will do for now:
            // - if we are being called from prop grid, then we have EditContext and edit that;
            // - else, if we are called to edit an expression - this is creating a new field;
            // - else, the big "Edit Scripts" button was pressed, and we default to GlobalScripts.

            EditorScriptItem scriptItem;

            if (typeDescriptorContext != null)
            {
                scriptItem = EditorScriptItem.FromTypeDescriptorContext(typeDescriptorContext, context, isScript, displayName);
            }
            else
            {
                scriptItem = EditorScriptItem.FromObjectProperty(propertyOwner, propertyName, context, isScript, displayName);
            }

            // A script item may not be "collected" if it is a new calc field being added, or e.g. in Maps there are many expressions:
            if (!_scriptItems.ContainsKey(scriptItem.Key))
            {
                scriptItem.EnsureTopKey();
                _scriptItems.Add(scriptItem.Key, scriptItem);
            }

            _scriptEditor0.Init(mainForm, _report, _scriptItems);
            _scriptEditor1.Init(mainForm, _report, _scriptItems);

            // _scriptItemKey is used ONLY for returning the script with which we were called:
            _scriptItemKey = scriptItem.Key;
            if (splitWindowMode)
            {
                _scriptEditor1.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                if (_scriptItems.ContainsKey(_mainForm._scriptEditorLastItemKey0))
                {
                    _scriptEditor0.SetCurrentScriptItem(_mainForm._scriptEditorLastItemKey0, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                }
                else
                {
                    _scriptEditor0.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                }
            }
            else
            {
                _scriptEditor0.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
                _scriptEditor1.SetCurrentScriptItem(_scriptItemKey, Forms.ScriptEditorControl.SetCurrentScriptItemContext.Initial);
            }

            // Apply main window's theme:
            var tl    = new C1ThemeLocator(_mainForm.Theme);
            var theme = tl.GetTheme();

            if (theme != null)
            {
                C1ThemeController.ApplyThemeToControlTree(this, theme);
                C1ThemeController.ApplyThemeToObject(contextMenu, theme);
            }

            // Set up script editors' glyphs - splitter and close window:
            _scriptEditor0.GlyphBox.Cursor = Cursors.HSplit;
            _scriptEditor1.GlyphBox.Image  = Properties.Resources.SplitWindowClose_16x16;

            _splitter.SplitterMoved                     += Splitter_SplitterMoved;
            _scriptEditor0.GlyphBox.MouseEnter          += GlyphBox0_MouseEnter;
            _scriptEditor0.GlyphBox.MouseLeave          += GlyphBox0_MouseLeave;
            _scriptEditor0.GlyphBox.MouseDown           += GlyphBox0_MouseDown;
            _scriptEditor0.GlyphBox.MouseMove           += GlyphBox0_MouseMove;
            _scriptEditor0.GlyphBox.MouseUp             += GlyphBox0_MouseUp;
            _scriptEditor0.GlyphBox.MouseCaptureChanged += GlyphBox0_MouseCaptureChanged;
            _scriptEditor1.GlyphBox.MouseDown           += GlyphBox1_MouseDown;

            // Ready to start:
            UpdateStatusBar();
            //
            rbnMain.EndUpdate();
            //
        }