Esempio n. 1
0
        private void pg_design_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
            string strtag = Convert.ToString(this.pg_design.Tag);

            if (strtag == "BarcodeAddData")
            {
                BarcodeAddData BarcodeAddDatatmp = (BarcodeAddData)pg_design.SelectedObject;

                //更新参数名字+关键字
                string old_key = Sl_par.GetKey(Sl_par.IndexOfValue(BarcodeAddDatatmp)).ToString();
                string new_key = BarcodeAddDatatmp.Name;
                Label  lab_tmp = (Label)this.Sl_Label[old_key];
                if (old_key != new_key)
                {
                    Sl_par.Remove(old_key);
                    Sl_par.Add(new_key, BarcodeAddDatatmp);
                    Sl_Label.Remove(old_key);
                    Sl_Label.Add(new_key, lab_tmp);
                    lab_tmp.Text = new_key;
                }

                lab_tmp.Location = new Point(BarcodeAddDatatmp.X, BarcodeAddDatatmp.Y);
                if (BarcodeAddDatatmp.Bold == true)
                {
                    lab_tmp.Font = new Font("宋体", BarcodeAddDatatmp.ForeSize, FontStyle.Bold);
                }
                else
                {
                    lab_tmp.Font = new Font("宋体", BarcodeAddDatatmp.ForeSize, FontStyle.Regular);
                }
            }
            else if (strtag == "BarcodeData")
            {
                reEncode();
            }
            else if (strtag == "DesignFormData")
            {
                this.pan_design.Height = (int)(dpiY * DesignFormData01.PrintHeight / (float)25.4 * DesignFormData01.DPI / dpiY);
                this.pan_design.Width  = (int)(dpiX * DesignFormData01.PrintWidth / (float)25.4 * DesignFormData01.DPI / dpiX);

                //barcode.Height = DesignFormData01.BarCodeHeight;
                DesignFormData01.BarCodeWidth = DesignFormData01.BarCodeHeight * 2;
                //barcode.Width = DesignFormData01.BarCodeWidth;
                BarcodeData01.Height = DesignFormData01.BarCodeHeight;
                BarcodeData01.Width  = DesignFormData01.BarCodeWidth;
                reEncode();
            }
        }
Esempio n. 2
0
 private void label_all_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Label lab_tmp = (Label)sender;
         mouseDownPoint.X = Cursor.Position.X;
         mouseDownPoint.Y = Cursor.Position.Y;
         isMove           = true;
         lab_tmp.Focus();
         //显示属性
         BarcodeAddData BarcodeAddDatatmp = (BarcodeAddData)this.Sl_par[lab_tmp.Text];
         this.pg_design.Tag       = "BarcodeAddData";
         pg_design.SelectedObject = BarcodeAddDatatmp;
         pg_design.Refresh();
     }
 }
Esempio n. 3
0
 private void tsm_del_Click(object sender, EventArgs e)
 {
     if (pg_design.Tag != null && this.pg_design.Tag == "BarcodeAddData")
     {
         BarcodeAddData BarcodeAddDatatmp = (BarcodeAddData)this.pg_design.SelectedObject;
         string         str_info_name     = BarcodeAddDatatmp.Name;
         Label          lab_tmp           = (Label)this.Sl_Label[str_info_name];
         this.pan_design.Controls.Remove(lab_tmp);
         Sl_Label.Remove(str_info_name);
         Sl_par.Remove(str_info_name);
     }
     else
     {
         MessageBox.Show("对不起!请先选定要删除的参数。");
     }
 }
Esempio n. 4
0
        private void tsm_create_Click(object sender, EventArgs e)
        {
            string str_BarcodeData    = BarcodeData01.GetXML();
            string str_DesignFormData = DesignFormData01.GetXML();
            string str_BarcodeAddData = "";

            if (this.Sl_par.Count > 0)
            {
                str_BarcodeAddData = "<BarcodeAddData>";
                for (int i = 0; i < Sl_par.Count; i++)
                {
                    BarcodeAddData BarcodeAddDatatmp = (BarcodeAddData)Sl_par.GetByIndex(i);
                    str_BarcodeAddData = str_BarcodeAddData + BarcodeAddDatatmp.GetXML();
                }
                str_BarcodeAddData = str_BarcodeAddData + "</BarcodeAddData>";
            }
            rtb_xml.Text = "<Data>" + str_DesignFormData + str_BarcodeData + str_BarcodeAddData + "</Data>";
            UserXmlUpdate(sender, e, rtb_xml.Text);
        }
