This repository has been archived by the owner on Feb 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddinGen.cs
106 lines (86 loc) · 2.86 KB
/
AddinGen.cs
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GGJason
{
public partial class AddinGen : Form
{
int i = -1;
List<exClass> allClass;
Dll dll;
string vendorID,vendorDescription,path;
public AddinGen()
{
InitializeComponent();
}
private void addinGen_Load(object sender, EventArgs e)
{
}
private void browse_Click(object sender, EventArgs e)
{
classes.Items.Clear();
allClass = new List<exClass>();
openFileDialog.ShowDialog();
location.Text = openFileDialog.FileName;
path = openFileDialog.FileName;
if (Path.GetExtension(path) == ".dll")
{
dll = new Dll(path);
int i = 0;
foreach (exClass t in dll.Classes)
{
classes.Items.Add(t);
}
}
else
{
}
}
private void guidGen_Click(object sender, EventArgs e)
{
Guid g = Guid.NewGuid();
guid.Text = g.ToString();
}
private void generateBut_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.RestoreDirectory = true;
sfd.InitialDirectory = @"C:\Users\" + Environment.UserName + @"\AppData\Roaming\Autodesk\Revit\Addins\2017";
sfd.FileName = DateTime.Now.ToString("yyyyMMdd-HHmmss")+".addin";
sfd.ShowDialog();
StreamWriter sw = new StreamWriter(Path.GetFullPath(sfd.FileName));
sw.WriteLine(dll.exportAddin());
sw.Close();
MessageBox.Show("Success Save to \""+ Path.GetFullPath(sfd.FileName) + "\"","Success Generate",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
this.Close();
}
private void vendor_TextChanged(object sender, EventArgs e)
{
vendorID = vendor.Text;
}
private void VendorDescriptionBox_TextChanged(object sender, EventArgs e)
{
vendorDescription = VendorDescriptionBox.Text;
}
private void classes_SelectedIndexChanged(object sender, EventArgs e)
{
if (i != -1)
{
allClass[i].GUID = Guid.Parse(guid.Text);
allClass[i].Name = name.Text;
}
i = classes.SelectedIndex;
type.Text = allClass.ElementAt(i).Type;
guid.Text = allClass[i].GUID.ToString();
name.Text = allClass[i].Name;
}
}
}