private void FaceItemsListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (FaceItemsListBox.SelectedIndex != -1)
     {
         ItemListBoxItem item1 = FaceItemsListBox.SelectedItem as ItemListBoxItem;
         if (item1 == null)
         {
             return;
         }
         TemplateItemSetting setting = new TemplateItemSetting(TemplateSettingType.Edit, item1.Item);
         DialogResult        result  = setting.ShowDialog();
         if (DialogResult.OK == result)
         {
             TemplateFaceItem item    = setting.Item;
             TemplateFaceItem newItem = template.Face.Items.EditItem(item1.Item);
             if (newItem != null)
             {
                 newItem.Name        = item.Name;
                 newItem.XAxis       = item.XAxis; //(int)PixelsToMillimetersWidth(item.XAxis);
                 newItem.YAxis       = item.YAxis; //(int)PixelsToMillimetersWidth(item.YAxis);
                 newItem.ItemColor   = item.ItemColor;
                 newItem.ItemFont    = item.ItemFont;
                 newItem.Description = item.Description;
             }
         }
         else if (DialogResult.Abort == result)
         {
             TemplateFaceItem item = setting.Item;
             template.Face.Items.DeleteItem(item1.Item);
         }
         BindFaceItemsListBox();
     }
 }
Beispiel #2
0
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
     if (showbg)
     {
         e.Graphics.DrawImage(template.Background.BgImage, new Rectangle(new Point(0, 0), new Size((int)MillimetersToPixelsWidthX(template.Background.ImageWidth, e.Graphics), (int)MillimetersToPixelsWidthY(template.Background.ImageHeight, e.Graphics))));
     }
     for (int i = 0; i < template.Face.Items.Count; i++)
     {
         TemplateFaceItem item = template.Face.Items[i];
         object           o    = GetFromType(item.Itemtype);
         if (o.GetType() == typeof(Image))
         {
             Image image = o as Image;
             e.Graphics.DrawImage(image, new Rectangle(new Point(0, 0), new Size(image.Size.Width, image.Size.Height)));
         }
         else
         {
             if (item.Itemtype != "条码")
             {
                 Brush b = new SolidBrush(item.ItemColor);
                 e.Graphics.DrawString(o.ToString(), item.ItemFont, b, new PointF((int)MillimetersToPixelsWidthX(item.XAxis, e.Graphics) - x, (int)MillimetersToPixelsWidthY(item.YAxis, e.Graphics) - y));
             }
             else
             {
                 if (_BarCode != null)
                 {
                     _BarCodeRectangle = new Rectangle((int)MillimetersToPixelsWidthX(item.XAxis, e.Graphics) - x, (int)MillimetersToPixelsWidthY(item.YAxis, e.Graphics) - y, 200, 60);
                     _BarCode.Draw(e.Graphics, _BarCodeRectangle, GraphicsUnit.Inch, 0.01f, 0, null);
                 }
             }
         }
     }
 }
Beispiel #3
0
        public TemplateItemSetting(TemplateSettingType type, TemplateFaceItem item)
        {
            InitializeComponent();
            this.type = type;

            font  = fontTextBox.Font;
            color = fontTextBox.ForeColor;

            if (type == TemplateSettingType.View)
            {
                button1.Enabled       = false;
                NameTextBox.Enabled   = false;
                XTextBox.Enabled      = false;
                YTextBox.Enabled      = false;
                SettingButton.Enabled = false;
                SelectButton.Enabled  = false;
                if (item != null)
                {
                    if (item.ItemFont != null)
                    {
                        this.font = item.ItemFont;
                    }
                    this.color = item.ItemColor;
                }
            }
            if (type == TemplateSettingType.Edit)
            {
                if (item != null)
                {
                    if (item.ItemFont != null)
                    {
                        this.font = item.ItemFont;
                    }
                    this.color = item.ItemColor;
                }
            }


            if (item != null)
            {
                //button1.Enabled = false;
                NameTextBox.Text = item.Name;
                DescTextBox.Text = item.Description;
                XTextBox.Text    = item.XAxis.ToString();
                YTextBox.Text    = item.YAxis.ToString();
            }
            fontTextBox.Text    = font.Name + " " + font.Size;
            ColorTextBox.Text   = color.ToString();
            fontLabel.Font      = font;
            fontLabel.ForeColor = color;
            itemtype            = item.Itemtype;
        }
