|
Inherit from Control[^]; that's the correct base-class to inherit from when visualizing things. For non-visual components inherit from Component[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok, and if i choose from Control to inherit(it's easier), then how I hide the rest of the properties showing in my Properties window?
|
|
|
|
|
You don't; they're inherited and required for the correct working of a control. Without them, you can't call it a control. You can hide properties using a hack, but that's all it is - a hack. It doesn't mean that the properties aren't accessible.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
then, yes, i'm very interested on it- can you give me an example on how to do it?
Please, and thanks.
|
|
|
|
|
|
Eddy is right. If you want to build a control from scratch you inherit from either Control or Component.
UserControl is normally used when you want to build a new control from a mash up of other controls, like a button and textbox.
|
|
|
|
|
+
I have another problem = it seem that i can not add new events- well,working events.
here is what i did so far:
public event EventHandler textchange2;
If i insert only this line in my "Car" control object , it will appear in events list when the new control will be added.
The rest of the code is over my head... >>>
protected virtual void ontextchange2(EventArgs e)
{
EventHandler handler = textchange2;
if (handler != null) handler(this, new EventArgs());
}
|
|
|
|
|
Hi, i'm a beginner for plc. Please somebody guide me or provide some samples to connect, read and write the OMRON PLC through ethernet port.
Thanks advance.
|
|
|
|
|
Why are you asking here? Why not http://www.omron.com/[^]?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I only know read & write Mitsubishi PLC from a Mitsubishi's control named MXComponent.
|
|
|
|
|
I connect my plc through ethernet port so is there any possibilities to read the port and get the values from the connected PLC.
|
|
|
|
|
I only know read & write Mitsubishi PLC from a Mitsubishi's control named MXComponent.
|
|
|
|
|
And that tells the OP what exactly?
|
|
|
|
|
I would look to a solution that uses OPC technology to achieve what you want. There are plenty of vendors that supply OPC Servers for Omron products - Look at KepWare and Matrikon as 2 of the bigger vendors. Omron may even supply there own OPC Server that you can use. The OPC Server talks to the PLC hardware through communication drivers and you then write a client application in C# to read and write to the PLC via the OPC Server.
There are a few examples on Code Project and as OPC is designed to remove the vendor specific quirks of hardware communication, what works for one PLC vendor will usually work for another with minimal changes. It may seem daunting at first, but there is a .NET wrapper around the OPC Core. Have a look at the OPC Foundation website for further details.
I've been working on a C# client that talks to Siemens hardware via an OPC Server recently and once you get a grip of how the OPC Server organises and presents the individual IO tags of the PLC hardware its an elegant system to use. It also scales very well with my C# client detecting changes in the PLC within 15ms even though its monitoring over 6000 tags!
|
|
|
|
|
I need a collection, which is easy to sort (or sorted collection).
If it is almost sorted, the sorting time must be minimal.
Or it can be collection, which keeps its elements sorted, even if you change the keys of elements.
The keys in collection must NOT be unique!
(Maybe some sort of tree collection internally.)
|
|
|
|
|
|
All of the standard sorted collections require unique keys which violates one of OP's requirements.
|
|
|
|
|
Member 10339829 wrote: If it is almost sorted, the sorting time must be minimal. We always strive for minimal time; how many elements are in your list?
Member 10339829 wrote: The keys in collection must NOT be unique! Then they're no longer "keys", but simply values. That equates to an array of objects - so, an IComparer would sort that.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You need a collection of ... what ? And, what is the "sorting algorithm" you require/need/want ?
.NET hands you the ability to easily sort (using a QuickSort algorithm) generic Lists of value types by just invoking the 'Sort function: "All numeric types (such as Int32 and Double) implement IComparable, as do String, Char, and DateTime. Custom types should also provide their own implementation of IComparable to enable object instances to be ordered or sorted."
And, writing your own IComparable is not that difficult; for example:
If you have a TreeNode Collection:
public List<TreeNode> sTNList = new List<TreeNode>
{
new TreeNode("1"),
new TreeNode("1"),
new TreeNode("2"),
new TreeNode("4"),
new TreeNode("1"),
new TreeNode("4"),
new TreeNode("8"),
new TreeNode("2"),
new TreeNode("3")
}; You can easily define a custom IComparer Class to sort the nodes:
public class TreeNodeICompare : IComparer<TreeNode>
{
public int Compare(TreeNode x, TreeNode y)
{
return(x.Text.CompareTo(y.Text));
}
} And invoke it:
sTNList.Sort(0, sTNList.Count, new TreeNodeICompare()); See [^] for the documentation on the call to 'Sort used here. And, note: "This method uses Array.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. ... On average, this method is an O(n log n) operation, where n is Count; in the worst case it is an O(n ^ 2) operation."
Using a non-unique property of a collection, like the 'Text property of a TreeNode, you avoid possible duplicate key issues that might arise with other types of collections.
Perhaps if you describe the scenario in which your collection is being used you can get more than a "mind-reader's guess" type of response here.
bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
modified 16-Oct-13 22:12pm.
|
|
|
|
|
|
If your list is almost sorted, you could use your own sort alogrithm.
If your run some tests[^], you will notice bubble sort does fairly well with lists that are almost sorted.
|
|
|
|
|
|
You could use the OrderBy<TSource, TKey>(Func<TSource, TKey>) extension method.
The actual sorting is deffered until result gets enumerated, so the call to OrderBy() itself is fast.
It performs a stable sort, which means that the order of already sorted elements is preserved.
it does not sort the original sequence in-place. Instead, the returned IEnumerable<tsource> returns elements of the original sequence in sorted order.
And you can speed things up a bit with parallel LINQ like:
var result = sourceSequence.AsParallel().OrderBy(item => item.Key);
Gabriel Szabo
|
|
|
|
|
Hi all,
i am trying to develop a simple application to capture image from USB 2.0 PC camera by pressing the phyiscal button on the camera.
i tried the below code. please help me. in the below code need to press button on the windows application to capture image from usb camera where as i need to capture image from physical button present on the camera.
public Form1()
{
InitializeComponent();
webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo VideoCaptureDevice in webcam)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
}
comboBox1.SelectedIndex = 1;
cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
cam.Start();
}
private FilterInfoCollection webcam;
private VideoCaptureDevice cam;
Bitmap bitmap;
void cam_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
bitmap = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = bitmap;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.Image = bitmap;
}
private void button3_Click(object sender, EventArgs e)
{
if (cam.IsRunning)
{
cam.Stop();
}
}
private void button2_Click(object sender, EventArgs e)
{
Bitmap current = (Bitmap)bitmap.Clone();
string filepath = Environment.CurrentDirectory;
string fileName = System.IO.Path.Combine(filepath, @"name.bmp");
current.Save(fileName);
current.Dispose();
}
|
|
|
|
|
The VideoCaptureDevice class does not expose any events; AFAIK there's no code triggered by .NET on a physical push on a button on a device. It's not something that's "standard" available for any webcam.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|