From 4a9fb8a89a7fc48d9d3ecc9f24770c472834453d Mon Sep 17 00:00:00 2001 From: Victoria Plitt Date: Sun, 7 Apr 2019 16:14:48 +0300 Subject: added code to launch dynamically dialogs during run time, correct styles treeview item --- .../Tango.Scripting.IDE/Dialogs/AddNewControl.xaml | 132 ------------------- .../Dialogs/AddNewControl.xaml.cs | 29 ----- .../Dialogs/AddProjectView.xaml | 131 +++++++++++++++++++ .../Dialogs/AddProjectView.xaml.cs | 28 +++++ .../Dialogs/AddProjectViewVM.cs | 18 +++ .../Dialogs/BaseProjectDialogVM.cs | 96 ++++++++++++++ .../Dialogs/CommonOpenFileDialog.cs | 7 ++ .../Dialogs/NewProjectDialog.xaml | 35 ------ .../Dialogs/NewProjectDialog.xaml.cs | 62 --------- .../Dialogs/NewProjectDialogVM.cs | 95 -------------- .../Dialogs/NewProjectView.xaml | 139 +++++++++++++++++++++ .../Dialogs/NewProjectView.xaml.cs | 29 +++++ .../Dialogs/NewProjectViewVM.cs | 59 +++++++++ 13 files changed, 507 insertions(+), 353 deletions(-) delete mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddNewControl.xaml delete mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddNewControl.xaml.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/CommonOpenFileDialog.cs delete mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml delete mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml.cs delete mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialogVM.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs create mode 100644 Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs (limited to 'Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs') diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddNewControl.xaml b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddNewControl.xaml deleted file mode 100644 index e49925dad..000000000 --- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddNewControl.xaml +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name: - - - - - - - + + + + + diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectView.xaml.cs new file mode 100644 index 000000000..83856f4e7 --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.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 +{ + /// + /// Interaction logic for AddProjectControl.xaml + /// + public partial class AddProjectView : UserControl + { + public AddProjectView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/AddProjectViewVM.cs new file mode 100644 index 000000000..2d636a6d5 --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.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/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs new file mode 100644 index 000000000..5f2ebcb15 --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/BaseProjectDialogVM.cs @@ -0,0 +1,96 @@ +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 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(); } + } + private String _projectLocation; + public String ProjectLocation + { + get { return _projectLocation; } + set { _projectLocation = value; RaisePropertyChangedAuto(); } + } + #endregion + #region constructor + public BaseProjectDialogVM() : base() + { + ProjectTypes = new ObservableCollection(); + RegisterProjectType(new StubProjectType()); + RegisterProjectType(new UnitTestProjectType()); + + _selectedProjectType = ProjectTypes.FirstOrDefault(); + + string workingDirectory = Environment.CurrentDirectory; + ProjectLocation = Directory.GetParent(workingDirectory).Parent.Parent.FullName; + + CanClose = true; + CloseCommand = new RelayCommand(Cancel, (x) => CanClose); + OKCommand = new RelayCommand(Accept, (x) => CanClose); + } + #endregion + #region commands + + #endregion + #region register_project_types + public void RegisterProjectType(IProjectType projectType) + { + ProjectTypes.Add(projectType); + } + + public void UnRegisterProjectItemHandler(IProjectType projectType) + { + ProjectTypes.Remove(projectType); + } + #endregion + } +} diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/CommonOpenFileDialog.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/CommonOpenFileDialog.cs new file mode 100644 index 000000000..6664e2d9c --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/CommonOpenFileDialog.cs @@ -0,0 +1,7 @@ +namespace Tango.Scripting.IDE.Dialogs +{ + //internal class CommonOpenFileDialog + //{ + // public string InitialDirectory { get; internal set; } + //} +} \ No newline at end of file diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml deleted file mode 100644 index 914740ede..000000000 --- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml.cs deleted file mode 100644 index 24c9511e7..000000000 --- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialog.xaml.cs +++ /dev/null @@ -1,62 +0,0 @@ - -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 -{ - /// - /// Interaction logic for NewProjectDialog.xaml - /// - public partial class NewProjectDialog : Window - { - static string _sAddNewProjectTitle = "Add New Project"; - static string _sNewProjectTitle = "New Project"; - protected bool _bNewProject; - - - public NewProjectDialog(bool bNewProject) - { - _bNewProject = bNewProject; - - InitializeComponent(); - Title = bNewProject ? _sAddNewProjectTitle : _sNewProjectTitle; - Loaded += DialogLoaded; - - - } - private void DialogLoaded(object sender, RoutedEventArgs e) - { - if (AddNewControl.DataContext is NewProjectDialogVM) - { - (AddNewControl.DataContext as NewProjectDialogVM).IsNewSolutionDialog = _bNewProject; - } - } - - private void CancelDialog(object sender, RoutedEventArgs e) - { - // Dialog box canceled - DialogResult = false; - } - - private void OKDialog(object sender, RoutedEventArgs e) - { - // Don't accept the dialog box if there is invalid data - // if (!IsValid(this)) return; - - // Dialog box accepted - DialogResult = true; - } - } -} diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialogVM.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialogVM.cs deleted file mode 100644 index 1dd0e3205..000000000 --- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectDialogVM.cs +++ /dev/null @@ -1,95 +0,0 @@ -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.Scripting.IDE.ProjectTypes; -using Tango.SharedUI; - -namespace Tango.Scripting.IDE.Dialogs -{ - public class NewProjectDialogVM : DialogViewVM - { - public ObservableCollection ProjectTypes { get; set; } - public List Locations { 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(); } - } - private String _projectLocation; - public String ProjectLocation - { - get { return _projectLocation; } - set { _projectLocation = value; RaisePropertyChangedAuto(); } - } - - private String _solutionName = "App1"; - public String SolutionName - { - get { return _solutionName; } - set { _solutionName = value; RaisePropertyChangedAuto(); } - } - - bool _isNewSolutionDialog = false; - public bool IsNewSolutionDialog { get { return _isNewSolutionDialog; } set { _isNewSolutionDialog = value; RaisePropertyChangedAuto(); } } - public NewProjectDialogVM() : base() - { - ProjectTypes = new ObservableCollection(); - RegisterProjectType(new StubProjectType()); - RegisterProjectType(new UnitTestProjectType()); - - _selectedProjectType = ProjectTypes.FirstOrDefault(); - - string workingDirectory = Environment.CurrentDirectory; - _projectLocation = Directory.GetParent(workingDirectory).Parent.Parent.FullName; - - Locations = new List(); - Locations.Add(_projectLocation); - - } - public void RegisterProjectType(IProjectType projectType) - { - ProjectTypes.Add(projectType); - } - - public void UnRegisterProjectItemHandler(IProjectType projectType) - { - ProjectTypes.Remove(projectType); - } - } -} diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml new file mode 100644 index 000000000..20a334f3b --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name: + + + + + + + + + + + + diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectView.xaml.cs new file mode 100644 index 000000000..5221146d8 --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.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 +{ + /// + /// Interaction logic for AddNewControl.xaml + /// + public partial class NewProjectView : UserControl + { + public NewProjectView() + { + InitializeComponent(); + } + + } +} diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs new file mode 100644 index 000000000..4b656c98c --- /dev/null +++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.IDE/Dialogs/NewProjectViewVM.cs @@ -0,0 +1,59 @@ +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 + { + + static public ObservableCollection Locations { get; set; } = new ObservableCollection(); + + private String _solutionName = "App1"; + public String SolutionName + { + get { return _solutionName; } + set { _solutionName = value; RaisePropertyChangedAuto(); } + } + #region Commands + public RelayCommand BrowseFileCommand { get; set; } + #endregion + public NewProjectViewVM() : base() + { + Title = "New Project"; + + if(Locations.IndexOf(ProjectLocation) < 0) + { + Locations.Add(ProjectLocation); + } + BrowseFileCommand = new RelayCommand(BrowseFile); + } + private void BrowseFile() + { + CommonOpenFileDialog dialog = new CommonOpenFileDialog(); + dialog.InitialDirectory = Locations.LastOrDefault(); + dialog.IsFolderPicker = true; + if (dialog.ShowDialog() == CommonFileDialogResult.Ok) + { + if( Directory.Exists(dialog.FileName) == true) + { + if(false == Locations.Contains(dialog.FileName)) + { + Locations.Add(dialog.FileName); + } + ProjectLocation = dialog.FileName; + } + } + } + } +} -- cgit v1.3.1