|
MasterSharp wrote: What are you talking about 100 posts a day
Not you - Chris. He's the most prolific poster on CodeProject.
MasterSharp wrote: I've calmed down a bit and took to a book!
That's the spirit. I buy (and read) 3 or 4 computer texts every other month. Hopefully that helps to keep me sharp.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
FYI - If you are interested in theory with a little code - mind you it is C++ but that's not important, check out the book "Beginning Math and Physics for Game Programmers" by Wendy Stahler. It is pretty good and might help you with game development. ISBN is 0-7357-1390-1. Anyhow, I found it to be invaluable in my game/physics programming.
Good Luck!
“You can't teach people to be lazy - either they have it, or they don't.”
-Dagwood Bumstead
|
|
|
|
|
|
Okay, I have just one more question about the this whole mess. After you assign the graphics...
private void Form1_Paint(object sender, PaintEventArgs e)<br />
{<br />
Graphics G = e.Graphics;<br />
<br />
G.DrawRectangle(new Pen(Color.Black, 3), 15, 15, 200, 150);<br />
<br />
G.DrawRectangle(new Pen(Color.Red, 3), 15, 15, 200, 150);<br />
(for example)
... how do you name those rectangles?
|
|
|
|
|
Hello,
You have to be carefull with the GDI objects here (memory leak)!
If you want to hold the instance of your pens for further use, you have to hold the m as local members of your class.
Same to Rectangles.
But you have to dispose (free the resourcess) them in the dispose method of your class (Form).
System Drawing.Rectangle rectangle1 = System Drawing.Rectangle.Empty;
System Drawing.Rectangle rectangle2 = System Drawing.Rectangle.Empty;
System.Drawing.Pen penBlack = new Pen(Color.Black, 3);
System.Drawing.Pen penRed = new Pen(Color.Red, 3);
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics actGraphics = e.Graphics;
rectangle1 = new System Drawing.Rectangle(15, 15, 200, 150);
rectangle2 = new System Drawing.Rectangle(35, 35, 200, 150);
actGraphics.DrawRectangle(penBlack , rectangle1);
actGraphics.DrawRectangle(penRed , rectangle2);
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
if(penBlack !=null)
penBlack.Dispose();
if(penRed !=null)
penRed.Dispose();
}
base.Dispose( disposing );
}
If you not want to hold the instances (not suggested in this case), you would have to dispose the pens write after usage in your Paint event. A using block will do that automaticaly.
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics actGraphics = e.Graphics;
using(System.Drawing.Pen penBlack = new Pen(Color.Black, 3))
using(System.Drawing.Pen penRed = new Pen(Color.Red, 3))
{
rectangle1 = new System Drawing.Rectangle(15, 15, 200, 150);
rectangle2 = new System Drawing.Rectangle(35, 35, 200, 150);
actGraphics.DrawRectangle(penBlack , rectangle1);
actGraphics.DrawRectangle(penRed , rectangle2);
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hey thanks, that's just what I needed!
|
|
|
|
|
That just helped a lot, and there's SIMPLE collision detection! All I fond was 50 lines of code that was... extremely confusing and hard, but thatnks again to everyone who replied... Time to continue reading.
|
|
|
|
|
Hello all,
I'm working on a project in C# where i don't want the user to be able to resize the application's form past the desktop's taskbar. Is there a command that prevents resizing beyond any of the sides of the desktop's working area? If not, what would be the best way to approach this issue?
|
|
|
|
|
You can restrict form's maximum size by setting its MaximumSize property. You can retrieve the size you need by using Screen class
|
|
|
|
|
oops, never mind, had the formborderstyle set to sizabletoolwindow instead of just sizable.
|
|
|
|
|
The big picture of what I'm trying to do is to allow all users of an active directory global group to log in to an ASP.net/C# website on my intranet. I have no idea how to do this. Lol. Can someone point me in a direction? thanks.
|
|
|
|
|
theory:
I think you need something like "Forms" authorization in your ASP.NET website set in web.config;
second step for you will be "custom membership provider" to write; i saw a few days ago example on msdn in C#.
third step is to create database for your custom membership provider, at this point you can google for the AD examples in C# [or maybe i can post you some, or simply take a look on System.DirectoryServices namespace] ...
some code which you've got to do is to obtain all info about users and/or groups and put it to your membership db. These 'DirectoryServices' then you can always use for password checking, etc.
mail me if you need further assistance
VirtualVoid.NET
|
|
|
|
|
I need help on how to add a string to the value in a dictionary type based on a particular key
when the value is a list of strings to be added to
So far I have something like this going on:
<pre>
Dictionary<string, List<string>> grammar = new Dictionary<string, List<string>>();
List<string> value = new List<string>();
const char space = ' ';
string element = "my big blue brown dog";
string key = "myString";
foreach(string word in element.Split(space))
{
//I get problems here
grammar.Add(key, value.Add(word));
}
</pre>
Any help is greatly appreciated.
Onward and Upward,
Ryan R.
|
|
|
|
|
You need to add all the strings first.
foreach(string word in element.Split(space))
{
value.Add(word);
}
grammar.Add(key, value);
Hope that helps.
Ben
|
|
|
|
|
Hi everybody,
it's possible to drag an E-Mail from Thunderbird or Outlook into a self-created application.
Is it also possible to do this in C#?
I get a Drag'n'Drop Event and can read out which format it has, for example "Windows Mail Message"
Now the next step is seriously to parse a Data-Object into a special Mail-Persistence-Class or something like this, or?
Big thanks for any help
|
|
|
|
|
Both outlook and thunderbird have specific mail format [in binary form, take a look on *msg files from outlook]. I think this will be possible using some APIs of these programs.
VirtualVoid.NET
|
|
|
|
|
Using a C++ base approach, I have:
// y = mx + b conversion format
public struct LinearConverion
{
double m;
double b;
};
public struct UnitConv
{
LinearConverion to[4,4];
};
UnitConv[] ConvFacts = new UnitConv[Ranges.length()/Ranges[0].length()];
This does not compile.
This seems direct and to the point. What am I missing. Thanks in advance.
This is part of a conversion system where US, IP, Metric, SI units are defined in a table.
US IP Metric SI
IP Metric SI US
Metric SI US IP
SI US IP Metric
where column is what is current and the other index points to the conversion value.
|
|
|
|
|
public struct UnitConv
{
LinearConverion to[4,4];
};
Thats the problem, i pretty sure c# doesn't use static arrays, they're all stylish and dynamic.
You'd need to use 'new'
public struct UnitConv
{
LinearConverion to = new LinearConverion[4,4];
};
But that won't work either, since you can't just start assigning things inside a struct. Instead, ditch the struct, and make it a class, it'll be exactly the same, except it'll work.
public class UnitConv
{
LinearConverion to = new LinearConverion[4,4];
}
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
As you can see from my change that I posted, I am using a class with a single array but I have lost the modularity of structs with the overhead of class based methods(runtime impacts).
I guess I could define a large storage system and decode it within my class and create access methods to decode it correctly. This seems to be more abstracted from a simple array based decode of the desired address by the compiler and value access compared to a subroutine call and return overhead.
|
|
|
|
|
public enum UnitDefs
{
UNDEFINED = 0,
LENGTH, // 1
PRESS, // 2
DPRESS, // 3
MASS, // 4
VOLUME, // 5
TIMEUNIT, // 6
TEMPERATURE, // 7
DENSITY, // 8
MASSFLOW, // 9
VOLFLOW, // 10
EXPANFACT, // 11
VISCOSITY, // 12
HEATVALUE, // 13
ENGYFLWRATE, // 14
VELOCITY, // 15
GASISEEXP, // 16
MYBOOL, // 17
End
}
public enum SysUnits
{
USUNITS = 0, // 1
IPUNITS, // 2
METRICUNITS, // 3
SIUNITS, // 4
End
}
public enum Line
{
m = 0,
b,
End
}
// y = mx + b conversion format
// since C# does not allow for struct->struct->instance, we will have to create a single array
// first dim => current units, second dim => desired units, third dim m=0, b=1
// so instead of names, we are reduced to numbers
public class UnitConv
{
double[, ,] To = new double[(int)SysUnits.End.GetTypeCode(),
(int)SysUnits.End.GetTypeCode(),
(int)Line.End.GetTypeCode()];
}
UnitConv[] ConvFacts = new UnitConv[(int)UnitDefs.End.GetTypeCode()];
Is this the best way?!
This appears to be runtime based resolution, not compile time resolution.
Is there a compile time (c preprocessor) method.
I can use defines which may perform the same replacement operations.
Any ideas?
-- modified at 12:18 Thursday 11th October, 2007
|
|
|
|
|
HI,
I like to know if there is a warehourse that contains UI controls?
like the popup info from gmail notifayer or a better more advanced toolTip
etc..
if u can point me to a link...
THNKS
kobkob
|
|
|
|
|
There are two of them for free: Code Project and Google. Seriously, if you are looking for a specific type of UI control look for one on either of those two sites and you will probably find what you are looking for. Even if you don't find exactly what you need, you will get something that does almost everything and can then add/fix what it doesn't do.
|
|
|
|
|
Well - if you want to pay out good money, there's always ComponentSource[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
would you please give some suggestions how to make a POS system. please just give me a hint what to do.
|
|
|
|
|
Name your threads something useful Download windows embedded 6.0, select your device type and get the .NET compact framework and go to town.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|