Exemplo n.º 1
0
                public EditarCampo(Lbl.Impresion.Campo campo)
                        : this()
                {
                        this.Campo = campo;

                        this.EntradaTexto.Text = this.Campo.Valor;
                        this.EntradaPreimpreso.ValueInt = this.Campo.Preimpreso ? 1 : 0;
                        if (this.Campo.Formato == null || this.Campo.Formato.Length == 0)
                                this.EntradaFormato.TextKey = "*";
                        else
                                this.EntradaFormato.TextKey = this.Campo.Formato;
                        this.EntradaX.ValueInt = this.Campo.Rectangle.X;
                        this.EntradaY.ValueInt = this.Campo.Rectangle.Y;
                        this.EntradaAncho.ValueInt = this.Campo.Rectangle.Width;
                        this.EntradaAlto.ValueInt = this.Campo.Rectangle.Height;
                        this.EntradaAlienacionHorizontal.TextKey = this.Campo.Alignment.ToString();
                        this.EntradaAlienacionVertical.TextKey = this.Campo.LineAlignment.ToString();
                        this.EntradaAjusteTexto.TextKey = this.Campo.Wrap ? "1" : "0";
                        this.EntradaAnchoBorde.ValueInt = this.Campo.AnchoBorde;
                        if (this.Campo.Font != null) {
                                Ignorar_EntradaFuenteFuenteTamano_TextChanged++;
                                this.EntradaFuenteNombre.TextKey = this.Campo.Font.Name;
                                this.EntradaFuenteTamano.ValueDecimal = Convert.ToDecimal(this.Campo.Font.Size);
                                Ignorar_EntradaFuenteFuenteTamano_TextChanged--;
                        } else {
                                this.EntradaFuenteNombre.TextKey = "*";
                                this.EntradaFuenteTamano.ValueDecimal = 10;
                        }

                        this.ActualizarMuestra();
                }
Exemplo n.º 2
0
 private void ActualizarCampos()
 {
     foreach (ListViewItem Itm in ListaCampos.Items)
     {
         Lbl.Impresion.Campo Cam = Itm.Tag as Lbl.Impresion.Campo;
         if (Cam != null)
         {
             Itm.Text = Cam.Valor;
         }
     }
 }
Exemplo n.º 3
0
        private void BotonAgregar_Click(object sender, EventArgs e)
        {
            Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

            Lbl.Impresion.Campo Cam = new Lbl.Impresion.Campo();
            Cam.Valor     = "Nuevo campo";
            Cam.Rectangle = new Rectangle(10, 10, 280, 52);
            Plantilla.Campos.Add(Cam);
            this.AgregarCampo(Cam);
            this.SeleccionarCampo(Cam);
            ListaCampos_DoubleClick(sender, e);
            ImagePreview.Invalidate();
        }
Exemplo n.º 4
0
        protected virtual void ImprimirInternaCampo(PrintPageEventArgs e, Lbl.Impresion.Campo Cam)
        {
            if (Plantilla.Tipo == Lbl.Impresion.TipoPlantilla.Preimpresa && Cam.Preimpreso)
            {
                return;
            }

            if (Cam.ColorFondo != Color.Transparent)
            {
                e.Graphics.FillRectangle(new SolidBrush(Cam.ColorFondo), Cam.Rectangle);
            }

            if (Cam.AnchoBorde > 0)
            {
                e.Graphics.DrawRectangle(new Pen(Cam.ColorBorde, Cam.AnchoBorde), Cam.Rectangle);
            }

            // Imprimir texto
            string Texto = Cam.Valor;
            // Expando variables tipo {nombrecampo} por el valor del campo
            Regex           Rx           = new Regex(@"\{[_\.0-9a-zA-Z]+\}", RegexOptions.ExplicitCapture | RegexOptions.Singleline);
            MatchCollection NombresCampo = Rx.Matches(Texto);

            foreach (Match Mt in NombresCampo)
            {
                string ValorCampo = ObtenerValorCampo(Mt.Value.Substring(1, Mt.Value.Length - 2), Cam.Formato);
                Texto = Texto.Replace(Mt.Value, ValorCampo);
            }

            StringFormat Fmt = new StringFormat();             //StringFormatFlags.NoClip);

            if (Cam.Wrap == false)
            {
                Fmt.FormatFlags |= StringFormatFlags.NoWrap;
            }
            Fmt.Alignment     = Cam.Alignment;
            Fmt.LineAlignment = Cam.LineAlignment;
            Fmt.Trimming      = StringTrimming.EllipsisCharacter;
            Font Fnt = Cam.Font;

            if (Fnt == null)
            {
                Fnt = Plantilla.Font;
            }
            if (Fnt == null)
            {
                Fnt = Lazaro.Pres.DisplayStyles.Template.Current.DefaultFont;
            }
            e.Graphics.DrawString(Texto, Fnt, new SolidBrush(Cam.ColorTexto), Cam.Rectangle, Fmt);
        }
