Wednesday, December 5, 2012

WPF - 2

Cheat sheet:
- XAML for WPF: http://blog.blueboxes.co.uk/2009/02/03/xaml-for-wpf-cheatsheet/
- DataBinding: http://www.nbdtech.com/Blog/archive/2009/02/02/wpf-xaml-data-binding-cheat-sheet.aspx

Programming tools
http://www.wpftutorial.net/wpfdevtools.html

Themes:
http://wpf.codeplex.com/wikipage?title=WPF%20Themes&referringTitle=Home
- Download is here: http://wpf.codeplex.com/releases/view/14962

Data binding:
- See http://msdn.microsoft.com/en-us/library/ms750612.aspx
- Why we shouldn't use DependencyObject inside ViewModel layer: http://stackoverflow.com/questions/291518/inotifypropertychanged-vs-dependencyproperty-in-viewmodel
- How to serialize Dependency Object using XamlReader/Writer: http://www.codeproject.com/Tips/61443/Serialize-DependencyObject-it-s-easy
- How to reduce coding for INotifyPropertyChanged:
  - http://stackoverflow.com/questions/1315621/implementing-inotifypropertychanged-does-a-better-way-exist
  - Use CallerMemberName attribute available from .NET 4.5, see http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

MVVM
 - How to implement Command pattern: http://www.codeproject.com/Articles/101881/Executing-Command-Logic-in-a-View-Model
 - Calling command by events: http://stackoverflow.com/questions/1048517/wpf-calling-commands-via-events

Topics:
- Async and data binding
- Types of bindings, multiple ? hierarchy ? collision ?
- Binding, converter, validation

Monday, November 5, 2012

Friday, October 12, 2012

WCF: Windows Communication Foundation

SelfHosting tutorial

http://msdn.microsoft.com/en-us/library/ms731758.aspx

How to publish metadata when using TCP binding:
1. Inside app.config, create service behavior element (e.g. HelloServiceBehavior)
2. Refer the behavior from service tag (behaviorConfiguration="HelloServiceBehavior")
3. Add endpoint to the service to exchange metadata, use contract="IMetadataExchange".
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="HelloServiceBehavior">
                    <serviceMetadata policyVersion="Policy15" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="HelloServiceBehavior" name="HelloService">
                <endpoint address="net.tcp://localhost:8080/hello" binding="netTcpBinding"
                    bindingConfiguration="" name="HelloService" contract="IHelloService" />
                <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
</configuration>



Using Async/Await



Async Cancellation/Progress is not supported


http://social.msdn.microsoft.com/Forums/en-US/async/thread/b1353952-ce52-4af7-b6ec-f792bef28566/


Enabling trace

netTcpBinding uses binary encoding and transport security, which delivers better performance.
Following URLS will help to get more information

http://stackoverflow.com/questions/665473/how-to-handle-wcf-client-disconnect
http://stackoverflow.com/questions/5338842/detect-socket-disconnect-in-wcf

Reliable Messaging

Need to turn-off or set level to Message Security for Bindings (doesn't work if the level is set to the default Transport level)
Working case
- Server not available during the first connection
- Network cable is blipping
Not working case
- Server is down and restarted

WCF and WebSocket

Monday, October 1, 2012

Linking Boost DLL on Windows

http://stackoverflow.com/questions/2520234/how-to-link-to-dynamic-boost-libs

.NET Async Await

* Performance consideration: http://msdn.microsoft.com/en-us/magazine/hh456402.aspx
* Comparison with old patterns: http://msdn.microsoft.com/en-us/library/jj152938.aspx

,NET timers

Comparisons: http://msdn.microsoft.com/en-us/magazine/cc164015.aspx

Note that System.Timers.Timer and System.Threading.Timer by default call your timer event handler on a worker thread obtained from the common language runtime (CLR) thread pool.



 System.Windows.FormsSystem.TimersSystem.Threading
Timer event runs on what thread?UI threadUI or worker threadWorker thread
Instances are thread safe?NoYesNo
Familiar/intuitive object model?YesYesNo
Requires Windows Forms?YesNoNo
Metronome-quality beat?NoYes*Yes*
Timer event supports state object?NoNoYes
Initial timer event can be scheduled?NoNoYes
Class supports inheritance?YesYesNo
* Depending on the availability of system resources (for example, worker threads)

Monday, September 24, 2012

WebGL

Model-View-Projection Matrices

  • Model maps object coordinate to world coordinate
  • View maps world coordinate to camera coordinate
  • Projection maps camera coordinate to screen coordinate

Monday, September 10, 2012

Thursday, September 6, 2012

WebSocket

Friday, July 20, 2012

Cookies

How to detect cookie in Javascript
http://stackoverflow.com/questions/8112634/jquery-detecting-cookies-enabled

Delete cookie for a specific site by clicking bookmark
http://labnol.blogspot.jp/2006/12/how-to-delete-browser-cookies-of-any.html

Cross-domain communication, 3rd party cookie problems:
http://vimeo.com/24705559, options:
  - PostMessage
  - JSONP
  - CORS Cross Origin Resource Sharing
  - Document.domain Hacks
  - Window.name Hacks
  - IFrame Hacks

Creating P3P compact policy:
 - http://blog.sweetxml.org/2007/10/minimal-p3p-compact-policy-suggestion.html
 - http://stackoverflow.com/questions/5774014/iframe-cant-read-nor-set-cookies
 - http://viralpatel.net/blogs/how-to-set-third-party-cookies-with-iframe/

Wednesday, June 20, 2012

ASP.NET background thread

http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

http://blogs.msdn.com/b/tmarq/archive/2010/04/14/performing-asynchronous-work-or-tasks-in-asp-net-applications.aspx

In v4.0 ASP.NET, we won’t unload the AppDomain until all requests have completed. In v2.0/3.5 ASP.NET in IIS 7 integrated mode, we also won’t unload the AppDomain until all the requests have completed.  In v2.0/3.5 classic mode, we will only wait until httpRuntime/shutdownTimeout has been exceeded before unloading the AppDomain, so long running async requests are vulnerable to being rudely aborted.  To work around this, you’d want the shutdownTimeout to be sufficiently long.

Wednesday, April 25, 2012

How to remove incomplete uninstalled package

Use msizap.exe T ___.msi See http://www.advancedinstaller.com/user-guide/qa-forced-uninstall.html

Thursday, February 23, 2012

Forcing Windows 7 to connect to SAMBA using old authentication method

For Windows 7 Pro
  1. from the run command or from a cmd window run secpol.msc
  2. go to “Local Policies” -> “Security Options” -> “Network Security: LAN Manager authentication level”
  3. change to “LM and NTLM – use NTLMV2 session security if negotiated”
  4. Press the OK button

For Windows 7 Home
Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\LsaCreate a new DWORD value with the following properties: NAME: LmCompatibilityLevel VALUE: 1