Ejemplo n.º 1
0
        private void listViewIds_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewIds.SelectedItems.Count <= 0)
            {
                return;
            }

            panelEditZone.Controls.Clear();

            if (lastSelected != null)
            {
                lastSelected.BackColor = System.Drawing.SystemColors.Window;
            }
            listViewIds.SelectedItems[0].BackColor = Color.Gold;
            lastSelected = listViewIds.SelectedItems[0];

            IniFile configData = new IniFile(String.Format("config/db/{0}.ini", packName));

            String[] data = listViewIds.SelectedItems[0].Text.Split('.');
            selectId = int.Parse(data[0]);

            int index = 0;
            int row   = 0;
            int col   = 0;

            foreach (BiData bikey in pack.data.Keys)
            {
                if (bikey.a != selectId)
                {
                    continue;
                }

                index = 0;
                int   wid        = panelEditZone.Width / 2;
                Point offside    = new Point(8, 20);
                Font  fontsong   = new Font("宋体", 10, FontStyle.Regular);
                int   enumsIndex = 0;
                foreach (String head in pack.headers)
                {
                    int indx = pack.GetPackIndexByName(head);
                    if (indx == 0)
                    {
                        continue;
                    }

                    #region 构建控件
                    Label lbl = new Label();
                    lbl.Location = new Point(col * wid + offside.X, row * 30 + offside.Y);
                    lbl.Text     = head;
                    lbl.AutoSize = true;
                    lbl.Font     = fontsong;
                    lbl.Name     = "lbl" + head;
                    panelEditZone.Controls.Add(lbl);

                    Label lbl2 = new Label();
                    lbl2.ForeColor = Color.DarkBlue;
                    lbl2.Location  = new Point(lbl.Location.X + lbl.Width + 5, row * 30 + 3 + offside.Y);
                    lbl2.Text      = pack.comment[indx];
                    int wordscap = (165 - lbl.Width) / 16;
                    if (lbl2.Text.Length > wordscap)
                    {
                        if (wordscap <= 0)
                        {
                            lbl2.Text = "";
                        }
                        else
                        {
                            lbl2.Text = String.Format("{0}...", lbl2.Text.Substring(0, wordscap - 1));
                        }
                    }
                    lbl2.AutoSize = true;
                    panelEditZone.Controls.Add(lbl2);
                    string  urlpath    = configData.IniReadValue(head, "path");
                    string  urlsize    = configData.IniReadValue(head, "size");
                    string  ext        = configData.IniReadValue(head, "ext");
                    string  enums      = configData.IniReadValue(head, "enums");
                    string  bind       = configData.IniReadValue(head, "bind");
                    string  groupitem  = configData.IniReadValue(head, "groupitem");
                    string  itemgroup  = configData.IniReadValue(head, "itemgroup");
                    string  attrcheck  = configData.IniReadValue(head, "attrcheck");
                    string  hide       = configData.IniReadValue(head, "hide");
                    string  timehour   = configData.IniReadValue(head, "timehour");
                    string  wisebox    = configData.IniReadValue(head, "wisebox");
                    string  colorwords = configData.IniReadValue(head, "colorwords");
                    string  itemlist   = configData.IniReadValue(head, "itemlist");
                    string  taskcond   = configData.IniReadValue(head, "taskcond");
                    Control c          = null;
                    if (urlpath != "") //图片combox
                    {
                        c = new UCPictureComboBox();
                        (c as UCPictureComboBox).PictureSize = urlsize;
                        (c as UCPictureComboBox).SetPath(urlpath, ext);
                    }
                    else if (enums != "") //combox
                    {
                        c = new UCComboBox();
                        (c as UCComboBox).Info = enums;
                        if (head == "bi_condition")
                        {
                            enumsIndex = indx;
                        }
                    }
                    else if (bind != "") //boxlabel
                    {
                        c = new UCBoxLabel();
                        (c as UCBoxLabel).TableName = bind;
                    }
                    else if (groupitem != "") //combox
                    {
                        c = new UCGroupItem();
                    }
                    else if (attrcheck != "")
                    {
                        c = new UCAttrBox();
                    }
                    else if (itemgroup != "")
                    {
                        c = new UCItem();
                        int indx2 = pack.GetPackIndexByName(itemgroup);
                        (c as UCItem).Type = int.Parse(pack.data[bikey][indx2]);
                    }
                    else if (timehour != "")
                    {
                        c = new UCTimeHour();
                    }
                    else if (wisebox != "")
                    {
                        c = new UCWiseBoxLabel();
                    }
                    else if (hide != "")
                    {
                        row++;
                        col          = 0;
                        lbl.Visible  = false;
                        lbl2.Visible = false;
                        continue;
                    }
                    else if (colorwords != "")
                    {
                        c = new UCColorWordsBox();
                    }
                    else if (itemlist != "")
                    {
                        c = new UCItemList();
                    }
                    else if (taskcond != "")
                    {
                        c = new UCTaskRequest();
                        Control c1 = panelEditZone.Controls[String.Format("{0}-{1}", taskcond, bikey.b)];
                        c1.Tag = String.Format("{0}-{1}", head, bikey.b);
                        (c1 as UCComboBox).SelectedIndexChanged += comboBoxChanged;
                    }
                    else //textbox
                    {
                        c = new UCTextBox();
                        if (pack.dataTypes[indx] == "char")
                        {
                            (c as UCTextBox).TextSize = pack.dataSizes[indx];
                        }
                    }
                    c.Enabled  = (indx > 1 && (packName != "group_drop" || bikey.a != bikey.b));
                    c.Name     = String.Format("{0}-{1}", head, bikey.b);
                    c.Location = new Point(col * wid + 170 + offside.X, row * 30 + offside.Y);
                    if (c.Height > 30)
                    {
                        row += c.Height / 30;
                        col  = 0;
                    }
                    panelEditZone.Controls.Add(c);
                    #endregion

                    if (taskcond != "")
                    {
                        setControlValue((panelEditZone.Controls[String.Format("{0}-{1}", taskcond, bikey.b)] as IAutoControl), pack.data[bikey][enumsIndex]);
                    }
                    if (enumsIndex != indx)
                    {
                        setControlValue(c as IAutoControl, pack.data[bikey][indx]);
                    }


                    index++;
                    if (col == 0 && row == 0)
                    {
                        row++;
                    }
                    else if (index < pack.dataTypes.Count && (pack.comment[index].Contains("[NL]") || pack.comment[index - 1].Contains("[NL]"))) //特殊标签
                    {
                        row++;
                        col = 0;
                    }
                    else if (indx < pack.dataTypes.Count && col == 0 && (pack.dataTypes[indx] != "char" || pack.dataSizes[indx] <= 8) && (indx > pack.dataTypes.Count - 2 || pack.dataTypes[indx + 1] != "char" || pack.dataSizes[indx + 1] <= 8))
                    {
                        col++;
                    }
                    else
                    {
                        row++;
                        col = 0;
                    }
                }

                row += 2;
                col  = 0;
                fontsong.Dispose();
            }

            Button tb = new Button();
            tb.Text     = "新建";
            tb.Location = new Point(30, row * 30);
            tb.Click   += buttonAdd_Click;
            panelEditZone.Controls.Add(tb);

            tb          = new Button();
            tb.Text     = "删除";
            tb.Location = new Point(130, row * 30);
            tb.Click   += buttonDelete_Click;
            panelEditZone.Controls.Add(tb);

            tb          = new Button();
            tb.Text     = "保存";
            tb.Location = new Point(230, row * 30);
            tb.Click   += buttonEdit_Click;
            panelEditZone.Controls.Add(tb);

            tb          = new Button();
            tb.Text     = "导出";
            tb.Location = new Point(330, row * 30);
            tb.Click   += buttonExport_Click;
            panelEditZone.Controls.Add(tb);

            tb          = new Button();
            tb.Text     = "导入";
            tb.Location = new Point(430, row * 30);
            tb.Click   += buttonImport_Click;
            panelEditZone.Controls.Add(tb);

            tb          = new Button();
            tb.Text     = "追加导入";
            tb.Location = new Point(530, row * 30);
            tb.Click   += buttonImportAppend_Click;
            panelEditZone.Controls.Add(tb);

            row += 2;

            panelEditZone.Height = (row + 2) * 30;

            searchBase = listViewIds.SelectedIndices[0];
        }