Exemplo n.º 5
0
 private void SeleccionarCampo(Lbl.Impresion.Campo campo)
 {
     foreach (ListViewItem Itm in ListaCampos.Items)
     {
         if (Itm.Tag == campo)
         {
             Itm.Selected = true;
             Itm.EnsureVisible();
         }
         else
         {
             Itm.Selected = false;
         }
     }
 }
Exemplo n.º 6
0
        private void ListaCampos_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

            if (Plantilla.Campos != null && ListaCampos.SelectedItems.Count > 0)
            {
                CampoSeleccionado = ListaCampos.SelectedItems[0].Tag as Lbl.Impresion.Campo;
            }
            else
            {
                CampoSeleccionado = null;
            }

            ImagePreview.Invalidate();
        }
Exemplo n.º 7
0
        public EditarCampo(Lbl.Impresion.Campo campo)
            : this()
        {
            this.Campo = campo;

            this.EntradaTexto.Text          = this.Campo.Valor;
            this.EntradaPreimpreso.ValueInt = this.Campo.Preimpreso ? 1 : 0;
            if (this.Campo.Formato == null || this.Campo.Formato.Length == 0)
            {
                this.EntradaFormato.TextKey = "*";
            }
            else
            {
                this.EntradaFormato.TextKey = this.Campo.Formato;
            }
            this.EntradaX.ValueInt     = this.Campo.Rectangle.X;
            this.EntradaY.ValueInt     = this.Campo.Rectangle.Y;
            this.EntradaAncho.ValueInt = this.Campo.Rectangle.Width;
            this.EntradaAlto.ValueInt  = this.Campo.Rectangle.Height;
            this.EntradaAlienacionHorizontal.TextKey = this.Campo.Alignment.ToString();
            this.EntradaAlienacionVertical.TextKey   = this.Campo.LineAlignment.ToString();
            this.EntradaAjusteTexto.TextKey          = this.Campo.Wrap ? "1" : "0";
            this.EntradaAnchoBorde.ValueInt          = this.Campo.AnchoBorde;
            if (this.Campo.Font != null)
            {
                Ignorar_EntradaFuenteFuenteTamano_TextChanged++;
                this.EntradaFuenteNombre.TextKey      = this.Campo.Font.Name;
                this.EntradaFuenteTamano.ValueDecimal = Convert.ToDecimal(this.Campo.Font.Size);
                Ignorar_EntradaFuenteFuenteTamano_TextChanged--;
            }
            else
            {
                this.EntradaFuenteNombre.TextKey      = "*";
                this.EntradaFuenteTamano.ValueDecimal = 10;
            }

            this.ActualizarMuestra();
        }
Exemplo n.º 8
0
        private void AgregarCampo(Lbl.Impresion.Campo campo)
        {
            ListViewItem Itm = ListaCampos.Items.Add(campo.Valor);

            Itm.Tag = campo;
        }
