using MahApps.Metro.Controls;
using Microsoft.WindowsAPICodePack.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Core.Commands;
using Tango.Protobuf.Compilers;
namespace Tango.Protobuf.UI
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : MetroWindow
{
private String _sourceFolder;
private CompilerFolderResult _lastFolderResult;
public RelayCommand LoadFileCommand { get; set; }
public RelayCommand LoadFolderCommand { get; set; }
public RelayCommand CompileCommand { get; set; }
public RelayCommand SaveCommand { get; set; }
public List SourceItems
{
get { return (List)GetValue(SourceItemsProperty); }
set { SetValue(SourceItemsProperty, value); }
}
public static readonly DependencyProperty SourceItemsProperty =
DependencyProperty.Register("SourceItems", typeof(List), typeof(MainWindow), new PropertyMetadata(null));
public String CurrentContent
{
get { return (String)GetValue(CurrentContentProperty); }
set { SetValue(CurrentContentProperty, value); }
}
public static readonly DependencyProperty CurrentContentProperty =
DependencyProperty.Register("CurrentContent", typeof(String), typeof(MainWindow), new PropertyMetadata(null));
public List TargetItems
{
get { return (List)GetValue(TargetItemsProperty); }
set { SetValue(TargetItemsProperty, value); }
}
public static readonly DependencyProperty TargetItemsProperty =
DependencyProperty.Register("TargetItems", typeof(List), typeof(MainWindow), new PropertyMetadata(null));
public CompilerLanguage CompilerLanguage
{
get { return (CompilerLanguage)GetValue(CompilerLanguageProperty); }
set { SetValue(CompilerLanguageProperty, value); }
}
public static readonly DependencyProperty CompilerLanguageProperty =
DependencyProperty.Register("CompilerLanguage", typeof(CompilerLanguage), typeof(MainWindow), new PropertyMetadata(CompilerLanguage.CSharp));
public MainWindow()
{
SourceItems = new List();
TargetItems = new List();
LoadFileCommand = new RelayCommand(LoadFile);
LoadFolderCommand = new RelayCommand(LoadFolder);
CompileCommand = new RelayCommand(Compile);
SaveCommand = new RelayCommand(Save);
InitializeComponent();
}
private void LoadFolder()
{
var dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
_sourceFolder = dialog.FileName;
SourceItems = ItemProvider.GetItems(_sourceFolder);
}
}
private void LoadFile()
{
throw new NotImplementedException();
}
private void Source_TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs