Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev gridmenu #181

Merged
merged 5 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ public sealed class ElementDescriptor : Descriptor, IDescriptorConnector
{
if (_element is ElementType) return;

contextMenu.AddMenuItem("Show element")
contextMenu.AddMenuItem()
.SetHeader("Show element")
.SetCommand(_element, element =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
4 changes: 3 additions & 1 deletion RevitLookup.UI/ForkModificationList.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Fork version b711c9b3 Bump @fluentui/react-icons from 2.0.190 to 2.0.195 in /bra
# Common

Application.Current changed to Application.Current static property
MenuBorderColorDefaultBrush replaced with ControlElevationBorderBrush

# Wpf.Ui.Appearance.AppearanceData

Expand Down Expand Up @@ -109,4 +110,5 @@ New control with ItemsSourceChanged event

# Wpf.Ui.Styles.Controls.MenuItem

- Edited SubmenuItem Symbol trigger
- Edited SubmenuItem Symbol trigger
- Removed IsCheckable checkbox icon border
2 changes: 1 addition & 1 deletion RevitLookup.UI/Styles/Controls/AutoSuggestBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
Margin="0"
Padding="0,6,0,6"
HorizontalAlignment="Stretch"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down
2 changes: 1 addition & 1 deletion RevitLookup.UI/Styles/Controls/ComboBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
x:Name="DropDownBorder"
Margin="0"
Padding="0,4,0,6"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="{DynamicResource PopupCornerRadius}"
SnapsToDevicePixels="True">
Expand Down
2 changes: 1 addition & 1 deletion RevitLookup.UI/Styles/Controls/ContextMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{DynamicResource SystemFillColorSolidNeutralBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource MenuBorderColorDefaultBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Setter Property="MinWidth" Value="140" />
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
Expand Down
44 changes: 16 additions & 28 deletions RevitLookup.UI/Styles/Controls/MenuItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
x:Name="SubmenuBorder"
Margin="12,0,12,18"
Padding="0,3,0,3"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down Expand Up @@ -368,7 +368,7 @@
x:Name="SubmenuBorder"
Margin="12,10,12,18"
Padding="0,3,0,3"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down Expand Up @@ -533,7 +533,7 @@
x:Name="SubmenuBorder"
Margin="12,0,12,18"
Padding="0,3,0,3"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down Expand Up @@ -690,29 +690,16 @@
<ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut" />
</Grid.ColumnDefinitions>

<Border
x:Name="CheckBoxIconBorder"
<TextBlock
Grid.Column="0"
Width="20"
Height="20"
Margin="0"
x:Name="CheckBoxIcon"
Visibility="Collapsed"
HorizontalAlignment="Center"
VerticalAlignment="Center"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="4"
Visibility="Collapsed">
<Border.Background>
<SolidColorBrush Color="{DynamicResource ControlFillColorDefault}" />
</Border.Background>
<TextBlock
x:Name="CheckBoxIcon"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{DynamicResource FluentSystemIcons}"
FontSize="16"
Text=""
TextAlignment="Center" />
</Border>
FontFamily="{DynamicResource FluentSystemIcons}"
FontSize="16"
Text="&#xF294;"
TextAlignment="Center" />

<ContentPresenter
x:Name="Icon"
Expand Down Expand Up @@ -762,11 +749,12 @@
<!-- <Setter TargetName="SymbolIcon" Property="Margin" Value="0" /> -->
</Trigger>
<Trigger Property="IsCheckable" Value="True">
<Setter TargetName="CheckBoxIconBorder" Property="Visibility" Value="Visible" />
<Setter TargetName="CheckBoxIconBorder" Property="Margin" Value="0,0,6,0" />
<Setter TargetName="CheckBoxIcon" Property="Visibility" Value="Hidden" />
<Setter TargetName="CheckBoxIcon" Property="Margin" Value="0,0,6,0" />
<Setter TargetName="SymbolIcon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="CheckBoxIcon" Property="Text" Value="&#xF294;" />
<Setter TargetName="CheckBoxIcon" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground">
Expand Down Expand Up @@ -850,7 +838,7 @@
x:Name="SubmenuBorder"
Margin="12,10,12,18"
Padding="0,3,0,3"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down
2 changes: 1 addition & 1 deletion RevitLookup.UI/Styles/Controls/ToolBar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
x:Name="DropDownBorder"
Margin="12,0,12,18"
Padding="0,3,0,3"
BorderBrush="{DynamicResource MenuBorderColorDefaultBrush}"
BorderBrush="{DynamicResource ControlElevationBorderBrush}"
BorderThickness="1"
CornerRadius="8"
SnapsToDevicePixels="True">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
using System.Windows.Controls;
#if R23_OR_GREATER
using System.Windows.Input;
using RevitLookup.Views.Extensions;
#endif
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;
using RevitLookup.Views.Extensions;

namespace RevitLookup.Core.ComponentModel.Descriptors;

Expand All @@ -45,7 +45,8 @@ public CurveDescriptor(Curve curve)
public void RegisterMenu(ContextMenu contextMenu, UIElement bindableElement)
{
#if R23_OR_GREATER
contextMenu.AddMenuItem("Show curve")
contextMenu.AddMenuItem()
.SetHeader("Show curve")
.SetCommand(_curve, curve =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@
using System.Windows.Controls;
#if R23_OR_GREATER
using System.Windows.Input;
using RevitLookup.Views.Extensions;
#endif
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;
using RevitLookup.Views.Extensions;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public sealed class EdgeDescriptor : Descriptor, IDescriptorCollector, IDescriptorConnector
{
#if R23_OR_GREATER
private readonly Edge _edge;

#endif
public EdgeDescriptor(Edge edge)
{
#if R23_OR_GREATER
_edge = edge;
#endif
Name = $"{edge.ApproximateLength.ToString(CultureInfo.InvariantCulture)} ft";
}

public void RegisterMenu(ContextMenu contextMenu, UIElement bindableElement)
{
#if R23_OR_GREATER
contextMenu.AddMenuItem("Show edge")
contextMenu.AddMenuItem()
.SetHeader("Show edge")
.SetCommand(_edge, edge =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public void RegisterMenu(ContextMenu contextMenu, UIElement bindableElement)
{
if (_element is ElementType) return;

contextMenu.AddMenuItem("Show element")
contextMenu.AddMenuItem()
.SetHeader("Show element")
.SetCommand(_element, element =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@
using System.Windows.Controls;
#if R23_OR_GREATER
using System.Windows.Input;
using RevitLookup.Views.Extensions;
#endif
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;
using RevitLookup.Views.Extensions;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public sealed class FaceDescriptor : Descriptor, IDescriptorCollector, IDescriptorConnector
{
#if R23_OR_GREATER
private readonly Face _face;

#endif
public FaceDescriptor(Face face)
{
#if R23_OR_GREATER
_face = face;
#endif
Name = $"{face.Area.ToString(CultureInfo.InvariantCulture)} ft²";
}

public void RegisterMenu(ContextMenu contextMenu, UIElement bindableElement)
{
#if R23_OR_GREATER
contextMenu.AddMenuItem("Show face")
contextMenu.AddMenuItem()
.SetHeader("Show face")
.SetCommand(_face, face =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.

using System.Collections;
using System.Reflection;
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,33 @@
using System.Windows.Controls;
#if R23_OR_GREATER
using System.Windows.Input;
using RevitLookup.Views.Extensions;
#endif
using Autodesk.Revit.DB;
using RevitLookup.Core.Contracts;
using RevitLookup.Core.Objects;
using RevitLookup.Views.Extensions;

namespace RevitLookup.Core.ComponentModel.Descriptors;

public sealed class SolidDescriptor : Descriptor, IDescriptorCollector, IDescriptorConnector
{
#if R23_OR_GREATER
private readonly Solid _solid;

#endif
public SolidDescriptor(Solid solid)
{
#if R23_OR_GREATER
_solid = solid;
#endif
Name = $"{solid.Volume.ToString(CultureInfo.InvariantCulture)} ft³";
}

public void RegisterMenu(ContextMenu contextMenu, UIElement bindableElement)
{
#if R23_OR_GREATER
contextMenu.AddMenuItem("Show solid")
contextMenu.AddMenuItem()
.SetHeader("Show solid")
.SetCommand(_solid, solid =>
{
Application.ActionEventHandler.Raise(_ =>
Expand Down
12 changes: 6 additions & 6 deletions RevitLookup/Services/SoftwareUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public SoftwareUpdateService(IConfiguration configuration)
_writeAccess = configuration.GetValue<string>("FolderAccess") == "Write";
}

public SoftwareUpdateState State { get; set; }
public SoftwareUpdateState State { get; private set; }
public string CurrentVersion { get; }
public string NewVersion { get; set; }
public string LatestCheckDate { get; set; }
public string ReleaseNotesUrl { get; set; }
public string ErrorMessage { get; set; }
public string LocalFilePath { get; set; }
public string NewVersion { get; private set; }
public string LatestCheckDate { get; private set; }
public string ReleaseNotesUrl { get; private set; }
public string ErrorMessage { get; private set; }
public string LocalFilePath { get; private set; }

public async Task CheckUpdates()
{
Expand Down
10 changes: 7 additions & 3 deletions RevitLookup/Views/Dialogs/UnitsDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ private void OnRowLoaded(object sender, RoutedEventArgs routedEventArgs)

private void CreateTreeContextMenu(UnitInfo info, FrameworkElement row)
{
row.ContextMenu = new ContextMenu();
row.ContextMenu.AddMenuItem(Resources["CopyMenuItem"])
row.ContextMenu = new ContextMenu
{
Resources = Resources
};

row.ContextMenu.AddMenuItem("CopyMenuItem")
.SetHeader("Copy unit")
.SetCommand(info, parameter => Clipboard.SetText(parameter.Unit))
.SetShortcut(row, ModifierKeys.Control, Key.C);
row.ContextMenu.AddMenuItem(Resources["CopyMenuItem"])
row.ContextMenu.AddMenuItem("CopyMenuItem")
.SetHeader("Copy label")
.SetCommand(info, parameter => Clipboard.SetText(parameter.Label))
.SetShortcut(row, ModifierKeys.Control | ModifierKeys.Shift, Key.C);
Expand Down
Loading