diff options
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs')
7 files changed, 521 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml new file mode 100644 index 000000000..1df26b2e6 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml @@ -0,0 +1,130 @@ +<UserControl x:Class="Tango.Scripting.IDE.Dialogs.AddProjectView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.Scripting.IDE.Dialogs" + mc:Ignorable="d" + xmlns:global="clr-namespace:Tango.Scripting.IDE" + Width="800" Height="450" + d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=local:NewProjectViewVM, IsDesignTimeCreatable=False}"> + <UserControl.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="/Tango.Scripting.IDE;component/Themes/DarkThemesColors.xaml"/> + <ResourceDictionary Source="/Tango.Scripting.IDE;component/Themes/Shared.xaml"/> + </ResourceDictionary.MergedDictionaries> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + </Style> + <Style TargetType="TextBox"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + <Setter Property="Background" Value="{DynamicResource ListBorder}" /> + <Setter Property="BorderThickness" Value="1"/> + <Setter Property="BorderBrush" Value="{DynamicResource ListBorder}"/> + </Style> + + <Style TargetType="Label"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + </Style> + <BooleanToVisibilityConverter x:Key="BoolToVis" /> + </ResourceDictionary> + </UserControl.Resources> + <Grid x:Name="Main_NewProject_grid" Background="{DynamicResource Window.Background}" > + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="240"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="*"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="40"/> + </Grid.RowDefinitions> + <Border Background="{DynamicResource Background.Static}" BorderThickness="0" Grid.Column="0" Grid.Row="0" > + <Border BorderThickness="0" Margin="5" Background="{DynamicResource Window.Background}"> + <ListView x:Name="ProjectTypes" ItemsSource="{Binding ProjectTypes}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectedItem="{Binding SelectedProjectType,Mode=TwoWay}" BorderBrush="Transparent" IsSynchronizedWithCurrentItem="True"> + <ListView.ItemTemplate> + <DataTemplate> + <Border Padding="2"> + <WrapPanel> + <Image Stretch="Fill" Height="30" Source="{Binding Path=SmallImage}"/> + <TextBlock Text="{Binding Name}" Margin="20,5,0,0" Foreground="{DynamicResource ControlTextBrush}"/> + </WrapPanel> + </Border> + </DataTemplate> + </ListView.ItemTemplate> + <ListView.Resources> + <Style TargetType="{x:Type ListViewItem}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ListViewItem}"> + <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"> + <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> + </Border> + <ControlTemplate.Triggers> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="Selector.IsSelectionActive" Value="False" /> + <Condition Property="IsSelected" Value="True" /> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBrushColorKey}" /> + </MultiTrigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="Selector.IsSelectionActive" Value="True" /> + <Condition Property="IsSelected" Value="True" /> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBrushColorKey}" /> + </MultiTrigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </ListView.Resources> + </ListView> + </Border> + </Border> + <Grid x:Name="ProjectImage" Grid.Column="1" Grid.Row="0" Background="{DynamicResource Background.Static}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" MinHeight="40"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <TextBlock Grid.Row="0" Text="{Binding SelectedDescription}" Margin="10" TextWrapping="Wrap"/> + <Border Grid.Row="1" BorderThickness="0"> + <Border Width="126" Height="126" VerticalAlignment="Center" HorizontalAlignment="Center"> + <Image Stretch="Uniform" Source="{Binding Path=LargeImage}" + VerticalAlignment="Center" + HorizontalAlignment="Center" /> + </Border> + </Border> + </Grid> + + <Border Grid.Row="1" Grid.ColumnSpan="2" Margin="10" > + <Grid x:Name="ProjectNameGrid" Grid.Row="1" Grid.ColumnSpan="2"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="110"/> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="240"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="24"/> + <RowDefinition Height="5"/> + <RowDefinition Height="24"/> + <RowDefinition Height="5"/> + <RowDefinition Height="24"/> + </Grid.RowDefinitions> + + <TextBlock Grid.Column="0" Grid.Row="0">Name:</TextBlock> + <TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding ProjectName}"/> + + </Grid> + </Border> + <Border Grid.Row="2" Grid.ColumnSpan="2"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" > + <Button Style="{DynamicResource TangoButtonStyle}" IsDefault="True" Width="80" Height="24" Command="{Binding OKCommand}">OK</Button> + <Button Margin="8,0,15,0" Style="{DynamicResource TangoButtonStyle}" Width="80" Height="24" Command="{Binding CloseCommand}">Cancel</Button> + </StackPanel> + </Border> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs new file mode 100644 index 000000000..83856f4e7 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +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; + +namespace Tango.Scripting.IDE.Dialogs +{ + /// <summary> + /// Interaction logic for AddProjectControl.xaml + /// </summary> + public partial class AddProjectView : UserControl + { + public AddProjectView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs new file mode 100644 index 000000000..2d636a6d5 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.SharedUI; + +namespace Tango.Scripting.IDE.Dialogs +{ + public class AddProjectViewVM : BaseProjectDialogVM + { + public AddProjectViewVM() : base() + { + Title = "Add Project"; + //ProjectName + } + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs new file mode 100644 index 000000000..7742a3434 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs @@ -0,0 +1,107 @@ +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.Media.Imaging; +using Tango.Core.Commands; +using Tango.Scripting.IDE.ProjectTypes; +using Tango.SharedUI; + +namespace Tango.Scripting.IDE.Dialogs +{ + public class BaseProjectDialogVM : IDEDialogViewModel + { + #region properties + + public ObservableCollection<IProjectType> ProjectTypes { get; set; } + + private IProjectType _selectedProjectType = null; + public IProjectType SelectedProjectType + { + get { return _selectedProjectType; } + set + { + _selectedProjectType = value; + RaisePropertyChangedAuto(); + RaisePropertyChanged("LargeImage"); + RaisePropertyChanged("SelectedDescription"); + } + } + private BitmapSource _defaultLargeImage = ProjectType.GetImage("Images/test.png"); + public BitmapSource LargeImage + { + get + { + if (SelectedProjectType != null) + return SelectedProjectType.LargeImage; + else return _defaultLargeImage; + } + } + public string SelectedDescription + { + get + { + if (SelectedProjectType != null) + return SelectedProjectType.Description; + return ""; + } + } + private String _projectName = "App1"; + public String ProjectName + { + get { return _projectName; } + set { _projectName = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + private String _projectLocation; + public String ProjectLocation + { + get { return _projectLocation; } + set { _projectLocation = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + #endregion + + #region constructor + + public BaseProjectDialogVM() : base() + { + ProjectTypes = new ObservableCollection<IProjectType>(); + RegisterProjectType(new StubProjectType()); + RegisterProjectType(new UnitTestProjectType()); + + _selectedProjectType = ProjectTypes.FirstOrDefault(); + + string workingDirectory = Environment.CurrentDirectory; + ProjectLocation = Directory.GetParent(workingDirectory).Parent.Parent.FullName; + } + + #endregion + + #region register_project_types + + public void RegisterProjectType(IProjectType projectType) + { + ProjectTypes.Add(projectType); + } + + public void UnRegisterProjectItemHandler(IProjectType projectType) + { + ProjectTypes.Remove(projectType); + } + + #endregion + + #region Override Methods + + protected override bool CanOK() + { + return !String.IsNullOrWhiteSpace(ProjectLocation) && !String.IsNullOrWhiteSpace(ProjectName); + } + + #endregion + + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml new file mode 100644 index 000000000..2a6842745 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml @@ -0,0 +1,139 @@ +<UserControl x:Class="Tango.Scripting.IDE.Dialogs.NewProjectView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Tango.Scripting.IDE.Dialogs" + mc:Ignorable="d" + xmlns:global="clr-namespace:Tango.Scripting.IDE" + d:DesignHeight="450" d:DesignWidth="800" + Width="800" Height="450" + > + <UserControl.Resources> + <ResourceDictionary> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="/Tango.Scripting.IDE;component/Themes/DarkThemesColors.xaml"/> + <ResourceDictionary Source="/Tango.Scripting.IDE;component/Themes/Shared.xaml"/> + </ResourceDictionary.MergedDictionaries> + <Style TargetType="TextBlock"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + </Style> + <Style TargetType="TextBox"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + <Setter Property="Background" Value="{DynamicResource ListBorder}" /> + <Setter Property="BorderThickness" Value="1"/> + <Setter Property="BorderBrush" Value="{DynamicResource ListBorder}"/> + </Style> + + <Style TargetType="Label"> + <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}" /> + </Style> + <BooleanToVisibilityConverter x:Key="BoolToVis" /> + </ResourceDictionary> + </UserControl.Resources> + <Grid Background="{DynamicResource Window.Background}"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="240"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="*"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="40"/> + </Grid.RowDefinitions> + <Border Background="{DynamicResource Background.Static}" BorderThickness="0" Grid.Column="0" Grid.Row="0" > + <Border BorderThickness="0" Margin="5" Background="{DynamicResource Window.Background}"> + <ListView x:Name="ProjectTypes" ItemsSource="{Binding ProjectTypes}" Background="Transparent" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectedItem="{Binding SelectedProjectType,Mode=TwoWay}" BorderBrush="Transparent" IsSynchronizedWithCurrentItem="True"> + <ListView.ItemTemplate> + <DataTemplate> + <Border Padding="2"> + <WrapPanel> + <Image Stretch="Fill" Height="30" Source="{Binding Path=SmallImage}"/> + <TextBlock Text="{Binding Name}" Margin="20,5,0,0" Foreground="{DynamicResource ControlTextBrush}"/> + </WrapPanel> + </Border> + </DataTemplate> + </ListView.ItemTemplate> + <ListView.Resources> + <Style TargetType="{x:Type ListViewItem}"> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type ListViewItem}"> + <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true"> + <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> + </Border> + <ControlTemplate.Triggers> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="Selector.IsSelectionActive" Value="False" /> + <Condition Property="IsSelected" Value="True" /> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBrushColorKey}" /> + </MultiTrigger> + <MultiTrigger> + <MultiTrigger.Conditions> + <Condition Property="Selector.IsSelectionActive" Value="True" /> + <Condition Property="IsSelected" Value="True" /> + </MultiTrigger.Conditions> + <Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBrushColorKey}" /> + </MultiTrigger> + </ControlTemplate.Triggers> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + </ListView.Resources> + </ListView> + </Border> + </Border> + <Grid x:Name="ProjectImage" Grid.Column="1" Grid.Row="0" Background="{DynamicResource Background.Static}"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" MinHeight="40"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <TextBlock Grid.Row="0" Text="{Binding SelectedDescription}" Margin="10" TextWrapping="Wrap"/> + <Border Grid.Row="1" BorderThickness="0"> + <Border Width="126" Height="126" VerticalAlignment="Center" HorizontalAlignment="Center"> + <Image Stretch="Uniform" Source="{Binding Path=LargeImage}" + VerticalAlignment="Center" + HorizontalAlignment="Center" /> + </Border> + </Border> + </Grid> + + <Border Grid.Row="1" Grid.ColumnSpan="2" Margin="10" > + <Grid x:Name="ProjectNameGrid" Grid.Row="1" Grid.ColumnSpan="2"> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="110"/> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="240"/> + </Grid.ColumnDefinitions> + <Grid.RowDefinitions> + <RowDefinition Height="24"/> + <RowDefinition Height="5"/> + <RowDefinition Height="24"/> + <RowDefinition Height="5"/> + <RowDefinition Height="24"/> + </Grid.RowDefinitions> + + <TextBlock Grid.Column="0" Grid.Row="0">Name:</TextBlock> + <TextBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" Text="{Binding ProjectName,UpdateSourceTrigger=PropertyChanged}"/> + + <TextBlock Grid.Column="0" Grid.Row="2" Text="Location"/> + <Border Background="{DynamicResource ListBorder}" Grid.Column="1" Grid.Row="2" Margin="0,2,0,2" BorderBrush="{DynamicResource Button.Static.Border}" > + <ComboBox Style="{DynamicResource TangoComboboxStyle}" VerticalAlignment="Stretch" SelectedItem="{Binding ProjectLocation}" ItemsSource="{Binding LastSolutionPaths}" HorizontalAlignment="Stretch" BorderBrush="Transparent"/> + </Border> + <Button Style="{DynamicResource TangoButtonStyle}" Grid.Column="2" Grid.Row="2" Width="80" HorizontalAlignment="Left" Margin="20,0,0,0" Content="Browse..." Command="{Binding BrowseFileCommand}"/> + <TextBlock Grid.Column="0" Grid.Row="4" Text="Solution name:"/> + <TextBox Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" Text="{Binding SolutionName,UpdateSourceTrigger=PropertyChanged}" /> + + </Grid> + </Border> + <Border Grid.Row="2" Grid.ColumnSpan="2"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" > + <Button Style="{DynamicResource TangoButtonStyle}" IsDefault="True" Width="80" Height="24" Command="{Binding OKCommand}">OK</Button> + <Button Margin="8,0,15,0" Style="{DynamicResource TangoButtonStyle}" Width="80" Height="24" Command="{Binding CloseCommand}">Cancel</Button> + </StackPanel> + </Border> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs new file mode 100644 index 000000000..5221146d8 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +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; + +namespace Tango.Scripting.IDE.Dialogs +{ + /// <summary> + /// Interaction logic for AddNewControl.xaml + /// </summary> + public partial class NewProjectView : UserControl + { + public NewProjectView() + { + InitializeComponent(); + } + + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs new file mode 100644 index 000000000..69cf8034e --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs @@ -0,0 +1,70 @@ +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.Media.Imaging; +using Tango.Core.Commands; +using Tango.Scripting.IDE.ProjectTypes; +using Tango.SharedUI; +using Microsoft.WindowsAPICodePack.Dialogs; +using Microsoft.Win32; + +namespace Tango.Scripting.IDE.Dialogs +{ + public class NewProjectViewVM : BaseProjectDialogVM + { + /// <summary> + /// Gets or sets the last solution locations. + /// </summary> + public ObservableCollection<String> LastSolutionPaths { get; set; } + + private String _solutionName = "App1"; + public String SolutionName + { + get { return _solutionName; } + set { _solutionName = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + } + + #region Commands + public RelayCommand BrowseFileCommand { get; set; } + #endregion + + public NewProjectViewVM() : base() + { + Title = "New Project"; + BrowseFileCommand = new RelayCommand(BrowseFile); + } + + public NewProjectViewVM(IEnumerable<String> lastSolutionFolders) : this() + { + LastSolutionPaths = new ObservableCollection<string>(lastSolutionFolders); + ProjectLocation = LastSolutionPaths.FirstOrDefault(); + } + + private void BrowseFile() + { + CommonOpenFileDialog dialog = new CommonOpenFileDialog(); + dialog.InitialDirectory = LastSolutionPaths.LastOrDefault<string>(); + dialog.IsFolderPicker = true; + if (dialog.ShowDialog() == CommonFileDialogResult.Ok) + { + if (Directory.Exists(dialog.FileName) == true) + { + if (false == LastSolutionPaths.Contains(dialog.FileName)) + { + LastSolutionPaths.Add(dialog.FileName); + } + ProjectLocation = dialog.FileName; + } + } + } + + protected override bool CanOK() + { + return base.CanOK() && !String.IsNullOrWhiteSpace(SolutionName); + } + } +} |
