Fixed memory leaks
This commit is contained in:
parent
dce21d84b3
commit
4e77075182
|
@ -8,6 +8,7 @@ namespace Filtration.Translators
|
|||
internal interface IBlockGroupHierarchyBuilder
|
||||
{
|
||||
void Initialise(ItemFilterBlockGroup rootBlockGroup);
|
||||
void Cleanup();
|
||||
ItemFilterBlockGroup IntegrateStringListIntoBlockGroupHierarchy(IEnumerable<string> groupStrings);
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,11 @@ namespace Filtration.Translators
|
|||
_rootBlockGroup = rootBlockGroup;
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_rootBlockGroup = null;
|
||||
}
|
||||
|
||||
public ItemFilterBlockGroup IntegrateStringListIntoBlockGroupHierarchy(IEnumerable<string> groupStrings)
|
||||
{
|
||||
if (_rootBlockGroup == null)
|
||||
|
|
|
@ -70,7 +70,8 @@ namespace Filtration.Translators
|
|||
}
|
||||
|
||||
script.ThemeComponents = _themeComponentListBuilder.GetComponents();
|
||||
|
||||
_blockGroupHierarchyBuilder.Cleanup();
|
||||
_themeComponentListBuilder.Cleanup();
|
||||
return script;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Filtration.Translators
|
|||
void Initialise();
|
||||
ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor);
|
||||
List<ThemeComponent> GetComponents();
|
||||
void Cleanup();
|
||||
}
|
||||
|
||||
internal class ThemeComponentListBuilder : IThemeComponentListBuilder
|
||||
|
@ -28,6 +29,11 @@ namespace Filtration.Translators
|
|||
_themeComponents = new List<ThemeComponent>();
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
{
|
||||
_themeComponents = null;
|
||||
}
|
||||
|
||||
public ThemeComponent AddComponent(ThemeComponentType componentType, string componentName, Color componentColor)
|
||||
{
|
||||
if (ComponentExists(componentType, componentName))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Windows;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Filtration.UserControls
|
||||
|
@ -10,6 +11,7 @@ namespace Filtration.UserControls
|
|||
InitializeComponent();
|
||||
// ReSharper disable once PossibleNullReferenceException
|
||||
(Content as FrameworkElement).DataContext = this;
|
||||
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty TextColorProperty = DependencyProperty.Register(
|
||||
|
@ -35,9 +37,9 @@ namespace Filtration.UserControls
|
|||
|
||||
public static readonly DependencyProperty BlockFontSizeProperty = DependencyProperty.Register(
|
||||
"BlockFontSize",
|
||||
typeof(int),
|
||||
typeof(double),
|
||||
typeof(ItemPreviewControl),
|
||||
new FrameworkPropertyMetadata()
|
||||
new FrameworkPropertyMetadata((double)19)
|
||||
);
|
||||
|
||||
public Color TextColor
|
||||
|
@ -58,9 +60,12 @@ namespace Filtration.UserControls
|
|||
set { SetValue(BorderColorProperty, value); }
|
||||
}
|
||||
|
||||
public int BlockFontSize
|
||||
public double BlockFontSize
|
||||
{
|
||||
get { return (int)GetValue(BlockFontSizeProperty); }
|
||||
get
|
||||
{
|
||||
return (double)GetValue(BlockFontSizeProperty);
|
||||
}
|
||||
set { SetValue(BlockFontSizeProperty, value); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,10 @@ namespace Filtration.ViewModels
|
|||
}
|
||||
|
||||
_openDocuments.Remove(document);
|
||||
if (_activeDocument == document)
|
||||
{
|
||||
_activeDocument = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchActiveDocument(IDocument document)
|
||||
|
|
|
@ -275,10 +275,16 @@ namespace Filtration.ViewModels
|
|||
get { return Block.HasBlockItemOfType<FontSizeBlockItem>(); }
|
||||
}
|
||||
|
||||
public int DisplayFontSize
|
||||
public double DisplayFontSize
|
||||
{
|
||||
// Dividing by 1.8 roughly scales in-game font sizes down to WPF sizes
|
||||
get { return HasFontSize ? (int)(BlockItems.OfType<FontSizeBlockItem>().First().Value / 1.8) : 19; }
|
||||
get
|
||||
{
|
||||
var fontSize = HasFontSize ? (BlockItems.OfType<FontSizeBlockItem>().First().Value / 1.8) : 19;
|
||||
|
||||
return fontSize;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasSound
|
||||
|
|
|
@ -98,8 +98,6 @@ namespace Filtration.ViewModels
|
|||
{
|
||||
case "ActiveDocumentChanged":
|
||||
{
|
||||
_activeDocument = _avalonDockWorkspaceViewModel.ActiveDocument;
|
||||
|
||||
CopyScriptCommand.RaiseCanExecuteChanged();
|
||||
SaveCommand.RaiseCanExecuteChanged();
|
||||
SaveAsCommand.RaiseCanExecuteChanged();
|
||||
|
@ -178,7 +176,7 @@ namespace Filtration.ViewModels
|
|||
get
|
||||
{
|
||||
{
|
||||
var isScript = _activeDocument is ItemFilterScriptViewModel;
|
||||
var isScript = AvalonDockWorkspaceViewModel.ActiveDocument is ItemFilterScriptViewModel;
|
||||
return isScript;
|
||||
}
|
||||
}
|
||||
|
@ -191,12 +189,12 @@ namespace Filtration.ViewModels
|
|||
|
||||
public bool ActiveDocumentIsTheme
|
||||
{
|
||||
get { { return _activeDocument is ThemeViewModel; } }
|
||||
get { { return AvalonDockWorkspaceViewModel.ActiveDocument is ThemeViewModel; } }
|
||||
}
|
||||
|
||||
private bool ActiveDocumentIsEditable()
|
||||
{
|
||||
return _activeDocument is IEditableDocument;
|
||||
return AvalonDockWorkspaceViewModel.ActiveDocument is IEditableDocument;
|
||||
}
|
||||
|
||||
public bool ShowAdvancedStatus
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Filtration.ViewModels
|
|||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
private static void OnOpenScriptCommand()
|
||||
{
|
||||
Messenger.Default.Send(new NotificationMessage("OpenScript"));
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
AllowMixedOrientation="True"
|
||||
DocumentsSource="{Binding OpenDocuments}"
|
||||
ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}" >
|
||||
<xcad:DockingManager.Theme>
|
||||
<!--<xcad:DockingManager.Theme>
|
||||
<xcad:Vs2013LightTheme />
|
||||
</xcad:DockingManager.Theme>
|
||||
</xcad:DockingManager.Theme>-->
|
||||
<xcad:DockingManager.LayoutItemTemplateSelector>
|
||||
<viewsAvalonDock:PanesTemplateSelector>
|
||||
<viewsAvalonDock:PanesTemplateSelector.ItemFilterScriptTemplate>
|
||||
|
|
Loading…
Reference in New Issue