Click here to Skip to main content
15,895,142 members
Articles / Desktop Programming / WPF

LocBaml + MsBuild + ClickOnce Deployment

Rate me:
Please Sign up or sign in to vote.
4.64/5 (7 votes)
19 Mar 2010CPOL6 min read 73.3K   802   39  
How to integrate LOCBAML with MSBuild to create a WPF ClickOnce deployment package
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;


namespace WpfLocalize
{
  /// <summary>
  /// Interaction logic for Login.xaml
  /// </summary>
  public partial class DialogLogin : Window
  {
    public string User { get; set; }
    public string Password { get; set; }
    public bool IsLanguageChange { get; set; }

    public DialogLogin()
    {
      InitializeComponent();
      IsLanguageChange= false;
      tbUser.Text     = "Login";
      tbPass.Password = "Login";
      label1.Content  = FindResource("LoginExample");
    }

    private void btCancel_Click( object sender, RoutedEventArgs e )
    {
      DialogResult = false;
      Close();
    }

    private void btLogin_Click( object sender, RoutedEventArgs eventArgs )
    {
      User      = tbUser.Text;
      Password  = tbPass.Password;

      // We accept all your answers
      btLogin.IsEnabled = false;
      DialogResult      = true;
      Close();
    }

    private void tbUser_TextChanged( object sender, TextChangedEventArgs e )
    {
      if( ( string.IsNullOrEmpty( tbUser.Text ) == true ) ||
          ( string.IsNullOrEmpty( tbPass.Password ) == true ) )
      {
        btLogin.IsEnabled = false;
      }
      else
      {
        btLogin.IsEnabled = true;
      }
    }

    private void tbPass_PasswordChanged( object sender, RoutedEventArgs e )
    {
      if ( ( string.IsNullOrEmpty( tbUser.Text ) == true ) ||
           ( string.IsNullOrEmpty( tbPass.Password ) == true ) )
      {
        btLogin.IsEnabled = false;
      }
      else
      {
        btLogin.IsEnabled = true;
      }
    }

    private void btGb_MouseDown( object sender, MouseButtonEventArgs e )
    {
      Image img = sender as Image;
      if (( img != null ) && ( img.Tag != null))
      {
        Thread.CurrentThread.CurrentUICulture = new CultureInfo( (string)img.Tag );
        Thread.CurrentThread.CurrentCulture = new CultureInfo( (string)img.Tag );

        // Reload all the merged dictionaries to reset the resources.
        List<Uri> dictionaryList = new List<Uri>();
        foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)
        {
          dictionaryList.Add(dictionary.Source); 
        }
        Application.Current.Resources.MergedDictionaries.Clear();
        foreach (Uri uri in dictionaryList)
        {
          ResourceDictionary resourceDictionary1 = new ResourceDictionary();
          resourceDictionary1.Source = uri;
          Application.Current.Resources.MergedDictionaries.Add( resourceDictionary1 );
        }
 
        IsLanguageChange = true;
        DialogResult = false;
        Close();
      }
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Eclectic (www.eclectic.nl)
Netherlands Netherlands
I am software developer working with microsoft technologies for the last 20 years. Seen almost all versions of DOS and windows and programming in Assembly, C / C++ / C# and VB.NET. Currently focussing completely on everything .NET.

Comments and Discussions