private void InitializeTopCatUI() { int index = 0; int selectedIndex = 0; scripts_listBox.Items.Clear(); var repo = _settings["TopCatScripts"]; foreach (var file in Directory.GetFiles(repo, "*.tcx", SearchOption.AllDirectories)) { scripts_listBox.Items.Add(new TopCatScript(file, Path.GetFileName(file))); if (_activityData.Script != null) { if (!string.IsNullOrEmpty(_activityData.Script.FileName)) { if (_activityData.Script.FileName.Equals(file)) { selectedIndex = index; } } } index++; } scripts_listBox.DisplayMember = "ScriptName"; scripts_listBox.ValueMember = "FileName"; if (_activityData.Script != null) { _selectedScript = _activityData.Script; _properties = _activityData.Script.Properties; setupPath_textBox.Text = _activityData.SetupFileName; runonce_checkBox.Checked = _activityData.RunOnce; copydir_checkBox.Checked = _activityData.CopyDirectory; if (!string.IsNullOrEmpty(_activityData.Script.ScriptName)) { scripts_listBox.SelectedIndex = selectedIndex; } if (_activityData.Script.SelectedTests.Count == 0) { alltests_checkBox.Checked = true; } else { alltests_checkBox.Checked = false; foreach (var selectedTest in _activityData.Script.SelectedTests) { if (topcattests_listBox.Items.IndexOf(selectedTest) > -1) { topcattests_listBox.SelectedIndices.Add(topcattests_listBox.Items.IndexOf(selectedTest)); } } } } }
/// <summary> /// Performs any teardown activities for plugin which implements this interface /// </summary> public void Teardown() { var action = new Action(() => { _configureScript = new TopCatScript(Path.Combine(Path.GetTempPath(), "TopCatScript", "CustomPrintSettings.tcx"), "CustomPrintSettings"); TopCatExecutionController topCatExecutionController = new TopCatExecutionController(_configureScript); topCatExecutionController.Cleanup(); }); var token = new LocalLockToken(_defaultPrintQueue.FullName, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); ExecutionServices.CriticalSection.Run(token, action); }
public XElement Convert(XElement xml) { XNamespace nsRoot = xml.GetDefaultNamespace(); XElement scriptElement = xml.Element(nsRoot + "Script"); var scriptNamespaceAttribute = scriptElement.Attributes().Where(n => n.IsNamespaceDeclaration).First(); XNamespace nsScript = XNamespace.Get(scriptNamespaceAttribute.Value); TopCatScript topCatScript = new TopCatScript ( (string)scriptElement.Element(nsScript + "FileName"), (string)scriptElement.Element(nsScript + "ScriptName") ); XElement selectedTestElement = scriptElement.Element(nsScript + "SelectedTests"); var tests = selectedTestElement.Descendants().Where(n => n.Name.LocalName == "string").Select(n => (string)n); foreach (string test in tests.Where(n => !string.IsNullOrEmpty(n))) { topCatScript.SelectedTests.Add(test); } var propertyNodes = scriptElement.Descendants(nsScript + "TopCatProperties"); foreach (var propertyNode in propertyNodes.Where(n => n.FirstNode != null)) { string propertyName = (string)propertyNode.Element(nsScript + "PropertyName"); string propertyValue = (string)propertyNode.Element(nsScript + "PropertyValue"); topCatScript.Properties.Add(propertyName, propertyValue); } TopCatActivityData activityData = new TopCatActivityData() { CopyDirectory = (bool?)xml.Element(nsRoot + "CopyDirectory") ?? false, RunOnce = (bool?)xml.Element(nsRoot + "RunOnce") ?? false, SetupFileName = (string)xml.Element(nsRoot + "SetupFileName"), Script = topCatScript }; return(Serializer.Serialize(activityData)); }
private void scripts_listBox_SelectedIndexChanged(object sender, EventArgs e) { _selectedScript = scripts_listBox.SelectedItem as TopCatScript; LoadProperties(); LoadTests(); }