Example #1
0
        public static IImageObject ShowCreate(Form owner)
        {
            IImageObject result = null;

            using (PrintObjectForm form = new PrintObjectForm())
            {
                Type type = typeof(VoucherAllocation);
                var properties = type.GetProperties();
                var propertiesstrList = properties.Convert<PropertyInfo, string>((i) => i.Name).ToArray();
                form.Bind(propertiesstrList);
                form.Location = Control.MousePosition;

                if (form.ShowDialog(owner) == DialogResult.OK)
                {
                    result = (form.IsBarCode) ? (IImageObject)new BarcodeInter2of5() : (IImageObject)new TextObject();
                    result.Text = form.SelectedText;
                    result.Font = form.SelectedFont;
                    result.BoundColumn = form.DataSourceColumn;
                    result.Format = form.Format;

                    using (Graphics g = owner.CreateGraphics())
                        result.Measure(g);

                }
                return result;
            }             
        }
Example #2
0
        public static bool ShowEdit(Form owner, IImageObject obj)
        {
            Debug.Assert(obj != null);

            using (PrintObjectForm form = new PrintObjectForm())
            {
                Type type = typeof(VoucherAllocation);
                var properties = type.GetProperties();
                var propertiesstrList = properties.Convert<PropertyInfo, string>((i) => i.Name).ToArray();
                form.Bind(propertiesstrList);
                form.Location = Control.MousePosition;
                form.SelectedFont = obj.Font;
                form.SelectedText = obj.Text;
                form.Format = obj.Format;
                form.IsBarCode = obj is BarcodeInter2of5;
                form.DataSourceColumn = obj.BoundColumn;
                form.DisableTypeChange();

                if (form.ShowDialog(owner) == DialogResult.OK)
                {
                    obj.Font = form.SelectedFont;
                    obj.Text = form.SelectedText;
                    obj.Format = form.Format;
                    obj.BoundColumn = form.DataSourceColumn;

                    using (Graphics g = owner.CreateGraphics())
                        obj.Measure(g);

                    return true;
                }
                return false;
            }
        }
Example #3
0
 private void AddDelete_Click(object sender, EventArgs e)
 {
     if (sender == tsmiAdd)
     {
         IImageObject point = PrintObjectForm.ShowCreate(this);
         if (point != null)
         {
             point.Location = m_CurrentLocation;
             m_DocumentLayout.MetaObjectsList.Add(point);
             Invalidate();
         }
     }
     else if (sender == tsmiDelete)
     {
         if (m_SelectImageObject != null && m_DocumentLayout.MetaObjectsList.Remove(m_SelectImageObject))
         {
             Invalidate();
         }
         m_SelectImageObject = null;
     }
     else if (sender == tsmiEdit)
     {
         if (m_SelectImageObject != null && PrintObjectForm.ShowEdit(this, m_SelectImageObject))
         {
             Invalidate();
         }
     }
     else
     {
         throw new NotImplementedException();
     }
 }