Sfall-ScriptEditor

Форк
0
623 строки · 25.4 Кб
1
using System;
2
using System.Collections.Generic;
3
using System.Drawing;
4
using System.Drawing.Text;
5
using System.IO;
6
using System.Text;
7
using System.Windows.Forms;
8

9
namespace ScriptEditor
10
{
11
    public enum SavedWindows { Main, Count }
12
    public enum  EncodingType : byte { Default, OEM866 }
13

14
    public static class Settings
15
    {
16
        public static Encoding EncCodePage;
17
        public static Size HeadersFormSize;
18

19
        public static readonly string ProgramFolder = Application.StartupPath;
20
        public static readonly string SettingsFolder = Path.Combine(ProgramFolder, "settings");
21
        public static readonly string ResourcesFolder = Path.Combine(ProgramFolder, "resources");
22
        public static readonly string DescriptionsFolder = Path.Combine(ProgramFolder, "descriptions");
23
        public static readonly string scriptTempPath = Path.Combine(ProgramFolder, "scrTemp");
24

25
        private static readonly string RecentPath = Path.Combine(SettingsFolder, "recent.dat");
26
        private static readonly string SettingsPath = Path.Combine(SettingsFolder, "settings.dat");
27

28
        public static readonly string SearchHistoryPath = Path.Combine(SettingsFolder, "SearchHistory.ini");
29
        public static readonly string SearchFoldersPath = Path.Combine(SettingsFolder, "SearchPaths.ini");
30
        public static readonly string PreprocDefPath = Path.Combine(SettingsFolder, "PreprocDefine.ini");
31

32
        public static PrivateFontCollection Fonts = new PrivateFontCollection();
33
        public static readonly Dictionary<string, float> FontAdjustSize = new Dictionary<string, float>() {
34
            {"Anonymous Pro", 10.5f},       {"Consolas", 10.5f},            {"Cousine", 10.5f},
35
            {"InconsolataCyr", 11.0f},      {"InputMono", 9.5f},            {"InputMonoCondensed", 9.5f},
36
            {"Liberation Mono", 10.25f},    {"Meslo LG S DZ", 9.75f},       {"Ubuntu Mono",  11.75f}
37
        };
38

39
        public static List<string> searchListPath = new List<string>();
40
        public static readonly List<string> msgListPath = new List<string>();
41

42
        private static List<string> recent = new List<string>();
43
        private static List<string> recentMsg = new List<string>();
44
        private static Dictionary<string, ushort> scriptPosition = new Dictionary<string, ushort>();
45
        private static readonly WindowPos[] windowPositions = new WindowPos[(int)SavedWindows.Count];
46

47
        const int MAX_RECENT = 40;
48

49
        public static byte optimize = 1;
50
        public static bool showWarnings = true;
51
        public static bool showDebug = true; //show additional information when compiling script
52
        public static bool searchIncludePath = true;
53
        public static bool warnOnFailedCompile = true;
54
        public static bool multiThreaded = true;
55
        public static bool autoOpenMsgs = false;
56
        public static bool openMsgEditor = false;
57
        public static string outputDir;
58
        public static string pathScriptsHFile;
59
        public static string lastMassCompile;
60
        public static string lastSearchPath;
61
        public static int editorSplitterPosition = -1;
62
        public static int editorSplitterPosition2 = -1;
63
        public static string language = "english";
64
        public static bool tabsToSpaces = true;
65
        public static int tabSize = 3;
66
        public static bool enableParser = true;
67
        public static bool shortCircuit = false;
68
        public static bool autocomplete = true;
69
        public static bool showLog = true;
70
        public static byte hintsLang = 0;
71
        public static byte highlight = 2; // 0 = Original, 1 = FGeck, 2 = Dark
72
        public static byte encoding = (byte)EncodingType.Default; // 0 = DEFAULT, 1 = DOS(cp866)
73
        public static bool allowDefine = false;
74
        public static bool parserWarn = true;
75
        public static bool useWatcom = false;
76
        public static string preprocDef = null;
77
        public static bool ignoreCompPath = true;
78
        public static bool userCmdCompile = false;
79
        public static bool msgHighlightComment = true;
80
        public static byte msgHighlightColor = 0;
81
        public static byte msgFontSize = 0;
82
        public static string pathHeadersFiles;
83
        public static bool associateID = false;
84
        public static bool useMcpp = true;
85
        public static bool autocompleteColor = true;
86
        public static bool autoInputPaired = true;
87
        public static bool showTabsChar = false;
88
        public static bool autoTrailingSpaces = true;
89
        public static bool showTips = true;
90
        public static bool shortDesc = false;
91
        public static byte selectFont = 11; // 0 - default
92
        public static sbyte sizeFont = 0; // 0 - default
93
        public static bool showVRuler = true;
94
        public static bool storeLastPosition = true;
95
        public static bool saveScriptUTF8 = false;
96
        public static bool decompileF1 = false;
97
        public static bool oldDecompile = false;
98
        public static bool winAPITextRender = true;
99
        public static int compileBackwardMode = 0;
100
        private static string ExternalEditorExePath;
101
        public static bool searchIgnoreCase = false;
102
        public static bool searchWholeWord = false;
103
        public static string solutionProjectFolder;
104

105
        // for Flowchart
106
        public static bool autoUpdate = false;
107
        public static bool autoSaveChart = true;
108
        public static bool autoArrange = false;
109
        public static bool woExitNode = true;
110
        public static bool autoHideNodes = false;
111

112
        // no saved settings
113
        public static bool msgLipColumn = false;
114
        public static bool firstRun = false;
115

116
        public static void SetupWindowPosition(SavedWindows window, Form f)
117
        {
118
            WindowPos wp = windowPositions[(int)window];
119
            if (wp.width == 0)
120
                return;
121
            f.Location = new System.Drawing.Point(wp.x, wp.y);
122
            if (wp.maximized)
123
                f.WindowState = FormWindowState.Maximized;
124
            else
125
                f.ClientSize = new System.Drawing.Size(wp.width, wp.height);
126
            f.StartPosition = FormStartPosition.Manual;
127
        }
128

129
        public static void SaveWindowPosition(SavedWindows window, Form f)
130
        {
131
            WindowPos wp = new WindowPos();
132
            wp.maximized = f.WindowState == FormWindowState.Maximized;
133
            wp.x = f.Location.X;
134
            wp.y = f.Location.Y;
135
            wp.width = f.ClientSize.Width;
136
            wp.height = f.ClientSize.Height;
137
            windowPositions[(int)window] = wp;
138
        }
139

140
        public static void SetLastScriptPosition(string script, int line)
141
        {
142
            if (!storeLastPosition || line < 10)
143
                return;
144
            if (scriptPosition.ContainsKey(script))
145
                scriptPosition[script] = (ushort)line;
146
            else
147
                scriptPosition.Add(script, (ushort)line);
148
        }
149

150
        public static int GetLastScriptPosition(string script)
151
        {
152
            if (scriptPosition.ContainsKey(script))
153
                return (ushort)scriptPosition[script];
154
            else
155
                return 0;
156
        }
157

158
        public static void AddMsgRecentFile(string s, bool b = false)
159
        {
160
            SubRecentFile(ref recentMsg, s, b);
161
        }
162

163
        public static void AddRecentFile(string s, bool b = false)
164
        {
165
            SubRecentFile(ref recent, s, b, true);
166
        }
167

168
        public static void SubRecentFile(ref List<string> recent, string s, bool b, bool p = false)
169
        {
170
            for (int i = 0; i < recent.Count; i++) {
171
                if (string.Compare(recent[i], s, true) == 0)
172
                    recent.RemoveAt(i--);
173
            }
174
            if (!b && recent.Count >= MAX_RECENT) {
175
                if (p) scriptPosition.Remove(Path.GetFileName(recent[0]));
176
                recent.RemoveAt(0);
177
            }
178
            if (!b) recent.Add(s);
179
        }
180

181
        public static void ClearRecent()
182
        {
183
            recent.Clear();
184
        }
185

186
        public static bool IsSearchIncludes
187
        {
188
            get { return (searchIncludePath && pathScriptsHFile != null); }
189
        }
190

191
        public static string[] GetRecent() { return recent.ToArray(); }
192
        public static string[] GetMsgRecent() { return recentMsg.ToArray(); }
193

194
        private static void LoadWindowPos(BinaryReader br, int i)
195
        {
196
            windowPositions[i].maximized = br.ReadBoolean();
197
            windowPositions[i].x = br.ReadInt32();
198
            windowPositions[i].y = br.ReadInt32();
199
            windowPositions[i].width = br.ReadInt32();
200
            windowPositions[i].height = br.ReadInt32();
201
        }
202

203
        private static void LoadInternal(BinaryReader br, BinaryReader brRecent)
204
        {
205
            if (br != null) {
206
                string temp;
207
                try {
208
                    firstRun = br.ReadBoolean();
209
                    allowDefine = br.ReadBoolean();
210
                    hintsLang = br.ReadByte();
211
                    highlight = br.ReadByte();
212
                    encoding = br.ReadByte();
213
                    optimize = br.ReadByte();
214
                    showWarnings = br.ReadBoolean();
215
                    showDebug = br.ReadBoolean();
216
                    searchIncludePath = br.ReadBoolean();
217

218
                    temp = br.ReadString();
219
                    if (temp.Length > 0) outputDir = temp;
220

221
                    warnOnFailedCompile = br.ReadBoolean();
222
                    multiThreaded = br.ReadBoolean();
223

224
                    temp = br.ReadString();
225
                    if (temp.Length > 0) lastMassCompile = temp;
226

227
                    temp = br.ReadString();
228
                    if (temp.Length > 0) lastSearchPath = temp;
229

230
                    LoadWindowPos(br, 0);
231
                    editorSplitterPosition = br.ReadInt32();
232
                    autoOpenMsgs = br.ReadBoolean();
233
                    editorSplitterPosition2 = br.ReadInt32();
234

235
                    temp = br.ReadString();
236
                    if (temp.Length > 0) pathHeadersFiles = temp;
237

238
                    language = br.ReadString();
239
                    if (language.Length == 0) language = "english";
240

241
                    tabsToSpaces = br.ReadBoolean();
242
                    tabSize = br.ReadInt32();
243
                    enableParser = br.ReadBoolean();
244
                    shortCircuit = br.ReadBoolean();
245
                    autocomplete = br.ReadBoolean();
246
                    showLog = br.ReadBoolean();
247
                    parserWarn = br.ReadBoolean();
248
                    useWatcom = br.ReadBoolean();
249

250
                    temp = br.ReadString();
251
                    if (temp.Length > 0) preprocDef = temp;
252

253
                    ignoreCompPath = br.ReadBoolean();
254

255
                    byte MsgItems = br.ReadByte();
256
                    for (byte i = 0; i < MsgItems; i++) msgListPath.Add(br.ReadString());
257

258
                    openMsgEditor = br.ReadBoolean();
259
                    userCmdCompile = br.ReadBoolean();
260
                    msgHighlightComment = br.ReadBoolean();
261
                    msgHighlightColor = br.ReadByte();
262
                    msgFontSize = br.ReadByte();
263

264
                    temp = br.ReadString();
265
                    if (temp.Length > 0) pathScriptsHFile = temp;
266

267
                    associateID = br.ReadBoolean();
268
                    //
269
                    autoUpdate = br.ReadBoolean();
270
                    autoSaveChart = br.ReadBoolean();
271
                    autoArrange = br.ReadBoolean();
272
                    woExitNode = br.ReadBoolean();
273
                    useMcpp = br.ReadBoolean();
274
                    autocompleteColor = br.ReadBoolean();
275
                    autoInputPaired = br.ReadBoolean();
276
                    showTabsChar = br.ReadBoolean();
277
                    autoTrailingSpaces = br.ReadBoolean();
278
                    showTips = br.ReadBoolean();
279
                    shortDesc = br.ReadBoolean();
280
                    autoHideNodes = br.ReadBoolean();
281
                    selectFont = br.ReadByte();
282
                    sizeFont = br.ReadSByte();
283
                    showVRuler = br.ReadBoolean();
284
                    storeLastPosition = br.ReadBoolean();
285
                    saveScriptUTF8 = br.ReadBoolean();
286
                    decompileF1 = br.ReadBoolean();
287
                    winAPITextRender = br.ReadBoolean();
288

289
                    temp = br.ReadString();
290
                    if (temp.Length > 0) ExternalEditorExePath = temp;
291

292
                    oldDecompile = br.ReadBoolean();
293
                    searchIgnoreCase = br.ReadBoolean();
294
                    searchWholeWord = br.ReadBoolean();
295

296
                    temp = br.ReadString();
297
                    if (temp.Length > 0) solutionProjectFolder = temp;
298
                } catch {
299
                    MessageBox.Show("An error occurred while reading configuration file.\n"
300
                                    + "File setting.dat may be in wrong format.", "Setting read error");
301
                }
302
                br.Close();
303
            }
304
            // Recent files
305
            if (brRecent == null) return;
306
            int recentItems = brRecent.ReadByte();
307
            int recentMsgItems = brRecent.ReadByte();
308
            for (int i = 0; i < recentItems; i++)
309
                recent.Add(brRecent.ReadString());
310
            for (int i = 0; i < recentMsgItems; i++)
311
                recentMsg.Add(brRecent.ReadString());
312
            //
313
            int positionItems = brRecent.ReadByte();
314
            for (int i = 0; i < positionItems; i++)
315
                scriptPosition.Add(brRecent.ReadString(), brRecent.ReadUInt16());
316
            brRecent.Close();
317
        }
318

319
        public static void Load()
320
        {
321
            Program.printLog("   Load configuration setting.");
322

323
            if (!Directory.Exists(scriptTempPath)) {
324
                Directory.CreateDirectory(scriptTempPath);
325
            } else
326
                foreach (string file in Directory.GetFiles(scriptTempPath))
327
                    File.Delete(file);
328
            File.Delete("errors.txt");
329

330
            if (!Directory.Exists(SettingsFolder)) {
331
                Directory.CreateDirectory(SettingsFolder);
332
            }
333
            if (!Directory.Exists(ResourcesFolder)) {
334
                Directory.CreateDirectory(ResourcesFolder);
335
            }
336
            var templatesFolder = Path.Combine(ResourcesFolder, "templates");
337
            if (!Directory.Exists(templatesFolder)) {
338
                Directory.CreateDirectory(templatesFolder);
339
            }
340

341
            BinaryReader brRecent = null, brSettings = null;
342
            if (File.Exists(RecentPath))
343
                brRecent = new BinaryReader(File.OpenRead(RecentPath));
344
            if (File.Exists(SettingsPath))
345
                brSettings = new BinaryReader(File.OpenRead(SettingsPath));
346
            LoadInternal(brSettings, brRecent);
347

348
            LoadScriptsProceduresFolding();
349

350
            if (!File.Exists(SearchHistoryPath))
351
                File.Create(SearchHistoryPath).Close();
352
            if (!File.Exists(PreprocDefPath))
353
                File.Create(PreprocDefPath).Close();
354

355
            if (!firstRun) {
356
                var culture = System.Globalization.CultureInfo.CurrentCulture;
357
                Settings.hintsLang = (byte)((culture.ToString() == "ru-RU") ? 1 : 0);
358
                FileAssociation.Associate();
359
            }
360

361
            EncCodePage = (encoding == (byte)EncodingType.OEM866) ? Encoding.GetEncoding("cp866") : Encoding.Default;
362

363
            //Load custom fonts
364
            try {
365
                foreach (string file in Directory.GetFiles(Settings.ResourcesFolder + @"\fonts\", "*.ttf"))
366
                    Fonts.AddFontFile(file);
367
            } catch (DirectoryNotFoundException ) { }
368
        }
369

370
        public static void SetTextAreaFont(ICSharpCode.TextEditor.TextEditorControl TE)
371
        {
372
            if (Fonts.Families.Length == 0)
373
                return;
374

375
            int indexFont = selectFont - 1;
376
            Font font;
377
            if (indexFont > -1) {
378
                FontFamily family = Fonts.Families[indexFont];
379
                float sz;
380
                if (!FontAdjustSize.TryGetValue(family.Name, out sz))
381
                    sz = 10.0f;
382
                font = new Font(family, sz + sizeFont, FontStyle.Regular, GraphicsUnit.Point);
383
            } else
384
                font = new Font("Courier New", 10.0f + sizeFont, FontStyle.Regular);
385
            TE.TextEditorProperties.Font = font;
386
        }
387

388
        private static void WriteWindowPos(BinaryWriter bw, int i)
389
        {
390
            bw.Write(windowPositions[i].maximized);
391
            bw.Write(windowPositions[i].x);
392
            bw.Write(windowPositions[i].y);
393
            bw.Write(windowPositions[i].width);
394
            bw.Write(windowPositions[i].height);
395
        }
396

397
        public static void Save()
398
        {
399
            if (!Directory.Exists(SettingsFolder))
400
                Directory.CreateDirectory(SettingsFolder);
401
            BinaryWriter bw = new BinaryWriter(File.Create(SettingsPath));
402
            bw.Write((byte)255);
403
            bw.Write(allowDefine);
404
            bw.Write(hintsLang);
405
            bw.Write(highlight);
406
            bw.Write(encoding);
407
            bw.Write(optimize);
408
            bw.Write(showWarnings);
409
            bw.Write(showDebug);
410
            bw.Write(searchIncludePath);
411
            bw.Write(outputDir ?? "");
412
            bw.Write(warnOnFailedCompile);
413
            bw.Write(multiThreaded);
414
            bw.Write(lastMassCompile ?? "");
415
            bw.Write(lastSearchPath ?? "");
416
            WriteWindowPos(bw, 0);
417
            bw.Write(editorSplitterPosition);
418
            bw.Write(autoOpenMsgs);
419
            bw.Write(editorSplitterPosition2);
420
            bw.Write(pathHeadersFiles ?? "");
421
            bw.Write(language ?? "english");
422
            bw.Write(tabsToSpaces);
423
            bw.Write(tabSize);
424
            bw.Write(enableParser);
425
            bw.Write(shortCircuit);
426
            bw.Write(autocomplete);
427
            bw.Write(showLog);
428
            bw.Write(parserWarn);
429
            bw.Write(useWatcom);
430
            bw.Write(preprocDef ?? string.Empty);
431
            bw.Write(ignoreCompPath);
432
            bw.Write((byte)msgListPath.Count);
433
            for (int i = 0; i < msgListPath.Count; i++)
434
                bw.Write(msgListPath[i]);
435
            bw.Write(openMsgEditor);
436
            bw.Write(userCmdCompile);
437
            bw.Write(msgHighlightComment);
438
            bw.Write(msgHighlightColor);
439
            bw.Write(msgFontSize);
440
            bw.Write(pathScriptsHFile ?? "");
441
            bw.Write(associateID);
442
            //
443
            bw.Write(autoUpdate);
444
            bw.Write(autoSaveChart);
445
            bw.Write(autoArrange);
446
            bw.Write(woExitNode);
447
            bw.Write(useMcpp);
448
            bw.Write(autocompleteColor);
449
            bw.Write(autoInputPaired);
450
            bw.Write(showTabsChar);
451
            bw.Write(autoTrailingSpaces);
452
            bw.Write(showTips);
453
            bw.Write(shortDesc);
454
            bw.Write(autoHideNodes);
455
            bw.Write(selectFont);
456
            bw.Write(sizeFont);
457
            bw.Write(showVRuler);
458
            bw.Write(storeLastPosition);
459
            bw.Write(saveScriptUTF8);
460
            bw.Write(decompileF1);
461
            bw.Write(winAPITextRender);
462
            bw.Write(ExternalEditorExePath ?? "");
463
            bw.Write(oldDecompile);
464
            bw.Write(searchIgnoreCase);
465
            bw.Write(searchWholeWord);
466
            bw.Write(solutionProjectFolder ?? "");
467
            bw.Close();
468

469
            // Recent files
470
            BinaryWriter bwRecent = new BinaryWriter(File.Create(RecentPath));
471
            bwRecent.Write((byte)recent.Count);
472
            bwRecent.Write((byte)recentMsg.Count);
473
            for (int i = 0; i < recent.Count; i++)
474
                bwRecent.Write(recent[i]);
475
            for (int i = 0; i < recentMsg.Count; i++)
476
                bwRecent.Write(recentMsg[i]);
477
            //
478
            string[] key = new string[scriptPosition.Count];
479
            ushort[] value = new ushort[scriptPosition.Count];
480
            scriptPosition.Keys.CopyTo(key, 0);
481
            scriptPosition.Values.CopyTo(value, 0);
482
            bwRecent.Write((byte)scriptPosition.Count);
483
            for (int i = 0; i < scriptPosition.Count; i++) {
484
                bwRecent.Write(key[i]);
485
                bwRecent.Write(value[i]);
486
            }
487
            bwRecent.Close();
488
            // Store folding procedures
489
            SaveScriptsProceduresFolding();
490
        }
491

492
        public static void SaveSettingData(Form mainfrm)
493
        {
494
            TextEditor frm = mainfrm as TextEditor;
495
            StreamWriter sw = new StreamWriter(Settings.SearchHistoryPath);
496
            int capHSearchHistory = 150;
497
            foreach (var item in frm.SearchTextComboBox.Items)
498
            {
499
                sw.WriteLine(item.ToString());
500
                if (--capHSearchHistory < 0) break;
501
            }
502
            sw.Close();
503
            File.WriteAllLines(Settings.SearchFoldersPath, searchListPath);
504
            openMsgEditor = frm.msgAutoOpenEditorStripMenuItem.Checked;
505
            if (frm.WindowState != FormWindowState.Minimized) SaveWindowPosition(SavedWindows.Main, mainfrm);
506
            Save();
507
            Directory.Delete(scriptTempPath, true);
508
        }
509

510
        public static void OpenInExternalEditor(string file)
511
        {
512
            if (ExternalEditorExePath != null && File.Exists(ExternalEditorExePath))
513
                System.Diagnostics.Process.Start(ExternalEditorExePath, file);
514
            else {
515
                var ofd = new OpenFileDialog() {
516
                    InitialDirectory = Settings.ProgramFolder,
517
                    DefaultExt = "exe",
518
                    Filter = "Executable file (.exe)|*.exe",
519
                    Title = "Select executable file"
520
                };
521
                if (ofd.ShowDialog() == DialogResult.OK) {
522
                    ExternalEditorExePath = ofd.FileName;
523
                    OpenInExternalEditor(file);
524
                }
525
            }
526
        }
527

528
        struct WindowPos
529
        {
530
            public bool maximized;
531
            public int x, y, width, height;
532
        }
533

534
        #region Folding save/load data
535
        private static readonly string FoldingPath = Path.Combine(SettingsFolder, "folding.dat");
536

537
        private static Dictionary<string, int> scriptsFolding = new Dictionary<string,int>(); // имя скрипта => позиция в массиве proceduresFolding
538
        private static HashSet<string>[] proceduresFolding; // имена процедур которые являются свернутыми
539

540
        public static void SetScriptProcedureFold(string scriptName, string procedure)
541
        {
542
            int index;
543
            if (!scriptsFolding.TryGetValue(scriptName, out index)) {
544
                index = proceduresFolding.Length;
545
                Array.Resize(ref proceduresFolding, index + 1);
546
                proceduresFolding[index] = new HashSet<string>();
547
                proceduresFolding[index].Add(procedure);
548
                scriptsFolding.Add(scriptName, index);
549
            } else {
550
                proceduresFolding[index].Add(procedure);
551
            }
552
        }
553

554
        public static void UsSetScriptProcedureFold(string scriptName, string procedure)
555
        {
556
            int index;
557
            if (!scriptsFolding.TryGetValue(scriptName, out index)) return;
558
            proceduresFolding[index].Remove(procedure);
559
        }
560

561
        public static bool ScriptProcedureIsFold(string scriptName, string procedure)
562
        {
563
            int index;
564
            if (!scriptsFolding.TryGetValue(scriptName, out index)) return false;
565
            return proceduresFolding[index].Contains(procedure);
566
        }
567

568
        private static void SaveScriptsProceduresFolding()
569
        {
570
            int sCount = scriptsFolding.Count;
571
            if (sCount == 0) {
572
                File.Delete(FoldingPath);
573
                return;
574
            }
575
            string[] keys = new string[sCount];
576
            scriptsFolding.Keys.CopyTo(keys, 0);
577
            int[] indexes = new int[sCount];
578
            scriptsFolding.Values.CopyTo(indexes, 0);
579

580
            BinaryWriter bwFolding = new BinaryWriter(File.Create(FoldingPath));
581
            bwFolding.Write(sCount);
582
            for (int i = 0; i < sCount; i++) {
583
                bwFolding.Write(keys[i]);
584
                int pCount = proceduresFolding[indexes[i]].Count;
585
                bwFolding.Write(pCount);
586
                string[] procedures = new string[pCount];
587
                proceduresFolding[indexes[i]].CopyTo(procedures, 0);
588
                for (int j = 0; j < pCount; j++) {
589
                    bwFolding.Write(procedures[j]);
590
                }
591
            }
592
            bwFolding.Close();
593
        }
594

595
        private static void LoadScriptsProceduresFolding()
596
        {
597
            if (File.Exists(FoldingPath)) {
598
                BinaryReader brFolding = new BinaryReader(File.OpenRead(FoldingPath));
599
                if (brFolding.BaseStream.Length == 0) {
600
                    brFolding.Close();
601
                    proceduresFolding = new HashSet<string>[0];
602
                    return;
603
                }
604
                int sCount = brFolding.ReadInt32();
605
                proceduresFolding = new HashSet<string>[sCount];
606
                for (int i = 0; i < sCount; i++) {
607
                    string script = brFolding.ReadString();
608
                    int pCount =  brFolding.ReadInt32();
609
                    if (pCount == 0) continue;
610
                    proceduresFolding[i] = new HashSet<string>();
611
                    for (int j = 0; j < pCount; j++) {
612
                        proceduresFolding[i].Add(brFolding.ReadString());
613
                    }
614
                    scriptsFolding.Add(script, i);
615
                }
616
                brFolding.Close();
617
            } else {
618
                proceduresFolding = new HashSet<string>[0];
619
            }
620
        }
621
        #endregion
622
    }
623
}
624

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.