|
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[^]
|
|
|
|
|
@Eddy Vluggen
Thanks for the reply.
any other solution? or sample code to do?
please help me
|
|
|
|
|
You should have to get with the manufacturer of the camera for an SDKto use so you can get at the button on it.
|
|
|
|
|
I need to make a 'bot' style program that will mimic real life user interface. On the fist page I have a login/pass on submit. This step I have conqured:
webBrowser1.Document.GetElementById("ctl00_MainContentArea_sei_form_password").SetAttribute("value", "PASSWORD");
webBrowser1.Document.GetElementById("ctl00_MainContentArea_sei_form_username").SetAttribute("value", "USER");
HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement el in elc)
{
if (el.GetAttribute("type").Equals("submit") && el.GetAttribute("name").Equals("ctl00$MainContentArea$sei_form_submit"))
{
el.InvokeMember("click");
}
}
but now i have to get to 2 a hrefs that are buried deep inside a div tag:(the 2 files marked Roster_Lookups.zip and IDX_Listing_Data)
<div id="ctl00_MainContentArea_sei_download_content_area" class="sei_content_padding"><div class="sei_left_float_small">
<div class="sei_content_bg_gold">
<h2>Data Download User Info</h2>
<div class="sei_content_gold">
<div class="sei_data_font">
<div id="sei_data_user_info"><p> <b>User Name: </b>LOGIN</p>
<p><b>MLS Account: </b>Door County</p>
<p><b>Date Created: </b>6/18/2008 3:14:00 PM</p>
<p align="center"><a href="data_download.aspx?loggout=true">Click Here to Logout</a></p></div>
</div>
</div>
</div>
</div>
<div class="sei_left_float_padding">
<div class="sei_content_bg_blue">
<h2>Data Available For Download</h2>
<div class="sei_content_blue">
<div class="sei_data_font">
<p>The data below is made available to you by your MLS. For data specifications, and general information please contact your MLS office.</p><br>
<p class="sei_require"><b>New Update:</b><br> The IDX_Custom.zip file has been split into 2 zip files. The file named IDX_Listing_Data.zip will contain the listing data. The file named Roster_Lookups.zip will contain the roster and lookup information.</p><br>
<p class="sei_data_file_name"><a href="popdown.asp?file=IDX_Listing_Data.zip" target="download"><img src="images/zip.gif" alt="File" border="0" align="absmiddle">IDX_Listing_Data.zip</a></p><div class="sei_data_file_update">File Last Updated: 10/15/2013 3:49:59 AM</div><p></p><p class="sei_data_file_name"><a href="popdown.asp?file=Roster_Lookups.zip" target="download"><img src="images/zip.gif" alt="File" border="0" align="absmiddle">Roster_Lookups.zip</a></p><div class="sei_data_file_update">File Last Updated: 10/15/2013 3:50:00 AM</div><p></p>
</div>
</div>
</div>
</div>
<div class="sei_clear"></div>
</div>
This is set to not allow a cookie post/response set, so i need to try to get some kind of mouse move, tab move, and click value to associate the hyperlinks that are buried inside of that flash element.
All ideas are welcome!
|
|
|
|
|
What do you want to achieve: a tool for testing a website or a robot which downloads some files from some web location?
And neither of them would use "mouse move" etc., they look for the element (here: href), get the necessary data (i.e. URL), and perform the correct operation (i.e. download) on them.
|
|
|
|
|
I have data in dataset or datatable I need to design table dynamically with alignment, table column as background colour using console application.Please help me out this query.
Regards,
Abhi
|
|
|
|