[Mono-winforms-list] ImageViewer still causing problems

Emery Conrad econrad at vt.edu
Wed Apr 26 11:02:02 EDT 2006


Just curious, is someone working on the scrolling code? I've finally got my
big fat application working under mono (mostly working that is), but one of
the main issues remaining right now is the scrolling behavior, which is
WHACKY-smacky!

I'm happy to help fix the code but if the main developer of this code could
maybe say a few words about the code and the logic, it would help! (For
example, what is the thumb stuff about?)

Thanks,

Emery


On 4/19/06, PFJ <paul at all-the-johnsons.co.uk> wrote:
>
> Hi,
>
> Again, same source as I posted yesterday (below). If I load a jpeg in
> and drag the slider bars, it rescales the window rather than show the
> next section of the picture.
>
> If I click beneath where the slider is (so it's on the bar itself), then
> the picture moves.
>
> I reserve the right to be wrong, insane or a bit foamy on this. I will
> put it into BZ if needs be. Mono was compiled about 20 minutes before
> posting this email ( 14:15 BST )
>
> 8-->
> /*
> * ImageViewer.cs - Simple MDI-based image viewer.
> *
> * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
> *
> * This program is free software, you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> * the Free Software Foundation, either version 2 of the License, or
> * (at your option) any later version.
> *
> * This program is distributed in the hope that it will be useful,
> * but WITHOUT ANY WARRANTY, without even the implied warranty of
> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> * GNU General Public License for more details.
> *
> * You should have received a copy of the GNU General Public License
> * along with this program, if not, write to the Free Software
> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> USA
> */
>
> using System;
> using System.IO;
> using System.Drawing;
> using System.Drawing.Drawing2D;
> using System.Windows.Forms;
>
> public class ImageViewer : Form
> {
>         private ImageViewer()
>         {
>                 MenuItem openMenuItem = new MenuItem("Open");
>                 MenuItem quitMenuItem = new MenuItem("Quit");
>                 MenuItem fileMenuItem =
>                         new MenuItem("File", new MenuItem[]
>                                 {openMenuItem, quitMenuItem});
>                 MainMenu mainMenu = new MainMenu(new MenuItem[] {
> fileMenuItem });
>                 Menu = mainMenu;
>
>                 Size = new Size(600, 500);
>                 Text = "DotGNU Image Viewer";
>                 IsMdiContainer = true;
>
>                 openMenuItem.Click += new EventHandler(OpenClicked);
>                 quitMenuItem.Click += new EventHandler(QuitClicked);
>         }
>
>         private void OpenClicked(Object sender, EventArgs e)
>         {
>                 OpenFileDialog dialog = new OpenFileDialog();
>                 dialog.Filter =
>                         "All image files (*.bmp, *.jpg, *.png, *.gif,
> *.ico, *.cur)" +
>                         "|*.bmp;*.jpg;*.png;*.gif;*.ico;*.cur" +
>                         "|BMP files (*.bmp)|*.bmp" +
>                         "|JPEG files (*.jpg)|*.jpg" +
>                         "|PNG files (*.png)|*.png" +
>                         "|GIF files (*.gif)|*.gif" +
>                         "|Icon files (*.ico)|*.ico" +
>                         "|Cursor files (*.cur)|*.cur" +
>                         "|All files (*.*)|*.*";
>                 if(dialog.ShowDialog(this) == DialogResult.OK)
>                 {
>                         Bitmap image;
>                         try
>                         {
>                                 image = new Bitmap(dialog.FileName);
>                         }
>                         catch(Exception)
>                         {
>                                 MessageBox.Show
>                                         (String.Format("Unknown image
> format for \"{0}\"",
>
> dialog.FileName),
>                                          "Error", MessageBoxButtons.OK,
> MessageBoxIcon.Hand);
>                                 image = null;
>                         }
>                         if(image != null)
>                         {
>                                 ImageWindow window = new ImageWindow
>                                         (dialog.FileName, image);
>                                 window.MdiParent = this;
>                                 window.Visible = true;
>                         }
>                 }
>         }
>
>         private void QuitClicked(Object sender, EventArgs e)
>         {
>                 Close();
>         }
>
>         protected override bool ProcessDialogKey(Keys keyData)
>         {
>                 if(keyData == (Keys.Control | Keys.O))
>                 {
>                         OpenClicked(this, EventArgs.Empty);
>                         return true;
>                 }
>                 return base.ProcessDialogKey(keyData);
>         }
>
>         public static void Main(String[] args)
>         {
>                 ImageViewer form = new ImageViewer();
>                 Application.Run(form);
>         }
>
> }
>
> internal class ImageWindow : Form
> {
>         private Image image;
>
>         public ImageWindow(String filename, Image image)
>         {
>                 this.image = image;
>                 ClientSize = image.Size;
>                 Text = Path.GetFileName(filename);
>         }
>
>         protected override void OnPaint(PaintEventArgs args)
>         {
>                 args.Graphics.DrawImage(image, 0, 0);
>         }
>
> }
> <--8
>
> TTFN
>
> Paul
> --
> "Logic, my dear Zoe, is merely the ability to be wrong with authority" -
> Dr Who
>
> _______________________________________________
> Mono-winforms-list maillist  -  Mono-winforms-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>



--
Emery Conrad
Department of Mathematics
Virginia Tech
5076 Derring Hall
Blacksburg, VA 24061-0406
(540) 231-3324
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-winforms-list/attachments/20060426/63a18dcd/attachment-0001.html


More information about the Mono-winforms-list mailing list