-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from Stuff-Mods/resize
Allow widget to be resized
- Loading branch information
Showing
6 changed files
with
99 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,24 @@ | ||
<src:Widget | ||
<UserControl | ||
x:Class="MHWItemBoxTracker.Views.InventoryView" | ||
xmlns:src="clr-namespace:HunterPie.GUI;assembly=HunterPie.UI" | ||
xmlns:Custom="clr-namespace:HunterPie.GUIControls.Custom_Controls;assembly=HunterPie.UI" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
ResizeMode="NoResize" | ||
WindowStyle="None" | ||
AllowsTransparency="True" | ||
ShowInTaskbar="False" | ||
Topmost="True" | ||
SizeToContent="Height" | ||
Width="350" | ||
WidgetActive="True"> | ||
<Window.Resources> | ||
Width="350"> | ||
<UserControl.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="../Resource/InventoryItemDataTemplate.xaml" /> | ||
<ResourceDictionary Source="../Resource/ItemDataTemplate.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Window.Resources> | ||
<Window.Background> | ||
<SolidColorBrush | ||
Color="#00000000" | ||
Opacity="0" /> | ||
</Window.Background> | ||
</UserControl.Resources> | ||
<ItemsControl | ||
BorderThickness="0" | ||
ItemsSource="{Binding Items}" | ||
HorizontalContentAlignment="Stretch" | ||
Background="{x:Null}" | ||
IsEnabled="False" /> | ||
</src:Widget> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,10 @@ | ||
using System.Threading.Tasks; | ||
using HunterPie.Core.Settings; | ||
using HunterPie.GUI; | ||
using HunterPie.Plugins; | ||
using MHWItemBoxTracker.Model; | ||
using MHWItemBoxTracker.ViewModel; | ||
using static MHWItemBoxTracker.Main; | ||
using System.Windows.Controls; | ||
|
||
namespace MHWItemBoxTracker.Views { | ||
public partial class InventoryView : Widget { | ||
private static readonly string settingsJson = "widget.settings.json"; | ||
private ItemBoxWidgetSettings widgetSettings { get; set; } | ||
public override IWidgetSettings Settings => widgetSettings; | ||
private InventoryViewModel VM; | ||
public bool ShouldShow { | ||
set { | ||
WidgetHasContent = value; | ||
ChangeVisibility(); | ||
} | ||
} | ||
|
||
public InventoryView(InventoryModel Inventory) : base() { | ||
// TODO: Delete this somehow | ||
public partial class InventoryView : UserControl { | ||
public InventoryView() : base() { | ||
InitializeComponent(); | ||
VM = new(Inventory); | ||
DataContext = VM; | ||
} | ||
|
||
public async Task Initialize() { | ||
widgetSettings = await Plugin.LoadJson<ItemBoxWidgetSettings>(settingsJson); | ||
ApplySettings(); | ||
} | ||
|
||
public void Unload() { | ||
ShouldShow = false; | ||
} | ||
|
||
public override void EnterWidgetDesignMode() { | ||
base.EnterWidgetDesignMode(); | ||
RemoveWindowTransparencyFlag(); | ||
} | ||
|
||
public async override void LeaveWidgetDesignMode() { | ||
base.LeaveWidgetDesignMode(); | ||
ApplyWindowTransparencyFlag(); | ||
await Plugin.SaveJson(settingsJson, widgetSettings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<src:Widget | ||
x:Class="MHWItemBoxTracker.Views.InventoryWidget" | ||
xmlns:src="clr-namespace:HunterPie.GUI;assembly=HunterPie.UI" | ||
xmlns:Custom="clr-namespace:HunterPie.GUIControls.Custom_Controls;assembly=HunterPie.UI" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:convert="clr-namespace:HunterPie.UI.Infrastructure.Converters;assembly=HunterPie.UI" | ||
xmlns:local="clr-namespace:MHWItemBoxTracker.Views" | ||
mc:Ignorable="d" | ||
ResizeMode="CanResize" | ||
WindowStyle="None" | ||
AllowsTransparency="True" | ||
ShowInTaskbar="False" | ||
Topmost="True" | ||
SizeToContent="WidthAndHeight" | ||
Width="350" | ||
Style="{StaticResource OVERLAY_WIDGET_STYLE}" | ||
WidgetActive="True"> | ||
<Grid> | ||
<local:InventoryView | ||
x:Name="contents" | ||
DataContext="{Binding VM}" /> | ||
<TextBlock | ||
Text="{Binding DesignModeDetails}" | ||
Visibility="{Binding DesignModeDetailsVisibility}" | ||
VerticalAlignment="Top" | ||
HorizontalAlignment="Left" | ||
Width="230" | ||
Style="{StaticResource OVERLAY_DESIGN_MODE_DEBUG}" /> | ||
</Grid> | ||
</src:Widget> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Threading.Tasks; | ||
using HunterPie.Core.Settings; | ||
using HunterPie.GUI; | ||
using HunterPie.Plugins; | ||
using MHWItemBoxTracker.Model; | ||
using MHWItemBoxTracker.ViewModel; | ||
using static MHWItemBoxTracker.Main; | ||
|
||
namespace MHWItemBoxTracker.Views { | ||
public partial class InventoryWidget : Widget { | ||
private static readonly string settingsJson = "widget.settings.json"; | ||
private ItemBoxWidgetSettings widgetSettings { get; set; } | ||
public override IWidgetSettings Settings => widgetSettings; | ||
public InventoryViewModel VM { get; } | ||
public bool ShouldShow { | ||
set { | ||
WidgetHasContent = value; | ||
ChangeVisibility(); | ||
} | ||
} | ||
|
||
public InventoryWidget(InventoryModel Inventory) : base() { | ||
InitializeComponent(); | ||
SetWindowFlags(); | ||
VM = new(Inventory); | ||
DataContext = this; | ||
} | ||
|
||
public async Task Initialize() { | ||
widgetSettings = await Plugin.LoadJson<ItemBoxWidgetSettings>(settingsJson); | ||
ApplySettings(); | ||
} | ||
|
||
public void Unload() { | ||
ShouldShow = false; | ||
} | ||
|
||
public override void EnterWidgetDesignMode() { | ||
base.EnterWidgetDesignMode(); | ||
RemoveWindowTransparencyFlag(); | ||
} | ||
|
||
public async override void LeaveWidgetDesignMode() { | ||
ApplyWindowTransparencyFlag(); | ||
base.LeaveWidgetDesignMode(); | ||
await Plugin.SaveJson(settingsJson, widgetSettings); | ||
} | ||
|
||
public override void ScaleWidget(double newScaleX, double newScaleY) { | ||
base.ScaleWidget(newScaleX, newScaleY); | ||
contents.LayoutTransform = LayoutTransform; | ||
} | ||
} | ||
} |