|
I'm facing the same problem. I somehow managed to get it selected in the similar way and opened the contextmenu like
TreeViewItem.ContextMenu.IsOpen=true;
but the problem that occurred was, the commands bindings to the menu items(in xaml) don't work.
|
|
|
|
|
hi,
I want to serialize a class which has the two kinds of elements. Custom elements (non graphic and made by me, which are serializable by the XmlSerializer), and UI Elements from the WPF. The class which i want to serialize is this:
Code Snippet
public class Region : ISerializable
{
private Control _control;
public Control Control
{
get { return _control; }
set { _control = value; }
}
private Border _bounds;
public Border Bounds
{
get { return _bounds; }
set { _bounds = value; }
}
public Region()
{
}
///
/// Initializes a new instance of the class.
///
public Region(Border bounds)
{
_bounds = bounds;
}
public Region(SerializationInfo info, StreamingContext ctxt)
{
this._control = (Control)info.GetValue("Control", typeof(Control));
this._bounds = (Border)XamlReader.Load(new XmlTextReader(new StringReader((string)info.GetValue("Bounds", typeof(string)))));
}
public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
{
info.AddValue("Control", this._control);
info.AddValue("Bounds", XamlWriter.Save(_bounds));
}
}
As you can see, this class is composed by a Control (custom made class specified by me) and a Border (UI Element). The class was serializable if i didnt have the border on it.
My attempt was to override the Iserialize methods in order to have serialization of the border based on XamlWriter.Save but it gives me error before getting there, in the following line:
Code Snippet
System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(Region));
With the message:
Code Snippet
"There was an error reflecting property 'Bounds'."
How can i solve this problem?
Thx,
Nuno
|
|
|
|
|
Dictionary<string, listviewitem=""> list = new Dictionary<string, listviewitem="">();
String nameAndJob, Job, line, name;
Int32 pages;
ListViewItem item1;
foreach (ListViewItem lvi in listView2.Items)
{
nameAndJob = string.Concat(lvi.SubItems[0].Text);
if (!list.ContainsKey(nameAndJob)) list.Add(nameAndJob, lvi);
Job = string.Concat(lvi.SubItems[1].Text);
if (!list.ContainsKey(Job)) list.Add(Job, lvi);
}
using (StreamReader sr = new StreamReader(path1 + "/personalpr.txt"))
{
while (sr.Peek() > 0)
{
line = sr.ReadLine();
if (line == "#")
{
name = sr.ReadLine();
nameAndJob = string.Concat(name);
Job = string.Concat(name);
if (list.ContainsKey(nameAndJob))
{
item1 = list[nameAndJob];
item1 = list[Job];
item1.SubItems[1].Text = sr.ReadLine();
item1.SubItems[3].Text = sr.ReadLine();
item1.SubItems[5].Text = sr.ReadLine();
}
int result = 0;
foreach (ListViewItem lvi in listView2.Items)
{
result += int.Parse(lvi.SubItems[2].ToString()) - int.Parse(lvi.SubItems[3].ToString()); ????????????????????
////I want to calculate lvi.subitems[2] - lvi.subitems[3] and pass the result to subitems[3].
}
item1.SubItems[3] = result.ToString();???????
}
}
}
}
Can i delete this readline from .txt file after this use??? and how??
Thanks all!! ;)
|
|
|
|
|
As you are reading the input file, you should generate a corresponding output file. Copy only the data you want to keep from the input file to the output file. When you have finished reading the input file, overwrite it with the output file.
aul
|
|
|
|
|
Any idea how to encode Arabic letters after retrieving them from a database?? I'm using Oracle8i and I made sure they're stored correctly and can view them correctly from sql*plus but not from a windows form.
Please help
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello Muammar,
Have you set a correct Unicode Font to the Control which should show the text?
All the best,
Martin
|
|
|
|
|
Thanks Martin , I should try that
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi Everyone,
I want to create something similar to www.20q.net but for business application. I know it uses a neural net (for which I have already created a library). But a neural net alone is not enough.
Can someone point out to me how I could design this 20 questions app and what algorithm/data structures I should use?
Any help would be appreciated!
Regards,
Andre
|
|
|
|
|
Hi,
Use Frameset and frame HTML tags.
For further clarification can mail me suveen.kulshreshtha@gmail.com or
mayur.mehta@indiatimes.com
|
|
|
|
|
Hi Suveen,
Thanks for the reply but I think you are misunderstanding.
My problem is not physical implementation or or even close to presentation layer. What I want to know is what logical design should I follow and how do I translate the problem space domain into a model.
In other words, how do I use a genetic algorithm and a neural network to teach my app.
Regards,
Andre
|
|
|
|
|
Does anyone know if the filename can be set programatically and the 'Save as' dialog-box suppressed when i want to print something with "Microsoft image printer"?
P.S. I am working on a Cristal Report project and i am using PrintToPrinter() function.
Thank you very much!
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
{
button2.Enabled = false;
Thread.Sleep(2000);
button2.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Button 2");
}
in the above code, when i click the button2 while the sleep i on, after the sleep is over, i get the message box in the button2 click event.
what is the function of setting enable = false then?
how to prevent this?
thanks
|
|
|
|
|
You are putting the current Thread in sleep stage so,
Your button2 is disabled but when you click on it,
The event is not fired. because the thread is sleep and it will not accept the click event it actually Fire the event when the thread is in running mode again so at that time the button2 is enabled.
if you are still confused then reply this message
Best Regards,
Chetan Patel
|
|
|
|
|
i dont want to fire the button2 click even when it is disabled. how do i do it?
|
|
|
|
|
Hello,
You have to set the "Enabled" property before the user clicks the button.
If you want to make a validation on the/an event itselfe,
I would suggest inherit your own Button from System.Windows.Forms.Button.
Use a validation method which uses Flags or some other stuff.
Override OnMouseDown, which checks the validation method and calls the base method or not!
Not calling the base method of OnMouseDown, will prevent the click event from fireing!
See this code example:
public class SpecialButton : System.Windows.Forms.Button
{
public SpecialButton()
{
}
private bool flag1 = true;
public bool Flag1
{
get
{
return flag1;
}
set
{
if(value!=flag1)
flag1 = value;
}
}
private bool flag2 = true;
public bool Flag2
{
get
{
return flag2;
}
set
{
if(value!=flag2)
flag2 = value;
}
}
private bool ValidateClick()
{
return Flag1&&Flag2;
}
protected override void OnMouseDown(MouseEventArgs e)
{
if(ValidateClick())
{
base.OnMouseDown (e);
}
else
{
}
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
the way you do it, button2 is not disabled at all, since the 2-second period it is disabled
you also "stop the world" by holding off the GUI thread.
don't put Thread.Sleep() in an event handler, it stops the GUI, which you never want to
happen. Instead, disable button2 and organize something to re-enable the button later.
For instance launch a Windows.Forms.Timer; when that timer expires, re-enable button2.
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
|
|
|
|
|
hi
i was created a pdf help for my application and now want to by click a button show pdf file.
how can show a pdf file in C#?
tanks
|
|
|
|
|
Create Process and start the process by giving obsolute path of PDF file.
Process.Start ("x:\\sample.pdf");
Thanks
|
|
|
|
|
With the proper mention that you must have a PDF reader installed on your machine and it must be registered with the "pdf" extension.
|
|
|
|
|
Alternatively you can use a WebBrowser Control (so you can show PDF inside your app);
this too assumes you have a PDF reader installed.
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
|
|
|
|
|
hi Luc Pattyn
your suggestion was very interest for me.
tanks so much
|
|
|
|
|
Hi.
Since ".net reflector" can decompile the assembly which means that all of the source can be restored, does any one know how to avoid that? since i have encryption keys stored in the assembly and can by seen with the .net reflector?
This has been bothering me for a few month.
Thanks.
|
|
|
|
|
maybe obfuscator helps you...
VirtualVoid.NET
|
|
|
|
|
You can obfuscate the assembly. VS2005 includes a Dotfuscator Community Edition (light version).
Many other obfuscator tools exist with prices from a couple of hundred to several thousand USD. (See also this Google search[^].)
|
|
|
|
|
Use an obfuscator. Visual Studio comes with the free edition of Dotfuscator, which can rename the symbols in your application. However, in order to achieve a higher degree of protection you'll need more than that. The superior versions Dotfuscator and most similar products have something called string encryption, which will prevent decompilers from reading keys, passwords, etc that are stored as strings in your app.
There are a myriad of commercial obfuscators out there and some of them have sponsored articles here on CP. If you want to invest some money into this I recommend {smartassembly}(trial version available on their site). It's way way cheaper than Dotfuscator or Spices.Obfuscator and it's very easy to use. Also, VERY IMPORTANT: if you use features such as serialization, reflection or remoting in your app, you'll have to be very careful with those classes/methods because most obfuscators break the application if those sections of your code are not excluded from renaming. As far as I saw from the trial version, {smartassembly} does that automatically, so that's a big advatage.
But download some trials and see which one fits you.
|
|
|
|