Attached are some code snippets that I use during code development.
- newClass – code Snippet for creating a class
- newClassNotify – code Snippet for creating a class which implements INotifyPropertyChanged interface
- dprop – code snippet for a property using DependencyProperty
- dpropu – code snippet for a property using DependencyProperty with ChangeCallback notifier
- dpropObCollection – code snippet for a property using DependencyProperty to an ObservableCollection
- conv – code Snippet for creating a IValueConverter
- multiconv – code Snippet for creating a IMultiValueConverter
- propNotify – code Snippet for creating a property with get/set accessors and property value change notification trigger
Here I put some facts about events and delegates.
Event vs. Delegate
- “event” in delegate definition is just a limitation of delegate invocation. If you use “event” you can invoke the delegate from the scope of the class ONLY. Usually you would not like a client of your class to directly trigger an event. Use “event” to encapsulate your delegates.
- Interfaces define public methods and properties of the class. Interface does not define member variables. In order to specify a delegate in an interface an “event” modifier should be used.
- “event” also provides an ability to perform some actions when something is subscribed or unsubscribed from the delegate. For that purpose “add” and “remove” accessors should be used inside the definition of an event (just like get/set accessors in a regular property).
Duplicate Subscription
- Duplicate subscription to events results in duplicate invocation of subscribed method.
“MyEvent += Function” vs. “MyEvent += new Handler(Function)”
- This syntax produces the same result. In both cases a “Function” is subscribed to “MyEvent”.
“MyEvent -= Function” vs. “MyEvent -= new Handler(Function)”
- This syntax produces the same result. In both cases a “Function” is unsubscribed from “MyEvent”.
Here I will accumulate link to cool effects in WPF.
Image Panning, Zooming and Rotating
Today I encountered another wild animal while surfing in the jungle. Pretty much nothing to comment
if (visiblePath
== null)
{
visiblePath
= new DispatcherTimer
();
visiblePath
.Tick -= new EventHandler
(visiblePath_Tick
);
visiblePath
.Tick += new EventHandler
(visiblePath_Tick
);
visiblePath
.Interval = TimeSpan
.FromSeconds(500);
}
else
{
visiblePath
.Tick -= new EventHandler
(visiblePath_Tick
);
visiblePath
.Tick += new EventHandler
(visiblePath_Tick
);
}
visiblePath
.Stop();
visiblePath
.Start();
This is another post where I will gather useful documentation about so called Model-View-ViewModel pattern used for GUI development in WPF environment.
Here I will keep track of available resources in the net related to memory leaks in C# and WPF caused by not proper use of Microsoft technologies. Further will add my own thoughts and conclusions.
Garbage Collection
Tools
Hi everybody. At last long-awaited “PhotoSuck Beta” is on air. Its still in testing stage and You’re welcome to be one of its first users. For those guys who are new to “PhotoSuck” – its a windows based application which downloads Your desired photos from Flickr and Picasa. Your desires are defined by sets of criterias. Criterias include social relevance(specific users’ photos, Your friends’ photos, …); tag relevance; picture quality (portrait, landscape, HD, SD, …); upload date; and more. All this is achieved using cute WPF application, which looks like this:

Read more…
Today at the office I encountered another nightmare. It seems like the author of the code above was doing the development late at night, he sleep in the middle and unintentionally pushed Ctrl-V button.

Read more…
Today at the workplace I came across a very weird chunk of code. An enormous block of code was wrapped in 25-30 levels of brackets. On a a standard resolution screen (1280×1024) the code was completely out of screen. After spending some time on refactoring it and eliminating annoying scopes I decided to take a screenshot and post it here.

Below I will describe reasons that can lead to such kind of issues and possible solutions.
Read more…