Beispiel #4
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (NameTextBox.Text.Trim() == "")
            {
                MessageBox.Show("请输入票面项名称");
                return;
            }
            int x = 0;

            try
            {
                if (XTextBox.Text.Trim() != "")
                {
                    x = Convert.ToInt32(XTextBox.Text.Trim());
                }
            }
            catch
            {
                MessageBox.Show("横坐标填写不正确。");
            }
            int y = 0;

            try
            {
                if (YTextBox.Text.Trim() != "")
                {
                    y = Convert.ToInt32(YTextBox.Text.Trim());
                }
            }
            catch
            {
                MessageBox.Show("纵坐标填写不正确。");
            }
            if (item == null)
            {
                item             = new TemplateFaceItem();
                item.Name        = NameTextBox.Text.Trim();
                item.XAxis       = x;
                item.YAxis       = y;
                item.ItemFont    = this.font;
                item.ItemColor   = this.color;
                item.Description = this.DescTextBox.Text.Trim();
                item.Itemtype    = itemtype;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void label6_MouseUp(object sender, MouseEventArgs e)
        {
            Label            la      = sender as Label;
            TemplateFaceItem item    = la.Tag as TemplateFaceItem;
            TemplateFaceItem newItem = template.Face.Items.EditItem(item);

            if (newItem != null)
            {
                newItem.Name        = item.Name;
                newItem.XAxis       = (int)PixelsToMillimetersWidth(la.Left);
                newItem.YAxis       = (int)PixelsToMillimetersWidth(la.Top);
                newItem.ItemColor   = item.ItemColor;
                newItem.ItemFont    = item.ItemFont;
                newItem.Description = item.Description;
            }
            BindFaceItemsListBox();
        }
        //private void TemplateFaceListBox_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (TemplateFaceListBox.SelectedIndex != -1)
        //    {
        //        string itemType = TemplateFaceListBox.SelectedItem.ToString();
        //        TemplateItemSetting setting = new TemplateItemSetting(TemplateSettingType.New, null);
        //        if (DialogResult.OK == setting.ShowDialog())
        //        {
        //            TemplateFaceItem item = setting.Item;
        //            item.Itemtype = itemType;
        //            template.Face.Items.AddItem(item);
        //            BindFaceItemsListBox();
        //        }
        //    }
        //}

        private void BindFaceItemsListBox()
        {
            FaceItemsListBox.Items.Clear();
            TemplateFacePanel.Controls.Clear();
            //throw new NotImplementedException();
            TemplateFaceItemCollection items = template.Face.Items;

            items.Reset();
            while (items.MoveNext())
            {
                TemplateFaceItem item = items.Current as TemplateFaceItem;
                if (item.Status != TemplateItemStatus.Delete)
                {
                    FaceItemsListBox.Items.Add(new ItemListBoxItem(item));
                }
                CreateItemTextBox(item);
            }
        }
 private void TemplateFacePanel_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.StringFormat))
     {
         TemplateFaceItem item = new TemplateFaceItem();
         item.Itemtype = (string)e.Data.GetData(
             DataFormats.StringFormat);
         item.Description = item.Itemtype;
         item.XAxis       = (int)PixelsToMillimetersWidth(e.X - GetPosX() + 3);
         item.YAxis       = (int)PixelsToMillimetersWidth(e.Y - GetPosY() - 1);
         TemplateItemSetting setting = new TemplateItemSetting(TemplateSettingType.Edit, item);
         if (DialogResult.OK == setting.ShowDialog())
         {
             TemplateFaceItem item1 = setting.Item;
             template.Face.Items.AddItem(item1);
             BindFaceItemsListBox();
         }
     }
 }
        void CreateItemTextBox(TemplateFaceItem item)
        {
            Label box = new Label();

            box.Text        = item.Name;
            box.Font        = item.ItemFont;
            box.ForeColor   = item.ItemColor;
            box.BorderStyle = BorderStyle.None;
            //box.Enabled = false;
            box.Location = new Point((int)MillimetersToPixelsWidth(item.XAxis), (int)MillimetersToPixelsWidth(item.YAxis));
            box.Tag      = item;
            if (type != TemplateSettingType.View)
            {
                box.MouseMove += label6_MouseMove;
                box.MouseDown += label6_MouseDown;
                box.MouseUp   += label6_MouseUp;

                //box.c
            }
            //box.BackColor = Color.Transparent;
            box.AutoSize = true;
            TemplateFacePanel.Controls.Add(box);
        }
 public ItemListBoxItem(TemplateFaceItem item)
 {
     this.item = item;
 }