|
Install DirectX SDK from Microsoft. Add the needed reference to your project. Then add namespace you need to compile it. If you are using VS2005, then just mouse over unknown class, then click at the small box "using DirectX.xxx.xxx.xxx", then namespace will be added automatically.
|
|
|
|
|
I have never worked with DirectX but just to be sure for others: When you say you installed DirectX, what is it that you installed exactly? The runtime or the SDK? If you didn't install the SDK, there is no chance that any DirectX project will work (I think!)
-- 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
|
|
|
|
|
Hi,
I'm experimenting on UPnP in Windows Vista Ultimate with Media Center. I've set up a few UPnP AV media servers and could connect to the data from Windows Media Player. But in Media Center I could only browse local files and no files from other UPnP servers.
That's why I'd try to write a C# UPnP client, that uses ALL available AV servers and not only the local storage in Vista MCE.
I've found out there are Intel tools für UPnP, but they are written in C. There is also UPnP support in Platform SDK CE, but I'm using UPnP on a standard PC.
I did not find any UPnP clients in C# here on codeproject. Maybe I've overlooked one in the results or someone of you knows some good external links on how to build a UPnP client in C# (without manually writing the protocol).
Thanks in advance,
Norbert
|
|
|
|
|
The Intel tools have C# stuff too the last time I looked. I didnt work on my router though, so I had to write on myself.
|
|
|
|
|
Alternatively you can import the UPnP COM library in Windows, and use that.
|
|
|
|
|
Hello everyone,
I am wondering if I am using TCPClient class in C#, how to setup timeout value? Timeout I mean, when connects to server for the 1st time, and during <timeout> interval, if no server response is received, the GetStream method will return will return other than wait forever.
thanks in advance,
George
|
|
|
|
|
Hey Guys, whats going on ? I want to check the the way I connect to sql and see if there's a more professional way, so please bare me !!! thanx
First I declare my SqlConnection, SqlDataAdapter and DataSet
SqlConnection InstConn = new SqlConnection();<br />
SqlDataAdapter InstDA = new SqlDataAdapter();<br />
DataSet DS = new DataSet();
then i create my Command text (Select, delete or update)
SqlCommand ChkCmd = new SqlCommand();
for selection then I fill my data set
InstDA .Fill(DS , "Table Name");
and if its Insert Delete or edit I use
ChkCmd .ExecuteNonQuery();
Not to mention that for edit I use SqlParameter.
so what do you think ? Is there a better way for doing this ?
and I also have another question, how can I prevent users from manipulating my database by entering some SQL command in a text box ! I know in ASP.net It authomatically prevent this, is this the same in C# Win or we have to manually do the same thing ?
Thanx
Mr.K
|
|
|
|
|
|
Does anyone know how i can vertical align the lines in a richtesxtbox? pls help
|
|
|
|
|
I am trying to draw a rubberband rectangle using one of the methods suggested in this forum. My problem is: after drawing the rectangle, if I move another window (for example a messagebox) over the rectangle (ruberband rectangle drawn earlier) part of this rectangle is not getting pained properly. Any help is highly appreciated.
The code that I am using is given below.
<br />
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.Drawing;<br />
<br />
namespace RubberbandShape<br />
{<br />
class MainForm : System.Windows.Forms.Form<br />
{<br />
public MainForm()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
void InitializeComponent() {<br />
this.button1 = new System.Windows.Forms.Button();<br />
this.SuspendLayout();<br />
this.button1.Location = new System.Drawing.Point(323, 256);<br />
this.button1.Name = "button1";<br />
this.button1.Size = new System.Drawing.Size(75, 23);<br />
this.button1.TabIndex = 0;<br />
this.button1.Text = "button1";<br />
this.button1.UseVisualStyleBackColor = true;<br />
this.button1.Click += new System.EventHandler(this.button1_Click);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(401, 282);<br />
this.Controls.Add(this.button1);<br />
this.Name = "MainForm";<br />
this.Text = "Rubber Band Shape Drawing";<br />
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainForm_Paint);<br />
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseUp);<br />
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseMove);<br />
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainForm_MouseDown);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
<br />
[STAThread]<br />
public static void Main(string[] args)<br />
{<br />
Application.Run(new MainForm());<br />
}<br />
<br />
private bool mouseDown = false;<br />
private bool mouseMoving = false;<br />
private bool haveRect = false;<br />
private int XDown;<br />
private int YDown;<br />
private int oldX;<br />
private Button button1;<br />
private int oldY;<br />
<br />
void MainForm_MouseDown(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
mouseDown = true;<br />
XDown = e.X;<br />
YDown = e.Y;<br />
mouseMoving = false;<br />
}<br />
else if( e.Button == MouseButtons.Right )<br />
{<br />
if( haveRect )<br />
{<br />
haveRect = false;
Invalidate();
}<br />
}<br />
}<br />
<br />
void MainForm_MouseMove(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( mouseDown )<br />
{<br />
if( mouseMoving )<br />
RubberRectangle( XDown, YDown, oldX, oldY );<br />
RubberRectangle( XDown, YDown, e.X, e.Y );<br />
mouseMoving = true;<br />
oldX = e.X;<br />
oldY = e.Y;<br />
}<br />
}<br />
<br />
void MainForm_MouseUp(object sender,<br />
System.Windows.Forms.MouseEventArgs e)<br />
{<br />
mouseDown = false;<br />
mouseMoving = false;<br />
haveRect = true;<br />
}<br />
<br />
private void RubberRectangle( int X1, int Y1, int X2, int Y2 )<br />
{<br />
System.Drawing.Graphics g = Graphics.FromHwnd( this.Handle );<br />
<br />
RubberbandRectangle rect<br />
= new RubberbandRectangle();<br />
rect.DrawXORRectangle( g, X1, Y1, X2, Y2 );<br />
}<br />
<br />
void MainForm_Paint(object sender,<br />
System.Windows.Forms.PaintEventArgs e)<br />
{ <br />
Graphics g = Graphics.FromHwnd( this.Handle );<br />
<br />
if( haveRect )<br />
RubberRectangle( XDown, YDown, oldX, oldY );<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
MessageBox.Show("err yty");<br />
}<br />
<br />
} <br />
<br />
public enum PenStyles<br />
{<br />
PS_SOLID = 0,<br />
PS_DASH = 1,<br />
PS_DOT = 2,<br />
PS_DASHDOT = 3,<br />
PS_DASHDOTDOT = 4<br />
}<br />
public class RubberbandRectangle<br />
{<br />
private int NULL_BRUSH = 5;<br />
private int R2_XORPEN = 7;<br />
private PenStyles penStyle;<br />
private int BLACK_PEN = 0;<br />
<br />
public RubberbandRectangle()<br />
{<br />
penStyle = PenStyles.PS_DOT;<br />
}<br />
<br />
public PenStyles PenStyle<br />
{<br />
get { return penStyle; }<br />
set { penStyle = value; }<br />
}<br />
<br />
public void DrawXORRectangle(Graphics grp,<br />
int X1, int Y1, int X2, int Y2)<br />
{<br />
IntPtr hdc = grp.GetHdc();<br />
<br />
IntPtr gdiPen = CreatePen(penStyle,<br />
1, BLACK_PEN);<br />
<br />
SetROP2(hdc, R2_XORPEN);<br />
<br />
IntPtr oldPen = SelectObject(hdc, gdiPen);<br />
<br />
IntPtr oldBrush = SelectObject(hdc,<br />
GetStockObject(NULL_BRUSH));<br />
<br />
Rectangle(hdc, X1, Y1, X2, Y2);<br />
<br />
SelectObject(hdc, oldBrush);
SelectObject(hdc, oldPen);<br />
DeleteObject(gdiPen);
<br />
grp.ReleaseHdc(hdc);<br />
}<br />
<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern int SetROP2(<br />
IntPtr hdc,
int enDrawMode
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr CreatePen(<br />
PenStyles enPenStyle,
int nWidth,
int crColor
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern bool DeleteObject(<br />
IntPtr hObject
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr SelectObject(<br />
IntPtr hdc,
IntPtr hObject
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern void Rectangle(<br />
IntPtr hdc,
int X1,
int Y1,
int X2,
int Y2
);<br />
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr GetStockObject(<br />
int brStyle
);<br />
<br />
private static int RGB(int R, int G, int B)<br />
{<br />
return (R | (G << 8) | (B << 16));<br />
}<br />
}<br />
}<br />
<br />
Cheers,
Prasad
|
|
|
|
|
Don't paste your whole code. I don't think it will be read. Try to find out which part of it generates that problem and then ask for help in regards with that specific problem giving as an example your code fragment.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
u must clear de background in the graphic object
void MainForm_Paint(object sender,<br />
System.Windows.Forms.PaintEventArgs e)<br />
{<br />
Graphics g = Graphics.FromHwnd(this.Handle);<br />
<br />
if (haveRect)<br />
{<br />
g.Clear(BackColor);<br />
RubberRectangle(XDown, YDown, oldX, oldY);<br />
}<br />
}
|
|
|
|
|
Cuciu,
Thanks for the suggestion. My problem is partially solved. Still the following problem persists. If I colse the messagebox, while it is on the rubber recatngle, that part is not redrawn.
Further, the suggested method doesn't work if I use "e.Graphics.Clear(BackColor)".
Could you please explain why?
My main problem is the Following:
<br />
private void FormMap_Paint(object Sender, PaintEventArgs e)<br />
{<br />
e.Graphics.Clear(this.BackColor);<br />
e.Graphics.DrawImage(Map.BMP, 0, 0);<br />
DrawFenceline();<br />
HiliteOn();<br />
}<br />
my Map object is stored on a bitmap. In form paint event I am drawing bitmap on to form. Then a fenceline is drawn (a region of rubberband lines) which is used to select a group of objects.
However, when I display a message box (or other form) on this form I am having problems with rubberband lines as explained earlier.
Any help to overcome this problem?
Regards,
Prasad
|
|
|
|
|
When you show your messagebox, call Invalidate() afterwards to force a paint event, which will draw your image again
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 know that GDI+ doesn't offer XOR drawing, but this still looks far too messy to me. What's wrong with just drawing a black ( or white, or whatever ), box in your paint event ?
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 )
|
|
|
|
|
Hi
I have an Excel sheet, has 4 columns. In the first column there is an industry code, which contains both numeric and alphanumeric chararcters. I'm not able to read the values to the dataset if the value is alphabets. For eg. if the value is 1,2,3,4 etc.. it will read. But if the value is 1a, 2b, 3e, 4d etc. then it will read as null. Anybody has any solution for these? Any help would be great. I'll post my code below:
OleDbCommand MyCommand;
OleDbConnection MyConnection;
MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=C:\\Projects\\LiquidCreditChains\\CreditCurveMapping.xls;Extended Properties=Excel 8.0;");
if (MyConnection.State != ConnectionState.Closed)
MyConnection.Close();
else
MyConnection.Open();
DataTable dtSector = new DataTable("SectorChains");
objds.Tables.Add(dtSector);
DataColumn dc1 = new DataColumn("Indust_Code");
dc1.DataType = System.Type.GetType("System.String");
dtSector.Columns.Add(dc1);
DataColumn dc2 = new DataColumn("Indust_Number");
dc2.DataType = System.Type.GetType("System.Int64");
dtSector.Columns.Add(dc2);
DataColumn dc3 = new DataColumn("MappingDescription");
dc3.DataType = System.Type.GetType("System.String");
dtSector.Columns.Add(dc3);
DataColumn dc4 = new DataColumn("SubDescription");
dc4.DataType = System.Type.GetType("System.String");
dtSector.Columns.Add(dc4);
DataColumn dc5 = new DataColumn("Mapping_Curve");
dc5.DataType = System.Type.GetType("System.String");
dtSector.Columns.Add(dc5);
MyCommand = new OleDbCommand("select * from [Sheet1$]", MyConnection);
OleDbDataReader dr1 = MyCommand.ExecuteReader();
while (dr1.Read())
{
DataRow newChainRow = objds.Tables[0].NewRow();
newChainRow["Indust_Code"] = dr1[0].ToString();
newChainRow["Indust_Number"]=dr1[1].ToString();
newChainRow["MappingDescription"] = dr1[2].ToString();
newChainRow["SubDescription"]= dr1[3].ToString();
newChainRow["Mapping_Curve"] = dr1[4].ToString();
objds.Tables[0].Rows.Add(newChainRow);
}
Any help in this regard would be great!!
Thanks
Meeram395
|
|
|
|
|
|
|
Hi to everybody
I have DB as dat file.I've paging concept works fine.Problem is when i delete or edit or add records, it is showing the first page on data grid( if i have 50 records-per page 20).I need if the record no 45 is updated OR deleted it has to show the current page i.e., 3rd page.I have not used connection string.Plz help me thanks in advance.
|
|
|
|
|
Hi,
As per my understanding after every edit or add you must be binding your grid somewhere and i think you are not setting its current page index...
Hope it will work...
Thanks
~Anuj~
|
|
|
|
|
i have not used connection string.I've used .dat file as DB, READING AND WRITING DATAS IN TMP TABLE.If anyone has code sample it will be more helpful.Thanks in advance.
|
|
|
|
|
Hi,
I am creating a windows application,that contains a folder,with 5 files. how to programaticlly get the names of all the files in that folder(getting names of all the contents of that folder)
Say folder name is "MyXMLFolder" .It contains elemnts as
-Customer.xml
-Employee.Xml
-Bank.xml
I want c# coding to get all the names of the files in "MyXMLFolder" folder
-- modified at 2:13 Monday 13th August, 2007
|
|
|
|
|
DirectoryInfo dir = new DirectoryInfo(@"F:\MyFolder");<br />
FileInfo[] files = dir.GetFiles("*.*");<br />
<br />
Foreach(FileInfo f in files )<br />
{<br />
Console.WriteLine("Name is : {0}", f.Name);<br />
Console.WriteLine("Length of the file is : {0}", f.Length);<br />
Console.WriteLine("Creation time is : {0}", f.CreationTime);<br />
Console.WriteLine("Attributes of the file are : {0}",<br />
f.Attributes.ToString());<br />
}
Ref:
Working with Files in C#[^]
File Information using C#[^]
Hope it helps.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Thank you, for detailed description,
working
|
|
|
|
|
Hi,
You need to use the System.IO namespace. The following code will get you all files in a folder as strings in a string array, including the folder path:
string[] files = Directory.GetFiles(@"c:\MyXMLFolder");
Everything you will need to work with files can be found in System.IO.
Regards,
Toby
|
|
|
|
|