diff --git a/Client/Application/Components/Skill.xaml b/Client/Application/Components/Skill.xaml new file mode 100644 index 0000000..a9fab9b --- /dev/null +++ b/Client/Application/Components/Skill.xaml @@ -0,0 +1,52 @@ + diff --git a/Client/Application/Components/Skill.xaml.cs b/Client/Application/Components/Skill.xaml.cs new file mode 100644 index 0000000..b9ecba1 --- /dev/null +++ b/Client/Application/Components/Skill.xaml.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Client.Application.Components +{ + /// + /// Interaction logic for Skill.xaml + /// + public partial class Skill : Button + { + public static readonly DependencyProperty IsButtonActiveProperty = + DependencyProperty.Register("IsButtonActive", typeof(bool), typeof(Skill), new PropertyMetadata(true, null, OnCoerceButtonActivity)); + public static readonly DependencyProperty ImageSourceProperty = + DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(Skill), new PropertyMetadata(default(ImageSource))); + public static readonly DependencyProperty IsReadyToUseProperty = + DependencyProperty.Register("IsReadyToUse", typeof(bool), typeof(Skill), new PropertyMetadata(true, OnButtonActivityChanged)); + public static readonly DependencyProperty SkillNameProperty = + DependencyProperty.Register("SkillName", typeof(string), typeof(Skill), new PropertyMetadata("Skill")); + public static readonly DependencyProperty LevelProperty = + DependencyProperty.Register("Level", typeof(uint), typeof(Skill), new PropertyMetadata((uint)1)); + public static readonly DependencyProperty CostProperty = + DependencyProperty.Register("Cost", typeof(uint?), typeof(Skill), new PropertyMetadata(null)); + public static readonly DependencyProperty RangeProperty = + DependencyProperty.Register("Range", typeof(int?), typeof(Skill), new PropertyMetadata(null)); + public static readonly DependencyProperty DescriptionProperty = + DependencyProperty.Register("Description", typeof(string), typeof(Skill), new PropertyMetadata(null)); + public static readonly DependencyProperty IsActiveProperty = + DependencyProperty.Register("IsActive", typeof(bool), typeof(Skill), new PropertyMetadata(true, OnButtonActivityChanged)); + + private static void OnButtonActivityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var model = (Skill)d; + model.CoerceValue(IsButtonActiveProperty); + } + + private static object OnCoerceButtonActivity(DependencyObject d, object baseValue) + { + var model = (Skill)d; + + return model.IsReadyToUse && model.IsActive; + } + + public Skill() + { + InitializeComponent(); + } + + public bool IsButtonActive + { + get { return (bool)GetValue(IsButtonActiveProperty); } + set { SetValue(IsButtonActiveProperty, value); } + } + public ImageSource ImageSource + { + get { return (ImageSource)GetValue(ImageSourceProperty); } + set { SetValue(ImageSourceProperty, value); } + } + public bool IsReadyToUse + { + get { return (bool)GetValue(IsReadyToUseProperty); } + set { SetValue(IsReadyToUseProperty, value); } + } + public string SkillName + { + get { return (string)GetValue(SkillNameProperty); } + set { SetValue(SkillNameProperty, value); } + } + public uint Level + { + get { return (uint)GetValue(LevelProperty); } + set { SetValue(LevelProperty, value); } + } + public uint? Cost + { + get { return (uint?)GetValue(CostProperty); } + set { SetValue(CostProperty, value); } + } + public int? Range + { + get { return (int?)GetValue(RangeProperty); } + set { SetValue(RangeProperty, value); } + } + public string? Description + { + get { return (string?)GetValue(DescriptionProperty); } + set { SetValue(DescriptionProperty, value); } + } + public bool IsActive + { + get { return (bool)GetValue(IsActiveProperty); } + set { SetValue(IsActiveProperty, value); } + } + } +} diff --git a/Client/Application/Converters/BooleanToVisibilityConverter.cs b/Client/Application/Converters/BooleanToVisibilityConverter.cs new file mode 100644 index 0000000..d18db59 --- /dev/null +++ b/Client/Application/Converters/BooleanToVisibilityConverter.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace Client.Application.Converters +{ + public class BooleanToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + var isInverted = parameter == null ? false : true; + var preparedValue = value == null ? false : (bool)value; + preparedValue = isInverted ? !preparedValue : preparedValue; + return innerConverter.Convert(preparedValue, targetType, parameter, culture); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + + System.Windows.Controls.BooleanToVisibilityConverter innerConverter = new System.Windows.Controls.BooleanToVisibilityConverter(); + } +} diff --git a/Client/Application/Converters/NullToVisibilityConverter.cs b/Client/Application/Converters/NullToVisibilityConverter.cs index eb69ab8..6f6ba3d 100644 --- a/Client/Application/Converters/NullToVisibilityConverter.cs +++ b/Client/Application/Converters/NullToVisibilityConverter.cs @@ -13,7 +13,9 @@ namespace Client.Application.Converters { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return value == null ? Visibility.Hidden : Visibility.Visible; + var isCollapsedWhenNull = parameter == null ? false : true; + var nullVisibility = isCollapsedWhenNull ? Visibility.Collapsed : Visibility.Hidden; + return value == null ? nullVisibility : Visibility.Visible; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/Client/Application/ViewModels/SkillListViewModel.cs b/Client/Application/ViewModels/SkillListViewModel.cs index c6d51ba..4186fa6 100644 --- a/Client/Application/ViewModels/SkillListViewModel.cs +++ b/Client/Application/ViewModels/SkillListViewModel.cs @@ -18,8 +18,8 @@ namespace Client.Application.ViewModels public bool IsActive => skill.IsActive; public bool IsReadyToUse => skill.IsReadyToUse; public bool IsBusy => !skill.IsReadyToUse; - public uint Cost => skill.Cost; - public int Range => skill.Range; + public uint? Cost => skill.Cost == 0 ? null : skill.Cost; + public int? Range => skill.Range <= 0 ? null : skill.Range; public SkillListViewModel(Skill skill) { diff --git a/Client/Application/Views/MainWindow.xaml b/Client/Application/Views/MainWindow.xaml index 879a575..67e07cd 100644 --- a/Client/Application/Views/MainWindow.xaml +++ b/Client/Application/Views/MainWindow.xaml @@ -5,9 +5,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Client" xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" - xmlns:ctrls="clr-namespace:System.Windows.Controls;assembly=PresentationFramework" xmlns:converters="clr-namespace:Client.Application.Converters" xmlns:components="clr-namespace:Client.Application.Components" + xmlns:views="clr-namespace:Client.Application.Views" mc:Ignorable="d" Title="L2Bot 2.0 Client" Height="600" Width="1024"> @@ -22,7 +22,6 @@ - @@ -105,74 +104,13 @@ Active - - - - - - - - - - - - + Passive - - - - - - - - - - - - + @@ -201,7 +139,7 @@ - + Position: diff --git a/Client/Application/Views/SkillPanel.xaml b/Client/Application/Views/SkillPanel.xaml new file mode 100644 index 0000000..d363386 --- /dev/null +++ b/Client/Application/Views/SkillPanel.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/Client/Application/Views/SkillPanel.xaml.cs b/Client/Application/Views/SkillPanel.xaml.cs new file mode 100644 index 0000000..9e820f5 --- /dev/null +++ b/Client/Application/Views/SkillPanel.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Client.Application.Views +{ + /// + /// Interaction logic for SkillPanel.xaml + /// + public partial class SkillPanel : ItemsControl + { + public SkillPanel() + { + InitializeComponent(); + } + } +} diff --git a/Client/Application/Components/StatsPanel.xaml b/Client/Application/Views/StatsPanel.xaml similarity index 85% rename from Client/Application/Components/StatsPanel.xaml rename to Client/Application/Views/StatsPanel.xaml index a160e32..cd62d39 100644 --- a/Client/Application/Components/StatsPanel.xaml +++ b/Client/Application/Views/StatsPanel.xaml @@ -1,11 +1,11 @@ - - - - - /// Interaction logic for StatsPanel.xaml