Skip to content

Commit 8965f36

Browse files
committed
improve ux
1 parent 68e8f23 commit 8965f36

File tree

6 files changed

+123
-99
lines changed

6 files changed

+123
-99
lines changed

RevitPythonShell/Properties/launchSettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
"Revit 2023": {
5252
"commandName": "Executable",
5353
"executablePath": "%ProgramW6432%\\Autodesk\\Revit 2023\\Revit.exe"
54+
},
55+
"Revit 2024": {
56+
"commandName": "Executable",
57+
"executablePath": "%ProgramW6432%\\Autodesk\\Revit 2024\\Revit.exe"
5458
}
5559
}
5660
}
390 Bytes
Loading
505 Bytes
Loading

RevitPythonShell/RevitPythonShell.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<Reference Include="System" />
8888
<Reference Include="System.Core" />
8989
<Reference Include="System.Drawing" />
90+
<Reference Include="System.Windows.Controls.Ribbon" />
9091
<Reference Include="System.Windows.Forms" />
9192
<Reference Include="System.Xaml" />
9293
<Reference Include="System.Xml.Linq" />
@@ -133,6 +134,8 @@
133134
</EmbeddedResource>
134135
</ItemGroup>
135136
<ItemGroup>
137+
<Resource Include="Resources\Theme\SaveAs.png" />
138+
<Resource Include="Resources\Theme\New.png" />
136139
<None Include="RevitPythonShell.addin" />
137140
<None Include="Manifests\AddinTemplate.addin">
138141
<Generator>MSDataSetGenerator</Generator>

RevitPythonShell/Views/IronPythonConsole.xaml

