Skip to content

Commit c95f364

Browse files
authored
Merge pull request #147 from SoftBIM/dev
Improvement UI/UX - Fix small bug
2 parents 0fb62ee + b702a64 commit c95f364

File tree

14 files changed

+177
-125
lines changed

14 files changed

+177
-125
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Changelog
2+
- 2023-09-13 **2.0.2**
3+
- Improvement user interface and user experience with coding.
4+
- Add new button create new file
5+
- Add new button save as file
6+
- Fix bug output with language is chines or Japanese
7+
- Follow up package IronPython latest.
8+
- Add more shortcut default.
29
- 2023-04-14 **2.0.1**
310
- Support Autodesk Revit version 2024.
411
- 2022-12-16 **2.0.0**

Installer/Installer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
const string projectName = "RevitPythonShell";
1313
const string outputName = "RevitPythonShell";
1414
const string outputDir = "output";
15-
const string version = "2.0.1";
15+
const string version = "2.0.2";
1616

1717
var fileName = new StringBuilder().Append(outputName).Append("-").Append(version);
1818
var project = new Project

PythonConsoleControl/PythonConsoleControl.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<DebugType>full</DebugType>
1414
</PropertyGroup>
1515
<ItemGroup>
16-
<PackageReference Include="AvalonEdit" Version="6.0.1" />
17-
<PackageReference Include="IronPython" Version="3.4.0" />
16+
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
17+
<PackageReference Include="IronPython" Version="3.4.1" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<Reference Include="IronPython">

PythonConsoleControl/PythonOutputStream.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Copyright (c) 2010 Joe Moorhouse
22

3+
using System;
34
using System.IO;
45
using System.Text;
6+
using System.Text.RegularExpressions;
57

68
namespace PythonConsoleControl
79
{
@@ -63,8 +65,18 @@ public override int Read(byte[] buffer, int offset, int count)
6365
/// </summary>
6466
public override void Write(byte[] buffer, int offset, int count)
6567
{
66-
string text = UTF8Encoding.UTF8.GetString(buffer, offset, count);
68+
string text = Encoding.UTF8.GetString(buffer, offset, count);
69+
text = DecodeUnicodeEscapes(text);
6770
textEditor.Write(text);
6871
}
72+
private string DecodeUnicodeEscapes(string input)
73+
{
74+
return Regex.Replace(input, @"\\u[0-9a-fA-F]{4}", match =>
75+
{
76+
var hex = match.Value.Substring(2);
77+
int charValue = Convert.ToInt32(hex, 16);
78+
return char.ConvertFromUtf32(charValue);
79+
});
80+
}
6981
}
7082
}

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
}
1.43 KB
Loading
985 Bytes
Loading
1.01 KB
Loading
2.16 KB
Loading
1.06 KB
Loading

