|
If you are interested in finding out how to do flashy effects, you should think about checking out Paint.Net - its an open source alternative to PhotoShop, which as far as I am aware, is programmed with GDI+ and can produce some quite nice stuff!
Chris
|
|
|
|
|
Hi,
Any one have to help me in this regard.. please........... since new to c#.net.
thanks in advance
I have a "logging.exe.config" file in different location,
I have to
1. Load The File,
2. Read The file
3. Modify particular values.
4. Update and Save The file in the same location.
My "Logger.exe.config" looks something like this
i need to set the values like enabled,logging values to true/false,.............
Please anyone help me...............
<?xml version="1.0" encoding="utf-8"?><br />
<configuration><br />
<configSections><br />
<section name="WriterTrace2Config" type="Configuration.ConfigSectionReader, Infrastructure.Logging.Helper" /><br />
<section name="TextReaderLogConfig" type="Configuration.ConfigSectionReader, Infrastructure.Logging.Helper" /><br />
</configSections><br />
--------------<br />
---------------<br />
<Listeners><br />
<ListenerInfo Type="Infrastructure.Logging.WriterTraceListener2,Infrastructure.Logging.Listeners.WriterListener2" Enabled="true" Name="TextLogger2" /><br />
<ListenerInfo Type="Infrastructure.Logging.TextReaderLog,Infrastructure.Logging.Listeners.TextReaderLogListener" Enabled="true" Name="TextReaderLog" /><br />
</Listeners><br />
--------------<br />
---------------<br />
<WriterTraceListener2Config type="Infrastructure.Logging.WriterTraceListener2Config,Infrastructure.Logging.Library.ConfigurationManager" xmlns="http://Infrastructure/Configuration.xsd" Name="WriterLog" Filtering="false"><br />
<Storage Location="C:\Logs\WriterLog" LogFileNamePrefix="TraceLog" Logging="false" SubDirectoryNamePrefix="Writer"><br />
<HeaderText>Logging Service Helper</HeaderText><br />
</Storage><br />
</WriterTraceListener2Config><br />
<TextReaderLogListenerConfig type="Infrastructure.Logging.ListenerConfig.TextReaderLogListenerConfig, Infrastructure.Logging.Listeners.TextReaderLogListener" xmlns="http://Infrastructure/Configuration.xsd" Name="ReaderLog" Filtering="true"><br />
<Storage Location="c:\Logs\TextReaderLog" SubDirectoryNamePrefix="TextReaderLog"><br />
<HeaderText>Logging Service Helper</HeaderText><br />
</Storage><br />
</KTTextRunLogListenerConfig><br />
</configuration>
BhuMan
|
|
|
|
|
Using System.IO;
// Read The File
string thePath = "";//Path to the XML Here
StreamReader sr = new StreamReader(thePath);
string tmp = sr.ReadToEnd();
tmp = tmp.Replace("Original Value", "New Value");
sr.Close();
// Write the file
StreamWriter sw = new StreamWriter(thePath);
sw.WriteLine(tmp);
sw.Flush();
sw.Close():
Hope that helps
|
|
|
|
|
|
hi, i'm posting 'cause i have a problem i can't manage to solve...
i have a page with a row of DropDownLists, and what i want to do is this: when the user selects a value from one of the dropdowns , a new one is created under the selected, with the same values of the previous one, except for the selected one.
i know i have to write a function in c# called from OnSelectedIndexChange, but i can't understand how to create the new ddl from the code..
can anyone one help me or suggest a better way to do that?
thanks anyway, and sorry for the poor english..
bye
Kontax
|
|
|
|
|
DropDownList1_OnSelectedIndexChange
{
DropDownList2.Visible = true;
}
Crude I know, but it works
|
|
|
|
|
thanks anyway, but i think i explaned it in a wrong way...
i dont know previously the number of DDL the user needs, so i cant create them before.
suggestions?
|
|
|
|
|
private System.Windows.Forms.ListBox listBox1;
private void button1_Click(object sender, EventArgs e)
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
this.listBox1.Location = new System.Drawing.Point(0, 0);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(50, 50);
this.listBox1.Items.Add("Testing");
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.l1_SelectedIndexChanged);
this.Controls.Add(listBox1);
this.ResumeLayout();
}
private void l1_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("It Works!");
}
Im not proud of it, but it works...
Might need some heavy modification...
|
|
|
|
|
Thanks for the answer,
it's just some days i'm working with c# so i can't understand what you wrote, anyway thank you another time, i'll try to understand and use it!
byee
|
|
|
|
|
Well, you didn't know how many ddl you will need so you can't create them in design time. What he showed you is that you can dynamically create them once you know that you need a ddl, during the post back.
|
|
|
|
|
hi..
I can't manage to work with that code...
It says that i need the System.Windows.Forms namespace. But if i include it with "using" it doesn't works, cause he can't find the system.windows namespace.
i tried to download System.Windows.Forms.dll and put it in C:\windows\assembly but nothing changed..suggestions?how can i include it?
|
|
|
|
|
hello
in my c# application and when i use the extender desktop, the open dialog box appear in the other screen of my application any idea???
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Hey Guys,
Have a look at this piece of code...
public void checkPollingTimesFromHash()
{
foreach (object TerminalID in pollTimesHash)
{
txtLog.AppendText("****** " + TerminalID + "\r\n");
foreach (object PollTime in TerminalID)
{
txtLog.AppendText(PollTime + "\r\n");
}
}
}
pollTimesHash is a hash table with an object (its a number - terminal id, its of type object cuz i assign these in a foreach obj in arraylist) as its key and an arraylist object in the value. The objects inside the arraylist are of type TimeSpan
in the block above im trying to iterate through each terminals polling times. but my IDE moans "foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'"
any ideas on how i can get my desired result?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Well, the compiler's "moaning" isn't really moaning at all: The foreach statement depends on the implementation of the IEnumerable interface.
Imagine the foreach statement wasn't there in c#, how would you use an ordinary for-loop to iterate through TerminalID to get each member? You'd need to cast it to a type you can actually iterate through first.
The compiler cannot guess the object type for TerminalID: You need to cast it to the type implementing IEnumerable interface (which most collection type classes do).
Standards are great! Everybody should have one!
|
|
|
|
|
yeah i get all that...
just not how to do what im supposed to
how would i go about casing to the type implementing IEnumerable interface?
ive just changed the block to this...
public void checkPollingTimesFromHash()
{
foreach (object TerminalID in pollTimesHash)
{
txtLog.AppendText("****** " + TerminalID + "\r\n");
foreach (object PollTime in pollTimesHash[TerminalID])
{
txtLog.AppendText(PollTime + "\r\n");
}
}
}
it makes more sence to me this way
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
public void checkPollingTimesFromHash()
{
foreach (object TerminalID in pollTimesHash)
{
IEnumerable pollTimes = (IEnumerable)pollTimesHash[TerminalID];
txtLog.AppendText("****** " + TerminalID + "\r\n");
foreach (object PollTime in pollTimes )
{
txtLog.AppendText(PollTime + "\r\n");
}
}
}
|
|
|
|
|
thanx
i get a nullReferenceExeption tho...pollTimes = null
any idea why? pollTimesHash defenitly has values in it
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Im pretty sure the problem here is in the way you're enumerating the hashtable.
<br />
foreach(object o in myHashTable)
In this case, the object "o" is a DictionaryEntry , not the Key nor the value from the hashtable.
Change this to:
foreach(DictionaryEntry de in myHashTable)
and you'll get intellisense help on "de" - where you'll see it has a property Key and a property Value .
Now, go from there... cast the Value to an IEnumerable (or better still, if you know what type of object is stored in the value cast it to that).
|
|
|
|
|
sweet
ok now i have this...
public void checkPollingTimesFromHash()
{
foreach (DictionaryEntry de in pollTimesHash)
{
int terminalID = Int32.Parse(de.Key.ToString());
txtLog.AppendText("****** " + terminalID.ToString() + "\r\n");
ArrayList pollTimes = (ArrayList)pollTimesHash[terminalID];
foreach (object obj in pollTimes)
{
txtLog.AppendText(obj.ToString() + "\r\n");
}
}
}
but im still getting nullReference on pollTimes.
while debugging i can see terminalID = 1, and pollTimesHash Count = 2. So there definitely is data in there
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Hashtable pollTimesHash = new Hashtable();
Random rand = new Random();
int hashCount = rand.Next(10, 20);
for (int i = 0; i < hashCount; i++)
{
ArrayList al = new ArrayList();
int alCount = rand.Next(10,20);
for(int j = 0; j<alCount; j++)
{
al.Add(new TimeSpan(rand.Next()));
}
pollTimesHash.Add(i, al);
}
StringBuilder sb = new StringBuilder();
foreach (DictionaryEntry item in pollTimesHash)
{
sb.AppendLine(string.Format("{0} ({1} count)", item.Key.ToString(), ((ArrayList)item.Value).Count.ToString()));
foreach (TimeSpan pollTime in (ArrayList)item.Value)
{
sb.AppendLine(pollTime.ToString());
}
}
Console.Write(sb.ToString());
|
|
|
|
|
Hello your code is wrong you need solution add me hussaingreat2@hotmail.com
i am certified in C# programming ok Br
but i need some 10g codes because i want to break linux server i have full linux source code
Hussaingreat
|
|
|
|
|
Bekjong wrote: The foreach statement depends on the implementation of the IEnumerable interface.
Almost. It actualy depends on GetEnumerator method, but enumerated object doesnt neccessary need to implement IEnumerable. See here[^]
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thanks for the info, I didn't realize ducktyping is used to determine GetEnumerator is present. Doesn't sound logical to me, since this would almost certainly mean reflection is involved, which smells like a performance penalty to me...
Standards are great! Everybody should have one!
|
|
|
|
|
Reflection? Nah. I've copied code from that blog and compiled it, and looked on result in Reflector:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 1
.locals init (
[0] class ForeachTest.Foo f,
[1] object o,
[2] valuetype ForeachTest.Foo/Bar CS$5$0000,
[3] bool CS$4$0001)
L_0000: nop
L_0001: newobj instance void ForeachTest.Foo::.ctor()
L_0006: stloc.0
L_0007: nop
L_0008: ldloc.0
L_0009: callvirt instance valuetype ForeachTest.Foo/Bar ForeachTest.Foo::GetEnumerator()
L_000e: stloc.2
L_000f: br.s L_0026
L_0011: ldloca.s CS$5$0000
L_0013: call instance object ForeachTest.Foo/Bar::get_Current()
L_0018: stloc.1
L_0019: nop
L_001a: ldstr "Hi!"
L_001f: call void [mscorlib]System.Console::WriteLine(string)
L_0024: nop
L_0025: nop
L_0026: ldloca.s CS$5$0000
L_0028: call instance bool ForeachTest.Foo/Bar::MoveNext()
L_002d: stloc.3
L_002e: ldloc.3
L_002f: brtrue.s L_0011
L_0031: ret
}
There is no reflection, all compile time. Lets say I comment out MoveNext or Current property, and compiler will complain:
"Error 2 foreach requires that the return type 'ForeachTest.Foo.Bar' of 'ForeachTest.Foo.GetEnumerator()' must have a suitable public MoveNext method and public Current property"
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
thanx for the help guys...
i came up with this in the end
public void checkPollingTimesFromHash()
{
foreach (DictionaryEntry de in pollTimesHash)
{
int terminalID = Int32.Parse(de.Key.ToString());
txtLog.AppendText("****** " + terminalID.ToString() + "\r\n");
foreach (TimeSpan ts in (ArrayList)de.Value)
{
txtLog.AppendText(ts.ToString() + "\r\n");
}
}
}
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|