mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Finished create project dialog
This commit is contained in:
		
							
								
								
									
										11
									
								
								RainmeterStudio/Resources/Strings.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										11
									
								
								RainmeterStudio/Resources/Strings.Designer.cs
									
									
									
										generated
									
									
									
								
							@@ -249,6 +249,15 @@ namespace RainmeterStudio.Resources {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        ///   Looks up a localized string similar to Select project path.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        public static string CreateProjectDialog_Browse_Title {
 | 
				
			||||||
 | 
					            get {
 | 
				
			||||||
 | 
					                return ResourceManager.GetString("CreateProjectDialog_Browse_Title", resourceCulture);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///   Looks up a localized string similar to Location:.
 | 
					        ///   Looks up a localized string similar to Location:.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
@@ -277,7 +286,7 @@ namespace RainmeterStudio.Resources {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        ///   Looks up a localized string similar to Path:.
 | 
					        ///   Looks up a localized string similar to Full path:.
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public static string CreateProjectDialog_Path {
 | 
					        public static string CreateProjectDialog_Path {
 | 
				
			||||||
            get {
 | 
					            get {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -184,7 +184,7 @@
 | 
				
			|||||||
    <value>Name:</value>
 | 
					    <value>Name:</value>
 | 
				
			||||||
  </data>
 | 
					  </data>
 | 
				
			||||||
  <data name="CreateProjectDialog_Path" xml:space="preserve">
 | 
					  <data name="CreateProjectDialog_Path" xml:space="preserve">
 | 
				
			||||||
    <value>Path:</value>
 | 
					    <value>Full path:</value>
 | 
				
			||||||
  </data>
 | 
					  </data>
 | 
				
			||||||
  <data name="CreateProjectDialog_PathCreateFolder" xml:space="preserve">
 | 
					  <data name="CreateProjectDialog_PathCreateFolder" xml:space="preserve">
 | 
				
			||||||
    <value>Create directory for project</value>
 | 
					    <value>Create directory for project</value>
 | 
				
			||||||
@@ -237,4 +237,7 @@
 | 
				
			|||||||
  <data name="ProjectTemplate_EmptyProject_DisplayText" xml:space="preserve">
 | 
					  <data name="ProjectTemplate_EmptyProject_DisplayText" xml:space="preserve">
 | 
				
			||||||
    <value>Empty project</value>
 | 
					    <value>Empty project</value>
 | 
				
			||||||
  </data>
 | 
					  </data>
 | 
				
			||||||
 | 
					  <data name="CreateProjectDialog_Browse_Title" xml:space="preserve">
 | 
				
			||||||
 | 
					    <value>Select project path</value>
 | 
				
			||||||
 | 
					  </data>
 | 
				
			||||||
</root>
 | 
					</root>
 | 
				
			||||||
@@ -102,18 +102,12 @@ namespace RainmeterStudio.UI.Controller
 | 
				
			|||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Displays the 'create project' dialog and creates a new project
 | 
					        /// Displays the 'create project' dialog and creates a new project
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public void CreateProject(string name = null, string path = null)
 | 
					        public void CreateProject()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Create dialog
 | 
					            // Create dialog
 | 
				
			||||||
            var dialog = new CreateProjectDialog(this);
 | 
					            var dialog = new CreateProjectDialog(this);
 | 
				
			||||||
            dialog.Owner = OwnerWindow;
 | 
					            dialog.Owner = OwnerWindow;
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if (name != null) 
 | 
					 | 
				
			||||||
                dialog.Name = name;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            if (path != null) 
 | 
					 | 
				
			||||||
                dialog.SelectedPath = path;
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            // Display
 | 
					            // Display
 | 
				
			||||||
            bool? res = dialog.ShowDialog();
 | 
					            bool? res = dialog.ShowDialog();
 | 
				
			||||||
            if (!res.HasValue || !res.Value)
 | 
					            if (!res.HasValue || !res.Value)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,23 +59,21 @@
 | 
				
			|||||||
            <ComboBox Name="textLocation" IsEditable="True"
 | 
					            <ComboBox Name="textLocation" IsEditable="True"
 | 
				
			||||||
                      Grid.Row="1" Grid.Column="1" />
 | 
					                      Grid.Row="1" Grid.Column="1" />
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            <Button Grid.Row="1" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}"/>
 | 
					            <Button Name="buttonBrowse"
 | 
				
			||||||
 | 
					                    Grid.Row="1" Grid.Column="2" 
 | 
				
			||||||
 | 
					                    Content="{x:Static r:Strings.Dialog_Browse}"
 | 
				
			||||||
 | 
					                    Click="buttonBrowse_Click" />
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            <CheckBox Name="checkLocationDefault" 
 | 
					            <CheckBox Name="checkLocationDefault" 
 | 
				
			||||||
                      Grid.Row="1" Grid.Column="3" 
 | 
					                      Grid.Row="1" Grid.Column="3" 
 | 
				
			||||||
                      Content="{x:Static r:Strings.CreateProjectDialog_LocationDefault}" 
 | 
					                      Content="{x:Static r:Strings.CreateProjectDialog_LocationDefault}" 
 | 
				
			||||||
                      VerticalAlignment="Center"/>
 | 
					                      VerticalAlignment="Center"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <!-- Path -->
 | 
					            <!-- Path -->
 | 
				
			||||||
            <TextBlock Grid.Row="2" Text="{x:Static r:Strings.CreateProjectDialog_Path}"/>
 | 
					 | 
				
			||||||
            <TextBox Name="textPath" Grid.Row="2" Grid.Column="1" />
 | 
					 | 
				
			||||||
            <Button Grid.Row="2" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}" />
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            <CheckBox Name="checkCreateDirectory" 
 | 
					            <CheckBox Name="checkCreateDirectory" 
 | 
				
			||||||
                      Grid.Row="2" Grid.Column="3" 
 | 
					                      Grid.Row="2" Grid.Column="3" 
 | 
				
			||||||
                      Content="{x:Static r:Strings.CreateProjectDialog_PathCreateFolder}"
 | 
					                      Content="{x:Static r:Strings.CreateProjectDialog_PathCreateFolder}"
 | 
				
			||||||
                      IsChecked="{Binding Source={x:Static p:Settings.Default}, Path=CreateProjectDialog_CreateDirectoryCheckbox, Mode=TwoWay}"
 | 
					                      IsChecked="{Binding Source={x:Static p:Settings.Default}, Path=CreateProjectDialog_CreateDirectoryCheckbox, Mode=TwoWay}"
 | 
				
			||||||
                      Checked="checkCreateDirectory_CheckChanged"
 | 
					 | 
				
			||||||
                      Unchecked="checkCreateDirectory_CheckChanged"
 | 
					 | 
				
			||||||
                      VerticalAlignment="Center"/>
 | 
					                      VerticalAlignment="Center"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        </Grid>
 | 
					        </Grid>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,11 +11,13 @@ using System.Windows.Input;
 | 
				
			|||||||
using System.Windows.Media;
 | 
					using System.Windows.Media;
 | 
				
			||||||
using System.Windows.Media.Imaging;
 | 
					using System.Windows.Media.Imaging;
 | 
				
			||||||
using System.Windows.Shapes;
 | 
					using System.Windows.Shapes;
 | 
				
			||||||
 | 
					using Microsoft.Win32;
 | 
				
			||||||
using RainmeterStudio.Business;
 | 
					using RainmeterStudio.Business;
 | 
				
			||||||
using RainmeterStudio.Core.Documents;
 | 
					using RainmeterStudio.Core.Documents;
 | 
				
			||||||
using RainmeterStudio.Core.Model;
 | 
					using RainmeterStudio.Core.Model;
 | 
				
			||||||
using RainmeterStudio.Core.Utils;
 | 
					using RainmeterStudio.Core.Utils;
 | 
				
			||||||
using RainmeterStudio.Properties;
 | 
					using RainmeterStudio.Properties;
 | 
				
			||||||
 | 
					using RainmeterStudio.Resources;
 | 
				
			||||||
using RainmeterStudio.UI.Controller;
 | 
					using RainmeterStudio.UI.Controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace RainmeterStudio.UI.Dialogs
 | 
					namespace RainmeterStudio.UI.Dialogs
 | 
				
			||||||
@@ -73,18 +75,18 @@ namespace RainmeterStudio.UI.Dialogs
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
        /// Gets or sets the path
 | 
					        /// Gets the selected path
 | 
				
			||||||
        /// </summary>
 | 
					        /// </summary>
 | 
				
			||||||
        public string SelectedPath
 | 
					        public string SelectedPath
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            get
 | 
					            get
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return textPath.Text;
 | 
					                string path = SelectedLocation;
 | 
				
			||||||
            }
 | 
					
 | 
				
			||||||
            set
 | 
					                if (checkCreateDirectory.IsChecked.HasValue && checkCreateDirectory.IsChecked.Value)
 | 
				
			||||||
            {
 | 
					                    path = System.IO.Path.Combine(path, SelectedName);
 | 
				
			||||||
                textPath.Text = value;
 | 
					
 | 
				
			||||||
                _pathUserSet = true;
 | 
					                return System.IO.Path.Combine(path, SelectedName + ".rsproj");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -92,8 +94,6 @@ namespace RainmeterStudio.UI.Dialogs
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        #region Private fields
 | 
					        #region Private fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private bool _pathUserSet = false;
 | 
					 | 
				
			||||||
        private bool _ignoreNextChange = false;
 | 
					 | 
				
			||||||
        private ProjectController _projectController;
 | 
					        private ProjectController _projectController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #endregion
 | 
					        #endregion
 | 
				
			||||||
@@ -146,73 +146,20 @@ namespace RainmeterStudio.UI.Dialogs
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            bool res = true;
 | 
					            bool res = true;
 | 
				
			||||||
            res &= (listTemplates.SelectedItem != null); 
 | 
					            res &= (listTemplates.SelectedItem != null); 
 | 
				
			||||||
            res &= !String.IsNullOrWhiteSpace(textPath.Text);
 | 
					 | 
				
			||||||
            res &= PathHelper.IsPathValid(textPath.Text);
 | 
					 | 
				
			||||||
           
 | 
					           
 | 
				
			||||||
            buttonCreate.IsEnabled = res;
 | 
					            buttonCreate.IsEnabled = res;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void UpdatePath()
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (!_pathUserSet)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // Start with location
 | 
					 | 
				
			||||||
                string path = textLocation.Text;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                try
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    // Combine with project directory
 | 
					 | 
				
			||||||
                    if (checkCreateDirectory.IsChecked.HasValue && checkCreateDirectory.IsChecked.Value)
 | 
					 | 
				
			||||||
                        path = System.IO.Path.Combine(path, textName.Text);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // Combine with project file name
 | 
					 | 
				
			||||||
                    path = System.IO.Path.Combine(path, textName.Text + ".rsproj");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    // Set new value
 | 
					 | 
				
			||||||
                    _ignoreNextChange = true;
 | 
					 | 
				
			||||||
                    textPath.Text = path;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch (ArgumentException)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void textName_TextChanged(object sender, TextChangedEventArgs e)
 | 
					        private void textName_TextChanged(object sender, TextChangedEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            UpdatePath();
 | 
					            Validate();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void textLocation_TextChanged(object sender, TextChangedEventArgs e)
 | 
					        private void textLocation_TextChanged(object sender, TextChangedEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            UpdatePath();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void textPath_TextChanged(object sender, TextChangedEventArgs e)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            if (_ignoreNextChange)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _ignoreNextChange = false;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                _pathUserSet = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                try
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    textLocation.Text = System.IO.Path.GetDirectoryName(textPath.Text);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch { }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Validate();
 | 
					            Validate();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private void checkCreateDirectory_CheckChanged(object sender, RoutedEventArgs e)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            UpdatePath();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        private void listTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
 | 
					        private void listTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Validate();
 | 
					            Validate();
 | 
				
			||||||
@@ -254,5 +201,23 @@ namespace RainmeterStudio.UI.Dialogs
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void buttonBrowse_Click(object sender, RoutedEventArgs e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Show dialog
 | 
				
			||||||
 | 
					            SaveFileDialog dialog = new SaveFileDialog();
 | 
				
			||||||
 | 
					            dialog.Title = Strings.CreateProjectDialog_Browse_Title;
 | 
				
			||||||
 | 
					            dialog.AddExtension = true;
 | 
				
			||||||
 | 
					            dialog.Filter = Strings.Dialog_FileType_Project + "|*.rsproj|" + Strings.Dialog_FileType_AllFiles + "|*.*";
 | 
				
			||||||
 | 
					            dialog.InitialDirectory = SelectedLocation;
 | 
				
			||||||
 | 
					            dialog.FileName = SelectedName;
 | 
				
			||||||
 | 
					            bool? res = dialog.ShowDialog();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (res.HasValue && res.Value)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                SelectedName = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
 | 
				
			||||||
 | 
					                SelectedLocation = System.IO.Path.GetDirectoryName(dialog.FileName);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user