mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-04 15:05:03 +00:00
b77d9ba4c8
Wrote segment parser.
103 lines
3.1 KiB
C#
103 lines
3.1 KiB
C#
/*
|
|
* Copyright 2020 faddenSoft
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
|
|
namespace SourceGen.Tools.Omf.WpfGui {
|
|
/// <summary>
|
|
/// Apple IIgs OMF file viewer.
|
|
/// </summary>
|
|
public partial class OmfViewer : Window, INotifyPropertyChanged {
|
|
private string mPathName;
|
|
private byte[] mFileData;
|
|
|
|
//private Brush mDefaultLabelColor = SystemColors.WindowTextBrush;
|
|
|
|
// INotifyPropertyChanged implementation
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
|
|
public class SegmentListItem {
|
|
private OmfSegment mOmfSeg;
|
|
|
|
public int SegNum {
|
|
get {
|
|
return mOmfSeg.SegNum;
|
|
}
|
|
}
|
|
public string Kind {
|
|
get {
|
|
return mOmfSeg.Kind.ToString();
|
|
}
|
|
}
|
|
public string LoadName {
|
|
get {
|
|
return mOmfSeg.LoadName;
|
|
}
|
|
}
|
|
public string SegName {
|
|
get {
|
|
return mOmfSeg.SegName;
|
|
}
|
|
}
|
|
public int MemLength {
|
|
get {
|
|
return mOmfSeg.Length;
|
|
}
|
|
}
|
|
public int FileLength {
|
|
get {
|
|
return mOmfSeg.FileLength;
|
|
}
|
|
}
|
|
|
|
public SegmentListItem(OmfSegment omfSeg) {
|
|
mOmfSeg = omfSeg;
|
|
}
|
|
}
|
|
|
|
public List<SegmentListItem> SegmentListItems { get; private set; } = new List<SegmentListItem>();
|
|
|
|
|
|
public OmfViewer(Window owner, string pathName, byte[] data) {
|
|
InitializeComponent();
|
|
Owner = owner;
|
|
DataContext = this;
|
|
|
|
mPathName = pathName;
|
|
mFileData = data;
|
|
|
|
OmfFile omfFile = new OmfFile(data);
|
|
omfFile.Analyze();
|
|
|
|
foreach (OmfSegment omfSeg in omfFile.SegmentList) {
|
|
SegmentListItems.Add(new SegmentListItem(omfSeg));
|
|
}
|
|
}
|
|
|
|
private void SegmentList_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
|
Debug.WriteLine("DCLICK");
|
|
}
|
|
}
|
|
}
|