Posts

Custom WPF Events

This shows an example of adding a custom WPF event to a control, called ImagingControl. public delegate void CameraConnectedEventHandler(object sender, CameraConnectedRoutedEventArgs e); public static readonly RoutedEvent CameraConnectedEvent = System.Windows.EventManager.RegisterRoutedEvent( "CameraConnected", RoutingStrategy.Bubble, typeof(CameraConnectedEventHandler), typeof(ImagingControl)); public event CameraConnectedEventHandler CameraConnected { add { this.AddHandler(CameraConnectedEvent, value); } remove { this.RemoveHandler(CameraConnectedEvent, value); } } public class CameraConnectedRoutedEventArgs : RoutedEventArgs { public CameraConnectedRoutedEventArgs(RoutedEvent routedEvent, bool bIsConnected) { RoutedEvent = routedEvent; IsConnected = bIsConnected; } public bool IsConnected { get; set; } } The event is raised in this lin...
I started getting warning messages like ' Could not find schema information for the element 'supportedRuntime'' after adding an app.config file to my project. It seems that Microsoft have not completely specified the 'startup' element in the relevant .xsd file. To fix this: Navigate to the file ' C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas\DotNetConfig.xsd'. If the startup element looks like this: <: xs:element name="startup" vs:help="configuration/startup"> Change it to: < xs:element name="startup" vs:help="configuration/startup"> < xs:complexType> < xs:choice minOccurs="1" maxOccurs="1"> < xs:element name="requiredRuntime" vs:help="configuration/startup/requiredRun...

Using Cognex 7.2 with .NET 4

Cognex 7.2 can be used with .NET 4, but it needs a bit of setting up… Right click on the project in Solution Explorer > Add > New Item. Select General > Application Configuration File. On the project properties set the Target framework to ‘.NET Framework 4’. Note – not the client profile version. It should warn you about reloading the project. Click OK and this will update the app.config file with the .NET version. To the app.config file add the attribute: useLegacyV2RuntimeActivationPolicy = " true ". It should now look like this: xml version = " 1.0 " ?> < configuration > < startup useLegacyV2RuntimeActivationPolicy = " true " >< supportedRuntime version = " v4.0 " sku = " .NETFramework,Version=v4.0 " /> startup > configuration > It should now compile OK.

Bitmap manipulation

Explanation of bitmap format and manipulation of pixels. http://www.bobpowell.net/lockingbits.htm

Installing Mercurial on iMac

Downloaded Mercurial 2.0.1 for MacOS X 10.7 from http://mercurial.selenic.com/downloads/. Ran the installer as usual. Mercurial installs to ' /usr/local/bin/' as the executable file 'hg'. Navigate to this in terminal and run the command 'hg version', should give you something like this if it's worked: Mercurial Distributed SCM (version 2.0.1+20111201) (see http://mercurial.selenic.com for more information) Copyright (C) 2005-2011 Matt Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Then need to setup a username. Do this in an .ini style file called .hgrc. This needs to be in your home directory (~/), which in my case is '/Users/steve/', and contains the following: [ui] username = Steve Richmond That's it!

How to show hidden files in Finder

Follow this link: http://www.techiecorner.com/153/how-to-show-hidden-files-in-finder-mac-os-x/

Using Mercurial from QT Creator on a Mac

This is using Mercurial version 2.0.1 and QT Creator 2.3.1 and assumes Mercurial has already been installed and a .hgrc file setup with your username (see Installing Mercurial on iMac post). Start QT Creator and go to Preferences > Version Control and select Mercurial from the segment control. In Configuration enter for the Command enter: /usr/local/bin/hg In User enter the username and email in your .hgrc file (see Installing Mercurial on iMac post). I didn't do anything with the Miscellaneous section. Restart QT Creator and under the Tools menu Mercurial should appear and all the sub-menu items should be enabled.