Lines changed: 97 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-->
1515
<Grid>
1616
<Grid.RowDefinitions>
17-
<RowDefinition Height="30" />
17+
<RowDefinition Height="120" />
1818
<RowDefinition Height="20*" />
1919
<RowDefinition Height="10" />
2020
<RowDefinition Height="12*" />
@@ -24,105 +24,105 @@
2424
<ColumnDefinition Width="Auto" />
2525
</Grid.ColumnDefinitions>
2626
<DockPanel Grid.Column="0" Grid.Row="0">
27-
<ToolBar DockPanel.Dock="Top">
28-
<ToolBar.Resources>
27+
<Ribbon Margin="0,-22,0,0"
28+
KeyboardNavigation.TabIndex="0"
29+
ContextMenu="{x:Null}"
30+
AllowDrop="False">
31+
<Ribbon.Resources>
2932
<Style TargetType="{x:Type Image}">
3033
<Style.Triggers>
31-
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
34+
<DataTrigger
35+
Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}"
36+
Value="False">
3237
<Setter Property="Opacity" Value="0.30" />
3338
</DataTrigger>
3439
</Style.Triggers>
3540
</Style>
36-
</ToolBar.Resources>
37-
<Button Click="openFileClick">
38-
<Image
39-
Height="16"
40-
SnapsToDevicePixels="True"
41-
Source="/RevitPythonShell;component/Resources/Theme/Open.png"
42-
ToolTip="Open Python Script" />
43-
</Button>
44-
<Button Click="saveFileClick">
45-
<Image
46-
Height="16"
47-
SnapsToDevicePixels="True"
48-
Source="/RevitPythonShell;component/Resources/Theme/Save.png"
49-
ToolTip="Save This Script Into File" />
50-
</Button>
51-
<Separator />
52-
<Button Command="Cut">
53-
<Image
54-
Height="16"
55-
SnapsToDevicePixels="True"
56-
Source="/RevitPythonShell;component/Resources/Theme/Cut.png"
57-
ToolTip="Cut Selected" />
58-
</Button>
59-
<Button Command="Copy">
60-
<Image
61-
Height="16"
62-
SnapsToDevicePixels="True"
63-
Source="/RevitPythonShell;component/Resources/Theme/Copy.png"
64-
ToolTip="Copy Selected" />
65-
</Button>
66-
<Button Command="Paste">
67-
<Image
68-
Height="16"
69-
SnapsToDevicePixels="True"
70-
Source="/RevitPythonShell;component/Resources/Theme/Paste.png"
71-
ToolTip="Paste Into Script Editor" />
72-
</Button>
73-
<Button Command="Delete">
74-
<Image
75-
Height="16"
76-
SnapsToDevicePixels="True"
77-
Source="/RevitPythonShell;component/Resources/Theme/Delete.png"
78-
ToolTip="Delete Selected" />
79-
</Button>
80-
<Separator />
81-
<Button Command="Undo">
82-
<Image
83-
Height="16"
84-
SnapsToDevicePixels="True"
85-
Source="/RevitPythonShell;component/Resources/Theme/Undo.png"
86-
ToolTip="Undo" />
87-
</Button>
88-
<Button Command="Redo">
89-
<Image
90-
Height="16"
91-
SnapsToDevicePixels="True"
92-
Source="/RevitPythonShell;component/Resources/Theme/Redo.png"
93-
ToolTip="Redo" />
94-
</Button>
95-
<Separator />
96-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=WordWrap}">
97-
<Image
98-
Height="16"
99-
SnapsToDevicePixels="True"
100-
Source="/RevitPythonShell;component/Resources/Theme/WordWrap.png"
101-
ToolTip="Toggle Word Wrap" />
102-
</CheckBox>
103-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}">
104-
<Image
105-
Height="16"
106-
SnapsToDevicePixels="True"
107-
Source="/RevitPythonShell;component/Resources/Theme/Number.png"
108-
ToolTip="Toggle Line Numbers" />
109-
</CheckBox>
110-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}">
111-
<Image
112-
Height="16"
113-
SnapsToDevicePixels="True"
114-
Source="/RevitPythonShell;component/Resources/Theme/Paragraph.png"
115-
ToolTip="Toggle Show End of Line" />
116-
</CheckBox>
117-
<Separator />
118-
<Button Click="runClick">
119-
<Image
120-
Height="16"
121-
SnapsToDevicePixels="True"
122-
Source="/RevitPythonShell;component/Resources/Theme/Run.png"
123-
ToolTip="Run Script. Results will be displayed in the IronPython prompt." />
124-
</Button>
125-
</ToolBar>
41+
</Ribbon.Resources>
42+
<Ribbon.ApplicationMenu>
43+
<RibbonApplicationMenu Visibility="Collapsed">
44+
</RibbonApplicationMenu>
45+
</Ribbon.ApplicationMenu>
46+
<RibbonTab Header="Home" ContextMenu="{x:Null}">
47+
<RibbonGroup Header="File">
48+
<RibbonButton Label="New" LargeImageSource="../Resources/Theme/New.png"
49+
ToolTip="New (Ctrl + N)"
50+
SnapsToDevicePixels="True"
51+
Click="newFileClick" />
52+
<RibbonButton Label="Open" LargeImageSource="../Resources/Theme/Open.png"
53+
ToolTip="Open Python Script"
54+
Click="openFileClick" />
55+
<RibbonButton Label="Save" LargeImageSource="../Resources/Theme/Save.png"
56+
ToolTip="Save This Script Into File"
57+
Click="saveFileClick"
58+
SnapsToDevicePixels="True" />
59+
<RibbonButton Label="Save As" LargeImageSource="../Resources/Theme/SaveAs.png"
60+
ToolTip="Save As"
61+
SnapsToDevicePixels="True"
62+
Click="saveAsFileClick" />
63+
</RibbonGroup>
64+
<RibbonGroup Header="Modify">
65+
<RibbonButton Label="Cut" SmallImageSource="../Resources/Theme/Cut.png"
66+
ToolTip="Cut Selected"
67+
SnapsToDevicePixels="True"
68+
Command="Cut" />
69+
<RibbonButton Label="Copy" SmallImageSource="../Resources/Theme/Save.png"
70+
ToolTip="Copy Selected"
71+
SnapsToDevicePixels="True"
72+
Command="Copy" />
73+
<RibbonButton Label="Paste" SmallImageSource="../Resources/Theme/Paste.png"
74+
ToolTip="Paste Into Script Editor"
75+
SnapsToDevicePixels="True"
76+
Command="Paste" />
77+
</RibbonGroup>
78+
<RibbonGroup Header="Edit">
79+
<RibbonToggleButton Label="Undo"
80+
SmallImageSource="../Resources/Theme/Undo.png"
81+
SnapsToDevicePixels="True"
82+
ToolTip="Undo"
83+
Command="Undo" />
84+
<RibbonButton Label="Redo" SmallImageSource="../Resources/Theme/Redo.png"
85+
ToolTip="Redo"
86+
SnapsToDevicePixels="True"
87+
Command="Redo" />
88+
<RibbonButton Label="Delete" SmallImageSource="../Resources/Theme/Delete.png"
89+
ToolTip="Delete Selected"
90+
SnapsToDevicePixels="True"
91+
Command="Delete" />
92+
</RibbonGroup>
93+
<RibbonGroup Header="Cell">
94+
<RibbonCheckBox Label="WordWrap" SmallImageSource="../Resources/Theme/WordWrap.png"
95+
ToolTip="Toggle Word Wrap"
96+
SnapsToDevicePixels="True"
97+
IsChecked="{Binding ElementName=textEditor, Path=WordWrap}" />
98+
<RibbonCheckBox Label="Paragraph" SmallImageSource="../Resources/Theme/Paragraph.png"
99+
ToolTip="Toggle Show End of Line"
100+
SnapsToDevicePixels="True"
101+
IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}"
102+
/>
103+
<RibbonCheckBox Label="Number" SmallImageSource="../Resources/Theme/Number.png"
104+
IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}"
105+
ToolTip="Toggle Line Numbers"
106+
SnapsToDevicePixels="True"/>
107+
</RibbonGroup>
108+
<RibbonGroup Header="Execute">
109+
<RibbonButton Label="Run" LargeImageSource="../Resources/Theme/Run.png"
110+
SnapsToDevicePixels="True"
111+
Click="runClick"
112+
ToolTip="Run Script. Results will be displayed in the IronPython prompt." />
113+
</RibbonGroup>
114+
</RibbonTab>
115+
</Ribbon>
116+
<!-- <ToolBar DockPanel.Dock="Top"> -->
117+
<!-- <Separator /> -->
118+
<!-- <CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}"> -->
119+
<!-- <Image -->
120+
<!-- Height="16" -->
121+
<!-- SnapsToDevicePixels="True" -->
122+
<!-- Source="/RevitPythonShell;component/Resources/Theme/Number.png" -->
123+
<!-- ToolTip="Toggle Line Numbers" /> -->
124+
<!-- </CheckBox> -->
125+
<!-- </ToolBar> -->
126126
</DockPanel>
127127
<Grid Grid.Column="0" Grid.Row="1">
128128
<avalonEdit:TextEditor
@@ -135,13 +135,14 @@
135135
</Grid>
136136
<GridSplitter
137137
Grid.Row="2"
138+
Grid.Column="0"
138139
Height="10"
139140
HorizontalAlignment="Stretch"
140141
VerticalAlignment="Center" />
141-
142+
142143
<Grid Grid.Row="3" MinHeight="20">
143144
<console:IronPythonConsoleControl Name="consoleControl" />
144145
</Grid>
145146

