forked from chuongmep/CadPythonShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIronPythonConsoleApp.cs
More file actions
85 lines (80 loc) · 3.2 KB
/
IronPythonConsoleApp.cs
File metadata and controls
85 lines (80 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
using Orientation = System.Windows.Controls.Orientation;
namespace CADPythonShell
{
public class IronPythonConsoleApp
{
public const string RibbonTitle = "Python Shell";
public const string RibbonId = "PythonShell";
[CommandMethod("InitPythonConsole")]
public void Execute()
{
CreateRibbon();
}
private void CreateRibbon()
{
RibbonControl ribbon = ComponentManager.Ribbon;
if (ribbon != null)
{
RibbonTab rtab = ribbon.FindTab(RibbonId);
if (rtab != null)
{
ribbon.Tabs.Remove(rtab);
}
rtab = new RibbonTab();
rtab.Title = RibbonTitle;
rtab.Id = RibbonId;
ribbon.Tabs.Add(rtab);
AddContentToTab(rtab);
}
}
private void AddContentToTab(RibbonTab rtab)
{
rtab.Panels.Add(AddOnePanel());
}
private static RibbonPanel AddOnePanel()
{
RibbonPanelSource rps = new RibbonPanelSource();
rps.Title = "Cad Python Shell";
RibbonPanel rp = new RibbonPanel();
rp.Source = rps;
RibbonButton rci = new RibbonButton();
rci.Name = "Python Shell Console";
rps.DialogLauncher = rci;
//create button1
var addinAssembly = typeof(IronPythonConsoleApp).Assembly;
RibbonButton btnPythonShell = new RibbonButton
{
Orientation = Orientation.Vertical,
AllowInStatusBar = true,
Size = RibbonItemSize.Large,
Name = "Run CPS",
ShowText = true,
Text = "Run CPS",
Description = "Start Write Python Console\nCommand: PythonShellConsole",
Image = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.Python-16.png"),
LargeImage = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.Python-32.png"),
CommandHandler = new RelayCommand(new IronPythonConsoleCommand().Execute)
};
rps.Items.Add(btnPythonShell);
//create button2
RibbonButton btnConfig = new RibbonButton
{
Orientation = Orientation.Vertical,
AllowInStatusBar = true,
Size = RibbonItemSize.Large,
Name = "Configure CPS",
ShowText = true,
Text = "Configure CPS",
Description = "Configure Cad Python Shell\nCommand: PythonShellSetting",
Image = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.Settings-16.png"),
LargeImage = CADPythonShellApplication.GetEmbeddedPng(addinAssembly, "CADPythonShell.Resources.Settings-32.png"),
CommandHandler = new RelayCommand(new ConfigureCommand().Execute)
};
//Add the Button to the Tab
rps.Items.Add(btnConfig);
return rp;
}
}
}