private void SetupImagePreview()
        {
            var group = new TransformGroup();


            var xform = new ScaleTransform();

            //xform.ScaleY = -1;
            group.Children.Add(xform);

            var tt = new TranslateTransform();

            group.Children.Add(tt);

            //TranslateTransform zoomCenter = new TranslateTransform();
            //group.Children.Add(zoomCenter);

            ImagePreview.SetCurrentValue(RenderTransformProperty, group);

            ImagePreviewCanvas.PreviewMouseWheel += ImagePreview_MouseWheel;
            ImagePreviewCanvas.MouseDown         += ImagePreview_MouseLeftButtonDown;
            ImagePreviewCanvas.MouseUp           += ImagePreview_MouseLeftButtonUp;
            ImagePreviewCanvas.MouseMove         += ImagePreview_MouseMove;

            ImageDropZone.DragEnter += ImageDropZone_DragEnter;
            ImageDropZone.DragLeave += ImageDropZone_DragLeave;
            ImageDropZone.Drop      += ImageDropZone_Drop;

            _imageScale = new ScaleTransform();
            //_imageScale.SetCurrentValue(ScaleTransform.ScaleYProperty, (double)-1);
            ActualImage.SetCurrentValue(RenderTransformProperty, _imageScale);
        }
Exemplo n.º 2
0
 private void ShowFile(int imageIndex)
 {
     if (imageIndex < media.Count)
     {
         ImagePreview file = media.ElementAt(imageIndex);
         photoWindow.Update(file.ImagePath);
     }
 }
Exemplo n.º 3
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "PNG|*.png",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Multiselect      = false,
                Title            = "Open Image",
                CheckPathExists  = true,
                CheckFileExists  = true
            };

            var urlString = string.Empty;

            if (openFileDialog.ShowDialog() == true)
            {
                RevealedImage = null;
                urlString     = openFileDialog.FileName;

                SelectPhotoButton.IsEnabled = false;
                RevealButton.IsEnabled      = false;

                if (InitialImageLoad)
                {
                    ThumbText.Visibility = Visibility.Collapsed;
                }
                else
                {
                    await ImagePreview.HideUsingLinearAnimationAsync();
                }

                await ThumbLoading.ShowUsingLinearAnimationAsync();

                var availableToProcess = await ProcessImageAsync(urlString);

                await ThumbLoading.HideUsingLinearAnimationAsync();

                if (!availableToProcess)
                {
                    await ImagePreview.ShowUsingLinearAnimationAsync();

                    RevealButton.IsEnabled = true;
                }

                SelectPhotoButton.IsEnabled = true;

                if (InitialImageLoad)
                {
                    InitialImageLoad = false;
                }
                if (!RevealButton.IsVisible && !availableToProcess)
                {
                    RevealButton.ShowUsingLinearAnimation();
                }
            }
        }
Exemplo n.º 4
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());
            }
        }
Exemplo n.º 5
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();
            }
        }
Exemplo n.º 6
0
 private void EditarCampoSeleccionado()
 {
     if (CampoSeleccionado != null)
     {
         EditarCampo FormEditarCampo = new EditarCampo(CampoSeleccionado);
         if (FormEditarCampo.ShowDialog() == DialogResult.OK)
         {
             this.ActualizarCampos();
             ImagePreview.Invalidate();
         }
     }
 }
Exemplo n.º 7
0
        public void ShowPreview(Photo photo)
        {
            var idx = photos.IndexOf(photo);

            if (preview != null)
            {
                preview.Close();
            }
            preview = new ImagePreview(photos, idx);

            preview.Show();
        }
Exemplo n.º 8
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.º 9
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            RockPage.AddCSSLink("~/Plugins/com_blueboxmoon/Crex/Styles/crex.css");
            RockPage.AddScriptLink("~/Plugins/com_blueboxmoon/Crex/Scripts/crex.js");

            MenuPreview = new MenuPreview
            {
                ID      = "previewMenu",
                Visible = false
            };
            PreviewPanel.Controls.Add(MenuPreview);

            PosterListPreview = new PosterListPreview
            {
                ID      = "previewPosterList",
                Visible = false
            };
            PreviewPanel.Controls.Add(PosterListPreview);

            ImagePreview = new ImagePreview
            {
                ID      = "previewImage",
                Visible = false
            };
            PreviewPanel.Controls.Add(ImagePreview);

            VideoPreview = new VideoPreview
            {
                ID      = "previewVideo",
                Visible = false
            };
            PreviewPanel.Controls.Add(VideoPreview);

            RedirectPreview = new NotificationBox
            {
                ID = "previewRedirect",
                NotificationBoxType = NotificationBoxType.Info,
                Visible             = false
            };
            PreviewPanel.Controls.Add(RedirectPreview);

            DebugPreview = new Literal
            {
                ID = "previewDebug"
            };
            DebugPanel.Controls.Add(DebugPreview);
        }
Exemplo n.º 10
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();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "Jpeg Photos|*.jpg;*.jpeg",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Multiselect      = false,
                Title            = "Open Image",
                CheckPathExists  = true,
                CheckFileExists  = true
            };

            var urlString = string.Empty;

            if (openFileDialog.ShowDialog() == true)
            {
                urlString = openFileDialog.FileName;

                SelectPhotoButton.IsEnabled = false;
                NextPageButton.IsEnabled    = false;

                if (initialImageLoad)
                {
                    ThumbText.Visibility = Visibility.Collapsed;
                }
                else
                {
                    await ImagePreview.HideUsingLinearAnimationAsync();
                }

                await ThumbLoading.ShowUsingLinearAnimationAsync();

                await ProcessImageAsync(urlString);

                await ThumbLoading.HideUsingLinearAnimationAsync();

                await ImagePreview.ShowUsingLinearAnimationAsync();

                SelectPhotoButton.IsEnabled = true;
                NextPageButton.IsEnabled    = true;

                if (initialImageLoad)
                {
                    initialImageLoad = false;
                    NextPageButton.ShowUsingLinearAnimation();
                }
            }
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
0
    private void CreatePreview()
    {
        if (!activePreview)
        {
            // Try to get a canvas in parent objects
            Canvas root = GetComponentInParent <Canvas>();

            // Make sure that we have a canvas in a parent somewhere
            if (root)
            {
                // Get the root canvas in this object
                root = root.rootCanvas;

                // Instantiate a preview as a child of the root
                activePreview = Instantiate(previewPrefab, root.transform);
                activePreview.Setup(baseImage.sprite);
            }
        }
    }
Exemplo n.º 15
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;
                }
            }
        }
Exemplo n.º 16
0
 internal ImageStruct(int id, string name, ImagePreview image)
 {
     this.id    = id;
     this.name  = name;
     this.image = image;
 }
Exemplo n.º 17
0
 public void Fix()
 {
     ImagePreview = ImagePreview.Replace(".jpg", ".JPG");
 }
Exemplo n.º 18
0
        private void SaveImage_Opened(object sender, EventArgs e)
        {
            Save_Image.Source = new BitmapImage(new Uri(@"/L3.Cargo.Workstation.Plugins.XRayImageBase;component/Resources/Icons/SaveOn.png", UriKind.Relative));

            ImagePreview.GenerateLayers(MainImage.Source, _AdornerLayerManager, GetListOfEffects());
        }
Exemplo n.º 19
0
 private void ImagePreview_MouseEnter(object sender, EventArgs e)
 {
     ImagePreview.Focus();
 }
Exemplo n.º 20
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();
            }
        }