Mit diesem Script wird eine History für Projekte in EPLAN integriert. Diese kann (fast) endlos gespeichert werden.

Wird ein Projekt mehrfach hintereinander geschlossen taucht es auch öfters auf, weiß nicht ob das so gewünscht ist, aber finde ich praktisch da ich den Verlauf verfolgen kann.

 

Es können mehrere Projekte gleichzeitig geöffnet werden. Zusätzlich kann die History geleert werden.

Es wird einer neuer Menüpunkt unter Projekte > Projekt History… erstellt. Beim Schließen eines Projektes wird der Pfad unter Skripte/ProjectHistory/Name gespeichert.

 

Das Script ist aus einer User-Anfrage entstanden. Darum ist es bisl “Quick & Dirty” für Optimierungen bin ich immer offen  :biggrin:

ProjectHistory (106)

 

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
using System;
using System.Collections;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
 
public class FrmProjectHistory : System.Windows.Forms.Form
{
    public string strUserHistory = string.Empty; 
    public string strProjectsPath = string.Empty; 
    public ArrayList arrProjectsDirectories = new ArrayList();
    private System.Windows.Forms.StatusStrip statusStrip1;
    private System.Windows.Forms.ToolStripProgressBar prgBar;
    private ListView liviLastOpend;
    private ColumnHeader columnHeader4;
    private ColumnHeader columnHeader5;
    private ColumnHeader columnHeader6;
    private Button btnProjectsHistory;
    private Button btnHistory;
 
    // Formular (Programmdateien zur Generierung des Forms)
    #region Formular
    public FrmProjectHistory()
    {
        InitializeComponent();
    }
 
    // ListView: Sortierung
    class ListViewItemComparer : IComparer
    {
        private int col;
        public ListViewItemComparer()
        {
            col = 0;
        }
        public ListViewItemComparer(int column)
        {
            col = column;
        }
        public int Compare(object x, object y)
        {
            int returnVal = -1;
            returnVal = String.Compare(((ListViewItem)x).SubItems[col].Text,
            ((ListViewItem)y).SubItems[col].Text);
            return returnVal;
        }
    }
 
    private System.Windows.Forms.Button btnAbbrechen;
    private System.Windows.Forms.ToolStripStatusLabel lblStatus2;
 
    ///
    /// Erforderliche Designervariable.
    ///
    private System.ComponentModel.IContainer components = null;
 
