|
Hi everybody
I'm currently developing a 2D RPG game like diablo 2. And this year I finally finished the physics engine .
For drawing the objects I use GDI+. Now I'm working on the level editor and I want to give more freedom for the level designers like giving them the option to decide by their own which regions of the map shall be impassable. The point is to give them a pen tool which they can use to freehand draw the impassable regions - something like Microsoft inkball game(http://www.windowsvistauserguide.com/vista2/games/inkball3.JPG) where you draw a line and when the ball touches the line it bouns from it. For that pen tool I use System.Drawing.Drawing2D.GraphicsPath function - the problem I have is that I don't know how to provide to the level designer a tool for erasing the created impassable regions - do you know a way to erase part of graphic created with System.Drawing.Drawing2D.GraphicsPath function? I've read an article where you can "erase" the created line by drawing another one with the same background color as the containing control but it just didn't work in my case because for background I don't have a solid color but a complex bitmap texture and objects like units and buildings.
Please help, thank you in advance and sorry for my bad english.
|
|
|
|
|
It doesn't sound like you have much of a choice but to repaint everything except the portions you're removing.
|
|
|
|
|
I have a block of code like so; I use to get the number of lines in a text file once I load it in a multiline textbox on my Form1.
Private Sub countLinesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles countLinesToolStripMenuItem.Click<br />
''count claims between ST & SE segments<br />
Dim totLines As String() = IO.File.ReadAllLines(Me.lblClaimsFile.Text)<br />
<br />
MessageBox.Show("The file had " & totLines.Length & " lines before processing.")<br />
End Sub
Once this file is loaded, I do some manipulations, including inserting additional lines. I would like some codes to determine the total number of lines in the textfile after the manipulation.
I am using stringbuilder to load file contents.
Dim newString As New StringBuilder<br />
newString.Append(My.Computer.FileSystem.ReadAllText(FileName))
TIA.
|
|
|
|
|
As you said, you have a multiline text box to load the file. I assume you are editing the file text there itself. Hene if you get the lines count in the multiline text box, I suppose it will be same as that in the file.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
The line count I get on load is static. After inserting additional lines in the file, I need a way to get a dynamic update of the number of lines in the "modified" file. Sorry if this was not clear. thanks
|
|
|
|
|
Have you looked at the Lines property of the TextBox control?
|
|
|
|
|
Thanks Dave. I will give it a whirl.
|
|
|
|
|
If you want to find out the number of lines in the textbox, use:
int lineCount = textBox1.Lines.Count;
|
|
|
|
|
Thanks Shameel .. it worked great; I just had to use Length instead of Count (since I got a message that count was not in the array).
Dim lineCount As String<br />
lineCount = txtClaimsDetail.Lines.Length<br />
MessageBox.Show("You have " & lineCount & " in your batch")
|
|
|
|
|
yep, I forgot. Arrays have a Length property and Collections have a Count property.
|
|
|
|
|
Hi All,
I want to get the data coming from a weighing scale (rs232 signal) to a vb.net prgram, to a text box, how i get this? can any one give the code,
Kind Regards
Jamith
|
|
|
|
|
Check out Coad's Code[^]. I know it is C# but it easy enough to translate. Plenty of tools available on the web to translate code.
|
|
|
|
|
Hi All,
I have two forms, Form1 and Form2.
Form1 has a tab control with tab name "A". I want to enable/disable this tab from Form2.
How to do this?
|
|
|
|
|
A reasonably simple solution is to put a public boolean variable somewhere, and changing it in form2. Then choose a suitable event (for example GotFocus ) in Form1 and based on the variable enable or disable your tab.
My advice is free, and you may get what you paid for.
|
|
|
|
|
My implelentation is like this:
In Form1, Code is:
Sub Functioname()
{
GroupbBox1.Enabled = False
}
Now I want to enable this GroupBox1 through Form2 in following function:
Sub FunctionEnable()
{
''''' Code will come here
}
Please let me know how to call that GroupBox1 control so that I can use its properties in Form2.
Regards
R.S.
|
|
|
|
|
See the other reply to your question.
P.S. Besides that it seems you are on the wrong forum.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Do you have a reference to form1 in form2? If you do then just call the Functioname method directly. If not then change your structure to have a reference. If the forms are intrinsically linked like this then there is no point doing this with events.
|
|
|
|
|
Please see my requirement below carefully: need immediate help.
I have 2 forms, main Form1 and a loginform. When I start the application, first "Form1" is loaded and then with a button click, user can load "loginform" if required to enable/disable some features/controls on Form1.
The sequence is like this:
1) Load main form Form1
2) click a button on Form1
3) Load the loginform.
4) enter user/pwd and click OK button
5) enable/disable "GroupBox" control on Form1 if login sucessful.
For this,
I made a click event for OK button in loginform, so once user clicks the OK button, I want to call one function which is defined in Form1 as a Public, which enables/disables the "GroupBox" control on Form1. The code structure is like this:
in main Form1, i created a function like this:
Class Form1()
Public Function DoThis() ' Function to enable/disable GroupBox control
....some task...
End Function
End
now in loginform, in the click event for OK button:
Class loginform()
Click_OK()
{
DoThis().... 'call function DoThis() of Form1
}
End
I am not able to call the DoThis() function in loginform. Please suggest me with a piece of code how to do this??
Please remember that Form1 is my main form which is loading first. If anyother way is there to make a password protected feature for GroupBox control in Form1, it will be highly appriciated.
Hope my problem is clear..Thanks.
|
|
|
|
|
You cannot Enable / Disbale a tab directly. It does not have a property for this.
The recommended method on MSDN is to handle the TabControl SelectedIndexChanged event. you will need to have a flag somewhere that you can set to reflect the state of the tab (enabled/Disabled) and then check in this event which tab you are on and then move to another tab if you try to select it when it is disabled.
Search google for "How to: Disable Tab Pages" and you will find the article at MSDN.
Dave
|
|
|
|
|
Actually, you can disable tab pages. Read this[^] thread.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Didn't know that!
Although, i dare say if you are using unsupported methods (or hidden ones) and something breaks folling updates to the api, you don't really have a leg to stand on!
|
|
|
|
|
You need a reference for Form1 in Form2 so you can directly manipulate its controls and set its properties.
|
|
|
|
|
Hi Shameel,
I am sedning You the actual scenario where I am using multiple forms this:
I have 2 forms, main Form1 and a loginform. I made a click event for OK button in loginform, so once user clicks the OK button, I want to call one function which is defined in Form1 as a Public. The code structure is like this:
in main Form1, i created a function like this:
Class Form1()
Public Function DoThis()
....some task...
End Function
End
now in loginform, in the click event for OK button:
Class loginform()
Click_OK()
{
DoThis()....call function DoThis() of Form1
}
End
I am not able to call the DoThis() function in loginform. Please tell me how to do this??
Hope my problem is clear..Thanks.
|
|
|
|
|
To call a function on Form1, you need a reference to the form in your loginform. It depends on where you instantiate Form1 in your app. Assuming that you instantiate Form1 in loginform (since loginform should ideally be the first form that is loaded in your app from main() method), the code could be something like this:
Form1 form1 = new Form1();
form1.DoThis();
form1.Show();
|
|
|
|
|
my Form1 is the first form which get loaded. loginform is loaded on the click of a button on Form1.
Pls tell me how to do this.
|
|
|
|