jasper22

[info]jasper22


Jasper journal

This is mirror site for main blog: http://jasper-net.blogspot.com/


Split Generic.xaml in Silverlight Applications
jasper22
[info]jasper22
If you work with Templated controls in a big Silverlight project, your Generic.xaml might grow fast. Here’s a quick tutorial on how to split the Generic.xaml into multiple resource files.
Step1: Find the resource

You will typically have the control code:

public class TemplatedControl1 : Control {
    public TemplatedControl1() {
        this.DefaultStyleKey = typeof(TemplatedControl1);
    }
}

and the XAML in the Generic.xaml:

<Style TargetType="local:TemplatedControl1">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="local:TemplatedControl1">
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Step2: Create a new resource file

Create a copy of Generic.xaml and rename to TemplatedControl1.xaml.
Delete the TemplatedControl1 style from Generic.xaml.
So Generic.xaml looks like:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SilverlightApplication1">
</ResourceDictionary>

Read more: LOEKVANDENOUWELAND
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://loekvandenouweland.com/index.php/2012/01/split-generic-xaml-in-silverlight-applications/

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

IDisposable, Finalizer, and SuppressFinalize in C# and C++/CLI
jasper22
[info]jasper22
The .NET Framework features an interface called IDisposable. It basically exists to allow freeing unmanaged resources (think: C++ pointers). In most cases, you won’t need IDisposable when writing C# code. There are some exceptions though, and it becomes more important when writing C++/CLI code.

The help page for IDisposable provides the code for IDisposable's default implementation pattern in C#. This article will explain each part of it step by step and also provide the equivalent C++/CLI code in each step.
Summary – for the impatient

Here’s the summary of this article for those who don’t want to read the actual explanations.

Rules:

    For a class owning managed resources, implement IDisposable (but not a finalizer).
    For a class owning at least one unmanaged resource, implement both IDisposable and a finalizer.

C# code:

class DataContainer : IDisposable {
  public void Dispose() {
    Dipose(true);
    GC.SuppressFinalizer(this);
  }

  ~DataContainer() { // finalizer
    Dispose(false);
  }

  protected virtual void Dispose(bool disposing) {
    if (m_isDisposed)
      return;

    if (disposing) {
      // Dispose managed data
      //m_managedData.Dispose();
    }
    // Free unmanaged data
    //DataProvider.DeleteUnmanagedData(m_unmanagedData);
    m_isDisposed = true;
  }

  private bool m_disposed = false;
}

C++/CLI code:

ref class DataContainer {
public:
  ~DataContainer() {
    if (m_isDisposed)
       return;

    // dispose managed data
    //delete m_managedData;
    this->!DataContainer(); // call finalizer
    m_isDisposed = true;
  }

  // Finalizer
  !DataContainer() {
    // free unmanaged data
    //DataProvider::DeleteUnmanagedData(m_unmanagedData);
  }

private:
  bool m_isDisposed; // must be set to false
};

The Root of all Evil

In C#, all classes are managed by the garbage collector. However, some things just can’t be expressed in pure managed code. In these cases you’ll need to store unmanaged data in a managed class. Examples are file handles, sockets, or objects created by unmanaged functions/frameworks.

Read more: Codeproject
QR: IDisposable-Finalizer-and-SuppressFinalize-in-Csha

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Catel v2.5 [Updated: Jan 23 2012 by GeertvanHorrik ]
jasper22
[info]jasper22
Release Notes
Catel history
=============

(+) Added
(*) Changed
(-) Removed
(x) Error / bug (fix)

For more information about issues or new feature requests, please visit:

http://catel.codeplex.com

Documentation can be found at: http://catel.catenalogic.com

**********************************************************

===========
Version 2.5
===========

Release date:
=============
2011/01/23

Added/fixed:
============
(+) Added MessageMediator that implements the Mediator pattern
(+) Added IValidationSummary to get an easy summary of a IValidationContext
(+) Added ValidationToViewModel attribute to easily get validation summaries mapped onto properties of a view model
(+) Added ViewModel extensions to retrieve a IValidationSummary that includes all child view models as well
(+) Added CommandHelper that allows to automatically hook a command CanExecute to an IValidationSummary
(+) Added SelectTextOnFocus behavior
(+) Added GetBindingExpression extension method for DependencyObject in Silverlight to allow the retrieval of
bindings for non-FrameworkElement types that still do support bindings (such as behaviors and dependency objects)


Read more: Codeplex
QR: 75452

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Crawling Websites with C# and XPath
jasper22
[info]jasper22
Trying to index every item of clothing on the internet for Clossit seems like a pretty difficult task but is easy with C# and the HTML Agility Pack library. Our crawler, nick named Monocle, is written using both.

HTML is pretty messy and can be inconsistent between different sites but HTML Agility Pack seems to be able to handle it all and lets you access it all with XPath. In this example we will be crawling Superalloy’s Wikipedia page. After adding the .dll as a reference you can download and load a single page like this:

string url = "http://en.wikipedia.org/wiki/Superalloy";
var wc = new WebClient();
var document = new HTMLDocument();
document.LoadHtml(wc.DownloadString(url));

At this point the document object is holding the html content and is ready to receive XPath queries. Let’s say we’d like to select the title of the page which appears here:

<h1 id="firstHeading" class="firstHeading">Superalloy</h1>

What makes this node unique is the H1 tag with an id of “firstHeading”. We can select this by using XPath

