Compare commits
2 Commits
9d41119710
...
ee6a565ce0
| Author | SHA1 | Date | |
|---|---|---|---|
| ee6a565ce0 | |||
| 334accd070 |
44
Assets/AppIcons/ClearKeys.svg
Normal file
44
Assets/AppIcons/ClearKeys.svg
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
sodipodi:docname="ClearKeys.svg"
|
||||
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="32.916667"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1017"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg1" />
|
||||
<path
|
||||
d="m 19.36,2.72 1.42,1.42 -5.72,5.71 c 1.07,1.54 1.22,3.39 0.32,4.59 L 9.06,8.12 c 1.2,-0.9 3.05,-0.75 4.59,0.32 L 19.36,2.72 M 5.93,17.57 C 3.92,15.56 2.69,13.16 2.35,10.92 l 4.88,-2.09 7.44,7.44 -2.09,4.88 C 10.34,20.81 7.94,19.58 5.93,17.57 Z"
|
||||
id="path1"
|
||||
style="display:none" />
|
||||
<path
|
||||
style="fill:#607d8b;stroke-width:0.000911392;fill-opacity:1"
|
||||
d="M 12.136709,21.054947 C 9.849802,20.570498 7.6401138,19.296543 5.8025316,17.403096 4.4028758,15.960889 3.3992023,14.37058 2.7993906,12.644655 2.6463627,12.204326 2.4273042,11.35402 2.3985171,11.088608 L 2.3803943,10.921519 4.7251585,9.9189873 C 6.0147788,9.3675949 7.1043011,8.9044989 7.1463187,8.8898851 c 0.071606,-0.024904 0.3085786,0.2056059 3.7789633,3.6759029 2.036411,2.03636 3.702566,3.714727 3.702566,3.729703 0,0.01498 -0.461067,1.105251 -1.024592,2.422831 l -1.024593,2.395602 -0.09186,-0.0021 c -0.05053,-0.0012 -0.208066,-0.02675 -0.350091,-0.05684 z"
|
||||
id="path2" />
|
||||
<path
|
||||
style="fill:#607d8b;fill-opacity:1;stroke-width:0.000911392"
|
||||
d="M 12.228787,11.256636 9.0890771,8.1168152 9.262956,8.0055861 c 0.537045,-0.3435433 1.29721,-0.5112188 2.003468,-0.4419202 0.416509,0.040868 0.869029,0.1466631 1.241447,0.2902384 0.298885,0.1152267 0.773018,0.3576119 0.98551,0.5038104 0.07023,0.04832 0.138874,0.087855 0.152539,0.087855 0.01366,0 1.306513,-1.281613 2.872996,-2.8480292 l 2.84815,-2.8480293 0.691078,0.6910787 0.691079,0.6910786 -2.855424,2.8555452 C 15.12356,9.75757 15.039674,9.8448024 15.081906,9.911253 c 0.598284,0.941377 0.857172,1.729415 0.860857,2.620393 0.002,0.475353 -0.04848,0.782692 -0.194207,1.183063 -0.08105,0.222676 -0.299494,0.631956 -0.355907,0.666821 -0.01328,0.0082 -1.437021,-1.397993 -3.163862,-3.124894 z"
|
||||
id="path3" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
BIN
BallanceTasEditor/Assets/ClearKeys.ico
Normal file
BIN
BallanceTasEditor/Assets/ClearKeys.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
64
BallanceTasEditor/Utils/CountableEnumerable.cs
Normal file
64
BallanceTasEditor/Utils/CountableEnumerable.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BallanceTasEditor.Utils {
|
||||
/// <summary>
|
||||
/// 一种提前给定元素个数的的IEnumerable。
|
||||
/// </summary>
|
||||
public sealed class CountableEnumerable<T> {
|
||||
/// <summary>
|
||||
/// 以直接方式构建。
|
||||
/// </summary>
|
||||
/// <param name="enumerable">一个迭代器,其最多只能迭代给定次数。</param>
|
||||
/// <param name="count">迭代器会迭代的次数。</param>
|
||||
public CountableEnumerable(IEnumerable<T> enumerable, int count) {
|
||||
m_Inner = enumerable;
|
||||
m_Count = count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从数组便捷构建。
|
||||
/// </summary>
|
||||
/// <param name="array">要使用的数组。</param>
|
||||
public CountableEnumerable(T[] array) {
|
||||
m_Inner = array;
|
||||
m_Count = array.Length;
|
||||
}
|
||||
|
||||
private IEnumerable<T> m_Inner;
|
||||
private int m_Count;
|
||||
|
||||
/// <summary>
|
||||
/// 获取迭代器对象。
|
||||
/// </summary>
|
||||
/// <returns>用于迭代的迭代器。</returns>
|
||||
/// <exception cref="ArgumentException">当迭代器迭代次数与给定次数不匹配时。</exception>
|
||||
public IEnumerable<T> GetInner() {
|
||||
int counter = 0;
|
||||
foreach (var item in m_Inner) {
|
||||
if (counter >= m_Count) {
|
||||
throw new ArgumentException("Given IEnumerable<T> is not stopped at given count.");
|
||||
} else {
|
||||
yield return item;
|
||||
++counter;
|
||||
}
|
||||
}
|
||||
|
||||
if (counter != m_Count) {
|
||||
throw new ArgumentException("Given IEnumerable<T> is not stopped at given count.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该迭代器会迭代的次数。
|
||||
/// </summary>
|
||||
/// <returns>迭代器会迭代的次数,用于给使用该结构的方法提前分配必要的空间。</returns>
|
||||
public int GetCount() {
|
||||
return m_Count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@ namespace BallanceTasEditor.Utils {
|
||||
/// <param name="index">要在前方插入数据的元素的索引。</param>
|
||||
/// <param name="items">要插入的元素的迭代器。</param>
|
||||
/// <exception cref="ArgumentException">给定的索引超出范围。</exception>
|
||||
void Insert(int index, IEnumerable<T> items);
|
||||
void Insert(int index, CountableEnumerable<T> items);
|
||||
/// <summary>
|
||||
/// 从给定单元开始,移除给定个数的元素。
|
||||
/// </summary>
|
||||
@ -70,7 +70,7 @@ namespace BallanceTasEditor.Utils {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Insert(int index, IEnumerable<T> items) {
|
||||
public void Insert(int index, CountableEnumerable<T> items) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@ -108,8 +108,8 @@ namespace BallanceTasEditor.Utils {
|
||||
return m_Container[index];
|
||||
}
|
||||
|
||||
public void Insert(int index, IEnumerable<T> items) {
|
||||
m_Container.InsertRange(index, items);
|
||||
public void Insert(int index, CountableEnumerable<T> items) {
|
||||
m_Container.InsertRange(index, items.GetInner());
|
||||
}
|
||||
|
||||
public void Remove(int index, int count) {
|
||||
@ -219,11 +219,11 @@ namespace BallanceTasEditor.Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public void Insert(int index, IEnumerable<T> items) {
|
||||
public void Insert(int index, CountableEnumerable<T> items) {
|
||||
if (index < 0 || index > GetCount()) {
|
||||
throw new ArgumentOutOfRangeException("Index out of range.");
|
||||
} else if (index == GetCount()) {
|
||||
foreach (T item in items) {
|
||||
foreach (T item in items.GetInner()) {
|
||||
m_Container.AddLast(item);
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ namespace BallanceTasEditor.Utils {
|
||||
MoveToIndex(index);
|
||||
|
||||
int count = 0;
|
||||
foreach (T item in items) {
|
||||
foreach (T item in items.GetInner()) {
|
||||
m_Container.AddBefore(m_Cursor, item);
|
||||
++count;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
<Image x:Key="IconDrawMode" Source="/Assets/DrawMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconFillMode" Source="/Assets/FillMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconSelectMode" Source="/Assets/SelectMode.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconClearKeys" Source="/Assets/ClearKeys.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconUniformFps" Source="/Assets/SetFps.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconPreference" Source="/Assets/Preference.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
<Image x:Key="IconReportBug" Source="/Assets/ReportBug.ico" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||
@ -67,7 +68,7 @@
|
||||
<MenuItem Header="Fill Mode" Icon="{StaticResource IconFillMode}"/>
|
||||
<MenuItem Header="Draw Mode" Icon="{StaticResource IconDrawMode}"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="Clear Keys"/>
|
||||
<MenuItem Header="Clear Keys" Icon="{StaticResource IconClearKeys}"/>
|
||||
<MenuItem Header="Uniform FPS" Icon="{StaticResource IconUniformFps}" Click="MenuItem_Click_5"/>
|
||||
<Separator/>
|
||||
<MenuItem Header="Preference" Icon="{StaticResource IconPreference}" InputGestureText="Ctrl+P" Click="MenuItem_Click"/>
|
||||
|
||||
@ -13,6 +13,14 @@ namespace BallanceTasEditorTests.Utils {
|
||||
private static readonly int[] BLANK = { };
|
||||
private static readonly int[] PROBE = { 10, 20, 30, 40, 50 };
|
||||
|
||||
private static CountableEnumerable<int> GetCountableProbe() {
|
||||
return new CountableEnumerable<int>(PROBE);
|
||||
}
|
||||
|
||||
private static CountableEnumerable<int> GetCountableBlank() {
|
||||
return new CountableEnumerable<int>(BLANK);
|
||||
}
|
||||
|
||||
private static IEnumerable<object[]> TasStorageInstanceProvider {
|
||||
get {
|
||||
yield return new object[] { new ListTasStorage<int>() };
|
||||
@ -34,7 +42,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Visit(1));
|
||||
|
||||
// 设置数据
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
// 访问数据
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Visit(-1));
|
||||
for (int i = 0; i < PROBE.Length; i++) {
|
||||
@ -53,9 +61,9 @@ namespace BallanceTasEditorTests.Utils {
|
||||
// 和在非空时的头,中,尾分别插入的结果。
|
||||
|
||||
// 先检测空插入
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Insert(-1, PROBE));
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Insert(1, PROBE));
|
||||
storage.Insert(0, PROBE);
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Insert(-1, GetCountableProbe()));
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Insert(1, GetCountableProbe()));
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
for (int i = 0; i < PROBE.Length; i++) {
|
||||
Assert.AreEqual(storage.Visit(i), PROBE[i]);
|
||||
}
|
||||
@ -65,8 +73,8 @@ namespace BallanceTasEditorTests.Utils {
|
||||
foreach (var index in indices) {
|
||||
// 清空,一次插入,然后二次插入
|
||||
storage.Clear();
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(index, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
storage.Insert(index, GetCountableProbe());
|
||||
|
||||
// 用List做正确模拟
|
||||
var expected = new List<int>();
|
||||
@ -96,7 +104,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
foreach (var index in indices) {
|
||||
// 清空,插入,删除
|
||||
storage.Clear();
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
storage.Remove(index, 1);
|
||||
|
||||
// 用List做正确模拟
|
||||
@ -119,7 +127,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
[DynamicData(nameof(TasStorageInstanceProvider))]
|
||||
public void ClearTest(ITasStorage<int> storage) {
|
||||
// 设置数据后清空
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
storage.Clear();
|
||||
|
||||
// 检查是否为空
|
||||
@ -136,7 +144,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
Assert.IsTrue(storage.IsEmpty());
|
||||
|
||||
// 插入数据后再检查
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
Assert.IsFalse(storage.IsEmpty());
|
||||
}
|
||||
|
||||
@ -150,7 +158,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
Assert.AreEqual(storage.GetCount(), 0);
|
||||
|
||||
// 插入数据后再检查
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
Assert.AreEqual(storage.GetCount(), PROBE.Length);
|
||||
}
|
||||
|
||||
@ -166,7 +174,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
Assert.AreEqual(storage.GetCount(), 0);
|
||||
|
||||
// 设置内容
|
||||
storage.Insert(0, PROBE);
|
||||
storage.Insert(0, GetCountableProbe());
|
||||
// 并再次检查大小
|
||||
Assert.IsFalse(storage.IsEmpty());
|
||||
Assert.AreEqual(storage.GetCount(), PROBE.Length);
|
||||
@ -185,7 +193,7 @@ namespace BallanceTasEditorTests.Utils {
|
||||
|
||||
// 清空后插入0项,然后确认
|
||||
storage.Clear();
|
||||
storage.Insert(0, BLANK);
|
||||
storage.Insert(0, GetCountableBlank());
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Visit(-1));
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Visit(0));
|
||||
AssertExtension.ThrowsDerivedException<ArgumentException>(() => storage.Visit(1));
|
||||
|
||||
Reference in New Issue
Block a user