Ejemplo n.º 2
0
        private void DataEditForm_Load(object sender, EventArgs e)
        {
            pack = DataPackBook.GetPack(packName);
            IniFile configData = new IniFile(String.Format("config/db/{0}.ini", packName));

            string nameindex = configData.IniReadValue("main", "nameindex");

            if (nameindex != "")
            {
                nameIndex = int.Parse(nameindex);
            }

            Label lbc = new Label();

            lbc.Location = new Point(0, 0);
            lbc.Text     = "";
            lbc.Name     = "lbltop";
            panelEditZone.Controls.Add(lbc);

            int   index    = 0;
            int   row      = 0;
            int   col      = 0;
            int   wid      = panelEditZone.Width / 2;
            Point offside  = new Point(8, 20);
            Font  fontsong = new Font("宋体", 10, FontStyle.Regular);

            foreach (String head in pack.headers)
            {
                #region 构建控件
                Label lbl = new Label();
                lbl.Location = new Point(col * wid + offside.X, row * 30 + offside.Y);
                lbl.Text     = head;
                lbl.AutoSize = true;
                lbl.Font     = fontsong;
                lbl.Name     = "lbl" + head;
                panelEditZone.Controls.Add(lbl);

                Label lbl2 = new Label();
                lbl2.ForeColor   = Color.DarkBlue;
                lbl2.Location    = new Point(lbl.Location.X + lbl.Width + 5, row * 30 + 3 + offside.Y);
                lbl2.Text        = pack.comment[index];
                lbl2.Tag         = pack.comment[index];
                lbl2.MouseHover += new EventHandler(lbl2_MouseHover);
                int wordscap = (165 - lbl.Width) / 16;
                if (lbl2.Text.Length > wordscap)
                {
                    if (wordscap <= 0)
                    {
                        lbl2.Text = "";
                    }
                    else
                    {
                        lbl2.Text = String.Format("{0}...", lbl2.Text.Substring(0, wordscap - 1));
                    }
                }
                lbl2.AutoSize = true;
                panelEditZone.Controls.Add(lbl2);

                string urlpath      = configData.IniReadValue(head, "path");
                string urlsize      = configData.IniReadValue(head, "size");
                string enums        = configData.IniReadValue(head, "enums");
                string ext          = configData.IniReadValue(head, "ext");
                string bind         = configData.IniReadValue(head, "bind");
                string checktxt     = configData.IniReadValue(head, "checktxt");
                string dialogcheck  = configData.IniReadValue(head, "dialogcheck");
                string attrcheck    = configData.IniReadValue(head, "attrcheck");
                string taskcond     = configData.IniReadValue(head, "taskcond");
                string icon         = configData.IniReadValue(head, "icon");
                string icondes      = configData.IniReadValue(head, "icondes");
                string unixtime     = configData.IniReadValue(head, "unixtime");
                string itemlist     = configData.IniReadValue(head, "itemlist");
                string rectgraph    = configData.IniReadValue(head, "rectgraph");
                string movie        = configData.IniReadValue(head, "movie");
                string timehour     = configData.IniReadValue(head, "timehour");
                string wisebox      = configData.IniReadValue(head, "wisebox");
                string wiseguidebox = configData.IniReadValue(head, "wiseguidebox");
                string colorwords   = configData.IniReadValue(head, "colorwords");
                string effectpath   = configData.IniReadValue(head, "effpath");
                string itemgroup    = configData.IniReadValue(head, "itemgroup");
                string hide         = configData.IniReadValue(head, "hide");

                Control c = null;
                if (urlpath != "") //图片combox
                {
                    c = new UCPictureComboBox();
                    (c as UCPictureComboBox).PictureSize = urlsize;
                    (c as UCPictureComboBox).SetPath(urlpath, ext);
                }
                else if (effectpath != "")
                {
                    c = new UCEffectBox();
                    (c as UCEffectBox).SetPath(effectpath, ext);
                }
                else if (enums != "") //combox
                {
                    c = new UCComboBox();
                    (c as UCComboBox).Info = enums;
                }
                else if (bind != "") //boxlabel
                {
                    c = new UCBoxLabel();
                    (c as UCBoxLabel).TableName = bind;
                }
                else if (checktxt != "")
                {
                    c = new UCCheckBoxGroup();
                    (c as UCCheckBoxGroup).Info = checktxt;
                }
                else if (dialogcheck != "")
                {
                    c = new UCDialogBox();
                }
                else if (attrcheck != "")
                {
                    c = new UCAttrBox();
                }
                else if (rectgraph != "")
                {
                    c = new UCRectGraph();
                    string[] info = rectgraph.Split('|');
                    (panelEditZone.Controls[info[0]] as UCTextBox).TextChanged  += rectTextChanged;
                    (panelEditZone.Controls[info[1]] as UCTextBox).TextChanged  += rectTextChanged;
                    (panelEditZone.Controls[info[2]] as UCTextBox).TextChanged  += rectTextChanged;
                    (panelEditZone.Controls[info[3]] as UCTextBox).TextChanged  += rectTextChanged;
                    (panelEditZone.Controls[info[4]] as UCBoxLabel).TextChanged += rectTextChanged;
                    (panelEditZone.Controls[info[5]] as UCBoxLabel).TextChanged += rectTextChanged;

                    (panelEditZone.Controls[info[0]] as UCTextBox).Tag  = "x1";
                    (panelEditZone.Controls[info[1]] as UCTextBox).Tag  = "y1";
                    (panelEditZone.Controls[info[2]] as UCTextBox).Tag  = "x2";
                    (panelEditZone.Controls[info[3]] as UCTextBox).Tag  = "y2";
                    (panelEditZone.Controls[info[4]] as UCBoxLabel).Tag = "m1";
                    (panelEditZone.Controls[info[5]] as UCBoxLabel).Tag = "m2";
                }
                else if (taskcond != "")
                {
                    c = new UCTaskRequest();
                    panelEditZone.Controls[taskcond].Tag = head;
                    (panelEditZone.Controls[taskcond] as UCComboBox).SelectedIndexChanged += comboBoxChanged;
                }
                else if (movie != "")
                {
                    c = new UCMovieData();
                    panelEditZone.Controls[movie].Tag = head;
                    (panelEditZone.Controls[movie] as UCComboBox).SelectedIndexChanged += comboBoxChanged;
                }
                else if (icon != "")
                {
                    c = new UCBoxIcon();
                    (c as UCBoxIcon).Icon = icon;
                    (c as UCBoxIcon).Des  = icondes;
                }
                else if (unixtime != "")
                {
                    c = new UCUnixTimeLabel();
                }
                else if (itemlist != "")
                {
                    c = new UCItemList();
                }
                else if (timehour != "")
                {
                    c = new UCTimeHour();
                }
                else if (wisebox != "")
                {
                    c = new UCWiseBoxLabel();
                }
                else if (wiseguidebox != "")
                {
                    c = new UCWiseGuideBoxLabel();
                }
                else if (colorwords != "")
                {
                    c = new UCColorWordsBox();
                }
                else if (itemgroup != "")
                {
                    c = new UCItem();
                }
                else if (hide != "")
                {
                    row++;
                    col          = 0;
                    lbl.Visible  = false;
                    lbl2.Visible = false;
                    index++;
                    continue;
                }
                else //textbox
                {
                    c = new UCTextBox();
                    if (pack.dataTypes[index] == "char")
                    {
                        (c as UCTextBox).TextSize = pack.dataSizes[index];
                    }
                }
                c.Enabled  = (index > 0);
                c.Name     = head;
                c.Location = new Point(col * wid + 170 + offside.X, row * 30 + offside.Y);
                if (c.Height > 30)
                {
                    row += c.Height / 30;
                    col  = 0;
                }
                panelEditZone.Controls.Add(c);
                #endregion

                index++;
                if (col == 0 && row == 0)
                {
                    row++;
                }
                else if (index < pack.dataTypes.Count && (pack.comment[index].Contains("[NL]") || pack.comment[index - 1].Contains("[NL]"))) //特殊标签
                {
                    row++;
                    col = 0;
                }
                else if (c.Height <= 30 && index < pack.dataTypes.Count && col == 0 && (pack.dataTypes[index] != "char" || pack.dataSizes[index] <= 8) && (pack.dataTypes[index - 1] != "char" || pack.dataSizes[index - 1] <= 8))
                {
                    col++;
                }
                else
                {
                    row++;
                    col = 0;
                }
                comboBoxWord.Items.Add(head);
            }
            comboBoxWord.SelectedIndex = 0;
            fontsong.Dispose();
            panelEditZone.Height = (row + 2) * 30;

            refreshList(0);

            isInit = true;
        }