Example #1
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 #2
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;
            }             
        }