Esempio n. 5
0
 private void label_all_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         Label lab_tmp = (Label)sender;
         isMove = false;
         //显示属性
         BarcodeAddData BarcodeAddDatatmp = (BarcodeAddData)this.Sl_par[lab_tmp.Text];
         if (lab_tmp.Location.X < 0 || lab_tmp.Location.X > this.pan_design.Width || lab_tmp.Location.Y < 0 || lab_tmp.Location.Y > pan_design.Height)
         {
             lab_tmp.Location = new Point(BarcodeAddDatatmp.X, BarcodeAddDatatmp.Y);
         }
         else
         {
             BarcodeAddDatatmp.X = lab_tmp.Location.X;
             BarcodeAddDatatmp.Y = lab_tmp.Location.Y;
         }
         this.pg_design.Refresh();
     }
 }
Esempio n. 6
0
        private void tsm_add_Click(object sender, EventArgs e)
        {
            int labcount = 0, intlab = 0;

            while (intlab == 0)
            {
                labcount++;
                if (Sl_Label["parameter" + labcount.ToString()] == null)
                {
                    intlab = 1;
                    //MessageBox.Show("对不起!自动增加遇到参数重名,请先修改成自定义参数名。");
                    //return;
                }
            }
            //this.dgv_01.RowCount++;
            string strname = "parameter" + labcount.ToString();
            //dgv_01.Rows[dgv_01.RowCount - 1].Cells["info_name"].Value = strname;
            //dgv_01.Rows[dgv_01.RowCount - 1].Cells["id"].Value = strname;
            Label lab_tmp = new Label();

            lab_tmp.Text       = strname;
            lab_tmp.AutoSize   = true;
            lab_tmp.BackColor  = Color.Transparent;
            lab_tmp.Location   = new Point(20, 20);
            lab_tmp.Font       = new Font("宋体", 15, FontStyle.Bold);
            lab_tmp.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseDown);
            lab_tmp.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseMove);
            lab_tmp.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseUp);
            Sl_Label.Add(strname, lab_tmp);
            BarcodeAddData BarcodeAddData_tmp = new BarcodeAddData();

            BarcodeAddData_tmp.Name = strname;
            this.Sl_par.Add(strname, BarcodeAddData_tmp);
            this.pan_design.Controls.Add(lab_tmp);
            lab_tmp.BringToFront();
        }
