|
|
Forgot the second one.
In the context you have presented this[] creates an indexer method for the class.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
It's a conditional value. If the value in front of the question mark is true, the first value is used, otherwise the second. It has the same effect as:
public int GetBufferedSize()
{
if (m_Player != null) {
return m_Player.GetBufferedSize();
} else {
return 0;
}
}
redfish34 wrote: What is with the 'this'?
That is the way you declare an indexer for the class.
---
b { font-weight: normal; }
|
|
|
|
|
|
I've found several articles on comparing two bitmaps to see if they are the same, however, they address two images that are the same size. What if I have two images of different sizes and I want to determine if the smaller image resides somewhere within the larger one. This seems like an easy task, but I'm not having any success as of yet.
Any help would be appreciated.
Thanks.
|
|
|
|
|
I've been reading through the projects here on codeproject, but i still don't fully grasp all of this.
I'm writing a simple class that I can use manage application settings in my forms. Note, it is not meant to handle nested elements. There will be one root element "<configuration>" and inside that will be the settings as key/value pairs.
Here's what I've got so far:
class Config
{
private string m_Path;
private string m_Err;
private XmlDocument xmlDoc;
private XmlNode xmlNode;
// The Config constructor - supply the path name to the file, load the document
public Config(string Path)
{
m_Path = Path;
Load();
}
// Load the stored settings into the XmlDocument
public bool Load()
{
try
{
XmlTextReader xtr = new XmlTextReader(m_Path);
}
catch (Exception ex)
{
m_Err = ex.ToString();
return false;
}
try
{
xmlDoc = new XmlDocument();
xmlDoc.Load(xtr);
}
catch (Exception ex)
{
m_Err = ex.ToString();
return false;
}
return true;
}
// Attempt to return the value, given the key name
public string GetValue(string key)
{
// ITERATE THROUGH KEYS, IF FOUND, RETURN THE VALUE, OTHERWISE, return "NULL";
return "NULL";
}
// Attempt to set the value of the given key. If it does not exist, create a new key/value
// Upon creation or modification of the XmlDocument, write the document to the configuration file
public bool SetValue(string key, string value)
{
// ITERATE THROUGH THE VALUES, FIND THE CORRECT NODE
// IF NODE IS FOUND, MODIFY THE VALUE
// IF NODE IS NOT FOUND, CREATE THE NEW VALUE
return true;
}
// Return an arraylist containing all key/value pairs as such: "key:value"
public ArrayList GetAllValues()
{
ArrayList aryList = new ArrayList();
// Finish Me!
// foreach(key k in XmlDocument)
// aryList.Add((string)(key) + (string)(value));
return aryList;
}
public bool WriteFile()
{
try
{
XmlTextWriter xmw = new XmlTextWriter(m_Path);
// WRITE xmlDoc using xmw to m_Path
}
catch(Exception ex)
{
m_Err = ex.ToString();
return false;
}
return true;
}
}
As you can see, the things I don't know how to do are written as comments describing what needs to happen at that particular segement. If somoene can help me out with this, I'd be greatly appreciative. I've been pouring over my C# manuals and the projects online for about 8 hours or so, trying to find a straight forward way to do this, but haven't figured it out yet.
As always, thanks much.
|
|
|
|
|
budidharma wrote: public string GetValue(string key)
{
// ITERATE THROUGH KEYS, IF FOUND, RETURN THE VALUE, OTHERWISE, return "NULL";
return "NULL";
}
You can use the SelectNodes[^] or the SelectSingleNode[^] method on XmlDocument to do that. Give it an XPath expression and it will return you the appropriate nodes. In your case, it will probably look like
xmlDoc.SelectNodes("//nodeName[@key='keyValue'");
assuming the key value pairs are of the form <nodeName key="KeyValue value="Value>
budidharma wrote: public bool SetValue(string key, string value)
{
// ITERATE THROUGH THE VALUES, FIND THE CORRECT NODE
// IF NODE IS FOUND, MODIFY THE VALUE
// IF NODE IS NOT FOUND, CREATE THE NEW VALUE
return true;
}
To modify an existing node, get a reference to it using the above method. Then use the Attributes property and the indexer to get a reference to the attribute and then just set the Value[^] property to the desired value.
You can use the CreateNode[^] method to create a new node.
budidharma wrote: public ArrayList GetAllValues()
{
You can again use SelectNodes, or you can just do a foreach over XmlDocument.DocumentElement.ChildNodes, if it's always going to be the key-value pairs directly under the root.
budidharma wrote: // WRITE xmlDoc using xmw to m_Path
Use the WriteTo[^] method.
I guess you didn't look hard enough, all the details are available in MSDN
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I would like to know how create a button that can scroll the content of a tabpage.
Thank you for your help
To be
|
|
|
|
|
Here we go. In your Form , you have the following somewhere:
private TabControl myTabControl;
private Button scrollLeftButton;
myTabControl.TabPages.Add( new TabPage( "A Tab Page" ) );
myTabControl.TabPages[ 0 ].AutoScroll = true;
scrollLeftButton = new Button();
scrollLeftButton.Text = "Scroll Left";
scrollLeftButton.Click += new System.EventHandler( scrollLeftButton_Click );
private void scrollLeftButton_Click(object sender, System.EventArgs e)
{
myTabControl.TabPages[ 0 ].AutoScrollPosition =
new System.Drawing.Point( 10 - myTabControl.TabPages[ 0 ].AutoScrollPosition.X,
mtc.TabPages[ 3 ].AutoScrollPosition.Y );
} And, that should do it. Just make other buttons to adjust up, down, and right scrolling.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello gurus,
I would like to know what is the C# equivalent of the LOBYTE and HIBYTE Win32 macros?
I wish to get the low byte and high byte from a C# ushort . How can I do that?
Thanks for your help.
Best regards.
There is no spoon.
|
|
|
|
|
Well the C++ macros are defined as follows:
<br />
#define MAKEWORD(a, b) ((WORD)(((BYTE)((DWORD_PTR)(a) & 0xff)) | ((WORD)((BYTE)((DWORD_PTR)(b) & 0xff))) << 8))<br />
#define MAKELONG(a, b) ((LONG)(((WORD)((DWORD_PTR)(a) & 0xffff)) | ((DWORD)((WORD)((DWORD_PTR)(b) & 0xffff))) << 16))<br />
#define LOWORD(l) ((WORD)((DWORD_PTR)(l) & 0xffff))<br />
#define HIWORD(l) ((WORD)((DWORD_PTR)(l) >> 16))<br />
#define LOBYTE(w) ((BYTE)((DWORD_PTR)(w) & 0xff))<br />
#define HIBYTE(w) ((BYTE)((DWORD_PTR)(w) >> 8))<br />
Looks ugly and complex but its not as hard as it looks. Most of the casting can be removed actually. C++ macros don't have parameter types so their casting to ensure all the integers are the correct size before performing the math on them.
I used the UInt32, UInt16 and Byte types to be explicit.
So I created the C# equivalent:
<br />
class ByteAccess<br />
{<br />
public static UInt32 MakeLong(UInt16 high, UInt16 low)<br />
{<br />
return ((UInt32)low & 0xFFFF) | (((UInt32)high & 0xFFFF) << 16);<br />
}<br />
public static UInt16 MakeWord(byte high, byte low)<br />
{<br />
return (UInt16)(((UInt32)low & 0xFF) | ((UInt32)high & 0xFF) << 8);<br />
}<br />
public static UInt16 LoWord(UInt32 nValue)<br />
{<br />
return (UInt16)(nValue & 0xFFFF);<br />
}<br />
public static UInt16 HiWord(UInt32 nValue)<br />
{<br />
return (UInt16)(nValue >> 16);<br />
}<br />
public static Byte LoByte(UInt16 nValue)<br />
{<br />
return (Byte)(nValue & 0xFF);<br />
}<br />
public static Byte HiByte(UInt16 nValue)<br />
{<br />
return (Byte)(nValue >> 8);<br />
}<br />
}<br />
Enjoy.
David
|
|
|
|
|
I got a question regarding Table Class and how to programmatically add a table.
First of all i build my Dynamic table in Page_Load() event in the Code Behind C# class as:
private void Page_Load(object sender, System.EventArgs e)
{
// Generate rows and cells.
Table Table1 = new Table();
int numrows = 3;
int numcells = 2;
for (int j=0; j<numrows; j++)=""
="" {="" tablerow="" r="new" tablerow();
="" for="" (int="" i="0;" i<numcells;="" i++)="" {
="" tablecell="" c="new" tablecell();
="" c.controls.add(new="" literalcontrol("row="" "="" +="" j.tostring()="" ",="" cell="" i.tostring()));
="" r.cells.add(c);
="" }
="" table1.rows.add(r);
="" }
="" }
next="" added="" the="" following="" line="" to="" html="" code:
<asp:table="" id="Table1" style="Z-INDEX: 106; LEFT: 50px; POSITION: absolute; TOP: 80px" runat="server"
font-size="X-Small" font-names="Century Gothic" font-bold="True" forecolor="Red">
When i run tha application, it doesn't give me any errors but it still don't show the generated table either?
What Am I doing Wrong???
|
|
|
|
|
|
tat's must it!!!!
i didn't
|
|
|
|
|
hi,
I want to create a tab control in my application using with xml.
each tab links to separate pages.
give me one example
baski
|
|
|
|
|
Then add a TabControl to your form.
Other than that, you haven't given near enough detail in your question to help you with anything else.
What does XML have to do with a TabControl?
What do you mean by "each tab links to seperate pages"? This is the normal functionality for a TabControl.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello,
Once you go through this site
http://timothyhumphrey.name/thwc/mainmenu/stabs.aspx
this site having 4 tabs in a page like File, Edit, View etc.
if u click on any tab without postback its opened, i want also like this.
The tab pages are implemented as div elements with their display style property set to none; except for the first page.
what i am expecting is, For Example, one parent window like home.aspx, in this form we display the tab control like File, Edit, View... If i Click the File Tab, open the File.aspx page insides the Home.aspx parent window.
If i click the Edit tab open the Edit.aspx page insides the Home.aspx parent window like this....
baski
|
|
|
|
|
You didn't mention you wanted to do this in a web page.
This is done using style sheets and JavaScript. All you have to do is view the page source (under the browsers View menu), an examine the code to find out how it's done. This is done entirely in client-side code.
There's nothing in C# and ASP.NET that will allow you to do this without a postback. ASP.NET is a server-side ONLY technology that generates HTML for the browser, with a little JavaScript to handle posting back to the server.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi All.
In my application i have allot of Button.
Some of my button are invisible and the user cant click on them.
I check some key in the registry and turn on\off the not relevant keys.
But i have some problem....i don't want to create all the button and then run in the code on the button and turn off the not relevant button...i want to create them in run time.
The only thnk that i will know about the button is the string that will be writing on them.
The problem that i have is :
How can i catch the event of click button in run time in this case (the button are not exist in compile) ?
Thanks for any help.
-- modified at 6:46 Saturday 3rd December, 2005
|
|
|
|
|
Just add the following code into the block where u r creating the buttons dynamically:
this.ButtonName.Click += new System.EventHandler(this.ButtonName_Click);
After that u can define the function:
ButtonName_Click(object sender,EventArgs e)
Sandeep
+919891027854
|
|
|
|
|
i want to know the path where this .exe located.
ofcourse most of user set path c:/program file and the software's folder.
but if it is else where then what ?
so i want to know location of exe and then start that exe using Process.strat.
Thanks
Prakash Paghdal (prakash_paghdal@hotmail.com)
|
|
|
|
|
Hi Prakash,
If I got it right ,then you are probably talking about the path set by the user for installing a software in this case your .exe.you will get the location of all the assemblies being installed by the program under the HKLM\SOFTWARE\Classes\Installer\Assemblies registry key.Iterate through all the keys and check whether the name of any subkey ends with "app.exe" where app.exe is the name of your .exe file.The seperator used in the name will be "|" .so don't forget to replace it with "\".Hope it Helps.
Rakesh
|
|
|
|
|
I have one thing to say:
System.Windows.Forms.Application.ExecutablePath
|
|
|
|
|
You can also use System.Reflection.Assembly.GetExecutingAssembly().Location or GetName().CodeBase
|
|
|
|
|
How I can implement the username password form in windows forms application in C#......
Thanks,
Sandeep
+919891027854
|
|
|
|