|
Thanks , I have modfied that , it helps
now , the key thing how to create those node on to of them?
|
|
|
|
|
A couple of points...
1. Your pen should be disposed (or better still enclosed in a using block.)
2. Any graphics object you create yourself should also be disposed (gfx)
2b. Creating grapics is 'expensive', there is already a Graphics object in e.
3. Better to override the OnPaint method.
3b. You should call the base's method at a suitable location.
so the code would become...
protected override void OnPaint(PaintEventArgs e)
{
using (Pen pen = new Pen(Color.Black, 3))
{
e.Graphics.DrawEllipse(pen, 20, 20, 50, 50);
}
base.OnPaint(e);
}
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Dave,
DaveyM69 wrote: You should call the base's method at a suitable location
Really? I never do that for Paint, and neither does this MSDN example[^].
So my questions are: why? what does it do for me? and if so, what is "a suitable location"?
|
|
|
|
|
Because otherwise (if overriding OnPaint rather than handling the Paint event) the Paint event will not get raised. I normally do it at the end of the method i.e. after all painting, however if there is some custom action that needs doing after all paint handlers have finished then base.OnPaint(e) should be called before then.
Edit: I've just followed the link a reread your post - In my point before I had suggested overriding OnPaint rather than handling the Paint event which is where the confusion comes from!
I prefer to override OnPaint if painting as I can be sure that no subscribers to the Paint event will be called until I've done with painting. If I paint in the Paint event handler then other subscribers may already have been notified yet my painting hasn't even begun!
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Saturday, January 2, 2010 9:32 AM
|
|
|
|
|
hi......
i want to protect my application with licence key....in Xaml
can anyone help mee....
thanquuu...
|
|
|
|
|
Its pretty simple, make some random characters using a random number generator and specify how many you want?
Random ran = new Random();
string mySerial = string.Empty;
int serialLength = 12;
for (int i = 0; i < serialLength;i++)
{
int ascii = ran.Next(70,90);
char myChar = (char)ascii;
mySerial += myChar.ToString();
}
A bit like that, next time lookup the problem.
|
|
|
|
|
Why do you say you want it in XAML? XAML is a markup language - pure and simple.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I have develop one window application in C#.Net. I want to create a trial version for 15 Days. How can I do.
|
|
|
|
|
You can use preprocessors for example you could place this statement before your declare the namespaces:
#define TRIAL
using System..... ect
and in the form load event you could:
#if TRIAL
if (firstusedate.days < firstusedate.days + 15)
{
MessageBox.Show("Sorry trial expired");
System.Thread.Sleep(3000);
}
#endif
My answer is pretty vague but you should get the idea, feel free to ask if there is still some problems
|
|
|
|
|
I don't think anyone is going to get the idea because what you propose only does anything at compile time. It doesn't protect the app at all.
|
|
|
|
|
I see the app is not being built as a trial, but a dynamic trial based app.
...
|
|
|
|
|
First When U installed Your Software you must have to insert the Date any where either in Database or Text File or System Registry. When Person Start The Software Check That and +15 and Current Date Of System When Your Insert
Date+15=CurrentDate The Close That Software or any Message trial Period of your Software is Over. Application.Exit(),Application.ExitThread().
Thanku Dinesh
|
|
|
|
|
Hi,
I made one combobox which i canwrite some text, in C# and i build that as DLL.
And i call this to VC++.
My problem, when it is in C#,i can write text in combobox.
But in VC++,i cannot write.
When i press alphapets in keyboard nothing is displayed in combobox. only beep sound is coming.
Whats the mistake?
Anu
|
|
|
|
|
I have made this small application that can write and read XML and I am new to XML parsing.
The following source is probably pretty bad so does anyone have some ideas to make it better for example, a better design strategy for it?
I would really like to follow a good conduct before I look further
The main class (normal console application)
using System;
using System.Collections.Generic;
using System.Text;
namespace xml
{
class Program
{
static void Main(string[] args)
{
List<Product> list = new List<Product>()
{
new Product(0, "Xbox 360", ProductType.Electronic, 129.99m),
new Product(1,"Playstation 3",ProductType.Electronic,130.99m),
new Product(2,"Playmobile Tonka",ProductType.Toy,29.99m),
new Product(3,"Tennis rack",ProductType.Sports,50.99m)
};
XmlRules rules = new XmlRules();
rules.SortList(ref list, SortType.IDLowest);
Xml xml = new Xml();
xml.SaveProductAsXML(list);
xml.ReadXml();
list = null;
}
}
public class Product
{
public int ID { get; set; }
public string Name { get; set; }
public ProductType Type { get; set; }
public decimal Cost { get; set; }
public Product(int id, string name, ProductType type, decimal cost)
{
ID = id;
Name = name;
Type = type;
Cost = cost;
}
}
public enum ProductType
{
Electronic, Toy, Sports
}
}
An XML class that deals with saving and reading XML:
using System;
using System.IO;
using System.Collections.Generic;
using System.Xml;
namespace xml
{
class Xml
{
const string _FILE_NAME = "products.xml";
public void SaveProductAsXML(List<Product> list)
{
XmlDocument root = new XmlDocument();
XmlElement rootElement = root.CreateElement("Products");
root.AppendChild(rootElement);
for (int i = 0; i < list.Count; i++)
{
XmlElement elemnt = root.CreateElement("Product");
XmlAttribute att = root.CreateAttribute("Name");
att.Value = list[i].Name;
elemnt.Attributes.Append(att);
XmlAttribute idAttr = root.CreateAttribute("ID");
idAttr.Value = list[i].ID.ToString();
elemnt.Attributes.Append(idAttr);
XmlAttribute typeAttr = root.CreateAttribute("Type");
typeAttr.Value = list[i].Type.ToString();
elemnt.Attributes.Append(typeAttr);
XmlAttribute priceAttr = root.CreateAttribute("Price");
priceAttr.Value = string.Format("{0}", list[i].Cost);
elemnt.Attributes.Append(priceAttr);
rootElement.AppendChild(elemnt);
}
root.Save(_FILE_NAME);
root = null;
rootElement = null;
}
public void ReadXml()
{
using (FileStream file = File.OpenRead(_FILE_NAME))
{
XmlDocument document = new XmlDocument();
document.Load(file);
XmlNodeList nodeList = document.GetElementsByTagName("Product");
for (int i = 0; i < nodeList.Count; i++)
{
string name = nodeList[i].Attributes[0].InnerText;
string id = nodeList[i].Attributes[1].InnerText;
string type = nodeList[i].Attributes[2].InnerText;
string price = string.Format("{0:c}", decimal.Parse(nodeList[i].Attributes[3].InnerText));
Console.WriteLine("Name {0}", name);
Console.WriteLine("ID {0}", id);
Console.WriteLine("Type {0}", type);
Console.WriteLine("Price {0}", price);
Console.WriteLine();
}
}
Console.ReadKey();
}
}
}
And finally a class that stores the sorting rules for the XML document:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace xml
{
class XmlRules
{
public void SortList(ref List<Product> list, SortType sort)
{
IEnumerable<Product> products;
if (sort == SortType.PriceLowest || sort == SortType.PriceHighest)
{
products =
from p in list
orderby (sort == SortType.PriceHighest ? p.Cost * -1 : p.Cost)
select p;
list = products.ToList();
}
else if (sort == SortType.IDLowest || sort == SortType.IDHighest)
{
products =
from p in list
orderby (sort == SortType.IDHighest ? p.ID * -1 : p.ID)
select p;
list = products.ToList();
}
products = null;
}
}
public enum SortType
{
PriceLowest, PriceHighest, IDLowest, IDHighest
}
}
Thanks!
|
|
|
|
|
If it works, I'd leave it alone and move on into the rest of the project.
Beyond that, I would make the method in XmlRules static so that you don't have to instantiate the class to use that method. (By the way, you neglected to take into account the sort direction.)
Second, I would use Linq-to_Xml to load/save the XML data from the disk file. It's much simpler.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I have developed a windows app that will run on a local network. I have the app set so users can run the app from the server. What do I need to do so the user doesn't get the message: "The publisher could not be verified. Are you sure you want to run this software"
Thanks in advance!
sk
|
|
|
|
|
Digital Signature -- see here: http://www.kinook.com/blog/?p=10[^]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I assume you are using IE 7 or 8. Add your app to the browser's trusted sites list.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
The Solution that i Provided U is For Win App.
1)First U Have to installed Your application on Server and The Folder Which is Created on Your Server Must Be Shared with Full Permission on That Folder.
2)Go To The Start->Run->Cmd->cd \->CD Windows (Enter)
CD \Microsoft .NET FramreWork 2.0 (Enter)
CD \Framework (Enter)
CD \v2.0.50727 (Enter)
C:\Windows\Microsoft .NET FramreWork 2.0\Framework \v2.0.50727(this you path)
after that you have to Write The command
caspol -cg 1.2 FullTrust (Case Senstitive)
Ask For Yes Or No Press Y
All This Work is Done At Server.
Now on Client
1)First Installed .NEt FrameWork 2.0 Setup
2)MYComputer Right Click MAP Driver From That Server on Your Client Computer
3)Repate The Setup Of Command on the Client as Above
|
|
|
|
|
Happy New Year ! to all.
Just wondering if someone would give me a bit of guidance on this.
I need to signal various points of code execution from a windows service to a monitoring application on the same machine.
This is apart from those handled by "Service controller class".
I have had a look at tcp sockets, .net remoting and named pipes, but that all seems like overkill.
As i am simply looking for a boolean flag, no messages or data transfer as such.
Has anyone found a simple way of doing this,i know i must be missing something ?
Thanks in advance.
|
|
|
|
|
IPC generally isn't a simple thing. If you want to signal state from one process to another then you have to send some sort of message but it doesn't have to be a big one.
Two simpler options than the ones you listed are shared file IO (see the System.IO[^] namespace) and MSMQ (see the MessageQueue[^] class). If you want quick and easy, I suggest you look into the MSMQ option; it boils down to just a few lines of code for both sending and receiving messages.
|
|
|
|
|
Thanks for that, i will investigate the message queue alternative i think.
I had thought about using an XML file but it seems like that could introduce possible problems.
It is reliability i am after.
|
|
|
|
|
Hi,
I'm experimenting with the new System.Threading.Parallel methods like parallel for and foreach.
They seem to work nicely but I need a way to increase the number of concurrent threads that are executed which are 8 (I have a quad core).
I know there is a way I just can find the right property.
Gilad.
P.S. Please don't write that more threads won't give better output, I already have got a bunch of those.
|
|
|
|
|
Well, I believe (but don't quote me on that), that you can create a new TaskManager and give it a parameter maxConcurrentThreads (or such)
Is that what you're looking for?
-- edited to not be an answer --
modified on Friday, January 1, 2010 6:30 PM
|
|
|
|
|
Well... this is kinda tricky..
in the System.Threading 2008CTP you could see the TaskManager and it actually had properties for Threads-Per-Cpu under
System.Threading.Tasks.TaskManager.Current.Policy.IdealThreadsPerProcessor
but for some reason it wasn't possible see the default taskManager nor to access those values (read-only) or create a TaskManager of your own.
In the 2010 beta there is no TaskManager... hmmm... I couldn't find any similar object that might do the same job.
What is going on???
|
|
|
|