<commit_before>﻿//Project: Hotspotizer (https://github.com/mbaytas/hotspotizer)
//File: MainWindow.xaml.cs
//Version: 20150818

using Microsoft.Kinect;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Hotspotizer.Models;
using GlblRes = Hotspotizer.Properties.Resources;
using WPFLocalizeExtension.Engine;
using System.Globalization;
using System.Threading;

namespace Hotspotizer
{
  public partial class MainWindow : Window
  {

    #region --- Fields ---

    Gesture InitGesture = new Gesture(); // Needed for Editor's data bindings to come alive

    #endregion

    #region --- Initialization ---

    public MainWindow()
    {
      Localize();

      RegisterCommands();

      GestureCollection = new ObservableCollection<Gesture>();

      InitializeComponent();

      DependencyPropertyDescriptor.FromProperty(Controls.HotspotGrid.ItemsSourceProperty, typeof(Controls.HotspotGrid)).
        AddValueChanged(FVGrid, (s, e) =>
        {
          if (SVGrid.ItemsSource != null && FVGrid.ItemsSource != null)
            SyncEditorGrids();
        });

      DependencyPropertyDescriptor.FromProperty(Controls.HotspotGrid.ItemsSourceProperty, typeof(Controls.HotspotGrid)).
        AddValueChanged(SVGrid, (s, e) =>
        {
          if (SVGrid.ItemsSource != null && FVGrid.ItemsSource != null)
            SyncEditorGrids();
        });

      //EditorTipsOverlay.Visibility = Visibility.Visible;
      EditorOverlay.Visibility = Visibility.Visible;

      // Holla Kinect
      kinect = GetKinectSensor();

      // KinectErrorStackPanel that displays errors & warnings is shown if Kinect isn't connected
      KinectErrorStackPanel.Visibility = (kinect == null)? Visibility.Visible : Visibility.Hidden;
    }

    #endregion

    #region --- Properties ---

    public ObservableCollection<Gesture> GestureCollection { get; set; } // The gesture collection and gesture we are operating on

    #endregion

    #region --- Methods ---

    private void Localize()
    {
      LocalizeDictionary.Instance.Culture = Thread.CurrentThread.CurrentCulture;

      //To force a specific culture can use the following:
      /*
      LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
      LocalizeDictionary.Instance.Culture = new CultureInfo("el");
      */
    }

    private Gesture MakeNewGesture()
    {
      return new Gesture()<commit_msg>Updated comments at "Localize" method of MainWindow.xaml.cs on how to detect available languages (from sattelite resource assemblies) and show XAML list to pick one (WpfLocalizationExtension supports applying the new language at runtime without closing/reopening the UI)<commit_after>﻿//Project: Hotspotizer (https://github.com/mbaytas/hotspotizer)
//File: MainWindow.xaml.cs
//Version: 20150821

using Microsoft.Kinect;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Hotspotizer.Models;
using GlblRes = Hotspotizer.Properties.Resources;
using WPFLocalizeExtension.Engine;
using System.Globalization;
using System.Threading;

namespace Hotspotizer
{
  public partial class MainWindow : Window
  {

    #region --- Fields ---

    Gesture InitGesture = new Gesture(); // Needed for Editor's data bindings to come alive

    #endregion

    #region --- Initialization ---

    public MainWindow()
    {
      Localize();

      RegisterCommands();

      GestureCollection = new ObservableCollection<Gesture>();

      InitializeComponent();

      DependencyPropertyDescriptor.FromProperty(Controls.HotspotGrid.ItemsSourceProperty, typeof(Controls.HotspotGrid)).
        AddValueChanged(FVGrid, (s, e) =>
        {
          if (SVGrid.ItemsSource != null && FVGrid.ItemsSource != null)
            SyncEditorGrids();
        });

      DependencyPropertyDescriptor.FromProperty(Controls.HotspotGrid.ItemsSourceProperty, typeof(Controls.HotspotGrid)).
        AddValueChanged(SVGrid, (s, e) =>
        {
          if (SVGrid.ItemsSource != null && FVGrid.ItemsSource != null)
            SyncEditorGrids();
        });

      //EditorTipsOverlay.Visibility = Visibility.Visible;
      EditorOverlay.Visibility = Visibility.Visible;

      // Holla Kinect
      kinect = GetKinectSensor();

      // KinectErrorStackPanel that displays errors & warnings is shown if Kinect isn't connected
      KinectErrorStackPanel.Visibility = (kinect == null)? Visibility.Visible : Visibility.Hidden;
    }

    #endregion

    #region --- Properties ---

    public ObservableCollection<Gesture> GestureCollection { get; set; } // The gesture collection and gesture we are operating on

    #endregion

    #region --- Methods ---

    private void Localize()
    {
      LocalizeDictionary.Instance.Culture = Thread.CurrentThread.CurrentCulture;

      //To force a specific culture can use the following:
      /*
      LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
      LocalizeDictionary.Instance.Culture = new CultureInfo("el");
      */

      //To detect and show an available languages menu for selection see:
      //http://stackoverflow.com/questions/3226974/get-all-available-cultures-from-a-resx-file-group
      //and http://stackoverflow.com/questions/14668640/wpf-localize-extension-translate-window-at-run-time/ (can get the English and the localized names from respective Culture objects)
    }

    private Gesture MakeNewGesture()
    {
      return new Gesture()
{'fraction_non_alphanumeric': 0.09882687522218273, 'fraction_numerical': 0.005510131532172059, 'mean_word_length': 3.25642965204236, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '227322', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1485, 'n_words': 374}