Exemplo n.º 9
0
        private void ImagePreview_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Middle)
            {
                ButtonDown     = new Point(e.X, e.Y);
                MouseOperation = MouseOperations.PageDrag;
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                ButtonDown = PuntoDesdePantalla(new Point(e.X, e.Y));
                Point MyButtonDown = PuntoDesdePantalla(new Point(e.X, e.Y), false);

                //Lbl.Impresion.Campo CampoSeleccionadoOriginal = CampoSeleccionado;
                if (CampoSeleccionado != null)
                {
                    Rectangle RectKnob = new Rectangle(CampoSeleccionado.Rectangle.Right - KnobSize / 2, CampoSeleccionado.Rectangle.Bottom - KnobSize / 2, KnobSize, KnobSize);
                    if (CampoSeleccionado != null && RectKnob.Contains(MyButtonDown))
                    {
                        //Agarró el knob
                        MouseOperation = MouseOperations.KnobDrag;
                        return;
                    }
                    else
                    {
                        MouseOperation = MouseOperations.None;
                    }
                }

                Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

                bool Select = false;
                CampoSeleccionado = null;
                foreach (Lbl.Impresion.Campo Cam in Plantilla.Campos)
                {
                    //Busco el campo del clic (según coordenadas)
                    if (Cam.Valor == null || Cam.Valor.Length == 0 && Cam.AnchoBorde > 0)
                    {
                        //En el caso particular de los rectángulos con borde y sin texto, tiene que hacer clic en el contorno
                        if ((MyButtonDown.X >= (Cam.Rectangle.Left - 5) && (MyButtonDown.X <= (Cam.Rectangle.Left + 5)) ||
                             MyButtonDown.X >= (Cam.Rectangle.Right - 5) && (MyButtonDown.X <= (Cam.Rectangle.Right + 5)) ||
                             MyButtonDown.Y >= (Cam.Rectangle.Top - 5) && (MyButtonDown.Y <= (Cam.Rectangle.Top + 5)) ||
                             MyButtonDown.Y >= (Cam.Rectangle.Bottom - 5) && (MyButtonDown.Y <= (Cam.Rectangle.Bottom + 5))))
                        {
                            Select         = true;
                            MouseOperation = MouseOperations.ObjectDrag;
                        }
                        else
                        {
                            Select         = false;
                            MouseOperation = MouseOperations.None;
                        }
                    }
                    else if (Cam.Rectangle.Contains(MyButtonDown))
                    {
                        //El resto de los campos, se seleccionan haciendo clic en cualquier parte del rectángulo
                        Select         = true;
                        MouseOperation = MouseOperations.ObjectDrag;
                    }

                    if (Select)
                    {
                        //Encontré el campo del Click
                        //Lo selecciono mediante la listview
                        CampoSeleccionado = Cam;
                        this.SeleccionarCampo(Cam);
                        MouseOperation = MouseOperations.ObjectDrag;
                        break;
                    }
                }

                //if (CampoSeleccionado == null)
                //        CampoSeleccionado = CampoSeleccionadoOriginal;

                if (CampoSeleccionado == null)
                {
                    this.SeleccionarCampo(null);
                    ButtonDown     = new Point(e.X, e.Y);
                    MouseOperation = MouseOperations.PageDrag;
                }
                else
                {
                    CampoDown = CampoSeleccionado.Rectangle;
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                this.MostrarTextosDeEjemplo = !this.MostrarTextosDeEjemplo;
                ImagePreview.Invalidate();
            }
        }
Exemplo n.º 10
0
                private void BotonAgregar_Click(object sender, EventArgs e)
                {
                        Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

                        Lbl.Impresion.Campo Cam = new Lbl.Impresion.Campo();
                        Cam.Valor = "Nuevo campo";
                        Cam.Rectangle = new Rectangle(10, 10, 280, 52);
                        Plantilla.Campos.Add(Cam);
                        this.AgregarCampo(Cam);
                        this.SeleccionarCampo(Cam);
                        ListaCampos_DoubleClick(sender, e);
                        ImagePreview.Invalidate();
                }
