Click here to Skip to main content
15,890,845 members
Home / Discussions / C#
   

C#

 
QuestionCan someone please tell me what is wrong with this List function? Pin
stonebergftw10-Apr-09 7:49
stonebergftw10-Apr-09 7:49 
AnswerRe: Can someone please tell me what is wrong with this List function? Pin
Colin Angus Mackay10-Apr-09 8:00
Colin Angus Mackay10-Apr-09 8:00 
GeneralRe: Can someone please tell me what is wrong with this List function? Pin
stonebergftw10-Apr-09 8:12
stonebergftw10-Apr-09 8:12 
GeneralRe: Can someone please tell me what is wrong with this List function? Pin
Colin Angus Mackay10-Apr-09 8:25
Colin Angus Mackay10-Apr-09 8:25 
GeneralRe: Can someone please tell me what is wrong with this List function? Pin
stonebergftw10-Apr-09 8:37
stonebergftw10-Apr-09 8:37 
GeneralRe: Can someone please tell me what is wrong with this List function? Pin
Colin Angus Mackay10-Apr-09 8:57
Colin Angus Mackay10-Apr-09 8:57 
GeneralRe: Can someone please tell me what is wrong with this List function? Pin
stonebergftw10-Apr-09 9:08
stonebergftw10-Apr-09 9:08 
QuestionWhy is the image erased by the background? Pin
garry.fang10-Apr-09 6:41
garry.fang10-Apr-09 6:41 
I am drafting a control which can zoom the image and scroll. But unfortunately, the background will erase the image. I do not know why. Maybe something is wrong with 'ControlStyles'.

Code is below -

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace GoldenEye
{
class ImageBox:ScrollableControl
{
private Image _image;
public Image image
{
set
{
_image = value;
UpdateScaleFactor();
Invalidate();
}
get
{
return _image;
}
}

private Matrix mx;
private float _zoom;
public float zoom
{
set
{
if (value < 0.00001f)
{
value = 0.00001f;
}
_zoom = value;
mx = new Matrix(_zoom, 0, 0, _zoom, 0, 0);
UpdateScaleFactor();
Invalidate();
}
get
{
return _zoom;
}
}

private void UpdateScaleFactor()
{
if (_image == null)
{
AutoScrollMargin = Size;
}
else
{
AutoScrollMinSize = new Size(Convert.ToInt32(_image.Width*_zoom+0.5), Convert.ToInt32(_image.Height*_zoom+0.5));
}
}

protected override void OnPaint(PaintEventArgs e)
{
if (_image == null)
{
base.OnPaintBackground(e);
return;
}
mx.Translate(AutoScrollPosition.X / _zoom, AutoScrollPosition.Y / _zoom);
e.Graphics.Transform = mx;
e.Graphics.InterpolationMode = InterpolationMode.High;

e.Graphics.DrawImage(_image, new Rectangle(0, 0, _image.Width, _image.Height), 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel);
base.OnPaint(e);
}

public ImageBox()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.Opaque| ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true);

AutoScroll = true;
}
}
}
AnswerRe: Why is the image erased by the background? Pin
Luc 64801110-Apr-09 6:58
Luc 64801110-Apr-09 6:58 
GeneralRe: Why is the image erased by the background? Pin
garry.fang10-Apr-09 7:20
garry.fang10-Apr-09 7:20 
GeneralRe: Why is the image erased by the background? Pin
Dan Neely10-Apr-09 8:36
Dan Neely10-Apr-09 8:36 
GeneralRe: Why is the image erased by the background? Pin
garry.fang10-Apr-09 9:26
garry.fang10-Apr-09 9:26 
AnswerRe: Why is the image erased by the background? Pin
Dan Neely10-Apr-09 7:04
Dan Neely10-Apr-09 7:04 
QuestionHow to run swf file from c#? Pin
Supra210-Apr-09 5:26
Supra210-Apr-09 5:26 
AnswerRe: How to run swf file from c#? Pin
Dan Neely10-Apr-09 7:08
Dan Neely10-Apr-09 7:08 
AnswerRe: How to run swf file from c#? Pin
krishna_goluguri8-Jul-10 0:25
krishna_goluguri8-Jul-10 0:25 
QuestionExcel grid lines issue Pin
winsrividhya10-Apr-09 5:24
winsrividhya10-Apr-09 5:24 
AnswerRe: Excel grid lines issue Pin
Henry Minute10-Apr-09 8:31
Henry Minute10-Apr-09 8:31 
Questionusing infomessege in firebird or other database Pin
muhammedmustafa10-Apr-09 4:48
muhammedmustafa10-Apr-09 4:48 
AnswerRe: using infomessege in firebird or other database Pin
Colin Angus Mackay10-Apr-09 5:04
Colin Angus Mackay10-Apr-09 5:04 
GeneralRe: using infomessege in firebird or other database Pin
muhammedmustafa10-Apr-09 21:24
muhammedmustafa10-Apr-09 21:24 
GeneralRe: using infomessege in firebird or other database Pin
Colin Angus Mackay12-Apr-09 12:12
Colin Angus Mackay12-Apr-09 12:12 
Questionaccesing Gridview Data in javascript function Pin
Abhishek Rana10-Apr-09 2:45
Abhishek Rana10-Apr-09 2:45 
AnswerRe: accesing Gridview Data in javascript function Pin
Henry Minute10-Apr-09 8:33
Henry Minute10-Apr-09 8:33 
QuestionTreeview Problem Pin
Digubha10-Apr-09 2:02
Digubha10-Apr-09 2:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.