issue #1 save XML into the Mappings folder AND a backup copy in 'My Documents\SCJMapper"

load from Game Mappings folder all - SC and user mappings
pull/20/head
bm98 10 years ago
parent fee09048c1
commit 1a9bbdaf4d

@ -514,21 +514,16 @@ namespace SCJMapper_V2
private void tsiOpen_Click( object sender, EventArgs e )
{
if ( OFD.ShowDialog( this ) == System.Windows.Forms.DialogResult.OK ) {
using ( StreamReader istr = new StreamReader( OFD.OpenFile( ) ) ) {
rtb.Text = istr.ReadToEnd( ); // load the complete XML from the file into the textbox
btGrab.BackColor = MyColors.DirtyColor;
}
rtb.LoadFile( OFD.FileName, RichTextBoxStreamType.PlainText );
btGrab.BackColor = MyColors.DirtyColor;
}
}
private void tsiSaveAs_Click( object sender, EventArgs e )
{
if ( SFD.ShowDialog( this ) == System.Windows.Forms.DialogResult.OK ) {
using ( StreamWriter istr = new StreamWriter( SFD.OpenFile( ) ) ) {
istr.Write( rtb.Text ); // just dump the whole XML text
}
rtb.SaveFile( SFD.FileName, RichTextBoxStreamType.PlainText );
}
}
@ -592,6 +587,8 @@ namespace SCJMapper_V2
}
if ( !cancel ) {
rtb.SaveFile( SCMappings.MappingFileName( txMappingName.Text ), RichTextBoxStreamType.PlainText );
rtb.SaveFile( TheUser.MappingFileName( txMappingName.Text ), RichTextBoxStreamType.PlainText ); // backup copy
// get the new one into the list
SCMappings.UpdateMappingNames( );
LoadMappingDD( );
@ -625,13 +622,7 @@ namespace SCJMapper_V2
#endregion
}
}

@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle( "SC Joystick Mapper" )]
[assembly: AssemblyTitle( "SC Joystick Mapper V2" )]
[assembly: AssemblyDescription( "SC Joystick mapping tool" )]
[assembly: AssemblyConfiguration( "" )]
[assembly: AssemblyCompany( "Cassini (SC handle)" )]
[assembly: AssemblyProduct( "SCJMapper-V2" )]
[assembly: AssemblyProduct( "SCJMapper" )]
[assembly: AssemblyCopyright( "Copyright (c) 2014 M.Burri" )]
[assembly: AssemblyTrademark( "" )]
[assembly: AssemblyCulture( "" )]

@ -103,6 +103,7 @@
<Compile Include="SC\SCDefaultProfile.cs" />
<Compile Include="SC\SCMappings.cs" />
<Compile Include="SC\SCPath.cs" />
<Compile Include="TheUser.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace SCJMapper_V2
{
/// <summary>
/// Provides some items that are user related - packed in one place..
/// </summary>
class TheUser
{
/// <summary>
/// Returns the name of the Personal Program folder in My Documents
/// Creates the folder if needed
/// </summary>
/// <returns>Path to the Personal Program directory</returns>
static public String UserDir
{
get
{
String docPath = Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.Personal ), Application.ProductName);
if ( !Directory.Exists( docPath ) ) Directory.CreateDirectory( docPath );
return docPath;
}
}
/// <summary>
/// Returns the mapping file name + path into our user dir
/// </summary>
/// <param name="mapName">The mapping name</param>
/// <returns>A fully qualified filename</returns>
static public String MappingFileName( String mapName )
{
return Path.Combine( UserDir, mapName + ".xml" );
}
}
}
Loading…
Cancel
Save