本文整理汇总了C#中Application.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Application.Close方法的具体用法?C# Application.Close怎么用?C# Application.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
// Main entry point.
public static void Main(String[] args)
{
Application app = new Application("XClockEmbed", args);
XClockEmbed topLevel = new XClockEmbed("Embedded Clock", 200, 200);
topLevel.Map();
app.Run();
app.Close();
}
示例2: Main
// Main entry point.
public static void Main(String[] args)
{
Application app = new Application("XHello", args);
Image image = new Image("dotgnu-logo.bmp");
XHello topLevel = new XHello
("Hello DotGNU!", image.Width, image.Height, image);
topLevel.Map();
app.Run();
app.Close();
}
示例3: GetNamedRangeTest
public void GetNamedRangeTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
Names namedCollection = book.Names;
Name expected = book.Names.GetNamedRange("InsertRows");
string rangeName = "InsertRows";
Name actual = namedCollection.GetNamedRange(rangeName);
Assert.AreEqual(expected, actual);
}
finally
{
application.Close();
}
}
示例4: ValidateLocalInWWTLayerDataTest
public void ValidateLocalInWWTLayerDataTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("TestData.xlsx", false);
Name namedRange = book.Names.GetNamedRange("ColumnList");
Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
LayerMap_Accessor localLayerMap = new LayerMap_Accessor(namedRange);
localLayerMap.LayerDetails.Name = "Layer";
localLayerMap.MapType = LayerMapType.LocalInWWT;
WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
target.currentWorkbookMap = new WorkbookMap_Accessor(book);
target.currentWorkbookMap.SelectedLayerMap = localLayerMap;
// Active sheet returned will be the book.Sheets[3] object.
book.Sheets[3].Activate();
Range selectedRange = namedRange.RefersToRange;
_Worksheet activeSheet = WorkflowController_Accessor.GetActiveWorksheet();
bool expected = true;
bool actual = target.ValidateLocalInWWTLayerData(activeSheet, selectedRange);
Assert.AreEqual(expected, actual);
}
finally
{
application.Close();
}
}
示例5: AddChildNodesToGroupTest
public void AddChildNodesToGroupTest()
{
Application application = new Application();
try
{
// Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
// wither null or actual application object.
ThisAddIn_Accessor.ExcelApplication = application;
Group childGroup = new Group("Earth", GroupType.ReferenceFrame, null);
Layer layer = new Layer();
layer.Name = "Layer1";
layer.Group = childGroup;
LayerMap_Accessor localLayerMap = new LayerMap_Accessor(layer);
localLayerMap.MapType = LayerMapType.Local;
GroupChildren groupChild = LayerMapExtensions_Accessor.AddChildNodesToGroup(localLayerMap);
Assert.AreEqual("Earth", groupChild.Name);
Assert.AreEqual(1, groupChild.AllChildren.Count);
Assert.AreEqual(1, groupChild.Layers.Count);
foreach (Layer layerVal in groupChild.Layers)
{
Assert.AreEqual("Layer1", layerVal.Name);
}
}
finally
{
application.Close();
}
}
示例6: UpdateHeaderPropertiesTest
public void UpdateHeaderPropertiesTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
// Get the named range stored in the test data excel file.
// This range refers to address "$A$1:$D$7".
Name oldName = book.Names.GetNamedRange("GetSelectedLayerWorksheet");
Name newName = book.Names.GetNamedRange("UpdateHeaderPropertiesTestRADEC");
LayerMap selectedlayer = new LayerMap(oldName);
Range selectedRange = newName.RefersToRange;
LayerMapExtensions.UpdateHeaderProperties(selectedlayer, selectedRange);
Assert.AreEqual(selectedlayer.MappedColumnType[0], ColumnType.RA);
Assert.AreEqual(selectedlayer.MappedColumnType[1], ColumnType.Dec);
}
finally
{
application.Close();
}
}
示例7: CleanLayerMapTest
public void CleanLayerMapTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
// Where ever we are creating object for WorkflowController_Accessor, we need to set the ThisAddIn_Accessor.ExcelApplication to
// wither null or actual application object.
ThisAddIn_Accessor.ExcelApplication = application;
using (WorkflowController_Accessor target = new WorkflowController_Accessor())
{
Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
target.OnNewWorkbook(book);
Name namedRange = book.Names.GetNamedRange("TestProperties_1");
namedRange.RefersTo = null;
// CurrentWorkbookMap cannot be accessed directly through WorkflowController_Accessor object.
WorkbookMap currentWorkbookMap = target.currentWorkbookMap.Target as WorkbookMap;
// Before making call to CleanLayerMap method, AllLayerMaps count should be 1.
Assert.AreEqual(currentWorkbookMap.AllLayerMaps.Count, 2);
Addin.WorkbookExtensions_Accessor.CleanLayerMap(book, target.currentWorkbookMap);
// After the call to CleanLayerMap method, AllLayerMaps count should be 0.
Assert.AreEqual(currentWorkbookMap.AllLayerMaps.Count, 1);
}
}
finally
{
application.Close();
}
}
示例8: ValidateFormulaTest
public void ValidateFormulaTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("TestData.xlsx", false);
// Get the named range stored in the test data excel file.
// This range contains no formula.
Name rangeWithoutFormula = book.Names.GetNamedRange("RangeWithoutFormula");
bool expected = false;
bool actual = RangeExtensions.ValidateFormula(rangeWithoutFormula.RefersToRange);
Assert.AreEqual(expected, actual);
// Get the named range stored in the test data excel file.
// This range contains formula.
Name rangeWithFormula = book.Names.GetNamedRange("RangeWithFormula");
expected = true;
actual = RangeExtensions.ValidateFormula(rangeWithFormula.RefersToRange);
Assert.AreEqual(expected, actual);
}
finally
{
application.Close();
}
}
示例9: SerializeTest
public void SerializeTest()
{
Application application = new Application();
try
{
ThisAddIn_Accessor.ExcelApplication = application;
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
Name layerOne = book.Names.GetNamedRange("UpdateLayerRangeInitial");
LayerMap layerMap = new LayerMap(layerOne);
WorkbookMap workbookMap = new WorkbookMap(book);
workbookMap.AllLayerMaps.Add(layerMap);
string expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><WorkbookMap xmlns:d1p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Addin\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"Microsoft.Research.Wwt.Excel.Addin.WorkbooMap\"><d1p1:SerializableLayerMaps><d1p1:LayerMap><d1p1:LayerDetails xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Common\"><d4p1:AltColumn>-1</d4p1:AltColumn><d4p1:AltType>Depth</d4p1:AltType><d4p1:AltUnit>Meters</d4p1:AltUnit><d4p1:Color>ARGBColor:255:255:0:0</d4p1:Color><d4p1:ColorMapColumn>-1</d4p1:ColorMapColumn><d4p1:CoordinatesType>Spherical</d4p1:CoordinatesType><d4p1:DecColumn>-1</d4p1:DecColumn><d4p1:EndDateColumn>-1</d4p1:EndDateColumn><d4p1:EndTime>9999-12-31T23:59:59.9999999</d4p1:EndTime><d4p1:FadeSpan>PT0S</d4p1:FadeSpan><d4p1:FadeType>None</d4p1:FadeType><d4p1:GeometryColumn>-1</d4p1:GeometryColumn><d4p1:Group i:nil=\"true\" /><d4p1:HasTimeSeries>false</d4p1:HasTimeSeries><d4p1:ID i:nil=\"true\" /><d4p1:LatColumn>-1</d4p1:LatColumn><d4p1:LngColumn>-1</d4p1:LngColumn><d4p1:MarkerIndex>0</d4p1:MarkerIndex><d4p1:MarkerScale>World</d4p1:MarkerScale><d4p1:Name>UpdateLayerRangeInitial</d4p1:Name><d4p1:NameColumn>0</d4p1:NameColumn><d4p1:Opacity>1</d4p1:Opacity><d4p1:PlotType>Gaussian</d4p1:PlotType><d4p1:PointScaleType>StellarMagnitude</d4p1:PointScaleType><d4p1:RAColumn>-1</d4p1:RAColumn><d4p1:RAUnit>Hours</d4p1:RAUnit><d4p1:ReverseXAxis>false</d4p1:ReverseXAxis><d4p1:ReverseYAxis>false</d4p1:ReverseYAxis><d4p1:ReverseZAxis>false</d4p1:ReverseZAxis><d4p1:ScaleFactor>8</d4p1:ScaleFactor><d4p1:ShowFarSide>true</d4p1:ShowFarSide><d4p1:SizeColumn>-1</d4p1:SizeColumn><d4p1:StartDateColumn>-1</d4p1:StartDateColumn><d4p1:StartTime>0001-01-01T00:00:00</d4p1:StartTime><d4p1:TimeDecay>16</d4p1:TimeDecay><d4p1:Version>0</d4p1:Version><d4p1:XAxis>-1</d4p1:XAxis><d4p1:YAxis>-1</d4p1:YAxis><d4p1:ZAxis>-1</d4p1:ZAxis></d1p1:LayerDetails><d1p1:MapType>Local</d1p1:MapType><d1p1:MappedColumnType xmlns:d4p1=\"http://schemas.datacontract.org/2004/07/Microsoft.Research.Wwt.Excel.Common\"><d4p1:ColumnType>None</d4p1:ColumnType><d4p1:ColumnType>None</d4p1:ColumnType><d4p1:ColumnType>None</d4p1:ColumnType><d4p1:ColumnType>None</d4p1:ColumnType><d4p1:ColumnType>None</d4p1:ColumnType><d4p1:ColumnType>None</d4p1:ColumnType></d1p1:MappedColumnType><d1p1:RangeAddress>=UpdateLayer!$A$1:$F$9</d1p1:RangeAddress><d1p1:RangeDisplayName>UpdateLayerRangeInitial</d1p1:RangeDisplayName></d1p1:LayerMap></d1p1:SerializableLayerMaps><d1p1:SerializableSelectedLayerMap i:nil=\"true\" /></WorkbookMap>";
string actual = WorkbookMapExtensions.Serialize(workbookMap);
Assert.AreEqual(expected, actual);
}
finally
{
application.Close();
}
}
示例10: GetSelectedLayerWorksheetTest
public void GetSelectedLayerWorksheetTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("TestData.xlsx", false);
// Get the named range stored in the test data excel file.
// This range refers to address "$A$1:$D$7".
Name name = book.Names.GetNamedRange("GetSelectedLayerWorksheet");
ThisAddIn_Accessor.ExcelApplication = application;
LayerMap_Accessor selectedLayerMap = new LayerMap_Accessor(name);
// Active the first sheet, to verify the actual sheet to which the range belongs to is getting selected.
book.Sheets[1].Activate();
// GetSelectedLayerWorksheet range belongs to sheet 6.
_Worksheet expected = book.Sheets[6];
_Worksheet actual = WorkflowController_Accessor.GetSelectedLayerWorksheet(selectedLayerMap);
// Verify that both Worksheet objects are same.
Assert.AreEqual(expected, actual);
// Also verify that the active sheet is same as the one returned.
Assert.AreEqual(application.ActiveSheet, actual);
}
finally
{
application.Close();
}
}
示例11: GetSelectedLayerMapWWTTest
public void GetSelectedLayerMapWWTTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
target.OnNewWorkbook(book);
Layer layer = new Layer();
LayerMap_Accessor localLayer = new LayerMap_Accessor(layer);
localLayer.MapType = LayerMapType.WWT;
localLayer.LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
// CurrentWorkbookMap cannot be accessed directly through WorkflowController_Accessor object.
WorkbookMap currentWorkbookMap = target.currentWorkbookMap.Target as WorkbookMap;
currentWorkbookMap.AllLayerMaps[0].LayerDetails.ID = "2cf4374f-e1ce-47a9-b08c-31079765ddcf";
currentWorkbookMap.AllLayerMaps[0].MapType = LayerMapType.WWT;
LayerMap_Accessor layerMapAccessor = target.GetSelectedLayerMap(localLayer);
// Make sure LayerMap is returned and the expected LayerMap ID is returned.
Assert.IsNotNull(layerMapAccessor);
Assert.AreEqual(layerMapAccessor.LayerDetails.ID, "2cf4374f-e1ce-47a9-b08c-31079765ddcf");
}
finally
{
application.Close();
}
}
示例12: GetLastUsedGroupTestForSky
public void GetLastUsedGroupTestForSky()
{
Application application = new Application();
try
{
Collection<Group> groups = new Collection<Group>();
bool isWWTRunning = false;
Group expected = groups.GetDefaultSkyGroup();
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
// Get the named range stored in the test data excel file.
Name namedRange = book.Names.GetNamedRange("GetLastUsedGroupTestRaDec");
LayerMap_Accessor selectedlayer = new LayerMap_Accessor(namedRange);
selectedlayer.MapType = LayerMapType.Local;
selectedlayer.IsNotInSync = false;
selectedlayer.LayerDetails.ID = "Exits";
Group actual = WorkflowController_Accessor.GetLastUsedGroup(selectedlayer, isWWTRunning);
Assert.AreEqual(expected.Name, actual.Name);
Assert.AreEqual(expected.Path, actual.Path);
}
finally
{
application.Close();
}
}
示例13: GetCurrentRangeLayerTest
public void GetCurrentRangeLayerTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("WorkbookTestData.xlsx", false);
WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
Common.Globals_Accessor.wwtManager = new WWTManager(new WWTMockRequest());
Common.Globals_Accessor.TargetMachine = new TargetMachine("localhost");
target.OnWorkbookOpen(book);
book.Sheets[12].Activate();
Worksheet worksheet = (Worksheet)book.Sheets[12];
Range selectedRange = worksheet.get_Range("A2:H6");
LayerMap_Accessor layerMap = target.GetCurrentRangeLayer(selectedRange);
Assert.AreEqual("TestProperties_1", layerMap.RangeDisplayName);
Assert.AreEqual("TestProperties_1", layerMap.LayerDetails.Name);
}
finally
{
application.Close();
}
}
示例14: GetActiveWorksheetTest
public void GetActiveWorksheetTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("TestData.xlsx", false);
ThisAddIn_Accessor.ExcelApplication = application;
book.Sheets[3].Activate();
// Active sheet returned will be the book.Sheets[3] object.
_Worksheet activeSheet = WorkflowController_Accessor.GetActiveWorksheet();
Assert.AreEqual(activeSheet, book.Sheets[3]);
}
finally
{
application.Close();
}
}
示例15: DeleteMappingTest
public void DeleteMappingTest()
{
Application application = new Application();
try
{
Workbook book = application.OpenWorkbook("TestData.xlsx", false);
WorkflowController_Accessor target = GetWorkflowControllerAccessor(application);
target.currentWorkbookMap = new WorkbookMap_Accessor(book);
Worksheet worksheet = application.ActiveSheet;
Range address = worksheet.get_Range("A1:G8");
Name namedRange = book.CreateNamedRange("DeleteMappingRange", address);
LayerMap_Accessor localLayer = new LayerMap_Accessor(namedRange);
target.currentWorkbookMap.SelectedLayerMap = localLayer;
target.DeleteMapping();
Assert.IsNull(book.Names.GetNamedRange("DeleteMappingRange"));
Assert.IsNull(target.currentWorkbookMap.SelectedLayerMap);
}
finally
{
application.Close();
}
}