Esempio n. 7
0
        private void Analysis_XML(string inXML)
        {
            xmldoc.LoadXml(inXML);
            XmlElement DesignFormDataXML = xmldoc["Data"]["DesignFormData"];
            XmlElement BarcodeDataXML    = xmldoc["Data"]["BarcodeData"];
            //XmlElement BarcodeAddDataXML = xmldoc["Data"]["BarcodeAddData"];
            XmlNodeList BarcodeAddDataXML = xmldoc.SelectNodes("/Data/BarcodeAddData/BarcodeAdd");
            string      aaa0 = DesignFormDataXML.InnerXml;
            string      aaa1 = BarcodeDataXML.InnerXml;


            #region 构造DesignFormData-BarcodeDataXML-BarCode

            //DesignFormDataXML
            DesignFormData01.BarCodeHeight = int.Parse(DesignFormDataXML["BarCodeHeight"].InnerText.Trim());
            DesignFormData01.BarCodeWidth  = int.Parse(DesignFormDataXML["BarCodeWidth"].InnerText.Trim());
            DesignFormData01.Height        = int.Parse(DesignFormDataXML["Height"].InnerText.Trim());
            DesignFormData01.Width         = int.Parse(DesignFormDataXML["Width"].InnerText.Trim());
            DesignFormData01.PrintHeight   = int.Parse(DesignFormDataXML["PrintHeight"].InnerText.Trim());
            DesignFormData01.PrintWidth    = int.Parse(DesignFormDataXML["PrintWidth"].InnerText.Trim());
            DesignFormData01.DPI           = int.Parse(DesignFormDataXML["DPI"].InnerText.Trim());
            //构造组件
            this.pan_design.Height = (int)(DesignFormData01.PrintHeight / (float)25.4 * DesignFormData01.DPI);
            this.pan_design.Width  = (int)(DesignFormData01.PrintWidth / (float)25.4 * DesignFormData01.DPI);

            //this.Height = DesignFormData01.Height;
            //this.Width = DesignFormData01.Width;

            //BarcodeDataXML
            BarcodeData01.Height       = int.Parse(BarcodeDataXML["Height"].InnerText.Trim());
            BarcodeData01.Width        = int.Parse(BarcodeDataXML["Width"].InnerText.Trim());
            BarcodeData01.IsLabel      = bool.Parse(BarcodeDataXML["IsLabel"].InnerText.Trim().ToLower());
            BarcodeData01.BarcodeValue = BarcodeDataXML["BarcodeValue"].InnerText.Trim();
            BarcodeData01.X            = int.Parse(BarcodeDataXML["X"].InnerText.Trim());
            BarcodeData01.Y            = int.Parse(BarcodeDataXML["Y"].InnerText.Trim());

            string str_tmp = BarcodeDataXML["Alignment"].InnerText.Trim();
            foreach (AlignmentPositions type in Enum.GetValues(typeof(AlignmentPositions)))
            {
                if (str_tmp == type.ToString())
                {
                    BarcodeData01.Alignment = type;
                }
            }
            str_tmp = BarcodeDataXML["Background"].InnerText.Trim();
            BarcodeData01.Background = System.Drawing.Color.FromArgb(int.Parse(str_tmp));
            str_tmp = BarcodeDataXML["Foreground"].InnerText.Trim();
            BarcodeData01.Foreground = System.Drawing.Color.FromArgb(int.Parse(str_tmp));
            str_tmp = BarcodeDataXML["Encoding"].InnerText.Trim();
            foreach (TYPE type in Enum.GetValues(typeof(TYPE)))
            {
                if (str_tmp == type.ToString())
                {
                    BarcodeData01.Encoding = type;
                }
            }
            str_tmp = BarcodeDataXML["LabelLocation"].InnerText.Trim();
            foreach (LabelPositions type in Enum.GetValues(typeof(LabelPositions)))
            {
                if (str_tmp == type.ToString())
                {
                    BarcodeData01.LabelLocation = type;
                }
            }
            str_tmp = BarcodeDataXML["Rotate"].InnerText.Trim();
            foreach (RotateFlipType type in Enum.GetValues(typeof(RotateFlipType)))
            {
                if (str_tmp == type.ToString())
                {
                    BarcodeData01.Rotate = type;
                }
            }

            //构造组件
            reEncode();

            #endregion


            #region 构造BarcodeAddDataXML
            //BarcodeAddDataXML
            if (BarcodeAddDataXML != null && BarcodeAddDataXML.Count > 0)
            {
                string str_Bold = "", str_DefaultValue = "", str_ForeSize = "", str_Name = "", str_X = "", str_Y = "";
                for (int i = 0; i < BarcodeAddDataXML.Count; i++)
                {
                    BarcodeAddData BarcodeAddData_tmp = new BarcodeAddData();

                    str_Bold         = BarcodeAddDataXML[i]["Bold"].InnerXml;
                    str_DefaultValue = BarcodeAddDataXML[i]["DefaultValue"].InnerXml;
                    str_ForeSize     = BarcodeAddDataXML[i]["ForeSize"].InnerXml;
                    str_Name         = BarcodeAddDataXML[i]["Name"].InnerXml;
                    str_X            = BarcodeAddDataXML[i]["X"].InnerXml.Trim();
                    str_Y            = BarcodeAddDataXML[i]["Y"].InnerXml.Trim();

                    BarcodeAddData_tmp.Name         = str_Name;
                    BarcodeAddData_tmp.DefaultValue = str_DefaultValue;
                    BarcodeAddData_tmp.ForeSize     = int.Parse(str_ForeSize);
                    BarcodeAddData_tmp.X            = int.Parse(str_X);
                    BarcodeAddData_tmp.Y            = int.Parse(str_Y);

                    Label lab_tmp = new Label();
                    lab_tmp.AutoSize = true;
                    lab_tmp.Location = new Point(int.Parse(str_X), int.Parse(str_Y));
                    if (str_Bold.ToLower() == "true")
                    {
                        BarcodeAddData_tmp.Bold = true;
                        lab_tmp.Font            = new Font("宋体", int.Parse(str_ForeSize), FontStyle.Bold);
                    }
                    else
                    {
                        BarcodeAddData_tmp.Bold = false;
                        lab_tmp.Font            = new Font("宋体", int.Parse(str_ForeSize), FontStyle.Regular);
                    }
                    lab_tmp.Text       = str_Name;
                    lab_tmp.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseDown);
                    lab_tmp.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseMove);
                    lab_tmp.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.label_all_MouseUp);

                    Sl_Label.Add(str_Name, lab_tmp);
                    this.Sl_par.Add(str_Name, BarcodeAddData_tmp);
                    this.pan_design.Controls.Add(lab_tmp);
                    lab_tmp.BringToFront();
                }
            }

            #endregion
        }