146147
</Grid>
147-
</Window>
148+
</Window>

RevitPythonShell/Views/IronPythonConsole.xaml.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Reflection;
44
using System.Windows;
5+
using System.Windows.Controls.Ribbon;
56
using System.Windows.Input;
67
using System.Xml;
78
using ICSharpCode.AvalonEdit;
@@ -53,7 +54,11 @@ private void MainWindow_Initialized(object sender, EventArgs e)
5354
//propertyGridComboBox.SelectedIndex = 1;
5455
textEditor.ShowLineNumbers = true;
5556
}
56-
57+
private void newFileClick(object sender, RoutedEventArgs e)
58+
{
59+
currentFileName = null;
60+
textEditor.Text = string.Empty;
61+
}
5762
private void openFileClick(object sender, RoutedEventArgs e)
5863
{
5964
OpenFileDialog dlg = new OpenFileDialog();
@@ -65,13 +70,23 @@ private void openFileClick(object sender, RoutedEventArgs e)
6570
//textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(currentFileName));
6671
}
6772
}
68-
73+
private void saveAsFileClick(object sender, EventArgs e)
74+
{
75+
currentFileName = null;
76+
SaveFile();
77+
}
6978
private void saveFileClick(object sender, EventArgs e)
79+
{
80+
SaveFile();
81+
}
82+
private void SaveFile()
7083
{
7184
if (currentFileName == null)
7285
{
7386
SaveFileDialog dlg = new SaveFileDialog();
74-
dlg.DefaultExt = ".txt";
87+
dlg.Filter = "Save Files (*.py)|*.py";
88+
dlg.DefaultExt = "py";
89+
dlg.AddExtension = true;
7590
if (dlg.ShowDialog() ?? false)
7691
{
7792
currentFileName = dlg.FileName;
@@ -116,5 +131,6 @@ private void textEditor_GotFocus(object sender, RoutedEventArgs e)
116131
tb.GotFocus -= textEditor_GotFocus;
117132
}
118133
}
134+
119135
}
120136
}

0 commit comments

Comments
 (0)