|
I have been tasked with creating a windows form that will be like a paint program. The user should be able to drag units from a toolbox and drop them on the map. Then be able to resize them and move them around on the map. This way they create a map over their facility with storage units.
I have never developed much GDI+ related stuff and i have no clue how to do this. Can someone please hint me where i can find some good articles on how to place items like this on a surface and then move them around.
Thanks for any help.
-- modified at 14:07 Monday 20th August, 2007
|
|
|
|
|
This is not a paint program, it's a drawing program. The difference is that when you paint, you leave behind pixels, when you draw, you leave shapes that you can then interact with. Basically, what you want to do is store a collection of a base shape class, and create derived classes for the shapes you draw. Then when you move the mouse, you need to iterate over those shapes to work out if the mouse is over one. If it is, you start using mouse actions to interact with the shape in question. Changing that instance of a shape class, obviously then changes how it is drawn on screen.
GDI+ actually does very little here, each shape knows how to draw itself, and presumably the drawings are not that complex. The real work is in working out what shape the mouse is over, and manipulating it.
Christian Graus - Microsoft MVP - C++
"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 hate to think how many times this question has been asked, but here goes--
I have a "Back" button where "CausesValidation" is false. It closes the current dialog. The stupid thing is, the close dialog fires the validation routine!!! WTF? That's why I don't want validation. And I checked which control has focus when close fires, and it's the Back button.
So, what's the correct way of closing (as in, canceling) a dialog that has some controls that do validation, but the user's clicked on a back or cancel button (with CausesValidation set to false) so we obviously don't want to do validation?
Because, the stupid thing is, it's focused on a control that doesn't cause validation yet it's trying to validate a control!
Automatic validation, BTW, is one of the lamest, most poorly implemented features of .NET. I'm not even sure why I'm using it! It must have been by written by some highschool dropout on a bender.
Marc
|
|
|
|
|
Marc Clifton wrote:
Automatic validation, BTW, is one of the lamest, most poorly implemented features of .NET. I'm not even sure why I'm using it! It must have been by written by some highschool dropout on a bender.
Hahaha, that must be quite some guy??
Doesn't the this.DialogResult = DialogResult.Cancel work?
|
|
|
|
|
Eduard Keilholz wrote: Doesn't the this.DialogResult = DialogResult.Cancel work?
I'll have to try that, even though these are modeless forms (not displayed with ShowDialog). Which I guess is why I didn't even think of trying that.
Marc
|
|
|
|
|
Eduard Keilholz wrote: Doesn't the this.DialogResult = DialogResult.Cancel work?
Just got around to trying it. Nope, doesn't work. I'm having the validator find the control that has focus and checking the CausesValidation button. Fortunately, all my validators go through one validation event.
Marc
|
|
|
|
|
Hey, i have a question...
I'm writing a program, it goes like the following:
it reads every line in the txt file as one option, and you can select those options, let's say the resolution of, and after that it writes the value to another file (a settings.ini for example), then boots the specified program with that changed value.
it's like:
Settings.txt:
<br />
640x320<br />
800x600<br />
1024x768<br />
1200x1024<br />
1600x1200<br />
and so on.
now how can i make the .txt file be shown in the listview, and how can i define every line as 1 option?
|
|
|
|
|
This should come close....
<br />
StreamReader sr = new StreamReader("path\to\file", FileMode.Open);<br />
<br />
string sLine = sr.ReadLine();<br />
<br />
bool Loop = (sLine.Length > 0);<br />
while (Loop)<br />
{<br />
ListItem li = new ListItem(sLine);<br />
listName.Items.Add(li);<br />
sLine = sr.ReadLine();<br />
Loop = (sLine.Length > 0);<br />
}<br />
sr.Close();<br />
|
|
|
|
|
FileMode.Open is an inacceptable overload =x
|
|
|
|
|
Hi,
this will get you started:
string[] stringArray=File.ReadAllLines(@"path\to\file");
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Does anyone know any API to install fonts to windows folder?
On XP I used to just copy those to windows/fonts folder, but it does not work on vista.
There is windows API AddFontResource, but it only installs font until user reboots computer.
Thanks.
|
|
|
|
|
You can add fonts to your setup & deployment project and then register it as font..
|
|
|
|
|
I need to do it programmatically.
|
|
|
|
|
I did not need to register the new font. I copied the new font file into the directory during the install. XP and Vista found it and listed it in the font selection dialog with no problems.
did not know that i had to register the font in anyway
|
|
|
|
|
I think i have the same problem. I want to copy the a font file by using my program, but the only thing i managed until now is to register the font file vie AddFontResoucre so openoffice can use it until my pc reboots. I tried to get write permissions by using FileIoPermission for the font-Directory but when my program actually copies the file to the directory it says i dont have the permission to do so.
My code looks like this:
FileIOPermission f2 = new FileIOPermission(FileIOPermissionAccess.Write, "C:\\Windows\\Fonts\\");
f2.AddPathList(FileIOPermissionAccess.Read, fontPath);
try
{
f2.Demand();
System.IO.File.Copy(fontPath, destination);
}
catch (SecurityException se)
{
MessageBox.Show(se.ToString());
}
catch (UnauthorizedAccessException ex)
{
MessageBox.Show(ex.ToString());
}
<pre>
|
|
|
|
|
hi Frnds
I want to call the .dll file created by c#.net. in one of my vb application
after creating the dll ,i am giving the reference of this Dll in my vb application ,but i am not able call the methods of this dll.
Please help me , or give me some good tutorial Link
Thanks in advance
«·´`·.(*·.¸(`·.* *.·´)¸.·*).·´`·» ©
*.¸¸.·´¨` »*Vicky*«´¨`·.¸¸ .*
«·´`·.(*.·´(¸.·* *·.¸)`·.*).·´`·»
|
|
|
|
|
What errors are being returned? Also, why don't you use VB.NET?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
i am not getting any error.
i am not able to call the functions of that Dll
«·´`·.(*·.¸(`·.* *.·´)¸.·*).·´`·» ©
*.¸¸.·´¨` »*Vicky*«´¨`·.¸¸ .*
«·´`·.(*.·´(¸.·* *·.¸)`·.*).·´`·»
|
|
|
|
|
Did you add a reference to the dll?
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
The only way you can use newer technology like C# via obsolete technology like VB6, is to use something that VB6 knows about. In this case, this means you need to create a COM DLL in C#, and then VB6 can call it via COM.
Christian Graus - Microsoft MVP - C++
"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 am able to take the reference of that dll.
i am not able to rectify either the problem with the dll creation or taking ref.
i have a c#.net project .i am creaing the dll using this.
the procss i am following:
1)tlbexp (to create typelib)
tlbexp ComInteropExample.DLL /out:ComInteropExample.tlb
2)regasm
regasm ComInteropExample.DLL /tlb: ComInteropExample.tlb
after this i m taking the ref of the .tlb file in my vb project.
i am not able to call the function inside.
Plz help
«·´`·.(*·.¸(`·.* *.·´)¸.·*).·´`·» ©
*.¸¸.·´¨` »*Vicky*«´¨`·.¸¸ .*
«·´`·.(*.·´(¸.·* *·.¸)`·.*).·´`·»
|
|
|
|
|
Hi All,
If you have a control (such as a textbox) which is placed inside any type of panel that has it's AutoSize property set to true, and the AutoSizeMode set to grow and shrink,
then when you ErrorProvider.SetError on it, the panel does not grow and as a result, the error icon is clipped.
Does anyone know a solution to this? it's driving me up the wall!
Thanks
Jon
|
|
|
|
|
I'm Looking for a control similar to ListBox, but it would be a little different. You would see the options that you can choose from on one side (preferably left), and then you would see what you've selected in the list on the box on the right hand side of control. You would be able to move the items back and forth by double clicking on them, or clicking on arrows that would move them. I've seen this type of control used multiple times, and so I figure it must be in the .Net framework, but I can't think of what it's called to find it.
Thanks for the help.
|
|
|
|
|
No, it doesn't exist. This control, as you describe it, is made of 2 listboxes and 2 buttons, one for move left to right and one for move right to left.
You can of course create your own custom control and render in it 2 listboxes and 2 buttons.
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
You could use the standard listbox control for this. Just create 2 list boxes, and place them side by side. have 2 buttons in the middle "->" and "<-". In the button mousedown control, check to see if something is selected in the list box. If there is, get the item in the list box, and add it to the other side. All the "magic" here is done by the buttons.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|