diff options
Diffstat (limited to 'Software/Visual_Studio')
21 files changed, 380 insertions, 88 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs index 2d636a6d5..d6fb870d6 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs @@ -9,10 +9,10 @@ namespace Tango.Scripting.IDE.Dialogs { public class AddProjectViewVM : BaseProjectDialogVM { - public AddProjectViewVM() : base() + public AddProjectViewVM(List<IProjectType> projectTypes) : base(projectTypes) { Title = "Add Project"; - //ProjectName + //Project location } } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs index 7742a3434..631aaaed3 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs @@ -61,39 +61,25 @@ namespace Tango.Scripting.IDE.Dialogs get { return _projectLocation; } set { _projectLocation = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } - + public String GetFullProjectPath() + { + StringBuilder builder = new StringBuilder(ProjectLocation); + builder.AppendFormat(@"{0}\{1}", ProjectLocation, ProjectName); + return builder.ToString(); + } #endregion #region constructor - public BaseProjectDialogVM() : base() + public BaseProjectDialogVM(List<IProjectType> project_types) : base() { ProjectTypes = new ObservableCollection<IProjectType>(); - RegisterProjectType(new StubProjectType()); - RegisterProjectType(new UnitTestProjectType()); - + project_types.ForEach(ProjectTypes.Add); _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() diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs index 69cf8034e..98558c7dc 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs @@ -32,13 +32,13 @@ namespace Tango.Scripting.IDE.Dialogs public RelayCommand BrowseFileCommand { get; set; } #endregion - public NewProjectViewVM() : base() + public NewProjectViewVM(List<IProjectType> projectTypes) : base(projectTypes) { Title = "New Project"; BrowseFileCommand = new RelayCommand(BrowseFile); } - public NewProjectViewVM(IEnumerable<String> lastSolutionFolders) : this() + public NewProjectViewVM(IEnumerable<String> lastSolutionFolders, List<IProjectType> projectTypes) : this(projectTypes) { LastSolutionPaths = new ObservableCollection<string>(lastSolutionFolders); ProjectLocation = LastSolutionPaths.FirstOrDefault(); diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolution.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolution.cs new file mode 100644 index 000000000..7ad659c69 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolution.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Scripting.IDE +{ + public interface ISolution :ISolutionItem + { + ObservableCollection<IProject> Projects { get; } + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItem.cs index 74bdab066..ca499b494 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,5 +15,7 @@ namespace Tango.Scripting.IDE BitmapSource Image { get; } bool CanOpen { get; } + + ObservableCollection<ISolutionItemCommand> Commands { get; set; } } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItemCommand.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItemCommand.cs new file mode 100644 index 000000000..e427b2e3b --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ISolutionItemCommand.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using System.Windows.Media.Imaging; + +namespace Tango.Scripting.IDE +{ + public interface ISolutionItemCommand : ICommand + { + String Name { get; set; } + BitmapSource Image { get; set; } + ObservableCollection<ISolutionItemCommand> Commands { get; set; } + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/BuildSolution_16x.png b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/BuildSolution_16x.png Binary files differnew file mode 100644 index 000000000..0f289bc8a --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/BuildSolution_16x.png diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/Cut_16xSM.png b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/Cut_16xSM.png Binary files differnew file mode 100644 index 000000000..2a277a034 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/Cut_16xSM.png diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/jigsaw.png b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/jigsaw.png Binary files differnew file mode 100644 index 000000000..fd58502a2 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/jigsaw.png diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Project.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Project.cs index 5a950d2c7..9ba1ed902 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Project.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Project.cs @@ -12,13 +12,8 @@ namespace Tango.Scripting.IDE { public abstract class Project : IProject { + #region properties private static Dictionary<String, BitmapSource> _imageCache; - - static Project() - { - _imageCache = new Dictionary<string, BitmapSource>(); - } - public string FilePath { get; set; } public string WorkingFolder => Path.GetDirectoryName(FilePath); @@ -28,15 +23,83 @@ namespace Tango.Scripting.IDE public abstract BitmapSource Image { get; } public ObservableCollection<IProjectItem> Items { get; set; } + public ObservableCollection<ISolutionItemCommand> Commands { get; set; } + #endregion + #region constructors + static Project() + { + _imageCache = new Dictionary<string, BitmapSource>(); + } + public Project() { Items = new ObservableCollection<IProjectItem>(); + Commands = new ObservableCollection<ISolutionItemCommand> + { + new SolutionItemCommand(BuildProject) { Name = "Build", Image= GetImage(@"Images/BuildSolution_16x.png") }, + new SolutionItemCommand(SetStartUpProject) { Name = "Set as StartUp Project" }, + new SolutionItemCommand(Remove) { Name = "Remove" }, + new SolutionItemCommand(Rename) { Name = "Rename" }, + new SolutionItemCommand(OpenFolderInFileExplorer) { Name = "Open Folder In File Explorer" }, + new SolutionItemCommand() + { + Name = "Add...", + Commands = new ObservableCollection<ISolutionItemCommand> + { + new SolutionItemCommand(AddNewScript) { Name = "Add New Script" }, + new SolutionItemCommand(AddExistingScript) { Name = "Add Existing Script" }, + } + } + }; + } + #endregion + + + + #region Commands + private void BuildProject() + { + + } + private void SetStartUpProject() + { + + } + private void Remove() + { + + } + private void Rename() + { + + } + private void OpenFolderInFileExplorer() + { + + } + /// <summary> + /// Adds a new script file of type IProjectItem to the current project. + /// </summary> + private void AddNewScript() + { + + } + /// <summary> + /// Adds the existing script file to the current project. + /// </summary> + private void AddExistingScript() + { + } + #endregion + #region Build_Run public abstract Task Build(); public abstract Task Run(); + #endregion + #region generic_functions protected static BitmapSource GetImage(String name) { if (_imageCache.ContainsKey(name)) @@ -52,5 +115,6 @@ namespace Tango.Scripting.IDE } public bool CanOpen => false; + #endregion } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItem.cs index 8adc26dc7..d7fbd8e92 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItem.cs @@ -22,8 +22,9 @@ namespace Tango.Scripting.IDE public string Name { get; set; } public ObservableCollection<IProjectItem> Items { get; set; } + public ObservableCollection<ISolutionItemCommand> Commands { get ; set; } - public ProjectItem() + public ProjectItem():base() { Items = new ObservableCollection<IProjectItem>(); } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/CSharpScriptItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/CSharpScriptItem.cs index cf4811047..e53f90ef3 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/CSharpScriptItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/CSharpScriptItem.cs @@ -26,5 +26,37 @@ namespace Tango.Scripting.IDE.ProjectItems { return new CSharpScriptItemView(this); } + + public CSharpScriptItem() : base() + { + Commands = new System.Collections.ObjectModel.ObservableCollection<ISolutionItemCommand>() + { + new SolutionItemCommand(Open) { Name = "Open" }, + new SolutionItemCommand(CutItem) { Name = "Cut" , Image = GetImage(@"Images/Cut_16xSM.png")}, + new SolutionItemCommand(CopyItem) { Name = "Copy" }, + new SolutionItemCommand(CopyItem) { Name = "Delete" }, + new SolutionItemCommand(RenameItem) { Name = "Rename" } + }; + } + + private void Open(object obj) + { + + } + + private void RenameItem(object obj) + { + + } + + private void CutItem(object obj) + { + + } + + private void CopyItem() + { + + } } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssembliesItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssembliesItem.cs index 0e66fd241..1493d7cbc 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssembliesItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssembliesItem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -13,6 +14,10 @@ namespace Tango.Scripting.IDE.ProjectItems public ReferenceAssembliesItem() { Name = "References"; + Commands = new ObservableCollection<ISolutionItemCommand> + { + new SolutionItemCommand(AddReference) { Name = "Add Reference..." } + }; } public override BitmapSource Image => GetImage("Images/Reference.png"); @@ -23,5 +28,10 @@ namespace Tango.Scripting.IDE.ProjectItems } public override bool CanOpen => false; + + private void AddReference() + { + + } } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssemblyItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssemblyItem.cs index e9cd1e8f2..87a9f8efa 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssemblyItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ProjectItems/ReferenceAssemblyItem.cs @@ -14,6 +14,22 @@ namespace Tango.Scripting.IDE.ProjectItems public String Path { get; set; } public override BitmapSource Image => GetImage("Images/Reference.png"); + public ReferenceAssemblyItem() + { + Commands = new ObservableCollection<ISolutionItemCommand> + { + new SolutionItemCommand(Remove) { Name = "Remove" } + }; + } + /// <summary> + /// Removes the specified object from References. + /// </summary> + private void Remove(object obj) + { + throw new NotImplementedException(); + } + + public override FrameworkElement OnGetView() { return null; diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml index 67a673d3b..6f3914ec8 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml @@ -15,7 +15,17 @@ <ResourceDictionary Source="Themes/Shared.xaml"/> </ResourceDictionary.MergedDictionaries> <BooleanToVisibilityConverter x:Key="BoolToVis" /> - </ResourceDictionary> + <Style x:Key="ContentMmenuItemStyle" TargetType="MenuItem"> + <Setter Property="Command" Value="{Binding}"/> + <Setter Property="Header" Value="{Binding Name}"/> + <Setter Property="ItemsSource" Value="{Binding Commands}"/> + <Setter Property="Icon"> + <Setter.Value> + <Image Source="{Binding Image}" Height="12" Width="12"/> + </Setter.Value> + </Setter> + </Style> + </ResourceDictionary> </UserControl.Resources> <Grid Background="{DynamicResource Background.Static}"> <Grid.RowDefinitions> @@ -231,31 +241,40 @@ <RowDefinition Height="4"/> </Grid.RowDefinitions> <GroupBox Grid.Row="0" Margin="0,0,5,0" Header="Solution Explorer" BorderThickness="1" Style="{DynamicResource TangoGroupBoxStyle}" > - <TreeView Style="{DynamicResource TangoTreeViewStyle}" x:Name="SolutionTree" ItemsSource="{Binding Solution.Projects}" Background="{DynamicResource TabItem.Content.Static}" Padding="0,8,0,0" SelectedItemChanged="TreeViewControl_SelectedItemChanged" PreviewMouseRightButtonDown="SolutionTree_PreviewMouseRightButtonDown" > - <TreeView.ItemTemplate> - <HierarchicalDataTemplate ItemsSource="{Binding Path=Items}" DataType="{x:Type local:IProject}"> - <controls:SolutionItemControl SolutionItem="{Binding}" OpenCommand="{Binding ElementName=control,Path=DataContext.OpenProjectItemCommand}" /> - </HierarchicalDataTemplate> - </TreeView.ItemTemplate> - <TreeView.Resources> - <ContextMenu x:Key ="SolutionContext" StaysOpen="true" BorderBrush="{DynamicResource Background.Static}" Foreground="{DynamicResource ControlForegroundKey}"> - <MenuItem Header="Add" > - <MenuItem Header="New Project..." Command="{Binding AddProjectCommand}"/> - </MenuItem> - <MenuItem Header="Rename"/> - </ContextMenu> - <ContextMenu x:Key="FolderContext" StaysOpen="true" > - <MenuItem Header="Rename"/> - <MenuItem Header="Remove"/> - <Separator/> - <MenuItem Header="Copy"/> - <MenuItem Header="Cut"/> - <MenuItem Header="Paste"/> - <MenuItem Header="Move"/> - </ContextMenu> - </TreeView.Resources> - - </TreeView> + <StackPanel Orientation="Vertical" VerticalAlignment="Stretch" Background="{DynamicResource TabItem.Content.Static}"> + <TreeView Style="{DynamicResource TangoTreeViewStyle}" x:Name="STree" DataContext="{Binding Solution}" Background="{DynamicResource TabItem.Content.Static}" Padding="0,0,2,0" PreviewMouseRightButtonDown="SolutionTree_PreviewMouseRightButtonDown" BorderThickness="1,0,1,1" + PreviewMouseLeftButtonDown="SolutionTree_PreviewMouseLeftButtonDown"> + <TreeViewItem > + <TreeViewItem.Header> + <StackPanel Orientation="Horizontal" Margin="-12,0,0,0"> + <Image Source="/Tango.Scripting.IDE;component/Images/jigsaw.png" Height="14" /> + <TextBlock Text="{Binding Name}" Margin="5,0,0,0" Foreground="{DynamicResource ControlForegroundKey}"/> + </StackPanel> + </TreeViewItem.Header> + </TreeViewItem> + <TreeView.ContextMenu> + <ContextMenu StaysOpen="true" BorderBrush="{DynamicResource Background.Static}" Foreground="{DynamicResource ControlForegroundKey}" + ItemsSource="{Binding PlacementTarget.DataContext.Commands, RelativeSource={RelativeSource Self}}" + ItemContainerStyle="{StaticResource ContentMmenuItemStyle}"> + </ContextMenu> + </TreeView.ContextMenu> + </TreeView> + <TreeView Style="{DynamicResource TangoTreeViewStyle}" Margin="0,-1,0,0" x:Name="SolutionTree" ItemsSource="{Binding Solution.Projects}" Background="{DynamicResource TabItem.Content.Static}" Padding="0,0,2,0" PreviewMouseRightButtonDown="SolutionTree_PreviewMouseRightButtonDown" BorderThickness="1,0,1,1" PreviewMouseLeftButtonDown="SolutionTree_PreviewMouseLeftButtonDown"> + <TreeView.ItemTemplate> + <HierarchicalDataTemplate ItemsSource="{Binding Path=Items}" DataType="{x:Type local:IProject}"> + <controls:SolutionItemControl SolutionItem="{Binding}" OpenCommand="{Binding ElementName=control,Path=DataContext.OpenProjectItemCommand}" + /> + </HierarchicalDataTemplate> + </TreeView.ItemTemplate> + <TreeView.ContextMenu> + <ContextMenu StaysOpen="true" BorderBrush="{DynamicResource Background.Static}" Foreground="{DynamicResource ControlForegroundKey}" + DataContext="{Binding PlacementTarget, RelativeSource={RelativeSource Self}}" + ItemsSource="{Binding PlacementTarget.SelectedItem.Commands, RelativeSource={RelativeSource Self}}" + ItemContainerStyle="{StaticResource ContentMmenuItemStyle}"> + </ContextMenu> + </TreeView.ContextMenu> + </TreeView> + </StackPanel> </GroupBox> <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{DynamicResource Background.Static}" /> <GroupBox Grid.Row="2" Margin="0,0,5,2" Header="Properties" BorderThickness="1" Style="{DynamicResource TangoGroupBoxStyle}" > diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml.cs index 5e4509beb..0a4a05c04 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEView2.xaml.cs @@ -8,10 +8,12 @@ using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; +using System.Windows.Interactivity; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Scripting.IDE.Controls; namespace Tango.Scripting.IDE { @@ -23,6 +25,7 @@ namespace Tango.Scripting.IDE { public enum eSkin { Dark, Light } public static eSkin Skin { get; set; } + public ScriptIDEView2() { InitializeComponent(); @@ -57,31 +60,44 @@ namespace Tango.Scripting.IDE { MessageBox.Show("I am here"); } - private void TreeViewControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) - { - IProject SelectedItem = SolutionTree.SelectedItem as IProject; - if(SelectedItem != null && DataContext is ScriptIDEViewVM && ((ScriptIDEViewVM)DataContext).IsSolutionProject(SelectedItem)) + #region selection solution trees + private TreeViewItem _selectedtreeViewItem; + private TreeViewItem SelectedtreeViewItem + { + get { - SolutionTree.ContextMenu = SolutionTree.Resources["SolutionContext"] as System.Windows.Controls.ContextMenu; + return _selectedtreeViewItem; } - else + set { - SolutionTree.ContextMenu = SolutionTree.Resources["FolderContext"] as System.Windows.Controls.ContextMenu; + if (_selectedtreeViewItem != null) + { + _selectedtreeViewItem.IsSelected = false; + } + _selectedtreeViewItem = value; + _selectedtreeViewItem.IsSelected = true; } - } + } private void SolutionTree_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); - if (treeViewItem != null) { - //treeViewItem.Focus(); - treeViewItem.IsSelected = true; + SelectedtreeViewItem = treeViewItem; e.Handled = true; } } + private void SolutionTree_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); + + if (treeViewItem != null) + { + SelectedtreeViewItem = treeViewItem; + } + } static TreeViewItem VisualUpwardSearch(DependencyObject source) { while (source != null && !(source is TreeViewItem)) @@ -89,5 +105,6 @@ namespace Tango.Scripting.IDE return source as TreeViewItem; } + #endregion } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEViewVM.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEViewVM.cs index facebe061..d41de8cd1 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEViewVM.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/ScriptIDEViewVM.cs @@ -29,7 +29,16 @@ namespace Tango.Scripting.IDE public Solution Solution { get { return _solution; } - set { _solution = value; RaisePropertyChangedAuto(); } + set { + if (_solution != value) + { + if(_solution != null) + _solution.AddProjectEvent -= delegate { AddProject(); }; + _solution = value; + _solution.AddProjectEvent += delegate { AddProject(); }; + RaisePropertyChangedAuto(); + } + } } private IProject _selectedProject; @@ -89,6 +98,7 @@ namespace Tango.Scripting.IDE RegisterProjectType(new UnitTestProjectType()); Solution = new Solution(); + Solution.Name = "Test Solution"; Solution.SolutionLocation = @"C:\Test"; Solution.Projects.Add(_projectTypes.First().NewProject("Test Project.stub")); @@ -147,7 +157,7 @@ namespace Tango.Scripting.IDE /// </summary> private async void AddNewProject() { - var vm = await NotificationManager.ShowDialog<NewProjectViewVM>(new NewProjectViewVM(Settings.LastSolutionLocations)); + var vm = await NotificationManager.ShowDialog<NewProjectViewVM>(new NewProjectViewVM(Settings.LastSolutionLocations, _projectTypes)); if (vm.DialogResult) { @@ -155,9 +165,8 @@ namespace Tango.Scripting.IDE newSolution.Name = vm.SolutionName; newSolution.SolutionLocation = vm.ProjectLocation; Solution = newSolution; - StringBuilder builder = new StringBuilder(vm.ProjectLocation); - builder.AppendFormat(@"\{0}", vm.ProjectName); - Solution.Projects.Add(vm.SelectedProjectType.NewProject(builder.ToString())); + + Solution.Projects.Add(vm.SelectedProjectType.NewProject(vm.GetFullProjectPath())); Settings.LastSolutionLocations.Insert(0, vm.ProjectLocation); Settings.Save(); @@ -165,18 +174,14 @@ namespace Tango.Scripting.IDE } private async void AddProject() { - var vm = await NotificationManager.ShowDialog<AddProjectViewVM>(new AddProjectViewVM() + var vm = await NotificationManager.ShowDialog<AddProjectViewVM>(new AddProjectViewVM(_projectTypes) { ProjectLocation = Solution.SolutionLocation - //ProjectLocation = Path.GetDirectoryName(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) - //ProjectLocation = "Current Solution folder..." }); if (vm.DialogResult) { - StringBuilder builder = new StringBuilder(vm.ProjectLocation); - builder.AppendFormat(@"\{0}", vm.ProjectName); - Solution.Projects.Add(vm.SelectedProjectType.NewProject(builder.ToString())); + Solution.Projects.Add(vm.SelectedProjectType.NewProject(vm.GetFullProjectPath())); } } public bool IsSolutionProject(IProject SelectedItem) diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Solution.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Solution.cs index cd7806698..b0c192003 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Solution.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Solution.cs @@ -1,21 +1,47 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Text; +using System.IO; using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.SharedUI.Helpers; + namespace Tango.Scripting.IDE { - public class Solution + public class Solution :ISolution { public ObservableCollection<IProject> Projects { get; set; } - public string Name{get; set;} + + public string Name { get; set; } + public string SolutionLocation { get; set; } + + public string WorkingFolder => Path.GetDirectoryName(SolutionLocation); + + public BitmapSource Image => ResourceHelper.GetImageFromResources("Images/NewFileCollection_16x.png"); + + public bool CanOpen => false; + + public ObservableCollection<ISolutionItemCommand> Commands { get; set; } + + public event EventHandler AddProjectEvent; public Solution() { + Name = "Solution"; Projects = new ObservableCollection<IProject>(); + Commands = new ObservableCollection<ISolutionItemCommand> + { + new SolutionItemCommand(AddProject) { Name = "Add New Project..." } + }; + } + /// <summary> + /// Adds Project Dialog. + /// </summary> + public void AddProject() + { + AddProjectEvent?.Invoke(this, new EventArgs()); } } } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/SolutionItemCommand.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/SolutionItemCommand.cs new file mode 100644 index 000000000..c6627d354 --- /dev/null +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/SolutionItemCommand.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media.Imaging; +using Tango.Core.Commands; + +namespace Tango.Scripting.IDE +{ + public class SolutionItemCommand : RelayCommand, ISolutionItemCommand + { + public SolutionItemCommand() : base(()=> { }) + { + Init(); + } + public SolutionItemCommand(Action<object> action) : base(action) + { + Init(); + } + + public SolutionItemCommand(Action action) : base(action) + { + Init(); + } + + public SolutionItemCommand(Action<object> action, Func<object, bool> canExecute) : base(action, canExecute) + { + Init(); + } + + public SolutionItemCommand(Action<object> action, Func<bool> canExecute) : base(action, canExecute) + { + Init(); + } + + public SolutionItemCommand(Action action, Func<object, bool> canExecute) : base(action, canExecute) + { + Init(); + } + + public SolutionItemCommand(Action action, Func<bool> canExecute) : base(action, canExecute) + { + Init(); + } + + private void Init() + { + Commands = new ObservableCollection<ISolutionItemCommand>(); + } + + public String Name { get; set; } + BitmapSource _bImage; + public BitmapSource Image { + get + { + return _bImage; + } + set + { + _bImage = value; + } + } + public ObservableCollection<ISolutionItemCommand> Commands { get; set; } + + } +} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Tango.Scripting.IDE.csproj b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Tango.Scripting.IDE.csproj index 9fac7041d..194f49ea8 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Tango.Scripting.IDE.csproj +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Tango.Scripting.IDE.csproj @@ -88,6 +88,8 @@ <Compile Include="IDEDialogViewModel.cs" /> <Compile Include="IDESettings.cs" /> <Compile Include="IDEViewModel.cs" /> + <Compile Include="ISolution.cs" /> + <Compile Include="ISolutionItemCommand.cs" /> <Compile Include="IProjectType.cs" /> <Compile Include="ISolutionItem.cs" /> <Compile Include="Notifications\DefaultNotificationManager.cs" /> @@ -117,6 +119,7 @@ <Compile Include="ScriptIDEViewVM.cs" /> <Compile Include="Solution.cs" /> <Compile Include="Projects\StubProject.cs" /> + <Compile Include="SolutionItemCommand.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="Windows\DialogWindow.xaml.cs"> <DependentUpon>DialogWindow.xaml</DependentUpon> @@ -257,7 +260,9 @@ <ItemGroup> <Resource Include="Images\StubProject.png" /> </ItemGroup> - <ItemGroup /> + <ItemGroup> + <Resource Include="Images\BuildSolution_16x.png" /> + </ItemGroup> <ItemGroup> <Resource Include="Images\Save_16x.png" /> </ItemGroup> @@ -304,5 +309,11 @@ <ItemGroup> <Resource Include="Images\Pause_16x.png" /> </ItemGroup> + <ItemGroup> + <Resource Include="Images\Cut_16xSM.png" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Images\jigsaw.png" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/TreeViewItem.xaml b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/TreeViewItem.xaml index f76c133d6..233c0c9da 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/TreeViewItem.xaml +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/TreeViewItem.xaml @@ -6,7 +6,7 @@ <Setter Property="Background" Value="{DynamicResource TreeBackgroundColor}"/> <Setter Property="BorderBrush" Value="{DynamicResource ListBorder}"/> <Setter Property="BorderThickness" Value="1"/> - <Setter Property="Padding" Value="1"/> + <Setter Property="Padding" Value="1,0,1,1"/> <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> @@ -102,6 +102,7 @@ <Setter Property="Padding" Value="4,0,0,0"/> <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}"/> <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/> + <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TreeViewItem}"> |
