Beispiel #1
0
    public virtual void  actionPerformed(System.Object event_sender, System.EventArgs event_Renamed)
    {
        if (event_sender.Equals(openMenu))
        {
            chooser.ShowDialog(this);
            if (new System.IO.FileInfo(chooser.FileName) == null)
            {
                return;
            }
            try
            {
                sourceImage = ImageIO.read(new System.IO.FileInfo(chooser.FileName));
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
        else if (SupportClass.CommandManager.GetCommand(event_sender).Equals("Open from URL"))
        {
            try
            {
                //UPGRADE_TODO: Class 'java.net.URL' was converted to a 'System.Uri' which does not throw an exception if a URL specifies an unknown protocol. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1132'"
                sourceImage = ImageIO.read(new System.Uri(url.Text));
            }
            catch (System.Exception e)
            {
                SupportClass.WriteStackTrace(e, Console.Error);
            }
        }
        else
        {
            return;
        }

        if (sourceImageLabel != null)
        {
            //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
            ((System.Windows.Forms.ContainerControl) this).Controls.Remove(sourceImageLabel);
        }

        System.Windows.Forms.Label temp_label;
        temp_label       = new System.Windows.Forms.Label();
        temp_label.Image = (System.Drawing.Image)sourceImage.Clone();
        sourceImageLabel = temp_label;
        //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'"
        ((System.Windows.Forms.ContainerControl) this).Controls.Add(sourceImageLabel);
        sourceImageLabel.Dock = System.Windows.Forms.DockStyle.Left;
        sourceImageLabel.BringToFront();


        QRCodeDecoder decoder = new QRCodeDecoder();

        if (canvas != null)
        {
            //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
            ((System.Windows.Forms.ContainerControl) this).Controls.Remove(canvas);
            //canvas.setImage(null);
        }
        canvas = new J2SEDebugCanvas();
        QRCodeDecoder.setCanvas(canvas);
        //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'"
        ((System.Windows.Forms.ContainerControl) this).Controls.Add(canvas);
        canvas.Dock = System.Windows.Forms.DockStyle.Right;
        canvas.BringToFront();
        System.String decodedString = null;
        try
        {
            decodedString = new String(decoder.decode(new J2SEImage(this, sourceImage)));
        }
        catch (DecodingFailedException e)
        {
            canvas.println(e.getMessage());
            canvas.println("--------");
            return;
        }
        decodedString = ContentConverter.convert(decodedString);
        canvas.println("\nDecode result:");
        canvas.println(decodedString);
        canvas.println("--------");
        if (decodedText != null)
        {
            //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
            ((System.Windows.Forms.ContainerControl) this).Controls.Remove(decodedText);
        }
        System.Windows.Forms.TextBox temp_TextBox;
        temp_TextBox            = new System.Windows.Forms.TextBox();
        temp_TextBox.Multiline  = true;
        temp_TextBox.WordWrap   = false;
        temp_TextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
        temp_TextBox.Text       = decodedString;
        decodedText             = temp_TextBox;
        decodedText.WordWrap    = true;
        //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setRows' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetRows_int'"
        decodedText.setRows(decodedString.Length / 20 + 1);
        if (decodedString.Length < 20)
        {
            //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setColumns' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetColumns_int'"
            decodedText.setColumns(decodedString.Length);
        }
        else
        {
            //UPGRADE_ISSUE: Method 'javax.swing.JTextArea.setColumns' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaxswingJTextAreasetColumns_int'"
            decodedText.setColumns(20);
        }
        //decodedText.setSize(sourceImageLabel.getSize().width,100);
        //UPGRADE_TODO: Method 'javax.swing.JFrame.getContentPane' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaxswingJFramegetContentPane'"
        //UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent_javalangObject'"
        ((System.Windows.Forms.ContainerControl) this).Controls.Add(decodedText);
        decodedText.Dock = System.Windows.Forms.DockStyle.Bottom;
        decodedText.SendToBack();
        //UPGRADE_ISSUE: Method 'java.awt.Window.pack' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtWindowpack'"
        pack();
    }