Exemplo n.º 11
0
                private void ImagePreview_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
                {
                        if (e.Button == System.Windows.Forms.MouseButtons.Middle) {
                                ButtonDown = new Point(e.X, e.Y);
                                MouseOperation = MouseOperations.PageDrag;
                        } else if (e.Button == System.Windows.Forms.MouseButtons.Left) {
                                ButtonDown = PuntoDesdePantalla(new Point(e.X, e.Y));
                                Point MyButtonDown = PuntoDesdePantalla(new Point(e.X, e.Y), false);

                                //Lbl.Impresion.Campo CampoSeleccionadoOriginal = CampoSeleccionado;
                                if (CampoSeleccionado != null) {
                                        Rectangle RectKnob = new Rectangle(CampoSeleccionado.Rectangle.Right - KnobSize / 2, CampoSeleccionado.Rectangle.Bottom - KnobSize / 2, KnobSize, KnobSize);
                                        if (CampoSeleccionado != null && RectKnob.Contains(MyButtonDown)) {
                                                //Agarró el knob
                                                MouseOperation = MouseOperations.KnobDrag;
                                                return;
                                        } else {
                                                MouseOperation = MouseOperations.None;
                                        }
                                }

                                Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

                                bool Select = false;
                                CampoSeleccionado = null;
                                foreach (Lbl.Impresion.Campo Cam in Plantilla.Campos) {
                                        //Busco el campo del clic (según coordenadas)
                                        if (Cam.Valor == null || Cam.Valor.Length == 0 && Cam.AnchoBorde > 0) {
                                                //En el caso particular de los rectángulos con borde y sin texto, tiene que hacer clic en el contorno
                                                if ((MyButtonDown.X >= (Cam.Rectangle.Left - 5) && (MyButtonDown.X <= (Cam.Rectangle.Left + 5)) ||
                                                        MyButtonDown.X >= (Cam.Rectangle.Right - 5) && (MyButtonDown.X <= (Cam.Rectangle.Right + 5)) ||
                                                        MyButtonDown.Y >= (Cam.Rectangle.Top - 5) && (MyButtonDown.Y <= (Cam.Rectangle.Top + 5)) ||
                                                        MyButtonDown.Y >= (Cam.Rectangle.Bottom - 5) && (MyButtonDown.Y <= (Cam.Rectangle.Bottom + 5)))) {
                                                        Select = true;
                                                        MouseOperation = MouseOperations.ObjectDrag;
                                                } else {
                                                        Select = false;
                                                        MouseOperation = MouseOperations.None;
                                                }
                                        } else if (Cam.Rectangle.Contains(MyButtonDown)) {
                                                //El resto de los campos, se seleccionan haciendo clic en cualquier parte del rectángulo
                                                Select = true;
                                                MouseOperation = MouseOperations.ObjectDrag;
                                        }

                                        if (Select) {
                                                //Encontré el campo del Click
                                                //Lo selecciono mediante la listview
                                                CampoSeleccionado = Cam;
                                                this.SeleccionarCampo(Cam);
                                                MouseOperation = MouseOperations.ObjectDrag;
                                                break;
                                        }
                                }

                                //if (CampoSeleccionado == null)
                                //        CampoSeleccionado = CampoSeleccionadoOriginal;

                                if (CampoSeleccionado == null) {
                                        this.SeleccionarCampo(null);
                                        ButtonDown = new Point(e.X, e.Y);
                                        MouseOperation = MouseOperations.PageDrag;
                                } else {
                                        CampoDown = CampoSeleccionado.Rectangle;
                                }
                        } else if (e.Button == System.Windows.Forms.MouseButtons.Right) {
                                this.MostrarTextosDeEjemplo = !this.MostrarTextosDeEjemplo;
                                ImagePreview.Invalidate();
                        }
                }
Exemplo n.º 12
0
                private void ListaCampos_SelectedIndexChanged(object sender, System.EventArgs e)
                {
                        Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

                        if (Plantilla.Campos != null && ListaCampos.SelectedItems.Count > 0) {
                                CampoSeleccionado = ListaCampos.SelectedItems[0].Tag as Lbl.Impresion.Campo;
                        } else {
                                CampoSeleccionado = null;
                        }

                        ImagePreview.Invalidate();
                }