|
Hi, Thanks. Helped a lot.
--------------------------------------------
Programming is a devine gift
|
|
|
|
|
Hi
I am beginner at C#.
I need to create two classes which will represent two picture models(like JPG and bitmap).It should look something like this
class JPGImage
{
..............
}
class BMPImage
{
..............
}
I don't know how to describe this classes.
In winForm I need 2 panels where I'll put this 2 models.
Can you help me with this?
Thanks
|
|
|
|
|
It depends what you want to do.
In .NET, you use the Bitmap class to handle not only BMP images but also GIF, PNG and JPG - so from most points of view there would be no difference as to what members you would use to describe them.
|
|
|
|
|
OK thanks,
Does it mean that I can inherit from Bitmap class my
class like this :
class JpgImage : Bitmap
{
....
}
and create object JpgImage?
Which methods I can use for working with my class (class JpgImage)?
|
|
|
|
|
videhr wrote: Does it mean that I can inherit from Bitmap class my class like this :
No. the Bitmap class is sealed , which means you can't inherit from it.
You'd either need to use the Bitmap class, entirely write your own JpgImage class or use a mixture (a JpgImage class which uses a Bitmap instance and its methods)
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks, i am starting to understand this.
Using this mixture should look like this:
Image JpgImage= new Bitmap("image1.jpg");
am I right?
|
|
|
|
|
I acutually thought about something like this:
class JpgImage
{
private Bitmap jpg;
public JpgImage(string file)
{
jpg = new Bitmap(file);
}
}
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm not sure I understand this,but it is ok.
Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right?
Thank you again,you have helped me a lot.
Sorry for bothering you.
|
|
|
|
|
videhr wrote: Now with jpg I can create drawing(like rectangular or elipse,line etc),am I right?
No you can't.
Sorry no offense, but I think you need to read a book about C# and take a lot of practice to understand how this stuff works
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
whats the point though? they all load in exactly the same way from Bitmap, no advantages / disadvantages from what you can do with them - just use the Bitmap class, or if you have to
public enum ImageType
{
JPG = 0;
PNG = 1;
etc
}
class Image
{
public bitmap itsBitmap;
public ImageType itsFormat;
}
|
|
|
|
|
hi guys,
how can i set the file that i create using c# (FileStream) to be automatically hidden or read-only? i dont want the client users to have access to that file that is why i want to hide it..
if there's a better way of doing this, im open to suggestions.. tnx in advance!
|
|
|
|
|
I think you have to use the File object in the System.IO namespace.
It would go something like:
<br />
File.SetAttributes(path, FileAttributes.Hidden);
See the following URL for reference:
File.SetAttributes Method
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Thanks for the immediate reply..
here's a follow up question. is it possible for the folder which contains the file to set its attribute also to hidden?
|
|
|
|
|
Have you looked at the DirectoryInfo object in the System.IO namespace?
It also has Attributes member.
Your code would be something like:
DirectoryInfo di = new DirectoryInfo(@"c:\Test");
di.Attributes = FileAttributes.Hidden;
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
thanks wayne! it workd..
|
|
|
|
|
Hello,
is it possible to create a .NET DLL (using C#.NET or C++.NET) that exports functions in C-style?
In VC++ we can use extern "C" __declspec(dllexport) for that. And in C#.NET or C++.NET?
Thanks in advance and best regards
Dominik
<small>and</small;gt;
<code>__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
-- modified at 4:46 Saturday 25th February, 2006
|
|
|
|
|
All public marked types are avalible outside your DLL in .NET
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thanks for your reply. How do I mark a type to be public? Note that I want the functions to be exported in C style, i.e. the other DLL won't have anything to do with .NET.
Best regards
Dominik
<small>and</small;gt;
<code>__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Works perfectly with C++/CLI. Here's some sample code:
extern "C" int __declspec(dllexport) Load(int *link)
{
Debug::Print("Load(int*) called");
...
}
Grüße nach Deutschland ;
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
I have an application where a customers may want to restrict access to specific features so I want to have some kind of user database to control access.
Now using this 'Login' is optional, the customers may not require/want to restrict access, so there is an option to 'show the login screen' (or not).
The idea I had was, if the users do not login using the login screen, there is another option which can restrict the users access because the app logs them in as an 'anonymous' user if the login is not used and privelages can be assigned to the anonymous user.
Now it appeared that as this is a windows forms app, the normal start-up form named 'MainForm' was not what I needed. I needed some kind of loop so that the login was shown (if required) and the main form was shown only if a valid user was logged in (this incudes anonymous).
I rigged up a couple of test applications and have come up with the following sample code:
private static void Start()
{
MainMenu mainMenu = new MainMenu();
Login login = new Login();
Config.load();
ShowLogin = Config.LoginRequired;
while ( !Shutdown )
{
if ( ShowLogin )
{
login.ShowDialog();
} else {
UserName = "Anonymous";
}
if ( !Shutdown && UserName != null )
{
mainMenu.ShowDialog();
}
}
}
[STAThread]
public static void Main(string[] args)
{
Application.Start();
System.Windows.Forms.Application.Run();
}
Now, as you can see, by using Application.Run() I don't start the app by loading a form.
Its the Start method of my Application class which actually decides what should be shown.
Now what I don't like is:
1) I have to use System.Windows.Forms.Application.Exit(); in my main menu and login form if I want to exit the app.
2) Its not very Object Oriented code, it is very procedural in style.
My questions are:
Is there a better way, perhaps more Object Oriented?
Is it good practice to start and end an application in this manor?
As always, your thoughts/comments are appreciated.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Hi folks
I have recently upgraded to Visual Studio 2005 and am horrified by the speed at which the UI appears to respond on a reasonable spec machine, even on small solutions.
Does anyone have any tips & tricks to get it to respond better.
Cheers
Rich
|
|
|
|
|
I agree and I have 1 GB RAM. If you find any tips let me know! The Tool Windows are particularly slow, as is Help.
Maybe SP1 will improve things?
Kevin
|
|
|
|
|
Imagine my shock! Microsoft conspiring with the hardware manufacturers to keep you locked into the "upgrade cycle". Add extra computer cycles, a little unecessary disk access. Hey, you can only speculate until an insider whistleblows about it. It is like how VSStudio help has inexplicably slow access. It is to encourage you to access online so Microsoft can profile usage. I would not be surprised if hardware manufacturers, such as USB memory manufacturers, included firmware in their products that would causes the hardware to "fail" sometime after the warranty period.
|
|
|
|
|
Unfortunately, VS 2005 does run slower than VS 2003 (and VS 6.) I have found no way to improve this except to get a faster computer. I believe this is largely due to more extensive use of .NET in the UI and lack of time to do much of the performance tweaking it required. I am hoping SP1 fixes at least some of this.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|