    ///
    /// Verwendete Ressourcen bereinigen.
    ///
    /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }
 
    #region Vom Windows Form-Designer generierter Code
 
    ///
    /// Erforderliche Methode für die Designerunterstützung.
    /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
    ///
    private void InitializeComponent()
    {
        this.btnAbbrechen = new System.Windows.Forms.Button();
        this.lblStatus2 = new System.Windows.Forms.ToolStripStatusLabel();
        this.statusStrip1 = new System.Windows.Forms.StatusStrip();
        this.prgBar = new System.Windows.Forms.ToolStripProgressBar();
        this.btnProjectsHistory = new System.Windows.Forms.Button();
        this.btnHistory = new System.Windows.Forms.Button();
        this.liviLastOpend = new System.Windows.Forms.ListView();
        this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
        this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
        this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
        this.statusStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // btnAbbrechen
        // 
        this.btnAbbrechen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
        this.btnAbbrechen.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        this.btnAbbrechen.Location = new System.Drawing.Point(612, 418);
        this.btnAbbrechen.Name = "btnAbbrechen";
        this.btnAbbrechen.Size = new System.Drawing.Size(120, 24);
        this.btnAbbrechen.TabIndex = 7;
        this.btnAbbrechen.Text = "Abbrechen";
        this.btnAbbrechen.UseVisualStyleBackColor = true;
        // 
        // lblStatus2
        // 
        this.lblStatus2.Margin = new System.Windows.Forms.Padding(2, 3, 0, 2);
        this.lblStatus2.Name = "lblStatus2";
        this.lblStatus2.Size = new System.Drawing.Size(235, 17);
        this.lblStatus2.Text = "Letzte Änderung: 2009-10-23  - Johann Weiher";
        // 
        // statusStrip1
        // 
        this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.prgBar});
        this.statusStrip1.Location = new System.Drawing.Point(0, 450);
        this.statusStrip1.Name = "statusStrip1";
        this.statusStrip1.Size = new System.Drawing.Size(744, 22);
        this.statusStrip1.SizingGrip = false;
        this.statusStrip1.TabIndex = 13;
        this.statusStrip1.Text = "statusStrip1";
        // 
        // prgBar
        // 
        this.prgBar.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
        this.prgBar.AutoSize = false;
        this.prgBar.Name = "prgBar";
        this.prgBar.Size = new System.Drawing.Size(740, 16);
        // 
        // btnProjectsHistory
        // 
        this.btnProjectsHistory.Enabled = false;
        this.btnProjectsHistory.Location = new System.Drawing.Point(486, 419);
        this.btnProjectsHistory.Name = "btnProjectsHistory";
        this.btnProjectsHistory.Size = new System.Drawing.Size(120, 23);
        this.btnProjectsHistory.TabIndex = 11;
        this.btnProjectsHistory.Text = "Projekt(e) öffnen";
        this.btnProjectsHistory.UseVisualStyleBackColor = true;
        this.btnProjectsHistory.Click += new System.EventHandler(this.btnProjectsHistory_Click);
        // 
        // btnHistory
        // 
        this.btnHistory.Location = new System.Drawing.Point(360, 419);
        this.btnHistory.Name = "btnHistory";
        this.btnHistory.Size = new System.Drawing.Size(120, 23);
        this.btnHistory.TabIndex = 17;
        this.btnHistory.Text = "History löschen";
        this.btnHistory.UseVisualStyleBackColor = true;
        this.btnHistory.Click += new System.EventHandler(this.btnHistory_Click);
        // 
        // liviLastOpend
        // 
        this.liviLastOpend.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
            this.columnHeader4,
            this.columnHeader5,
            this.columnHeader6});
        this.liviLastOpend.FullRowSelect = true;
        this.liviLastOpend.GridLines = true;
        this.liviLastOpend.HideSelection = false;
        this.liviLastOpend.Location = new System.Drawing.Point(12, 12);
        this.liviLastOpend.Name = "liviLastOpend";
        this.liviLastOpend.Size = new System.Drawing.Size(720, 400);
        this.liviLastOpend.TabIndex = 10;
        this.liviLastOpend.UseCompatibleStateImageBehavior = false;
        this.liviLastOpend.View = System.Windows.Forms.View.Details;
        this.liviLastOpend.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.liviLastOpend_ColumnClick);
        this.liviLastOpend.SelectedIndexChanged += new System.EventHandler(this.liviLastOpend_SelectedIndexChanged);
        this.liviLastOpend.DoubleClick += new System.EventHandler(this.liviLastOpend_DoubleClick);
        // 
        // columnHeader4
        // 
        this.columnHeader4.Text = "Projekt";
        this.columnHeader4.Width = 76;
        // 
        // columnHeader5
        // 
        this.columnHeader5.Text = "Pfad";
        this.columnHeader5.Width = 89;
        // 
        // columnHeader6
        // 
        this.columnHeader6.Text = "Erweiterung";
        this.columnHeader6.Width = 223;
        // 
        // FrmProjectHistory
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.BackColor = System.Drawing.SystemColors.Control;
        this.CancelButton = this.btnAbbrechen;
        this.ClientSize = new System.Drawing.Size(744, 472);
        this.Controls.Add(this.btnHistory);
        this.Controls.Add(this.btnProjectsHistory);
        this.Controls.Add(this.liviLastOpend);
        this.Controls.Add(this.statusStrip1);
        this.Controls.Add(this.btnAbbrechen);
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        this.MaximizeBox = false;
        this.MinimizeBox = false;
        this.Name = "FrmProjectHistory";
        this.ShowIcon = false;
        this.ShowInTaskbar = false;
        this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "ProjectHistory";
        this.Load += new System.EventHandler(this.FrmSearchMacros_Load);
        this.statusStrip1.ResumeLayout(false);
        this.statusStrip1.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();
 
    }
 
    #endregion
 
    # endregion // Code für das Formular
 
    // Menü
    [DeclareMenu]
    public void MenuFunction()
    {
        Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
        oMenu.AddMenuItem
            (
            "Projekt History...",
            "ProjectHistory",
            "Projekt History öffnen...",
            35002,
            1,
            false,
            false
            );
    }
 
    // Projekte speichern
    [DeclareEventHandler("onActionStart.String.XPrjActionProjectClose")]
    public void Function()
    {
        string dir = PathMap.SubstitutePath("$(MD_SCRIPTS)") + @"\ProjectHistory\";
 
        if (!Directory.Exists(dir))
        {
            Directory.CreateDirectory(dir);
        }
 
        StreamWriter myFile = new StreamWriter(dir + SystemInformation.UserName + ".txt", true);
        myFile.Write(PathMap.SubstitutePath("$(P)").Replace(".edb",".elk") + "\n");
        myFile.Close();
 
        return;
    }
 
    // Action initialisieren
    [DeclareAction("ProjectHistory")]
    public void SearchMacrosVoid()
    {
        FrmProjectHistory Frm1 = new FrmProjectHistory();
        Frm1.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        Frm1.ShowDialog();
        return;
 
    }
 
    // Form: Load
    private void FrmSearchMacros_Load(object sender, System.EventArgs e)
    {
        Cursor.Current = Cursors.WaitCursor;
        strProjectsPath = PathMap.SubstitutePath("$(MD_PROJECTS)");
        strUserHistory = PathMap.SubstitutePath("$(MD_SCRIPTS)") + @"\ProjectHistory\" + SystemInformation.UserName + ".txt";
        if(File.Exists(strUserHistory))
        {
            foreach (string line in File.ReadAllLines(strUserHistory))
            {
                FileInfo fi = new FileInfo(line);
                ListViewItem liviItem = new ListViewItem();
                liviItem.Text = Path.GetFileNameWithoutExtension(fi.FullName);
                liviItem.SubItems.Add(fi.Directory.ToString() + @"\");
                liviItem.SubItems.Add(fi.Extension.ToString());
                liviLastOpend.Items.Add(liviItem);
            }
        }
 
        // Anzeige
        liviLastOpend.BeginUpdate();
 
        // Anzeige
        for (int i = 0; i  0)
        {
            btnProjectsHistory.Enabled = true;
        }
    }
 
    private void btnProjectsHistory_Click(object sender, EventArgs e)
    {
        prgBar.Maximum = liviLastOpend.SelectedItems.Count + 1;
        foreach (ListViewItem item in liviLastOpend.SelectedItems)
        {
            prgBar.Value += 1;
            this.Update();
            string s = item.SubItems[1].Text + item.SubItems[0].Text + item.SubItems[2].Text;
            Eplan_OpenProject(s);
        }
        prgBar.Value = 0;
        this.Close();
    }
 
}