|
It depends on how you are loading the small images, and what you are loading them into.
You will have to give more information to get a useful reply.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Supra2 wrote: I am new to C# pls let me know how to write handlers for MOUSE move or mouse click.
On the controls that you want to detect mouse movement.
|
|
|
|
|
public List<int> CreateTableInstance(List<int>[,]myBoard)
{
List<int> zero = new List,int>(1);
zero.Add(0);
for(int y1=0;y1<3;y1++)
{
for(int x1=0;x1<3;x1++)
{
myBoard[x1,y1] = zero;
}
}
return myBoard[3,3];
}
private void button1_Click(object sender, EventArgs e)
{
List<int> theBoard = new List<int>();
theBoard = CreateTableInstance(theBoard);
}
/pre>
I know there is some syntax wrong, but I can't seem to get it to work through trial and error X| </int></int></int></int></int>
|
|
|
|
|
stonebergftw wrote: I know there is some syntax wrong, but I can't seem to get it to work through trial and error
Can I suggest that you read up on how the language works? It will save you a lot of frustration as trial and error, while excellent practical methods once you understand the theory, will only take you so far. Without the knowledge of what is supposed to happen it will often take you the wrong way down the path.
Now, as for your code, could you post it again so that the Browser doesn't eat the angle brackets? Do that by ensuring that "Auto-encode HTML when pasting?" is checked.
Finally, you might like to tell us what your code is supposed to do so we understand better what to look for.
|
|
|
|
|
<pre>public List CreateTableInstance(List[,]myBoard)
{
List zero = new List,int>(1);
zero.Add(0);
for(int y1=0;y1<3;y1++)
{
for(int x1=0;x1<3;x1++)
{
myBoard[x1,y1] = zero;
}
}
return myBoard[3,3];
}
private void button1_Click(object sender, EventArgs e)
{
List theBoard = new List();
theBoard = CreateTableInstance(theBoard);
}
|
|
|
|
|
public List CreateTableInstance(List[,]myBoard)
If this is the List in .NET, and not your own class, then it is a generic and must be specified as such
List<Type>
List[,]myBoard
You are defining a two dimentional array of list objects here called myBoard. Is that what you want to do, an array of lists?
List zero = new List,int>(1);
This is completely confused. You have a non-generic List on the left, and on the right is a half baked attempt at instantiting a generic list object containing integers with an initial capacity of 1.
List theBoard = new List();
theBoard = CreateTableInstance(theBoard);
You have already defined CreateTableInstance as requiring an array of list objects. However, you are passing a list (not an array of lists).
That takes care of the syntax errors that I can see. However, your compiler will have told you all about these already. Right?
You have not, as I requested, told me what you are attempting to do. By reading the code I cannot tell what it is you are trying to do because the code is too confused. You do one thing on one line, and then you undo it later on. Or you perform actions that have no effect because you throw away the work they have done.
|
|
|
|
|
I understand what you are saying. The List function is REALLY confusing me. Now that my coworker and my smoke break are over:
I am trying to create a 3x3 array(or list) in the function CreateTableInstance, set each value in that array to 0, and then return the value into the List Variable, theBoard, located in the module button1_Click.
The value of the array theBoard is being set by the called function CreateTableInstance.
I am trying to define an 2 dimensional array. Also, it is in a .NET class.
|
|
|
|
|
stonebergftw wrote: The List function is REALLY confusing me
List is a class not a function. A list has many methods (which is what C# calls functions).
stonebergftw wrote: I am trying to create a 3x3 array(or list) in the function CreateTableInstance, set each value in that array to 0, and then return the value into the List Variable, theBoard, located in the module button1_Click.
This is still confused. If you create an array there is no point returning it into a List variable. You would want to return it into an array variable.
The following returns a two dimensional array of type int:
public int[,] CreateTableInstance()
{
int[,] result = new int[3,3];
for (int i=0; i<3 i++)
{
for (int j; j<3; j++)
{
resut[i,j] = 0;
}
}
return result;
} DISCLAIMER: I typed it directly and didn't test it
In your event handler you would do something like this to get the array from the method
int[,] theBoard = CreateTableInstance();
|
|
|
|
|
This is exactly what I am trying to do. I was not even aware that arrays work like this... Thanks.
/me Going to Borders right after work.
While we are on this debacle, what would be a difference in usage between an integer array, and a multidimensional array of integers?
By usage, I do not mean syntax... I mean application. What would you use a List for that you would not use a normal array?
Thanks for the prior help.
|
|
|
|
|
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;
}
}
}
|
|
|
|
|
Try overriding OnPaintBackground() with an empty method
(and remove it from OnPaint)
|
|
|
|
|
Thanks for your reply. But when I put the null OnPaintBackground on it, the foreground image has still been erased, only difference is that the background has not been painted.
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 OnPaintBackground(PaintEventArgs e)
{
}
protected override void OnPaint(PaintEventArgs e)
{
if (_image == null)
{
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.UserPaint | ControlStyles.ResizeRedraw, true);
UpdateStyles();
AutoScroll = true;
}
}
}
|
|
|
|
|
you're calling base.OnPaint() *AFTER* you do your custom painting. The base method will (among other things) call OnPaintBackground thus painting over everything you've already done. If you need to call the base method for some of your painting do it *BEFORE* your custom painting not *AFTER*.
Alternately if you only need to get the background painting from it, just call OnPaintBackground at the start of your method, and don't call the base at all.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
Thanks to all the replies.
I know why this takes place. The OffsetX / OffsetY in the matrix has been changed.
Have a good day, gentlemen.
|
|
|
|
|
First. Please the the code block formatting. It preserves your indents to make the code readable.
garry.fang wrote: 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.
Second, you appear to be misinformed about what PaintBackground does. It repaints the background of the entire control, including any areas which you have previously drawn a foreground object. If you wish to preserve them, any forground objects must be repainted after the PaintBackground call.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I want to run swf file from C# windows application. I am able to run .wav file but not .swf file.
Thanks
|
|
|
|
|
.swf isn't supported by windows media player and the .net media player classes share a common core with it.
I believe there's a flash playing COM object that gets installed with flash player automatically. You'll have to add a reference to it in your project and use it to play the file.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
1.right click on toolbox at general select add new items
2.one popup is appeared with add references title select COM tab
3.select shock wave object
4.click on ok
5.u will find shock wave object on toolbox at general tab
6.now drag and drop ur flash object to windows form
then add below code
string path = System.Environment.CurrentDirectory;
path += @"\Top_1.swf";
axShockwaveFlash1.LoadMovie(0, path);
axShockwaveFlash1.Play();
Have a nice day
|
|
|
|
|
Hi all,
This is my first post.
I'm using "Infragistics.Excel v6.2" and C#.
I create an excel file using BIFFWriter.
I'm unable to hide teh grid lines in teh excel sheet through code.
Can anyone help me in this?
Thanks n Regards
Srividhya
|
|
|
|
|
You should probably be asking this on the Infragistics site, not here.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
hi everyone,
i am using firebird database and i want catch a message from firebird server. i am writing that code to catch info message but it is not giving me infomessage. i am looking for this problem on all web pages. but i did not find a knowledge.
is there a anyone to help me this subject i become happy.
private void Form1_Load(object sender, EventArgs e)
{
FbConnection baglanti = new FbConnection("DataSource = 192.168.2.99; Database = d:\\data\\vt.fdb; ConnectionTimeout = 20; UserID = SYSDBA; Password = sifre; PacketSize = 8192; Charset = WIN1254");
baglanti.InfoMessage += new FbInfoMessageEventHandler(baglanti_InfoMessage);
baglanti.Open();
FbTransaction trans = baglanti.BeginTransaction();
FbCommand sorgu = new FbCommand("insert into deneme (adi) values ('ee')",baglanti,trans);
sorgu.ExecuteNonQuery();
trans.Commit();
}
public static void baglanti_InfoMessage(object sender, FbInfoMessageEventArgs e)
{
MessageBox.Show(e.Errors[0].Message+e.Message);
}
|
|
|
|
|
According to the documentation[^] this event will only be raised if Firebird issues a warning message.
Are you expecting a warning message from the database?
|
|
|
|
|
i am waiting a knowledge message from database. i do not want a fail message from database. do you use this message before? is there a wrong part in my code block?
|
|
|
|
|
muhammedmustafa wrote: i am waiting a knowledge message from database.
What do you mean by a "knowledge message"?
muhammedmustafa wrote: i do not want a fail message from database
Nobody does. But the simple fact is that failures do occur and you have to be able to handle them gracefully when it happens.
The event you are handling is, according to the documentation, only used when an error of some description happens. If you have success the event won't need to be handled as there is no failure to deal with.
muhammedmustafa wrote: do you use this message before? is there a wrong part in my code block?
No never. It seems to me that I'm just reading the documentation on your behalf.
|
|
|
|
|
i am devloping a web application in which i have a gridview
contains two textbox as a template field.
i want to get the data filled in the gridview in the javascript function on the button click.
for the validation purpose so how can i do the same.
Thanks
|
|
|
|