|
hi,
i have created a editor in richtextBox
can any one help me in creating a copy,and paste method.
Thank You
Prasad
|
|
|
|
|
I thought the control gave you those for free ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all,
in my project i need to convert raw image to bmp or jpeg and i have some images with the extention .gry i dont know this is raw or any other special format but i am thinking this is a raw format so my problem is convert .gry image to bmp or jpeg in c#
so plz any one knows the way how to do it is plz tell me
thanks in advance
Regards,
santhosh
|
|
|
|
|
If you've got raw pixel data, you have a bmp, it just needs a header, assuming that it's word aligned, or that it has the right padding in it.
Where is the data coming from ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi Christian Graus,
we have live scanner that will be creating these images into one folder so now my responsibility is reading that .gry images and displaying in the form in c# .
Regards,
santhosh
|
|
|
|
|
You can create a bitmap object from a stream, you could try and see if the class can make sense of the data. If not, you could read my image processing articles, build a bitmap of the right size, and pass the data across one scanline at a time.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Isn't a raw image different then a bmp?
If not why would Xp have a powertoy Raw Image Support[^]
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
Yes, it is, but a bitmap IS 'raw' pixel data, with a bitmap header.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Im writing a test prep MDI program that calls random #s to select a question, im having a problem though i need it to only call those numbers once. A solution to this or something that will accomplish the same goal would be appreciated.
|
|
|
|
|
Use Hashtable to keep the record of these numbers and if they are repeated ignore them.
Regards
Shajeel
|
|
|
|
|
Create a list that contains all the numbers you may want, in sequence. When you get a random number, make a number that is a valid index into that list. When a number is selected, grab it, and remove it from the list.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all
i have to do something on remotesystem ....
now my application is ready
the remote sys. is my local server..
and client is my webserver...
i did all my things in console and got its exe
these exe works well
but how do i use it on webserver....
or do i need to change into asp.net applications
if i need to change how should i proccedd
please help me thanks byebye
|
|
|
|
|
Hello everyone,
I have created a Treeview which displays the DB server and Databases in the server.
I would like to add an extra option to my application. I would like the list of table to be open in another TextBox once a particular database is selected from the TreeView. If I am not mistaken I should use AfterSelect for this purpose. But I am not able to get the ChildNode name!
Could someone be kind enough to let me know how I can get this done or point me to some online code or tutorial?
As always, thank you very much for your help and have a great day.
Khoramdin
-- modified at 23:22 Wednesday 21st February, 2007
|
|
|
|
|
e.Node where e is the second argument of the event.
Regards
Shajeel
|
|
|
|
|
I have an object hierarchy where all of my objects in the application domain inherit from a base class. I also have a persistance layer which works using generics.
Looking at the code below, you realize that my object hierarchy is non-generic. But DBStore methods are genericised. How do I pass the type/class of current type?
e.g.
class DBStore
{
public T CreateObject<T>()
{
...
}
public void DeleteObject<T> (int id)
{
.. logic to delete from DB using metadata about T (containing table name) and primary key field matching 'id' ...
.. eg.. delete from typeof(T).Name where ID = id
}
}
abstract class DomainObject
{
private int _id;
private DBStore _dbStore;
public void Delete ()
{
_dbStore.DeleteObject<<big>WHAT SHOULD GO HERE</big>>(_id)
}
}
class Boat : DomainObject {...}
class Car : DomainObject {...}
I would like to be able to perform following:
Car car = new Car();
car.Delete();
or
Boat boat = new Boat();
boat.Delete();
Only things that come to my mind are:
1) Move "Delete" method from the base class to each of the deriving class: (code redundancy .. )
2) Ungenerecise the "DBStore" method (inconsistancy in DBStore -- all methods are generic, except for Delete object)
Thanks,
- Malhar
|
|
|
|
|
GetType() perhaps ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I wished! C# compiler expects a class, and not a variable of type 'type'.
<pre>Type t = GetType();
_dbStore.DeleteObject <t> (_id);</pre>
--> The type or namespace name 't' could not be found (are you missing a using directive or an assembly reference?)
-- modified at 21:22 Wednesday 21st February, 2007
|
|
|
|
|
OK, that really sucks.
C# generics are kind of gay, they are not much use for anything too complex. They are designed so people can't hurt themselves using them, I suspect.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Why instead don't you genericize abstract class DomainObject<t>?
|
|
|
|
|
If I'm not mistaken, then you're suggesting something like:
public abstract class DomainObject<T>
This will break majority of the app where I'm simply keeping a reference to the base DomainObject as opposed to DomainObject for Car. You could help clarify my misunderstanding .. but:
Assuming I changed the class declaration as above (with generics), what should I change my dependent method signature for the classes that do NOT inherit from generics?
e.g.
01. class ListViewEx
02. {
03.
04. DomainObject _selectedObject;
05.
06. public void AddItem (DomainObject obj)
07. { ... }
08.
09. public DomainObject SelectedObject
10. { get { return _selectedObject; }
11. set { ... } }
12.}
- What should the line #4, 6 & 9 look like after genericising DomainObject?
- And one thing to note is that currently, ListViewEx.AddItem is designed to allow consumer to pass both objects of type Car AND Boat. If I genericize the ListViewEx to class ListViewEx <T> then a. I'll lose the functionality of adding items of multiple types, and b. Win form designer will no longer work.
Thanks,
- Malhar
|
|
|
|
|
I don't see enough here to say what your line 4 should be (unless maybe I'm supposed to study the previous code or something). Sorry, not enough time for that.
But yes, you are correct in understanding what I am suggesting. In my haste to make the previous post, I neglected to write my < and > with code.
As to what you need to do with your line 4, I think it's a larger matter than that. If you declare your generic to descend from a base class B, then keep a reference to B. I don't see why you would have a problem with using that reference to refer to your domain object then.
|
|
|
|
|
What I meant was currently line
#4 is: DomainObject _selectedObject
#6 is: public void AddItem (DomainObject obj)
#9 is: public DomainObject SelectedObject
If DomainObject is converted to a generic class, then I can't really compile the ListViewEx class with the above code lines. I must change the declarations as well to .. :
#4 is: DomainObject<??> _selectedObject
#6 is: public void AddItem (DomainObject<??> obj)
#9 is: public DomainObject<??> SelectedObject
So the correct question is, what would I substitue "??" with? if you're implying the following, then there may be a possiblity but that'd just create unnecessary classes and cause confusion:
abstract class BaseObj
{
}
abstract class DomainObject <T> : BaseObj
{
}
class Car : DomainObject <Car>
{
}
class Boat : DomainObject <Boat>
{
}
class ListViewEx
{
void AddItem (BaseObj obj)
{
}
}
The "BaseObj" is simply an empty class and it just changes the object model where consumers can begin using 'baseobj' instead of DomainObject -- since classes such as "ListViewEx" have been changed to accept BaseObj.
- Malhar
|
|
|
|
|
Giving serious attention to this is going to swerve me way off course at the moment. Generics should always be addressed very carefully. I think you have some really sour syntax here.
When you call your DeleteObject() method, it must be able to handle an object of class/type t. You shouldn't have to tell it what class to handle at that point. Your method should just act on an index, and assumably remove a reference.
I think the compiler is possibly trying to interpret your _dbStore.DeleteObject <t> (_id); statement as a type declaration, and before it gets very far with that, it chokes on the <t> syntax.
|
|
|
|
|
mike montagne wrote: When you call your DeleteObject() method, it must be able to handle an object of class/type t.
I couldnt agree with you more on this point. But there are cases when from you non-generic class, you want to call a generic method and all you want do is to pass the "current type" and not any other type. In most cases, you will hard-code the class name, but if you're working in the base class, you would not know the type of the deriving class. The only workaround for this limiation, is to make the method from your base class abstract and let the deriving classes implement the call. That said, if I have to do this, then I'm working against the what the intention of generics was in the first place.
e.g.
class DomainObject
{
abstract bool Delete(int id)
}
class Car
{
override bool Delete(int id)
{
DBStore.SomeGenericMethod<Car>(args);
}
}
class Boat
{
override bool Delete(int id)
{
DBStore.SomeGenericMethod<Boat>(args);
}
}
Anyways, your input is much appreciated .. I'm simply being a devil's advocate here. I'm sure i'm not the only person encountering such scenarios and this would a common problem.
- Malhar
|
|
|
|
|
malharone wrote: I couldnt agree with you more on this point. But there are cases when from you non-generic class, you want to call a generic method and all you want do is to pass the "current type" and not any other type. In most cases, you will hard-code the class name, but if you're working in the base class, you would not know the type of the deriving class.
I think there's a conceptual problem here. First of all, you can overload your method if you need to process a handful of known classes, or you can simply let descendants override your method (if they need to), and whatever calls the method ends up firing, being as they belong to the instance you (or whoever) calls them on, this ends up firing the method implementation of the closest descendant to the class it's called on (which may be the instance class itself). As your class design is a matter of writing these methods *for each class* (if necessary to override them), this *is* the right method (whether overloads or overrides are necessary or not -- they may very well not be).
Now, if you need to identify the class otherwise (which isn't evident from your example), you can also pass your own identifier argument. It doesn't even have to be a real class -- it could be an enumerated type... anything, even an integer. C++ guys do this all the time to eliminate dynamic casting, and it's perfectly sound if you cover your bases... and faster than greased things unmentionable in C# forums.
Reflection will also work to determine the class (although I have to admit I'm a bit raw with this with C#, as it's something I'll be getting to in the near future). I know for instance I have substantial notes and collected material on the Activator class, which I intend to use to create instances of unknown classes, which certainly is an intersecting area.
-----
Now, I also have another thought. You have a mixture of generics and non-generics interacting. Something you wrote earlier also tells me you are flexible -- you could write this as all non-generic then?
If you can, that's a good way to work out the problem. Get it working without generics. This will tell you exactly how to build generics into it, if that is a good thing to do.
It probably is a good thing to do if you have to do any casting, because it can eliminate casting altogether, and provide wholy type safe operation with minimal code.
I really can't see what the problem is. I look at your question, and you say you have to pass the type, and I ask myself, is he trying to call a static method without an instance (which is a place where the method doesn't know what type it belongs to, because there is no inherent this or instance pointer). Otherwise, a method always knows what type it belongs to, and doesn't need to reference the type. So unless a method has to process a further type which hasn't been cast for processing, I have yet to see in your question why you can't get the job done one of these ways.
Actually, you say:
malharone wrote: The only workaround for this limiation, is to make the method from your base class abstract and let the deriving classes implement the call.
So we are in complete agreement. Why then can't you let that method call preciptate to the descendant, which, if it had needed to, has revised the method to handle itself however necessary? That's just general practice.
|
|
|
|