本文整理汇总了C#中System.Windows.Forms.Panel.onClosed方法的典型用法代码示例。如果您正苦于以下问题:C# Panel.onClosed方法的具体用法?C# Panel.onClosed怎么用?C# Panel.onClosed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Panel
的用法示例。
在下文中一共展示了Panel.onClosed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addStopInstanceGui
public static API_AmazonEC2 addStopInstanceGui(this API_AmazonEC2 amazonEC2, Panel targetPanel, TreeView treeViewWithInstances)
{
Action startTimer = null;
Action stopTimer = null;
var instancesToStop = targetPanel.add_GroupBox("Stop Instance in {0} minutes".format((amazonEC2.TimerCount * amazonEC2.TimerCount / 60)))
.add_TreeView();
var timerBar = instancesToStop.insert_Below(20).add_ProgressBar();
instancesToStop.add_ContextMenu().add_MenuItem("Stop now",true,
()=>{
"Stopping {0} instances now".debug(instancesToStop.nodes().size());
foreach(var node in instancesToStop.nodes())
amazonEC2.stopInstance((RunningInstance)node.get_Tag());
})
.add_MenuItem("Clear list", ()=>instancesToStop.clear());
var startTimerLink = instancesToStop.insert_Above(15).add_Link("Add instance to list",0,0,
()=>{
var selectedNode = treeViewWithInstances.selected();
if (selectedNode.notNull())
{
var tag = selectedNode.get_Tag();
if (tag is RunningInstance)
{
var selectedInstance = (RunningInstance)tag;
var nodeText = "{0} - {1}".format(selectedInstance.InstanceId, selectedInstance.IpAddress);
instancesToStop.add_Node(nodeText, selectedInstance);
}
}
//treeViewWithInstances.nodes().showInfo();
})
.append_Link("Start timer", ()=>startTimer());
var timerEnabled = false;
var stopTimerLink = startTimerLink.append_Link("Stop timer", ()=>stopTimer()).enabled(false);
startTimer = ()=>{
"starting timer".info();
timerEnabled = true;
timerBar.maximum(amazonEC2.TimerCount);
timerBar.value(0);
startTimerLink.enabled(false);
stopTimerLink.enabled(true);
while(timerEnabled && timerBar.Value < amazonEC2.TimerCount)
{
"In StopInstances Timer [{0}/{1}], sleeping for {2} seconds".info(timerBar.Value, amazonEC2.TimerCount, amazonEC2.TimerSleep/1000);
timerBar.sleep(amazonEC2.TimerSleep, false);
timerBar.increment(1);
}
if (timerEnabled)
{
"Timer is completed stopping {0} instances now".debug(instancesToStop.nodes().size());
foreach(var node in instancesToStop.nodes())
amazonEC2.stopInstance((RunningInstance)node.get_Tag());
}
else
"Timer was stopped so nothing to do".debug();
startTimerLink.enabled(true);
stopTimerLink.enabled(false);
};
stopTimer = ()=>{
"stopping timer".info();
timerEnabled = false;
startTimerLink.enabled(true);
stopTimerLink.enabled(false);
};
targetPanel.onClosed(()=> timerEnabled=false);
return amazonEC2;
}