2019-11-23 04:45:57 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2019 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;
|
2019-11-25 22:27:38 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
using System.ComponentModel;
|
2019-11-25 22:27:38 +00:00
|
|
|
|
using System.Diagnostics;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Windows;
|
2019-11-25 22:27:38 +00:00
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Input;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
|
2019-11-25 22:27:38 +00:00
|
|
|
|
using Asm65;
|
|
|
|
|
using PluginCommon;
|
|
|
|
|
using SourceGen.Sandbox;
|
|
|
|
|
|
2019-11-23 04:45:57 +00:00
|
|
|
|
namespace SourceGen.WpfGui {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Visualization set editor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class EditVisualizationSet : Window, INotifyPropertyChanged {
|
|
|
|
|
public VisualizationSet NewVisSet { get; private set; }
|
|
|
|
|
|
2019-11-25 22:27:38 +00:00
|
|
|
|
private DisasmProject mProject;
|
|
|
|
|
private Formatter mFormatter;
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<Visualization> VisualizationList { get; private set; } =
|
|
|
|
|
new ObservableCollection<Visualization>();
|
2019-11-23 04:45:57 +00:00
|
|
|
|
|
|
|
|
|
// INotifyPropertyChanged implementation
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 22:27:38 +00:00
|
|
|
|
public EditVisualizationSet(Window owner, DisasmProject project, Formatter formatter,
|
|
|
|
|
VisualizationSet curSet) {
|
2019-11-23 04:45:57 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
Owner = owner;
|
|
|
|
|
DataContext = this;
|
|
|
|
|
|
2019-11-25 22:27:38 +00:00
|
|
|
|
mProject = project;
|
|
|
|
|
mFormatter = formatter;
|
|
|
|
|
|
2019-11-23 04:45:57 +00:00
|
|
|
|
if (curSet != null) {
|
2019-11-25 22:27:38 +00:00
|
|
|
|
foreach (Visualization vis in curSet) {
|
|
|
|
|
VisualizationList.Add(vis);
|
|
|
|
|
}
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OkButton_Click(object sender, RoutedEventArgs e) {
|
2019-11-25 22:27:38 +00:00
|
|
|
|
if (VisualizationList.Count == 0) {
|
2019-11-23 04:45:57 +00:00
|
|
|
|
NewVisSet = null;
|
|
|
|
|
} else {
|
2019-11-25 22:27:38 +00:00
|
|
|
|
NewVisSet = new VisualizationSet(VisualizationList.Count);
|
|
|
|
|
foreach (Visualization vis in VisualizationList) {
|
|
|
|
|
NewVisSet.Add(vis);
|
|
|
|
|
}
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
DialogResult = true;
|
|
|
|
|
}
|
2019-11-25 22:27:38 +00:00
|
|
|
|
|
|
|
|
|
private void VisualizationList_SelectionChanged(object sender,
|
|
|
|
|
SelectionChangedEventArgs e) {
|
|
|
|
|
Debug.WriteLine("SEL CHANGE");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void VisualizationList_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
|
|
|
|
Debug.WriteLine("DBL CLICK");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NewButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
VisualizationList.Add(new Visualization("VIS #" + VisualizationList.Count,
|
|
|
|
|
"apple2-hi-res-bitmap", new Dictionary<string, object>()));
|
2019-11-27 02:54:42 +00:00
|
|
|
|
|
|
|
|
|
// TODO: disable New button if no appropriate vis plugins can be found (or maybe
|
|
|
|
|
// MessageBox here)
|
2019-11-25 22:27:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EditButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
Dictionary<string, object> testDict = new Dictionary<string, object>();
|
2019-12-01 01:52:33 +00:00
|
|
|
|
testDict.Add("offset", 0);
|
|
|
|
|
testDict.Add("byteWidth", 2);
|
|
|
|
|
testDict.Add("height", 7);
|
2019-11-25 22:27:38 +00:00
|
|
|
|
EditVisualization dlg = new EditVisualization(this, mProject, mFormatter,
|
|
|
|
|
new Visualization("arbitrary tag", "apple2-hi-res-bitmap", testDict));
|
|
|
|
|
if (dlg.ShowDialog() == true) {
|
2019-11-27 02:54:42 +00:00
|
|
|
|
Visualization newVis = dlg.NewVis;
|
|
|
|
|
Debug.WriteLine("New vis: " + newVis);
|
2019-11-25 22:27:38 +00:00
|
|
|
|
}
|
2019-11-27 02:54:42 +00:00
|
|
|
|
|
|
|
|
|
// TODO: disable edit button if matching vis can't be found (or maybe MessageBox)
|
2019-11-25 22:27:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DownButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
|
|
|
|
|
}
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|