mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
支持关闭时内存回收
This commit is contained in:
parent
51b55d18e8
commit
09e853677a
@ -19,7 +19,7 @@ namespace VPet_Simulator.Core
|
||||
/// <summary>
|
||||
/// Main.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class Main : UserControl
|
||||
public partial class Main : UserControl, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏核心
|
||||
@ -126,5 +126,17 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
ToolBar.Show();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
EventTimer.Stop();
|
||||
MoveTimer.Stop();
|
||||
EventTimer.Dispose();
|
||||
MoveTimer.Dispose();
|
||||
if (PetGrid.Child is IGraph g)
|
||||
g.Stop();
|
||||
if (PetGrid2.Child is IGraph g2)
|
||||
g2.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,39 +24,56 @@ namespace VPet_Simulator.Core
|
||||
public MessageBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
EndTimer.Elapsed += EndTimer_Elapsed;
|
||||
ShowTimer.Elapsed += ShowTimer_Elapsed;
|
||||
}
|
||||
|
||||
List<char> outputtext;
|
||||
private void ShowTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (outputtext.Count > 0)
|
||||
{
|
||||
Dispatcher.Invoke(() => { TText.Text += outputtext[0]; outputtext.RemoveAt(0); });
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowTimer.Stop();
|
||||
EndTimer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void EndTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (--timeleft <= 0)
|
||||
Dispatcher.Invoke(() => this.Visibility = Visibility.Collapsed);
|
||||
}
|
||||
|
||||
public Timer ShowTimer = new Timer() { Interval = 100 };
|
||||
public Timer EndTimer = new Timer() { Interval = 100 };
|
||||
public Timer ShowTimer = new Timer() { Interval = 20 };
|
||||
int timeleft;
|
||||
public void Show(string name, string text)
|
||||
{
|
||||
TText.Text = text;
|
||||
TText.Text = "";
|
||||
outputtext = text.ToList();
|
||||
LName.Content = name;
|
||||
timeleft = text.Length * 2 + 10;
|
||||
ShowTimer.Start();
|
||||
timeleft = text.Length + 5;
|
||||
ShowTimer.Start(); EndTimer.Stop();
|
||||
this.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void Border_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
ShowTimer.Stop();
|
||||
EndTimer.Stop();
|
||||
}
|
||||
|
||||
private void Border_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
ShowTimer.Start();
|
||||
if (!ShowTimer.Enabled)
|
||||
EndTimer.Start();
|
||||
}
|
||||
|
||||
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ShowTimer.Stop();
|
||||
EndTimer.Stop(); ShowTimer.Stop();
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ namespace VPet_Simulator.Core
|
||||
|
||||
private void MenuDIY_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
m.Say("private void MenuDIY_Click(object sender, RoutedEventArgs e)\r\n {\r\n m.Say(\"\");\r\n }");
|
||||
m.Say("您好,我是玛哈萝, 让我来帮您熟悉并掌握使用vos系统,成为永世流传的虚拟主播.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ResizeMode="NoResize"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ShowInTaskbar="False"
|
||||
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" WindowStyle="None" Title="MainWindow"
|
||||
Height="250" Width="250" Background="{x:Null}" Topmost="True">
|
||||
Height="250" Width="250" Background="{x:Null}" Topmost="True" Closed="Window_Closed">
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome GlassFrameThickness="-1" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
@ -101,7 +101,7 @@ namespace VPet_Simulator.Windows
|
||||
Dispatcher.Invoke(new Action(() => LoadingText.Content = "尝试加载游戏内容"));
|
||||
//加载游戏内容
|
||||
Core.Controller = new MWController(this);
|
||||
Core.Save = new Save("莉莉丝");
|
||||
Core.Save = new Save("玛哈萝");
|
||||
Dispatcher.Invoke(new Action(() => {
|
||||
Core.Graph = Pets[0].Graph;
|
||||
LoadingText.Visibility = Visibility.Collapsed;
|
||||
@ -110,6 +110,11 @@ namespace VPet_Simulator.Windows
|
||||
}));
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
((Main)DisplayGrid.Child).Dispose();
|
||||
}
|
||||
|
||||
//public void DEBUGValue()
|
||||
//{
|
||||
// Dispatcher.Invoke(() =>
|
||||
|
Loading…
Reference in New Issue
Block a user