Skip to content

Commit

Permalink
Added Open Folder
Browse files Browse the repository at this point in the history
  • Loading branch information
X39 committed Mar 14, 2020
1 parent 28349d3 commit d3f8b9d
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Arma.Studio.Data/UI/Converters/IsNullConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ public class IsNullConverter : IValueConverter
/// <returns>A converted value. If the method returns null, the valid null value is used.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool success = true;
if (parameter is string para && (para.Equals("true", StringComparison.InvariantCultureIgnoreCase) || para.Equals("false", StringComparison.InvariantCultureIgnoreCase)))
{
success = System.Convert.ToBoolean(para);
}

if (value is string s)
{
return String.IsNullOrWhiteSpace(s);
return String.IsNullOrWhiteSpace(s) ? success : !success;
}
else
{
return value == null;
return value == null ? success : !success;
}
}

Expand Down
9 changes: 9 additions & 0 deletions Arma.Studio.SolutionExplorer/Properties/Language.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Arma.Studio.SolutionExplorer/Properties/Language.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,7 @@
<data name="FilesDialog_Title" xml:space="preserve">
<value>Add New Item</value>
</data>
<data name="SolutionExplorer_ContextMenu_OpenFolder" xml:space="preserve">
<value>Open folder</value>
</data>
</root>
8 changes: 8 additions & 0 deletions Arma.Studio.SolutionExplorer/SolutionExplorer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
IsEnabled="{Binding DataContext, Converter={StaticResource IsAssignableFromConverter}, ConverterParameter={x:Type data:PBO}}">

</MenuItem>
<MenuItem Header="{x:Static p:Language.SolutionExplorer_ContextMenu_OpenFolder}"
Command="{Binding Tag.CmdOpenContainingFolder}"
CommandParameter="{Binding DataContext}"
IsEnabled="{Binding DataContext, Converter={StaticResource IsNullConverter}, ConverterParameter=False}">
<MenuItem.Icon>
<Rectangle Fill="{StaticResource DrawingBrushOpen}" Width="16" Height="16"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Grid.Resources>
<Grid.RowDefinitions>
Expand Down
15 changes: 15 additions & 0 deletions Arma.Studio.SolutionExplorer/SolutionExplorerDataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ public object InRenameMode
}
}
});
public ICommand CmdOpenContainingFolder => new RelayCommand<FileFolderBase>((ffb) =>
{
switch (ffb)
{
case File file:
System.Diagnostics.Process.Start("explorer.exe", string.Format("/select,\"{0}\"", file.PhysicalPath.Replace('/', '\\')));
break;
case PBO pbo:
System.Diagnostics.Process.Start("explorer.exe", pbo.FullPath.Replace('/', '\\'));
break;
case Folder folder:
System.Diagnostics.Process.Start("explorer.exe", folder.FullPath.Replace('/', '\\'));
break;
}
});

public ICommand CmdAddPbo => new RelayCommand(() =>
{
Expand Down
11 changes: 11 additions & 0 deletions Arma.Studio/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
<asd:EnumSourceConverter x:Key="EnumSourceConverter"/>
</ResourceDictionary>
<ResourceDictionary>
<DrawingBrush x:Key="DrawingBrushOpen">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M16,6.6719L16,7.3279 10.207,13.1209 7.379,10.2929 8.672,8.9999 5.5,8.9999C4.673,8.9999 4,9.6729 4,10.4999 4,11.3269 4.673,11.9999 5.5,11.9999L6.5,11.9999 6.5,15.9999 5.5,15.9999C2.467,15.9999 0,13.5319 0,10.4999 0,7.4669 2.467,4.9999 5.5,4.9999L8.672,4.9999 7.379,3.7069 10.207,0.878900000000001z" />
<GeometryDrawing Brush="#FF00529C" Geometry="F1M14.9141,7L10.2071,11.707 8.7931,10.293 11.0861,8 5.5001,8C4.1221,8 3.0001,9.121 3.0001,10.5 3.0001,11.879 4.1221,13 5.5001,13L5.5001,15C3.0181,15 1.0001,12.981 1.0001,10.5 1.0001,8.019 3.0181,6 5.5001,6L11.0861,6 8.7931,3.707 10.2071,2.293z" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
<DrawingBrush x:Key="DrawingBrushStatusInformation">
<DrawingBrush.Drawing>
<DrawingGroup>
Expand Down

0 comments on commit d3f8b9d

Please sign in to comment.