RevitPythonShell/RevitPythonShell.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<PublishTrimmed>true</PublishTrimmed>
6363
</PropertyGroup>
6464
<ItemGroup>
65-
<PackageReference Include="AvalonEdit" Version="6.0.1" />
65+
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
6666
</ItemGroup>
6767
<ItemGroup>
6868
<Reference Include="IronPython">
@@ -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: 117 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -14,132 +14,135 @@
1414
-->
1515
<Grid>
1616
<Grid.RowDefinitions>
17-
<RowDefinition Height="50*" />
1817
<RowDefinition Height="Auto" />
19-
<RowDefinition Height="30*" />
18+
<RowDefinition Height="20*" />
19+
<RowDefinition Height="10" />
20+
<RowDefinition Height="12*" />
2021
</Grid.RowDefinitions>
2122
<Grid.ColumnDefinitions>
2223
<ColumnDefinition Width="1*" />
2324
<ColumnDefinition Width="Auto" />
2425
</Grid.ColumnDefinitions>
25-
<Grid Grid.Column="0" Grid.Row="0">
26-
<console:IronPythonConsoleControl Name="consoleControl" />
27-
</Grid>
28-
<GridSplitter
29-
Grid.Row="1"
30-
Height="10"
31-
HorizontalAlignment="Stretch"
32-
VerticalAlignment="Center" />
33-
<DockPanel Grid.Column="0" Grid.Row="2">
34-
<ToolBar DockPanel.Dock="Top">
35-
<ToolBar.Resources>
26+
<DockPanel Grid.Column="0" Grid.Row="0">
27+
<Ribbon Margin="0,-22,0,0"
28+
KeyboardNavigation.TabIndex="0"
29+
ContextMenu="{x:Null}"
30+
AllowDrop="False">
31+
<Ribbon.Resources>
3632
<Style TargetType="{x:Type Image}">
3733
<Style.Triggers>
38-
<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">
3937
<Setter Property="Opacity" Value="0.30" />
4038
</DataTrigger>
4139
</Style.Triggers>
4240
</Style>
43-
</ToolBar.Resources>
44-
<Button Click="openFileClick">
45-
<Image
46-
Height="16"
47-
SnapsToDevicePixels="True"
48-
Source="/RevitPythonShell;component/Resources/Theme/Open.png"
49-
ToolTip="Open Python Script" />
50-
</Button>
51-
<Button Click="saveFileClick">
52-
<Image
53-
Height="16"
54-
SnapsToDevicePixels="True"
55-
Source="/RevitPythonShell;component/Resources/Theme/Save.png"
56-
ToolTip="Save This Script Into File" />
57-
</Button>
58-
<Separator />
59-
<Button Command="Cut">
60-
<Image
61-
Height="16"
62-
SnapsToDevicePixels="True"
63-
Source="/RevitPythonShell;component/Resources/Theme/Cut.png"
64-
ToolTip="Cut Selected" />
65-
</Button>
66-
<Button Command="Copy">
67-
<Image
68-
Height="16"
69-
SnapsToDevicePixels="True"
70-
Source="/RevitPythonShell;component/Resources/Theme/Copy.png"
71-
ToolTip="Copy Selected" />
72-
</Button>
73-
<Button Command="Paste">
74-
<Image
75-
Height="16"
76-
SnapsToDevicePixels="True"
77-
Source="/RevitPythonShell;component/Resources/Theme/Paste.png"
78-
ToolTip="Paste Into Script Editor" />
79-
</Button>
80-
<Button Command="Delete">
81-
<Image
82-
Height="16"
83-
SnapsToDevicePixels="True"
84-
Source="/RevitPythonShell;component/Resources/Theme/Delete.png"
85-
ToolTip="Delete Selected" />
86-
</Button>
87-
<Separator />
88-
<Button Command="Undo">
89-
<Image
90-
Height="16"
91-
SnapsToDevicePixels="True"
92-
Source="/RevitPythonShell;component/Resources/Theme/Undo.png"
93-
ToolTip="Undo" />
94-
</Button>
95-
<Button Command="Redo">
96-
<Image
97-
Height="16"
98-
SnapsToDevicePixels="True"
99-
Source="/RevitPythonShell;component/Resources/Theme/Redo.png"
100-
ToolTip="Redo" />
101-
</Button>
102-
<Separator />
103-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=WordWrap}">
104-
<Image
105-
Height="16"
106-
SnapsToDevicePixels="True"
107-
Source="/RevitPythonShell;component/Resources/Theme/WordWrap.png"
108-
ToolTip="Toggle Word Wrap" />
109-
</CheckBox>
110-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}">
111-
<Image
112-
Height="16"
113-
SnapsToDevicePixels="True"
114-
Source="/RevitPythonShell;component/Resources/Theme/Number.png"
115-
ToolTip="Toggle Line Numbers" />
116-
</CheckBox>
117-
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}">
118-
<Image
119-
Height="16"
120-
SnapsToDevicePixels="True"
121-
Source="/RevitPythonShell;component/Resources/Theme/Paragraph.png"
122-
ToolTip="Toggle Show End of Line" />
123-
</CheckBox>
124-
<Separator />
125-
<Button Click="runClick">
126-
<Image
127-
Height="16"
128-
SnapsToDevicePixels="True"
129-
Source="/RevitPythonShell;component/Resources/Theme/Run.png"
130-
ToolTip="Run Script. Results will be displayed in the IronPython prompt." />
131-
</Button>
132-
</ToolBar>
133-
<Grid DockPanel.Dock="Bottom">
134-
<avalonEdit:TextEditor
135-
FontFamily="Consolas"
136-
FontSize="10pt"
137-
GotFocus="textEditor_GotFocus"
138-
Name="textEditor">
139-
# IronPython Pad. Write code snippets here and F5 to run.
140-
</avalonEdit:TextEditor>
141-
</Grid>
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 (Ctrl + O)"
54+
Click="openFileClick" />
55+
<RibbonButton Label="Save" LargeImageSource="../Resources/Theme/Save.png"
56+
ToolTip="Save (Ctrl + S)"
57+
Click="saveFileClick"
58+
SnapsToDevicePixels="True" />
59+
<RibbonButton Label="Save As" LargeImageSource="../Resources/Theme/SaveAs.png"
60+
ToolTip="Save As (Ctrl + Shift + S)"
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="(F5) 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> -->
142126
</DockPanel>
127+
<Grid Grid.Column="0" Grid.Row="1">
128+
<avalonEdit:TextEditor
129+
FontFamily="Consolas"
130+
FontSize="10pt"
131+
GotFocus="textEditor_GotFocus"
132+
Name="textEditor">
133+
# IronPython Pad. Write code snippets here and F5 to run.
134+
</avalonEdit:TextEditor>
135+
</Grid>
136+
<GridSplitter
137+
Grid.Row="2"
138+
Grid.Column="0"
139+
Height="10"
140+
HorizontalAlignment="Stretch"
141+
VerticalAlignment="Center" />
142+
143+
<Grid Grid.Row="3" MinHeight="20">
144+
<console:IronPythonConsoleControl Name="consoleControl" />
145+
</Grid>
143146

144147
</Grid>
145-
</Window>
148+
</Window>

0 commit comments

Comments
 (0)