コード例 #1
0
        private Lfx.Types.OperationResult Cargar()
        {
            Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

            OpenFileDialog FileDialog = new OpenFileDialog();

            FileDialog.CheckFileExists  = true;
            FileDialog.CheckPathExists  = true;
            FileDialog.InitialDirectory = System.IO.Path.Combine(Lfx.Environment.Folders.UserFolder, "Plantillas");
            FileDialog.Multiselect      = false;
            FileDialog.Title            = "Cargar plantilla";
            FileDialog.ValidateNames    = true;

            switch ((Lbl.Impresion.TipoPlantilla)(EntradaTipo.ValueInt))
            {
            case Lbl.Impresion.TipoPlantilla.Pdf:
                FileDialog.Filter     = "Archivos PDF|*.pdf";
                FileDialog.DefaultExt = "pdf";
                break;

            default:
                FileDialog.Filter     = "Archivos de plantilla|*.ltx";
                FileDialog.DefaultExt = "ltx";
                break;
            }
            if (FileDialog.ShowDialog() == DialogResult.OK && FileDialog.FileName != null && FileDialog.FileName.Length > 0)
            {
                switch ((Lbl.Impresion.TipoPlantilla)(EntradaTipo.ValueInt))
                {
                case Lbl.Impresion.TipoPlantilla.Pdf:
                    int TotalBytes = (int)(new System.IO.FileInfo(FileDialog.FileName).Length);
                    using (System.IO.FileStream Str = new System.IO.FileStream(FileDialog.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
                        using (System.IO.BinaryReader Rdr = new System.IO.BinaryReader(Str)) {
                            Plantilla.Archivo = Rdr.ReadBytes(TotalBytes);
                            Rdr.Close();
                            Str.Close();
                        }
                    break;

                default:
                    using (System.IO.StreamReader Str = new System.IO.StreamReader(FileDialog.FileName, true)) {
                        Plantilla.CargarXml(Str.ReadToEnd());
                        Str.Close();
                    }
                    break;
                }
                this.MostrarListaCampos();
                BotonDiseno.PerformClick();
                ImagePreview.Invalidate();
                return(new Lfx.Types.SuccessOperationResult());
            }
            else
            {
                return(new Lfx.Types.CancelOperationResult());
            }
        }
コード例 #2
0
        private void BotonQuitar_Click(object sender, EventArgs e)
        {
            if (CampoSeleccionado != null)
            {
                Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

                Plantilla.Campos.Remove(CampoSeleccionado);
                this.MostrarListaCampos();
                ImagePreview.Invalidate();
            }
        }
コード例 #3
0
 private void EditarCampoSeleccionado()
 {
     if (CampoSeleccionado != null)
     {
         EditarCampo FormEditarCampo = new EditarCampo(CampoSeleccionado);
         if (FormEditarCampo.ShowDialog() == DialogResult.OK)
         {
             this.ActualizarCampos();
             ImagePreview.Invalidate();
         }
     }
 }
コード例 #4
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();
        }
コード例 #5
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();
        }
コード例 #6
0
        public void RecalcularTamanoVistaPrevia()
        {
            Lbl.Impresion.Plantilla Plantilla = this.Elemento as Lbl.Impresion.Plantilla;

            if (Plantilla == null)
            {
                return;
            }

            TamanoPagina = ObtenerTamanoPapel(Plantilla.TamanoPapel);
            if (Plantilla.Landscape)
            {
                TamanoPagina = new Size(TamanoPagina.Height, TamanoPagina.Width);
            }

            ImagePreview.Invalidate();
        }
コード例 #7
0
 private void ImagePreview_MouseUp(object sender, MouseEventArgs e)
 {
     if (CampoSeleccionado != null)
     {
         if (CampoSeleccionado.Rectangle.Width < 0)
         {
             CampoSeleccionado.Rectangle.Width = Math.Abs(CampoSeleccionado.Rectangle.Width);
             CampoSeleccionado.Rectangle.X    -= CampoSeleccionado.Rectangle.Width;
         }
         if (CampoSeleccionado.Rectangle.Height < 0)
         {
             CampoSeleccionado.Rectangle.Height = Math.Abs(CampoSeleccionado.Rectangle.Height);
             CampoSeleccionado.Rectangle.Y     -= CampoSeleccionado.Rectangle.Height;
         }
         ImagePreview.Invalidate();
     }
     MouseOperation = MouseOperations.None;
 }
コード例 #8
0
        private void ImagePreview_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left || e.Button == System.Windows.Forms.MouseButtons.Middle)
            {
                switch (MouseOperation)
                {
                case MouseOperations.KnobDrag:
                    if (CampoSeleccionado != null)
                    {
                        //Point NewCampoPos = new Point(CampoDown.Right, CampoDown.Bottom);
                        Point PosCursor = PuntoDesdePantalla(new Point(e.X, e.Y));
                        PosCursor.X -= CampoSeleccionado.Rectangle.Left;
                        PosCursor.Y -= CampoSeleccionado.Rectangle.Top;
                        CampoSeleccionado.Rectangle.Width  = PosCursor.X;
                        CampoSeleccionado.Rectangle.Height = PosCursor.Y;
                        ImagePreview.Invalidate();
                    }
                    break;

                case MouseOperations.PageDrag:
                    Point OldDesplazamiento = this.PosicionPagina;
                    this.PosicionPagina = new Point(0, 0);
                    Point Diferencia = PuntoDesdePantalla(new Point(e.X - ButtonDown.X, e.Y - ButtonDown.Y), false);
                    this.PosicionPagina = OldDesplazamiento;
                    this.PosicionPagina.Offset(Diferencia);
                    ButtonDown = new Point(e.X, e.Y);
                    ImagePreview.Invalidate();
                    break;

                case MouseOperations.ObjectDrag:
                    if (CampoSeleccionado != null)
                    {
                        Point NewCampoPos = CampoDown.Location;
                        Point PosCursor   = PuntoDesdePantalla(new Point(e.X, e.Y));
                        NewCampoPos.Offset(PosCursor.X - ButtonDown.X, PosCursor.Y - ButtonDown.Y);
                        CampoSeleccionado.Rectangle.Location = NewCampoPos;
                        ImagePreview.Invalidate();
                    }
                    break;
                }
            }
        }
コード例 #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();
            }
        }