Skip to content

Commit

Permalink
Added Background Tasks view
Browse files Browse the repository at this point in the history
  • Loading branch information
X39 committed Mar 17, 2020
1 parent 63ca3c7 commit 39ede67
Show file tree
Hide file tree
Showing 10 changed files with 621 additions and 12 deletions.
11 changes: 11 additions & 0 deletions Arma.Studio.Data/ArmA.Studio.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<Compile Include="UI\Converters\AllFalseMultiConverter.cs" />
<Compile Include="UI\Converters\AllTrueMultiConverter.cs" />
<Compile Include="UI\Converters\BoolAndMultiConverter.cs" />
<Compile Include="UI\Converters\OnEqualsConverter.cs" />
<Compile Include="UI\Converters\SingleToCollectionConverter.cs" />
<Compile Include="UI\Converters\StringEndsWithConverter.cs" />
<Compile Include="UI\Converters\EqualMultiConverter.cs" />
Expand All @@ -171,6 +172,8 @@
<Compile Include="UI\IMainWindow.cs" />
<Compile Include="UI\IEditorDocument.cs" />
<Compile Include="UI\IEditorProvider.cs" />
<Compile Include="UI\PopupContainer.cs" />
<Compile Include="UI\ProgressSpinner.cs" />
<Compile Include="UI\PropertyAttribute.cs" />
<Compile Include="UI\RelayCommand.cs" />
<Compile Include="UI\RelayCommandAsync.cs" />
Expand Down Expand Up @@ -204,6 +207,14 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UI\PopupContainer.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UI\ProgressSpinner.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UI\DialogWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
12 changes: 0 additions & 12 deletions Arma.Studio.Data/IO/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ namespace Arma.Studio.Data.IO
{
public class File : FileFolderBase
{
public PBO PBO
{
get
{
FileFolderBase ffb = this;
while (ffb != null && !(ffb is PBO))
{
ffb = ffb.Parent;
}
return ffb as PBO;
}
}
public string Extension => System.IO.Path.GetExtension(this.Name);
protected override void OnNameChanged()
{
Expand Down
2 changes: 2 additions & 0 deletions Arma.Studio.Data/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Arma.Studio.Data;component/UI/PopupContainer.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Arma.Studio.Data;component/UI/DialogWindow.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Arma.Studio.Data;component/UI/ProgressSpinner.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
30 changes: 30 additions & 0 deletions Arma.Studio.Data/UI/Converters/OnEqualsConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace Arma.Studio.Data.UI.Converters
{
public class OnEqualsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(parameter is string pstring))
{
return value.GetType().IsEquivalentTo(parameter.GetType()) ? value.Equals(parameter) : value;
}
string[] parr = pstring.Split('|');
var valueType = value.GetType();
if (value.Equals(valueType.IsEnum ? Enum.Parse(valueType, parr[0]) : System.Convert.ChangeType(parr[0], value.GetType())))
{
return System.Convert.ChangeType(parr[1], targetType);
}

return parr.Length == 3 ? System.Convert.ChangeType(parr[2], targetType) : value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
67 changes: 67 additions & 0 deletions Arma.Studio.Data/UI/PopupContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Markup;

namespace Arma.Studio.Data.UI
{
[ContentProperty(nameof(PopupContainer.Content))]
public class PopupContainer : Control
{
static PopupContainer()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PopupContainer), new FrameworkPropertyMetadata(typeof(PopupContainer)));
}

#region DependencyProperty: Content (System.Object)
public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(
nameof(Content), typeof(object), typeof(PopupContainer));
public object Content { get => this.GetValue(ContentProperty); set => this.SetValue(ContentProperty, value); }
#endregion
#region DependencyProperty: Placement (System.Windows.Controls.Primitives.PlacementMode)
public static readonly DependencyProperty PlacementProperty = DependencyProperty.Register(
nameof(Placement), typeof(PlacementMode), typeof(PopupContainer));
public PlacementMode Placement { get => (PlacementMode)this.GetValue(PlacementProperty); set => this.SetValue(PlacementProperty, value); }
#endregion
#region DependencyProperty: PopupContent (System.Object)
public static readonly DependencyProperty PopupContentProperty = DependencyProperty.Register(
nameof(PopupContent), typeof(object), typeof(PopupContainer));
public object PopupContent { get => this.GetValue(PopupContentProperty); set => this.SetValue(PopupContentProperty, value); }
#endregion
#region DependencyProperty: PopupContentTemplate (System.Windows.DataTemplate)
public static readonly DependencyProperty PopupContentTemplateProperty = DependencyProperty.Register(
nameof(PopupContentTemplate), typeof(DataTemplate), typeof(PopupContainer));
public DataTemplate PopupContentTemplate { get => (DataTemplate)this.GetValue(PopupContentTemplateProperty); set => this.SetValue(PopupContentTemplateProperty, value); }
#endregion
#region DependencyProperty: PopupCanOpen (System.Boolean)
public static readonly DependencyProperty PopupCanOpenProperty = DependencyProperty.Register(
nameof(PopupCanOpen), typeof(bool), typeof(PopupContainer), new PropertyMetadata(true));
public bool PopupCanOpen { get => (bool)this.GetValue(PopupCanOpenProperty); set => this.SetValue(PopupCanOpenProperty, value); }
#endregion
#region RoutedEvent: PopupOpened
public static readonly RoutedEvent PopupOpenedEvent = EventManager.RegisterRoutedEvent(nameof(PopupOpened), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PopupContainer));
public event RoutedEventHandler PopupOpened { add { this.AddHandler(PopupOpenedEvent, value); } remove { this.RemoveHandler(PopupOpenedEvent, value); } }
protected void RaisePopupOpened() { this.RaiseEvent(new RoutedEventArgs(PopupOpenedEvent, this)); }
#endregion

public override void OnApplyTemplate()
{
if (this.GetTemplateChild("PART_Popup") is Popup PART_Popup)
{
PART_Popup.Opened += this.PART_Popup_Opened;
PART_Popup.PreviewMouseDown += this.PART_Popup_PreviewMouseDown;
}
}

private void PART_Popup_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Application.Current.MainWindow.Activate();
}

private void PART_Popup_Opened(object sender, EventArgs e)
{
this.RaisePopupOpened();
}
}
}
42 changes: 42 additions & 0 deletions Arma.Studio.Data/UI/PopupContainer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Arma.Studio.Data.UI">
<Style x:Key="{x:Type local:PopupContainer}" TargetType="{x:Type local:PopupContainer}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Placement" Value="Bottom"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:PopupContainer}">
<Border x:Name="PART_Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="{TemplateBinding Margin}"
Padding="{TemplateBinding Padding}">
<Grid>
<ContentPresenter x:Name="PART_Content"/>
<Popup x:Name="PART_Popup"
PlacementTarget="{Binding ElementName=PART_Border}"
Placement="{TemplateBinding Placement}"
>
<ContentPresenter Content="{TemplateBinding PopupContent}"/>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" SourceName="PART_Popup" Value="True">
<Setter Property="IsOpen" Value="True" TargetName="PART_Popup"/>
</Trigger>
<Trigger Property="IsMouseOver" SourceName="PART_Border" Value="True">
<Setter Property="IsOpen" Value="True" TargetName="PART_Popup"/>
</Trigger>
<Trigger Property="PopupCanOpen" Value="False">
<Setter Property="IsOpen" Value="False" TargetName="PART_Popup"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Loading

0 comments on commit 39ede67

Please sign in to comment.