Skip to content

Improvement UI/UX - Fix small bug #147

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

Merged
merged 7 commits into from
Sep 20, 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog
- 2023-09-13 **2.0.2**
- Improvement user interface and user experience with coding.
- Add new button create new file
- Add new button save as file
- Fix bug output with language is chines or Japanese
- Follow up package IronPython latest.
- Add more shortcut default.
- 2023-04-14 **2.0.1**
- Support Autodesk Revit version 2024.
- 2022-12-16 **2.0.0**
Expand Down
2 changes: 1 addition & 1 deletion Installer/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const string projectName = "RevitPythonShell";
const string outputName = "RevitPythonShell";
const string outputDir = "output";
const string version = "2.0.1";
const string version = "2.0.2";

var fileName = new StringBuilder().Append(outputName).Append("-").Append(version);
var project = new Project
Expand Down
4 changes: 2 additions & 2 deletions PythonConsoleControl/PythonConsoleControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="IronPython" Version="3.4.0" />
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
<PackageReference Include="IronPython" Version="3.4.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="IronPython">
Expand Down
14 changes: 13 additions & 1 deletion PythonConsoleControl/PythonOutputStream.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) 2010 Joe Moorhouse

using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace PythonConsoleControl
{
Expand Down Expand Up @@ -63,8 +65,18 @@ public override int Read(byte[] buffer, int offset, int count)
/// </summary>
public override void Write(byte[] buffer, int offset, int count)
{
string text = UTF8Encoding.UTF8.GetString(buffer, offset, count);
string text = Encoding.UTF8.GetString(buffer, offset, count);
text = DecodeUnicodeEscapes(text);
textEditor.Write(text);
}
private string DecodeUnicodeEscapes(string input)
{
return Regex.Replace(input, @"\\u[0-9a-fA-F]{4}", match =>
{
var hex = match.Value.Substring(2);
int charValue = Convert.ToInt32(hex, 16);
return char.ConvertFromUtf32(charValue);
});
}
}
}
4 changes: 4 additions & 0 deletions RevitPythonShell/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"Revit 2023": {
"commandName": "Executable",
"executablePath": "%ProgramW6432%\\Autodesk\\Revit 2023\\Revit.exe"
},
"Revit 2024": {
"commandName": "Executable",
"executablePath": "%ProgramW6432%\\Autodesk\\Revit 2024\\Revit.exe"
}
}
}
Binary file added RevitPythonShell/Resources/Theme/New.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified RevitPythonShell/Resources/Theme/Open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified RevitPythonShell/Resources/Theme/Run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified RevitPythonShell/Resources/Theme/Save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added RevitPythonShell/Resources/Theme/SaveAs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion RevitPythonShell/RevitPythonShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<PublishTrimmed>true</PublishTrimmed>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="AvalonEdit" Version="6.3.0.90" />
</ItemGroup>
<ItemGroup>
<Reference Include="IronPython">
Expand All @@ -87,6 +87,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Controls.Ribbon" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
Expand Down Expand Up @@ -133,6 +134,8 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Theme\SaveAs.png" />
<Resource Include="Resources\Theme\New.png" />
<None Include="RevitPythonShell.addin" />
<None Include="Manifests\AddinTemplate.addin">
<Generator>MSDataSetGenerator</Generator>
Expand Down
231 changes: 117 additions & 114 deletions RevitPythonShell/Views/IronPythonConsole.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,132 +14,135 @@
-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="30*" />
<RowDefinition Height="20*" />
<RowDefinition Height="10" />
<RowDefinition Height="12*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Grid.Row="0">
<console:IronPythonConsoleControl Name="consoleControl" />
</Grid>
<GridSplitter
Grid.Row="1"
Height="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />
<DockPanel Grid.Column="0" Grid.Row="2">
<ToolBar DockPanel.Dock="Top">
<ToolBar.Resources>
<DockPanel Grid.Column="0" Grid.Row="0">
<Ribbon Margin="0,-22,0,0"
KeyboardNavigation.TabIndex="0"
ContextMenu="{x:Null}"
AllowDrop="False">
<Ribbon.Resources>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
<DataTrigger
Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}"
Value="False">
<Setter Property="Opacity" Value="0.30" />
</DataTrigger>
</Style.Triggers>
</Style>
</ToolBar.Resources>
<Button Click="openFileClick">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Open.png"
ToolTip="Open Python Script" />
</Button>
<Button Click="saveFileClick">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Save.png"
ToolTip="Save This Script Into File" />
</Button>
<Separator />
<Button Command="Cut">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Cut.png"
ToolTip="Cut Selected" />
</Button>
<Button Command="Copy">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Copy.png"
ToolTip="Copy Selected" />
</Button>
<Button Command="Paste">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Paste.png"
ToolTip="Paste Into Script Editor" />
</Button>
<Button Command="Delete">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Delete.png"
ToolTip="Delete Selected" />
</Button>
<Separator />
<Button Command="Undo">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Undo.png"
ToolTip="Undo" />
</Button>
<Button Command="Redo">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Redo.png"
ToolTip="Redo" />
</Button>
<Separator />
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=WordWrap}">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/WordWrap.png"
ToolTip="Toggle Word Wrap" />
</CheckBox>
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Number.png"
ToolTip="Toggle Line Numbers" />
</CheckBox>
<CheckBox IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Paragraph.png"
ToolTip="Toggle Show End of Line" />
</CheckBox>
<Separator />
<Button Click="runClick">
<Image
Height="16"
SnapsToDevicePixels="True"
Source="/RevitPythonShell;component/Resources/Theme/Run.png"
ToolTip="Run Script. Results will be displayed in the IronPython prompt." />
</Button>
</ToolBar>
<Grid DockPanel.Dock="Bottom">
<avalonEdit:TextEditor
FontFamily="Consolas"
FontSize="10pt"
GotFocus="textEditor_GotFocus"
Name="textEditor">
# IronPython Pad. Write code snippets here and F5 to run.
</avalonEdit:TextEditor>
</Grid>
</Ribbon.Resources>
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu Visibility="Collapsed">
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab Header="Home" ContextMenu="{x:Null}">
<RibbonGroup Header="File">
<RibbonButton Label="New" LargeImageSource="../Resources/Theme/New.png"
ToolTip="New (Ctrl + N)"
SnapsToDevicePixels="True"
Click="newFileClick" />
<RibbonButton Label="Open" LargeImageSource="../Resources/Theme/Open.png"
ToolTip="Open (Ctrl + O)"
Click="openFileClick" />
<RibbonButton Label="Save" LargeImageSource="../Resources/Theme/Save.png"
ToolTip="Save (Ctrl + S)"
Click="saveFileClick"
SnapsToDevicePixels="True" />
<RibbonButton Label="Save As" LargeImageSource="../Resources/Theme/SaveAs.png"
ToolTip="Save As (Ctrl + Shift + S)"
SnapsToDevicePixels="True"
Click="saveAsFileClick" />
</RibbonGroup>
<RibbonGroup Header="Modify">
<RibbonButton Label="Cut" SmallImageSource="../Resources/Theme/Cut.png"
ToolTip="Cut Selected"
SnapsToDevicePixels="True"
Command="Cut" />
<RibbonButton Label="Copy" SmallImageSource="../Resources/Theme/Save.png"
ToolTip="Copy Selected"
SnapsToDevicePixels="True"
Command="Copy" />
<RibbonButton Label="Paste" SmallImageSource="../Resources/Theme/Paste.png"
ToolTip="Paste Into Script Editor"
SnapsToDevicePixels="True"
Command="Paste" />
</RibbonGroup>
<RibbonGroup Header="Edit">
<RibbonToggleButton Label="Undo"
SmallImageSource="../Resources/Theme/Undo.png"
SnapsToDevicePixels="True"
ToolTip="Undo"
Command="Undo" />
<RibbonButton Label="Redo" SmallImageSource="../Resources/Theme/Redo.png"
ToolTip="Redo"
SnapsToDevicePixels="True"
Command="Redo" />
<RibbonButton Label="Delete" SmallImageSource="../Resources/Theme/Delete.png"
ToolTip="Delete Selected"
SnapsToDevicePixels="True"
Command="Delete" />
</RibbonGroup>
<RibbonGroup Header="Cell">
<RibbonCheckBox Label="WordWrap" SmallImageSource="../Resources/Theme/WordWrap.png"
ToolTip="Toggle Word Wrap"
SnapsToDevicePixels="True"
IsChecked="{Binding ElementName=textEditor, Path=WordWrap}" />
<RibbonCheckBox Label="Paragraph" SmallImageSource="../Resources/Theme/Paragraph.png"
ToolTip="Toggle Show End of Line"
SnapsToDevicePixels="True"
IsChecked="{Binding ElementName=textEditor, Path=Options.ShowEndOfLine}"
/>
<RibbonCheckBox Label="Number" SmallImageSource="../Resources/Theme/Number.png"
IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}"
ToolTip="Toggle Line Numbers"
SnapsToDevicePixels="True"/>
</RibbonGroup>
<RibbonGroup Header="Execute">
<RibbonButton Label="Run" LargeImageSource="../Resources/Theme/Run.png"
SnapsToDevicePixels="True"
Click="runClick"
ToolTip="(F5) Run Script. Results will be displayed in the IronPython prompt." />
</RibbonGroup>
</RibbonTab>
</Ribbon>
<!-- <ToolBar DockPanel.Dock="Top"> -->
<!-- <Separator /> -->
<!-- <CheckBox IsChecked="{Binding ElementName=textEditor, Path=ShowLineNumbers}"> -->
<!-- <Image -->
<!-- Height="16" -->
<!-- SnapsToDevicePixels="True" -->
<!-- Source="/RevitPythonShell;component/Resources/Theme/Number.png" -->
<!-- ToolTip="Toggle Line Numbers" /> -->
<!-- </CheckBox> -->
<!-- </ToolBar> -->
</DockPanel>
<Grid Grid.Column="0" Grid.Row="1">
<avalonEdit:TextEditor
FontFamily="Consolas"
FontSize="10pt"
GotFocus="textEditor_GotFocus"
Name="textEditor">
# IronPython Pad. Write code snippets here and F5 to run.
</avalonEdit:TextEditor>
</Grid>
<GridSplitter
Grid.Row="2"
Grid.Column="0"
Height="10"
HorizontalAlignment="Stretch"
VerticalAlignment="Center" />

<Grid Grid.Row="3" MinHeight="20">
<console:IronPythonConsoleControl Name="consoleControl" />
</Grid>

</Grid>
</Window>
</Window>
Loading