1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-08-09 20:25:24 +00:00

Load a hard-coded project file

Fixed some stuff that crashed.  The project is loaded but nothing
visually interesting happens yet.

I'm still not entirely sure what the deal with declaring resources
is, but it seems you can either declare a ResourceDictionary and put
everything in it, or you can declare a bunch of items, which are then
implicitly placed in a ResourceDictionary.  This matters if you want
to have your string definitions merged in with everything else.  All
of the examples I found did one thing or the other, not both at once,
so it took some fiddling.  Yay WPF.
This commit is contained in:
Andy McFadden
2019-05-08 18:00:17 -07:00
parent ce27ae720e
commit bf310d17bc
8 changed files with 26 additions and 13 deletions

View File

@@ -19,9 +19,9 @@ limitations under the License.
xmlns:local="clr-namespace:SourceGenWPF" xmlns:local="clr-namespace:SourceGenWPF"
StartupUri="ProjWin/MainWindow.xaml"> StartupUri="ProjWin/MainWindow.xaml">
<Application.Resources> <Application.Resources>
<FontFamily x:Key="GeneralMonoFont">Consolas</FontFamily> <ResourceDictionary>
<FontFamily x:Key="GeneralMonoFont">Consolas</FontFamily>
<ResourceDictionary x:Key="whatever">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Res/Strings.xaml"/> <ResourceDictionary Source="Res/Strings.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

View File

@@ -202,6 +202,12 @@ namespace SourceGenWPF {
switch (mIdentLocation) { switch (mIdentLocation) {
case Location.RuntimeDir: case Location.RuntimeDir:
dir = RuntimeDataAccess.GetDirectory(); dir = RuntimeDataAccess.GetDirectory();
if (string.IsNullOrEmpty(dir)) {
// Could happen if we can't find the runtime data directory, though
// we probably should've failed before now.
Debug.Assert(false);
return null;
}
subdirAllowed = true; subdirAllowed = true;
break; break;
case Location.ProjectDir: case Location.ProjectDir:

View File

@@ -184,9 +184,10 @@ namespace SourceGenWPF {
public void OpenRecentProject(int projIndex) { public void OpenRecentProject(int projIndex) {
//if (DoClose()) { if (DoClose()) {
// DoOpenFile(mRecentProjectPaths[projIndex]); //DoOpenFile(mRecentProjectPaths[projIndex]);
//} DoOpenFile(@"C:\Src\6502bench\EXTRA\ZIPPY#ff2000.dis65");
}
} }
/// <summary> /// <summary>

View File

@@ -42,6 +42,8 @@ namespace SourceGenWPF.ProjWin {
public MainWindow() { public MainWindow() {
InitializeComponent(); InitializeComponent();
// TODO: verify that RuntimeData dir is accessible
mUI = new MainController(); mUI = new MainController();
} }

View File

@@ -620,7 +620,7 @@ namespace SourceGenWPF {
} }
if (intKey < 0 || intKey + dfd.Length > spf.FileDataLength) { if (intKey < 0 || intKey + dfd.Length > spf.FileDataLength) {
report.Add(FileLoadItem.Type.Warning, report.Add(FileLoadItem.Type.Warning,
string.Format(Res.Strings.ERR_BAD_FD_FMT, intKey)); string.Format(Res.Strings.ERR_BAD_FD, intKey));
continue; continue;
} }
@@ -675,7 +675,7 @@ namespace SourceGenWPF {
subFormat = (FormatDescriptor.SubType)Enum.Parse( subFormat = (FormatDescriptor.SubType)Enum.Parse(
typeof(FormatDescriptor.SubType), sfd.SubFormat); typeof(FormatDescriptor.SubType), sfd.SubFormat);
} catch (ArgumentException) { } catch (ArgumentException) {
report.Add(FileLoadItem.Type.Warning, Res.Strings.ERR_BAD_FD_TYPE + report.Add(FileLoadItem.Type.Warning, Res.Strings.ERR_BAD_FD_FORMAT +
": " + sfd.Format + "/" + sfd.SubFormat); ": " + sfd.Format + "/" + sfd.SubFormat);
return false; return false;
} }

View File

@@ -3,8 +3,8 @@
xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:SourceGenWPF.Res"> xmlns:local="clr-namespace:SourceGenWPF.Res">
<system:String x:Key="str_ErrBadFdFmt">Bad format descriptor at +{0:x6}.</system:String> <system:String x:Key="str_ErrBadFd">Bad format descriptor at +{0:x6}.</system:String>
<system:String x:Key="str_ErrBadFdType">Bad format descriptor type</system:String> <system:String x:Key="str_ErrBadFdFormat">Bad format descriptor type</system:String>
<system:String x:Key="str_ErrBadFileLength">Bad file length</system:String> <system:String x:Key="str_ErrBadFileLength">Bad file length</system:String>
<system:String x:Key="str_ErrBadIdent">Invalid file identifier</system:String> <system:String x:Key="str_ErrBadIdent">Invalid file identifier</system:String>
<system:String x:Key="str_ErrBadRange">Bad range</system:String> <system:String x:Key="str_ErrBadRange">Bad range</system:String>

View File

@@ -18,10 +18,10 @@ using System.Windows;
namespace SourceGenWPF.Res { namespace SourceGenWPF.Res {
public static class Strings { public static class Strings {
public static string ERR_BAD_FD_FMT = public static string ERR_BAD_FD =
(string)Application.Current.FindResource("str_ErrBadFdFmt"); (string)Application.Current.FindResource("str_ErrBadFd");
public static string ERR_BAD_FD_TYPE = public static string ERR_BAD_FD_FORMAT =
(string)Application.Current.FindResource("str_ErrBadFdType"); (string)Application.Current.FindResource("str_ErrBadFdFormat");
public static string ERR_BAD_FILE_LENGTH = public static string ERR_BAD_FILE_LENGTH =
(string)Application.Current.FindResource("str_ErrBadFileLength"); (string)Application.Current.FindResource("str_ErrBadFileLength");
public static string ERR_BAD_IDENT = public static string ERR_BAD_IDENT =

View File

@@ -55,7 +55,11 @@ namespace SourceGenWPF {
return sBasePath; return sBasePath;
} }
// Hack during development: remove bin/Debug, and convert SourceGenWPF to SourceGen.
string upTwo = Path.GetDirectoryName(Path.GetDirectoryName(baseDir)); string upTwo = Path.GetDirectoryName(Path.GetDirectoryName(baseDir));
if (upTwo.EndsWith("WPF")) {
upTwo = upTwo.Substring(0, upTwo.Length - 3);
}
tryPath = Path.Combine(upTwo, RUNTIME_DATA_FILENAME); tryPath = Path.Combine(upTwo, RUNTIME_DATA_FILENAME);
if (Directory.Exists(tryPath)) { if (Directory.Exists(tryPath)) {
sBasePath = Path.GetFullPath(tryPath); sBasePath = Path.GetFullPath(tryPath);