-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (48 loc) · 1.52 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (48 loc) · 1.52 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EduNotepad
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FormMain formMain = new FormMain();
bool printAndExit = false;
if (args.Length > 0)
{
List<string> argsList = new List<string>(args);
if (args[0].ToLower() == "/p")
{
// Нужно будет сразу отправить файл на печать и завершить работу
printAndExit = true;
// Нужно собрать имя файла из остальных элементов (кроме первого)
argsList.RemoveAt(0);
}
string fileName = string.Join(" ", argsList.ToArray());
Encoding fileEncoding = formMain.CheckFileEncoding(fileName);
if (File.Exists(fileName)) formMain.PerformFileOpen(fileName, fileEncoding);
}
if (printAndExit)
{
// Надо выполнить распечатку и свалить
if (formMain.fileName != string.Empty)
{
// Файл открылся, отправляем его на печать
formMain.PerformPrint(Settings.PageSettings.PrinterSettings, Settings.PageSettings);
}
}
else
{
// Надо просто запустить приложение
Application.Run(formMain);
}
}
}
}