|
Hi guys,
I'm a newbee to programming.
I have a project coming on which involves many modules. The problem is the first module is created in C#. The others are developed in VB.NET. How can I integrate them all together at the final phase as one project?
Also how do I make that the different modules can talk to each other? For instance the C# module program might be able to invoke the VB.NET module program.
Can I add in the different modules in Visual Studio and compile them easily at the later stage?
Any advice?
Thanks.
|
|
|
|
|
It's easy. Create one class library (DLL) project with all the C# code and the windows application (EXE) with all the VB.NET code, and make the EXE depend on the DLL. You can then call the code written in another language as if it were written in the same language. .NET makes this very easy.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hello
I'm trying to use a MaskedTextBox but I'm having an unusual problem.
I set the Mask property on the Properties Window to support anyone of the templates (Data Validation, Hour Validation, etc...), after that, I execute the debug to test the whole Control (UserControl), then the problem appears: Any value that I type on the MaskedTextBox is written on another TextBox as I had typed on it ! Why is this happening ?!
When I remove the mask property from the MaskedTextBox control it works as a normal TextBox, writting the text on itself as it was supposed to be even with the Mask property set, but with the Mask property set it writes on any other TextBox avaliable on the Control I'm developing.
I'm using:
Microsoft Visual C# 2005 55603-000-0000016-00101
Microsoft Visual C# 2005
But I don't think that the problem is being caused by the VStudio version since I downloaded a tutorial about MaskedTextBoxes and it works perfectly here, but when I try to implement it (also copy) the tutorial's MaskedTextBox to my Control it "stops working". It seems to be a conflict... but as I don't receive any error or warning messages from the compiler I got confused.
I was testing right now and I detected that If the MaskedTextBox is the only thing on the Control it works perfectly but If I add only one or more TextBoxes the MaskedTextBox will write on any of them instead of filling itself with what I type. Any idea ?
Thank you.
-- modified at 23:59 Wednesday 9th November, 2005
|
|
|
|
|
Please share out relevant code so that we can help diagnose the problem.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am storing a photo in an image format in SQL Server 2000.
I am able to retrieve the stored photo in the code behind without mentioning the physical path location of the photo. But i need to show the retrieved photo in thumbnail.
Image controls in .net requires the physical path of the photo.
So, how can i do that?
Regards,
Syed.
|
|
|
|
|
Image classes do not require a physical path to an image. You can write it into a MemoryStream , for example, from SQL Server then use the Bitmap constructor that accepts a Stream . It will determine the image format based on encoding information in the image (for supported image types and assuming there are no errors in the encoded information). Then you can assign this Bitmap instance to PictureBox.Image , for example.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I am displaying images from a camera continuously in a PictureBox, it works fine, but when I minimize the window and restore again, it shows a cross symbol in picture box, as well as it throws argument exception, System.paint.getWidth(), etc,
Please help, should I draw inside paint method or so, but I use Thread method to draw directly...
Thanks in advance
|
|
|
|
|
All interaction with a control should be done on the thread on which the control was created. The Control.InvokeRequired property and the Control.Invoke method are for this very thing. You could load the image in a separate thread, but when you assign the image to a PictureBox , for example, you should do it in the control's owner thread:
void AssignImage(Image img)
{
if (!pictureBox1.InvokeRequired)
{
pictureBox1.Image = img;
}
else
{
MethodInfo setMethod = pictureBox1.GetType().GetProperty("Image").GetSetMethod();
MethodInfoInvokeHandler d = new MethodInfoInvokeHandler(setMethod.Invoke);
pictureBox1.Invoke(d, new object[] {pictureBox1, new object[] {img}});
}
}
delegate object MethodInfoInvokeHandler(object obj, object[] parameters); Interacting with a control from a different thread causes unusual problems that differ from control to control and even between properties and methods for a single control.
I'm not 100% sure this is the problem you're seeing but it's one possibility.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
What Heath said is probably what is happening, but you can also get those errors if you Dispose the image before the PictureBox gets a chance to draw it.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Is there a way to write a class that can modify private values of another class?
In this situation ...
I have a table (a black box which contains methods like AddPlayer, RemovePlayer, DealNewHand)
... but I don't want to directly work with the values. I want to call only certain methods that will modify the table exactly how it should be modified.
But ... I need to directy be able to read/modify some of those private values, for simulating play.
I want to write a class Dealer which will be able directly read/modify some of those values.
The dealer, for example, would be responsible for knowing who's turn it is to act (needs access to the private players objects stored in the table) and for updating the corresponding table values.
So, is there a way for me to give the Dealer Class access to the private members of the Table class, or am I going to need to make the members of the table class that I want the dealer only to be able to see, public?
As always, thanks!
|
|
|
|
|
C# doesn't have an equivalent to C++'s friend modifier. If you don't want to expose members of your table class outside of the namespace you are writing but would like other classes, namely your Dealer class, to be able to access them, you could make those members internal instead of private. Not quiet the same as C++'s friendship mechanism, but pretty close for many situations.
However, it occurred to me that your table class looks very much like a collection. I would suggest creating a strongly typed collection class that implements the ICollection interface. The Dealer class could access the players in the collection through using an enumerator, or maybe an indexer property that you provide. As the Dealer enumerates through the Players, it can deal each one a new hand, or whatever.
Does this make sense?
|
|
|
|
|
Something you said, just made me question myself. All these classes are defined in the same namespace: PokerLib, and compiled as a class library.
Are you saying that classes defined inside the same namespace CAN access private members of other classes defined in the same namespace?
|
|
|
|
|
budidharma wrote: Are you saying that classes defined inside the same namespace CAN access private members of other classes defined in the same namespace?
Nope. I'm saying that if you use the internal modifier instead of the private modified for class members, classes in the same assembly (I said namespace in my earlier post, but should have said assembly) will be able to access those internal members.
|
|
|
|
|
Ok, scared me for a second. I thought I was missing some fundamental understanding of C#. I just realized after reading through my code, that by simply writing three more public methods, I can transfer the dealer logic to the table logic - and the logic is better placed in the table anyways.
public BetAction[] GetPossibleActions(int Position); // Return an array of possible actions, given the game context, for the specified player.
public Update(BetAction Action, int Position); // Update the game context, given the player action at the specified position.
public int NextPlayerToAct(); // Return the position of the next player to act, given active players
By simply calling GetPossibleActions(NextPlayerToAct()), you'll recieve an array of possible actions. If it's empty - the hand's over and the simulator (or whatever is controlling input to the table) will simply call StartNextRound() (which may call FinalizeHand(), if your on the last hand).
If there are possible actions, (I have written public properties for the table which allow viewing, but not modifying table values), whatever selects the decision can view those properties and make a decision, then simply call the Update(SpecifiedAction, CurrentActingPlayer) which will update the game context and the player object.
... In other words, after thinking about this for awhile, I realized I don't need another class with private access.
Thanks!
|
|
|
|
|
I probably don't know enough about your application to advise you, but I won't let that stop me.
budidharma wrote: public BetAction[] GetPossibleActions(int Position); // Return an array of possible actions, given the game context, for the specified player.
Do you have a Player class? Would that be a good idea, do you think?
Also, who decides what the next BetAction will be? Maybe the logic for deciding should be in the Player class? If the logic varies, maybe have an IPlayer interface that can be implemented with various player strategy classes.
Here's what the code might look like:
public interface IPlayer
{
bool Bet();
event BetEventArgs BetPlaced;
}
Then somewhere else in your application:
PlayerCollection players = new PlayerCollection();
players.Add(new ConservativePlayer("Harry"));
players.Add(new AggressivePlayer("Joe"));
players.Add(new ModeratePlayer("Sue"));
foreach(Player p in players)
{
if(!p.Bet())
{
break;
}
}
The break looks ugly, and I'm sure there are cleaner ways of doing it. In part my suggestion is just guessing at a solution, but what I'm trying to get it is that maybe you should consider delegating some of the responsibilities of the table class to other classes. By putting everything in the table class, you may wind up with a monolithic class (a "God") class that does everything. This isn't considered good design in many circles.
Just a thought, and feel free to ignore it.
|
|
|
|
|
|
Not sure if this deserves a reply... Have you had a look at the list of controls on the "Toolbox" palette?
Matt Gerrans
|
|
|
|
|
Yeah, and?
Although, i usualy use sharp develop, but at the moment im using borlands c# builder, which i've noticed doesnt list some things. eg:
Process.Start - the Word 'Start' is not listed, which is pretty stupid, i'll go look around.
I may be back!!!
|
|
|
|
|
Okay, i dont find anything, well i found a link label, but where do i say what it actually links to?
|
|
|
|
|
You need to handle the LinkClicked event for the LinkLabel control:
private void linkWebSite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
System.Diagnostics.Process.Start("http://www.intelectix.com/");
}
catch
{
}
linkWebSite.LinkVisited = false;
} I hope this helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
> // Swallow the exception if anything goes wrong
Ack!
Please don't do this.
Matt Gerrans
|
|
|
|
|
Matt Gerrans wrote: Please don't do this.
I've seen that call fail and I'd rather just "ignore" the user click instead of displaying a message box telling the user that the browser could not be launched.
It's not that I do it often (to ignore exceptions).
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hello,
Is it possible for the C# class to know as soon as its object(s) goes out of the function scope?
Otherwise the burden is a kind of left to client to explicitly notify the class for cleanup.
Is it possible to simulate this feature supported by traditional C++ with less effort in C#(supports class as referenced type)?
Thanks & Best Regards,
|
|
|
|
|
The quick answer is: no.
The long answer is: as a workaround, probably you should take a look at the IDisposable pattern and the "using" statement for automatic object disposal. After you look at it, you'll think: that guy is insane, this is not what I'm looking for! Yes, I know, but it's the nearest that you can get to RAII in C#.
I don't see dead pixels anymore...
Yes, even I am blogging now!
|
|
|
|
|
I can't find any documentation on this anywhere ... is it possible?
I have a class:
public Player
{
... private fields
... public methods
}
And there are many times I need to simply say this Player equals that Player and have all the values from one copied into the next. I have created a pubic method inside player, called "Copy()"
which simply creates a new player from the current players data and returns it.
So I can do something like:
player1 = player2.Copy()
But this is VERY annoying.
Can I simply overload the assignment operator so that I can do:
player1 = player2 and it will copy all the data from player 2 into player 1, rather than setting player1 equal to the reference of player2?
|
|
|
|
|