-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented custom tags (missing new tags and tagbar, state backup)
- Loading branch information
Showing
10 changed files
with
367 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace DeFRaG_Helper.Behaviors | ||
{ | ||
public static class ListBoxBehavior | ||
{ | ||
public static readonly DependencyProperty BindableSelectedItemsProperty = | ||
DependencyProperty.RegisterAttached("BindableSelectedItems", typeof(IList), typeof(ListBoxBehavior), new PropertyMetadata(null, OnBindableSelectedItemsChanged)); | ||
|
||
public static IList GetBindableSelectedItems(DependencyObject obj) | ||
{ | ||
return (IList)obj.GetValue(BindableSelectedItemsProperty); | ||
} | ||
|
||
public static void SetBindableSelectedItems(DependencyObject obj, IList value) | ||
{ | ||
obj.SetValue(BindableSelectedItemsProperty, value); | ||
} | ||
|
||
private static void OnBindableSelectedItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (d is ListBox listBox) | ||
{ | ||
listBox.SelectionChanged -= ListBox_SelectionChanged; | ||
listBox.SelectionChanged += ListBox_SelectionChanged; | ||
} | ||
} | ||
|
||
private static void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) | ||
{ | ||
if (sender is ListBox listBox) | ||
{ | ||
IList selectedItems = GetBindableSelectedItems(listBox); | ||
if (selectedItems != null) | ||
{ | ||
selectedItems.Clear(); | ||
foreach (var item in listBox.SelectedItems) | ||
{ | ||
selectedItems.Add(item); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<UserControl x:Class="DeFRaG_Helper.UserControls.TagManager" | ||
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" | ||
d:DesignHeight="300" d:DesignWidth="400"> | ||
<Border Background="Transparent" Padding="10" CornerRadius="5"> | ||
<StackPanel> | ||
<TextBlock Text="Manage Tags" FontSize="16" Margin="0,0,0,10" Foreground="White"/> | ||
<ListBox ItemsSource="{Binding Tags}" SelectionMode="Multiple"> | ||
<ListBox.ItemTemplate> | ||
<DataTemplate> | ||
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked, Mode=TwoWay}" | ||
Command="{Binding DataContext.TagCheckedCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" | ||
CommandParameter="{Binding}" | ||
/> | ||
</DataTemplate> | ||
</ListBox.ItemTemplate> | ||
</ListBox> | ||
<TextBox x:Name="NewTagTextBox" Width="200" Margin="0,10,0,0" Text="{Binding NewTagName, UpdateSourceTrigger=PropertyChanged}"/> | ||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0"> | ||
<Button Command="{Binding CancelCommand}" Content="Cancel"/> | ||
<Button Command="{Binding RemoveTagCommand}" Content="Remove Tag"/> | ||
<Button Command="{Binding AddTagCommand}" Content="Add Tag" CommandParameter="{Binding Text, ElementName=NewTagTextBox}"/> | ||
</StackPanel> | ||
</StackPanel> | ||
</Border> | ||
</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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Windows.Controls; | ||
using System.Windows; | ||
using DeFRaG_Helper.ViewModels; | ||
|
||
namespace DeFRaG_Helper.UserControls | ||
{ | ||
public partial class TagManager : UserControl | ||
{ | ||
public TagManager(TagManagerViewModel viewModel) | ||
{ | ||
InitializeComponent(); | ||
DataContext = viewModel; | ||
|
||
viewModel.RequestClose += (sender, e) => | ||
{ | ||
var window = Window.GetWindow(this); | ||
if (window != null) | ||
{ | ||
window.Close(); | ||
} | ||
}; | ||
} | ||
} | ||
} |
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,14 @@ | ||
using System.ComponentModel; | ||
|
||
namespace DeFRaG_Helper.ViewModels | ||
{ | ||
public class BaseViewModel : INotifyPropertyChanged | ||
{ | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
Check warning on line 7 in DeFRaG_Helper/ViewModels/BaseViewModel.cs GitHub Actions / build-and-test
Check warning on line 7 in DeFRaG_Helper/ViewModels/BaseViewModel.cs GitHub Actions / build-and-test
|
||
|
||
protected virtual void OnPropertyChanged(string propertyName) | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.