string title = document.SelectSingleNode("//h1[@id='firstHeading']").InnerText;
Console.WriteLine(title);


Read more: Clossit
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://blog.clossit.com/crawling-websites/

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Dynamic Theme Switching in Silverlight Prism App
jasper22
[info]jasper22
INTRO

In my recent consulting assignment I was asked the question by one of the developer , that how can we get dynamic theming working in Prism application.My answer was that you can implement in the same manner as you do in the standard Silverlight application. But then he further asked that there are various regions in the RegionManager and how each views loaded in the different content regions can get unified theme , this encouraged me to try this out and see how it works.I started working on it and viola my answer was correct , there is no difference in implementing dynamic theming in prism specific app. In this blog post I explain you the same. I assume that readers are already aware of Prism library. If you are not then I strongly recommend that you acquire the knowledge of the same. In my example you will see the very basics of Prism app but the library has much more to offer.

GETTING STARTED

I created a very simple PRISM application which had only one Module (ModuleA). This module is loaded on demand when you click on the menu link which is under the ShellView.The application default gets loaded in the BlueTheme but it allows you to change the theme on the fly from the Themes menu. See the screen shot below of both themes.

Read more: Getting Deep into .net
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://goldytech.wordpress.com/2012/01/25/dynamic-theme-switching-in-silverlight-prism-app/

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

VBoxHeadless - Running Virtual Machines With VirtualBox 4.1 On A Headless Ubuntu 11.10 Server
jasper22
[info]jasper22
This guide explains how you can run virtual machines with VirtualBox 4.1 on a headless Ubuntu 11.10 server. Normally you use the VirtualBox GUI to manage your virtual machines, but a server does not have a desktop environment. Fortunately, VirtualBox comes with a tool called VBoxHeadless that allows you to connect to the virtual machines over a remote desktop connection, so there's no need for the VirtualBox GUI.

I do not issue any guarantee that this will work for you!

 
1 Preliminary Note

I have tested this on an Ubuntu 11.10 server (host system) with the IP address 192.168.0.100 where I'm logged in as a normal user (user name administrator in this example) instead of as root.

 
2 Installing VirtualBox

To install VirtualBox 4.1 on our Ubuntu 11.10 server, we open /etc/apt/sources.list...

sudo vi /etc/apt/sources.list

... and add the following line to it:

[...]
deb http://download.virtualbox.org/virtualbox/debian oneiric contrib

Read more: HowtoForge
QR: vboxheadless-running-virtual-machines-with-virtualbox-4.1-on-a-headless-ubuntu-11.10-server

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Security Compliance Manager 2.5 Beta is here!
jasper22
[info]jasper22
The latest version the Microsoft Security Compliance Manager (SCM) tool—version 2.5—is now available for beta download and review!

NEW baselines include:

* Exchange Server 2007 SP3 Security Baseline

* Exchange Server 2010 SP2 Security Baseline


Updated client product baselines include:

* Windows 7 SP1 Security Compliance Baseline

* Windows Vista SP2 Security Compliance Baseline

* Windows XP SP3 Security Compliance Baseline

* Office 2010 SP1 Security Baseline

* Internet Explorer 8 Security Compliance Baseline


SCM 2.5 enables you to quickly configure and manage your desktops and laptops, traditional data center, and private cloud using Group Policy and Microsoft System Center Configuration Manager.

Read more: Ohad Plotnik's Forefront Blog
QR: security-compliance-manager-2-5-beta-is-here.aspx

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Notification Control in Silverlight
jasper22
[info]jasper22
Password.png

Introduction

We used to see a Notification tool tip in Windows 7/Vista to inform something about particular context. For example, Capslock warning will be given through a balloon tip on Passwordbox, if capslock has ON. Or sometimes low battery information will be displayed on the Taskbar.

Read more: Codeproject
QR: Notification-Control-in-Silverlight

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Creating Cross-Platform XAML For Microsoft Developers
jasper22
[info]jasper22
With Windows 8 on the horizon and the potential for creating Metro-style applications for the desktop, crafting XAML that can be used across Windows Phone, Silverlight and the desktop is receiving greater attention. While Microsoft demoed “change a line of code and recompile” functionality late last year at BUILD, the reality is that there is typically a bit more to consider from a design and usability perspective for the user and true code reuse for the developer.

Recently, Greg Lutz of ComponentOne gave a presentation at Twin Cities – Tech Connection Live on just this topic – XAML Cubed – Developing for the Browser, Desktop and Phone.

Read more: WP MVP
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://wpmvp.com/2012/01/creating-cross-platform-xaml-for-microsoft-developers/

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories

Исходные коды кросс-платформенного фреймворка Enyo 1.0 и 2.0
jasper22
[info]jasper22
Компания HP начала выполнять обещанное и выкладывать в open source части webOS. Сегодня ночью состоялся первый подарок — JavaScript-фреймворк Enyo под лицензией Apache 2.0. Теперь это кросс-платформенный фреймворк.

Enyo отлично подходит для создания легковесных и быстрых приложений: ядро Enyo весит всего 13 КБ. На сайте Enyo есть Playground, где можно написать любой код и посмотреть, как он работает.

Скачать Enyo 2.0
Смотреть код на github

Read more: Habrahabr.ru
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://habrahabr.ru/blogs/mobiledev/137023/

Posted via email from Jasper-net

  • Leave a comment
  • Add to Memories