本文整理汇总了C#中Control.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# Control.ShowDialog方法的具体用法?C# Control.ShowDialog怎么用?C# Control.ShowDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control.ShowDialog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateOblicForOneSubject
private static void CreateOblicForOneSubject(Workbook book, Group group, string subjectName, int pivricha)
{
Log.Info(LoggerConstants.ENTER);
Workbook bookOfOblic = null;
try
{
var subjectFind = group.Subjects.Find(subject => subject.Name.Equals(subjectName));
var nameOfOblic = "";
if (subjectFind != null)
{
var semestrFindSemestr = pivricha == 1 ? subjectFind.FirstSemestr : subjectFind.SecondSemestr;
if (semestrFindSemestr != null)
{
nameOfOblic = semestrFindSemestr.CursovaRobota > 0
? CreateSheetName("КП" + subjectName)
: CreateSheetName(subjectName);
}
else
{
Log.Info(LoggerConstants.EXIT);
return;
}
}
else
{
Log.Warn("For group `" + group.Name + "` don`t find any subjects");
Log.Info(LoggerConstants.EXIT);
return;
}
bookOfOblic = App.OpenBook(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti
+ group.Name + PathsFile.PathsDto.ExcelExtensial);
Worksheet sheetOfOblic;
if (bookOfOblic == null)
{
if (!File.Exists(PathsFile.PathsDto.PathToFileWithMacros))
{
Log.Error(LoggerConstants.FILE_NOT_EXIST + ": " + PathsFile.PathsDto.PathToFileWithMacros);
Log.Info(LoggerConstants.EXIT);
return;
}
File.Copy(PathsFile.PathsDto.PathToFileWithMacros,
PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name +
PathsFile.PathsDto.ExcelExtensial);
bookOfOblic =
App.OpenBook(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name +
PathsFile.PathsDto.ExcelExtensial);
sheetOfOblic = App.OpenWorksheet(bookOfOblic, 1);
sheetOfOblic.Name = nameOfOblic;
}
else
{
var exist = bookOfOblic.Worksheets.Cast<object>()
.Any(sheet => ((Worksheet) sheet).Name.Equals(nameOfOblic));
if (exist)
{
if (!Control.IfShow)
{
var control =
new Control("Група [" + group.Name + "]. Уже існує облік успішності для предмету:\n" +
subjectName);
control.ShowDialog();
if (Control.ButtonClick == 1)
{
var newApp = new Application
{
Visible = true
};
((Worksheet)
newApp.Workbooks.Open(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti +
group.Name
+ PathsFile.PathsDto.ExcelExtensial).Worksheets[nameOfOblic])
.Select();
Control.ButtonClick = 0;
control.SetButtonReseachEnabled(false);
control.ShowDialog();
newApp.Quit();
ExcelApplication.ExcelApplication.Kill(newApp);
}
if (Control.ButtonClick == 2)
return;
sheetOfOblic = bookOfOblic.Worksheets[nameOfOblic];
sheetOfOblic.Cells.Delete();
Control.ButtonClick = 0;
}
else
{
if (Control.ButtonClick == 2)
{
Log.Info(LoggerConstants.EXIT);
return;
}
//.........这里部分代码省略.........
示例2: CreateZvedeniaVidomist
private static void CreateZvedeniaVidomist(Group @group, int pivricha, string mount)
{
Log.Info(LoggerConstants.ENTER);
Workbook bookTamplate = null;
Workbook book = null;
try
{
var stringPivricha = pivricha == 1 ? "1-ше півріччя.xls" : "2-ге півріччя.xls";
var pathToVidomist = PathsFile.PathsDto.PathToFolderWithZvedeniaVidomistUspishnosti
+ "Зведена відомість успішності за " + (string.IsNullOrWhiteSpace(mount)
? stringPivricha
: mount + PathsFile.PathsDto.ExcelExtensial);
if (!File.Exists(PathsFile.PathsDto.PathToExcelDataForProgram))
{
Log.Error(LoggerConstants.FILE_NOT_EXIST + ": DataToProgram");
Log.Info(LoggerConstants.EXIT);
return;
}
bookTamplate = App.OpenBook(PathsFile.PathsDto.PathToExcelDataForProgram);
var sheetTamplate = App.OpenWorksheet(bookTamplate, "Зведена відомість");
if (sheetTamplate == null)
{
Log.Error("DataToProgram must contains sheet with name `Зведена відомість`");
Log.Info(LoggerConstants.EXIT);
return;
}
Worksheet sheet;
if (!File.Exists(pathToVidomist))
{
if (!File.Exists(PathsFile.PathsDto.PathToFileWithMacros))
{
Log.Warn("Empty Excel file with macros not find");
Log.Info(LoggerConstants.EXIT);
return;
}
File.Copy(PathsFile.PathsDto.PathToFileWithMacros, pathToVidomist);
book = App.OpenBook(pathToVidomist);
sheet = App.OpenWorksheet(book, 1);
sheet.Cells.Delete();
sheet.Name = group.Name;
}
else
{
book = App.OpenBook(pathToVidomist);
var exist =
book.Worksheets.Cast<object>()
.Any(sheet2 => ((Worksheet) sheet2).Name.Equals(group.Name));
if (exist)
{
if (!Control.IfShow)
{
var control =
new Control("Уже існує зведена відомість для групи:\n" + group.Name);
control.ShowDialog();
if (Control.ButtonClick == 1)
{
var newApp = new Application {Visible = true};
((Worksheet)
newApp.Workbooks.Open(pathToVidomist).Worksheets[group.Name]).Select();
Control.ButtonClick = 0;
control.SetButtonReseachEnabled(false);
control.ShowDialog();
newApp.Quit();
ExcelApplication.ExcelApplication.Kill(newApp);
}
if (Control.ButtonClick == 2)
{
Log.Info(LoggerConstants.EXIT);
return;
}
sheet = App.OpenWorksheet(book, group.Name);
if (sheet != null)
sheet.Cells.Delete();
else
{
Log.Warn("Some sheet == null");
}
}
else
{
if (Control.ButtonClick == 2)
{
Log.Info(LoggerConstants.EXIT);
return;
}
sheet = App.OpenWorksheet(book, group.Name);
if (sheet != null)
sheet.Cells.Delete();
//.........这里部分代码省略.........