public static EnumDecisionReturn Show(string message, string caption) { using (Decider decider = new Decider()) { return(decider.Decide(EnumDecisionType.eOkDecision, message, caption, EnumDecisionReturn.eOK, EnumDecisionReturn.eOK)); } }
//Dokument kopieren public void DocumentCopy(string sDokument, string sZiel) { //gibt es das Dokument auch? if (File.Exists(sDokument)) { //Dateinamen ermitteln string sDateiname = Path.GetFileName(sDokument); try { //Dokument kopieren, mit überschreiben File.Copy(sDokument, Path.Combine(sZiel, sDateiname), true); } catch (Exception exc) { String strMessage = exc.Message; MessageBox.Show("Exception: " + strMessage + "\n\n" + sZiel + " -- " + sDateiname, "Documentation-Tool, DocumentCopy", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //Hinweis, Datei gibt es nicht #if DEBUG MessageBox.Show("Das Dokument [" + sDokument + "] ist nicht auf dem Datenträger vorhanden!", "Documentation-Tool", MessageBoxButtons.OK, MessageBoxIcon.Information); #else Decider eDecision = new Decider(); eDecision.Decide(EnumDecisionType.eOkDecision, "Das Dokument [" + sDokument + "] ist nicht auf dem Datenträger vorhanden!", "Documentation-Tool", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); #endif } return; }
public static EnumDecisionReturn Show(EnumDecisionType decision, string message, string caption, EnumDecisionReturn decisionReturn, EnumDecisionIcon icon) { using (Decider decider = new Decider()) { return(decider.Decide(decision, message, caption, decisionReturn, decisionReturn, "MessageDisplayHelper", false, icon)); } }
public void MyFunctionAsAction() { Decider decider = new Decider(); decider.Decide(EnumDecisionType.eOkDecision, "MyFunctionAsAction() was called!", "RegisterScriptMenu", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); String strAction = "FirstAction"; ActionManager oAMnr = new ActionManager(); Eplan.EplApi.ApplicationFramework.Action oAction = oAMnr.FindAction(strAction); if (oAction != null) { ActionCallingContext ctx = new ActionCallingContext(); String strParamValue = "Param1 Value"; ctx.AddParameter("Param1", strParamValue); bool bRet = oAction.Execute(ctx); if (bRet) { String strReturnValue = null; ctx.GetParameter("ReturnParam", ref strReturnValue); decider.Decide(EnumDecisionType.eOkDecision, string.Format("The Action '{0}' ended successfully with Return Value = [{1}]", strAction, strReturnValue), "MyFunctionAsAction", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); } else { decider.Decide(EnumDecisionType.eOkDecision, "The Action '" + strAction + "' ended with errors!", "MyFunctionAsAction", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); } } else { decider.Decide(EnumDecisionType.eOkDecision, "The Action '" + strAction + "' not found!", "MyFunctionAsAction", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); } decider.Dispose(); decider = null; return; }
private IEnumerator Waiter() { yield return(new WaitForSeconds(1f)); aiChoosed = ai.Choose(); AIChoosedEvent?.Invoke(aiChoosed); yield return(new WaitForSeconds(1f)); decider.Decide(playerChoosed, aiChoosed); }
public void Function() { string projectPath = PathMap.SubstitutePath("$(PROJECTPATH)"); // Save FileSelectDecisionContext fsdcSave = new FileSelectDecisionContext(); fsdcSave.Title = "Datei auswählen"; fsdcSave.OpenFileFlag = false; fsdcSave.CustomDefaultPath = projectPath; fsdcSave.AllowMultiSelect = false; fsdcSave.DefaultExtension = "txt"; fsdcSave.AddFilter("Textdatei (*.txt)", "*.txt"); fsdcSave.AddFilter("Alle Dateien (*.*)", "*.*"); Decider deciderSave = new Decider(); EnumDecisionReturn decisionSave = deciderSave.Decide(fsdcSave); if (decisionSave == EnumDecisionReturn.eCANCEL) { return; } string fullFileNameSave = fsdcSave.GetFiles()[0]; FileStream fileStream = File.Create(fullFileNameSave); fileStream.Dispose(); MessageBox.Show("Datei wurde gespeichert:" + Environment.NewLine + fullFileNameSave); // Open FileSelectDecisionContext fsdcOpen = new FileSelectDecisionContext(); fsdcOpen.Title = "Datei auswählen"; fsdcOpen.OpenFileFlag = true; fsdcOpen.CustomDefaultPath = projectPath; fsdcOpen.AllowMultiSelect = false; fsdcOpen.DefaultExtension = "txt"; fsdcOpen.AddFilter("Textdatei (*.txt)", "*.txt"); fsdcOpen.AddFilter("Alle Dateien (*.*)", "*.*"); Decider deciderOpen = new Decider(); EnumDecisionReturn decisionOpen = deciderOpen.Decide(fsdcOpen); if (decisionOpen == EnumDecisionReturn.eCANCEL) { return; } string fullFileNameOpen = fsdcOpen.GetFiles()[0]; MessageBox.Show("Datei wurde geöffnet:" + Environment.NewLine + fullFileNameOpen); }
public DialogResult Show() { EnumDecisionReturn answer = decider.Decide(fileSelectDecisionContext); if (answer == EnumDecisionReturn.eOK) { this.File = fileSelectDecisionContext.GetFiles()[0]; return(DialogResult.OK); } return(DialogResult.Cancel); }
public void Function() { #region Decider Decider decider = new Decider(); EnumDecisionReturn decision = decider.Decide( EnumDecisionType.eOkCancelDecision, // type "This is the text", "Title", EnumDecisionReturn.eOK, // selected Answer EnumDecisionReturn.eOK); // Answer if quite-mode on switch (decision) { case EnumDecisionReturn.eOK: // OK break; case EnumDecisionReturn.eCANCEL: // Cancel break; } #endregion #region FileSelector FileSelectDecisionContext fileContext = new FileSelectDecisionContext("MySelector", EnumDecisionReturn.eCANCEL); fileContext.Title = "Title"; fileContext.CustomDefaultPath = @"C:\MyDefaultPath"; fileContext.OpenFileFlag = true; // true=Open, false=save fileContext.AllowMultiSelect = true; fileContext.DefaultExtension = "xml"; fileContext.AddFilter("XML files (*.xml)", "*.xml"); fileContext.AddFilter("All files (*.*)", "*.*"); Decider oDecision = new Decider(); EnumDecisionReturn eAnswer = oDecision.Decide(fileContext); if (eAnswer != EnumDecisionReturn.eOK) { foreach (string file in fileContext.GetFiles()) { // do with file } } #endregion }
public string GameCycle(List <string> fromConsole) { var inputs = fromConsole[0].Split(' '); int x = int.Parse(inputs[0]); int y = int.Parse(inputs[1]); int myLife = int.Parse(inputs[2]); int oppLife = int.Parse(inputs[3]); int torpedoCooldown = int.Parse(inputs[4]); int sonarCooldown = int.Parse(inputs[5]); int silenceCooldown = int.Parse(inputs[6]); int mineCooldown = int.Parse(inputs[7]); string sonarResult = fromConsole[1]; string opponentOrders = fromConsole[2]; me.x = x; me.y = y; me.previousHealth = me.health; me.health = myLife; me.sonarCooldown = sonarCooldown; me.silenceCooldown = silenceCooldown; me.mineCooldown = mineCooldown; me.torpedoCooldown = torpedoCooldown; enemy.previousHealth = enemy.health; enemy.health = oppLife; if (sonarResult == "Y" || sonarResult == "N") { var action = me.previousOrders.Last().actions.Find(a => a.type == ActionType.sonar); if (action != null) { action.result = sonarResult == "Y"; } } enemy.previousOrders.Add(Order.ParceOrder(opponentOrders)); var order = decider.Decide(map, me, enemy); me.previousOrders.Add(order); return(order.ToString()); }
public static void HandleException(Exception exception, string name, UndoStep undoStep = null) { Decider decider = new Decider(); string message; if (undoStep == null) { message = "Es ist ein Fehler beim Erzeugen aufgetreten:"; } else { message = "Es ist ein Fehler beim Erzeugen aufgetreten. Soll die Aktion rückgängig gemacht werden?"; } string errorText; StringBuilder sb = new StringBuilder(); switch (exception) { case LockingException e: string[] failedLockingObjects = e.GetAllFailed2LockAsString(); foreach (var id in failedLockingObjects) { var storableObject = StorableObject.FromStringIdentifier(id); sb.AppendLine(storableObject.GetType().ToString()); } errorText = $"{message}{Environment.NewLine}{exception.Message}{Environment.NewLine}{Environment.NewLine}{sb}{Environment.NewLine}"; break; default: errorText = $"{message}{Environment.NewLine}{exception.Message}{Environment.NewLine}{Environment.NewLine}"; break; } // Log BaseException bexError = new BaseException($"{name}: {errorText}{Environment.NewLine}{exception}", MessageLevel.Error); bexError.FixMessage(); // Show EnumDecisionReturn decision; if (undoStep != null) { decision = decider.Decide(EnumDecisionType.eYesNoDecision, errorText, name, EnumDecisionReturn.eYES, EnumDecisionReturn.eYES, name, false, EnumDecisionIcon.eFATALERROR); } else { decision = decider.Decide(EnumDecisionType.eOkDecision, errorText, name, EnumDecisionReturn.eOK, EnumDecisionReturn.eOK, name, false, EnumDecisionIcon.eFATALERROR); } switch (decision) { case EnumDecisionReturn.eYES: undoStep?.DoUndo(); break; } }
public void Action() { try { string sSourceText = string.Empty; string sReturnText = string.Empty; string EplanCRLF = "¶"; // Empty clipboard System.Windows.Forms.Clipboard.Clear(); // Fill clipboard CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // Select all oCLI.Execute("GfDlgMgrActionIGfWind /function:Copy"); // Copy if (System.Windows.Forms.Clipboard.ContainsText()) { sSourceText = System.Windows.Forms.Clipboard.GetText(); if (sSourceText != string.Empty) { string[] sConnectionTerms = sSourceText.Split(new string[] { EplanCRLF }, StringSplitOptions.None); if (sConnectionTerms.Length > 2) // More than 2 connection names { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(EnumDecisionType.eYesNoDecision, "Should the connection designations be turned in pairs? ", "Turn the order", EnumDecisionReturn.eYES, EnumDecisionReturn.eYES, "ConnectionPointDesignationReverse", true, EnumDecisionIcon.eQUESTION); if (eAnswer == EnumDecisionReturn.eYES) { // Rebuild string for (int i = 0; i < sConnectionTerms.Length; i = i + 2) { sReturnText += sConnectionTerms[i + 1] + EplanCRLF + sConnectionTerms[i] + EplanCRLF; } } else { // Turn the string array Array.Reverse(sConnectionTerms); // Rebuild string foreach (string sConnection in sConnectionTerms) { sReturnText += sConnection + EplanCRLF; } } } else // Only 2 connection names { // Turn the string array Array.Reverse(sConnectionTerms); // Rebuild string foreach (string sConnection in sConnectionTerms) { sReturnText += sConnection + EplanCRLF; } } // Remove last character again sReturnText = sReturnText.Substring(0, sReturnText.Length - 1); // Insert clipboard System.Windows.Forms.Clipboard.SetText(sReturnText); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // Select all oCLI.Execute("GfDlgMgrActionIGfWindDelete"); // Clear oCLI.Execute("GfDlgMgrActionIGfWind /function:Paste"); // Insert } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Turn order, error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
//Form_Load private void frmDocumentationTool_Load(object sender, System.EventArgs e) { //Position und Größe aus Settings lesen #if !DEBUG Eplan.EplApi.Base.Settings oSettings = new Eplan.EplApi.Base.Settings(); if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Top")) { this.Top = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Top", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Left")) { this.Left = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Left", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Height")) { this.Height = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Height", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Width")) { this.Width = oSettings.GetNumericSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.Width", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuHerstellerVerzeichnis")) { this.toolStripMenuHerstellerVerzeichnis.Checked = oSettings.GetBoolSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuHerstellerVerzeichnis", 0); } if (oSettings.ExistSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuArtikelnummerVerzeichnis")) { this.toolStripMenuArtikelnummerVerzeichnis.Checked = oSettings.GetBoolSetting("USER.SCRIPTS.DOCUMENTATION_TOOL.toolStripMenuArtikelnummerVerzeichnis", 0); } #endif //Titelzeile anpassen string sProjekt = string.Empty; #if DEBUG sProjekt = "DEBUG"; #else CommandLineInterpreter cmdLineItp = new CommandLineInterpreter(); ActionCallingContext ProjektContext = new ActionCallingContext(); ProjektContext.AddParameter("TYPE", "PROJECT"); cmdLineItp.Execute("selectionset", ProjektContext); ProjektContext.GetParameter("PROJECT", ref sProjekt); sProjekt = Path.GetFileNameWithoutExtension(sProjekt); //Projektname Pfad und ohne .elk if (sProjekt == string.Empty) { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(EnumDecisionType.eOkDecision, "Es ist kein Projekt ausgewählt.", "Documentation-Tool", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); if (eAnswer == EnumDecisionReturn.eOK) { Close(); return; } } #endif Text = Text + " - " + sProjekt; //Button Extras Text festlegen //btnExtras.Text = " Extras ▾"; // ▾ ▼ //Zielverzeichnis vorbelegen #if DEBUG txtZielverzeichnis.Text = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Test"; #else txtZielverzeichnis.Text = PathMap.SubstitutePath(@"$(DOC)"); #endif // Temporären Dateinamen festlegen #if DEBUG string sTempFile = Path.Combine(Application.StartupPath, "tmp_Projekt_Export.epj"); #else string sTempFile = Path.Combine(PathMap.SubstitutePath(@"$(TMP)"), "tmpDocumentationTool.epj"); #endif //Projekt exportieren #if !DEBUG PXFexport(sTempFile); #endif //PXF Datei einlesen und in Listview schreiben PXFeinlesen(sTempFile); //PXF Datei wieder löschen #if !DEBUG File.Delete(sTempFile); #endif }
void DecideAction() { processPerceptions(); currentAction = decider.Decide(currentPerceptions); }
public void Action() { try { string sSourceText = string.Empty; string sReturnText = string.Empty; string EplanCRLF = "¶"; //Vaciar el portapapeles System.Windows.Forms.Clipboard.Clear(); //copiar portapapeles CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // seleccionar todo oCLI.Execute("GfDlgMgrActionIGfWind /function:Copy"); // copiar if (System.Windows.Forms.Clipboard.ContainsText()) { sSourceText = System.Windows.Forms.Clipboard.GetText(); if (sSourceText != string.Empty) { string[] sAnschlussbezeichnungen = sSourceText.Split(new string[] { EplanCRLF }, StringSplitOptions.None); if (sAnschlussbezeichnungen.Length > 2) // Más de 2 puntos de conexión { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(EnumDecisionType.eYesNoDecision, "Las designaciones de conexión están emparejadas?", "Invierte el orden", EnumDecisionReturn.eYES, EnumDecisionReturn.eYES, "ConnectionPointDesignationReverse", true, EnumDecisionIcon.eQUESTION); if (eAnswer == EnumDecisionReturn.eYES) { // Reconstruir cadena de texto for (int i = 0; i < sAnschlussbezeichnungen.Length; i = i + 2) { sReturnText += sAnschlussbezeichnungen[i + 1] + EplanCRLF + sAnschlussbezeichnungen[i] + EplanCRLF; } } else { // Invierte el texto guardado en el array Array.Reverse(sAnschlussbezeichnungen); // Reconstruir cadena de texto foreach (string sAnschluss in sAnschlussbezeichnungen) { sReturnText += sAnschluss + EplanCRLF; } } } else // Solo 2 puntos de conexión { // Invierte el texto guardado en el array Array.Reverse(sAnschlussbezeichnungen); // Reconstruir cadena de texto foreach (string sAnschluss in sAnschlussbezeichnungen) { sReturnText += sAnschluss + EplanCRLF; } } // Devuelve el último carácter de nuevo sReturnText = sReturnText.Substring(0, sReturnText.Length - 1); //Insertar portapapeles System.Windows.Forms.Clipboard.SetText(sReturnText); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // Seleccionar todo oCLI.Execute("GfDlgMgrActionIGfWindDelete"); // Borrar oCLI.Execute("GfDlgMgrActionIGfWind /function:Paste"); // Insertar } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Invertir orden, Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
public bool FuncToggleDT(string MODE) { //Modus festlegen string _sMode = MODE.ToUpper(); //BMK (sichtbar) ändern Eplan.EplApi.ApplicationFramework.CommandLineInterpreter oComLineInter = new Eplan.EplApi.ApplicationFramework.CommandLineInterpreter(); #region delete DT (visible) if (System.IO.File.Exists(PathMap.SubstitutePath(sExportFileName))) { try { System.IO.File.Delete(PathMap.SubstitutePath(sExportFileName)); } catch { return(false); } } //BMK (sichtbar) kann nicht direkt gesetzt werden --> Umweg über ext. Bearbeiten oComLineInter.Execute("XMExportFunctionAction /ConfigScheme:[ESS]_MacroScriptHelper_MultiLine_DT /CompleteProject:0 /Destination:" + sQuote + sExportFileName + sQuote + "/ExecutionMode:0"); //Textedatei einlesen und ändern #region read / change export file System.IO.FileInfo oFI = new System.IO.FileInfo(PathMap.SubstitutePath(sExportFileName)); if (oFI.Exists) { string sFileContentOld = ReadFile(PathMap.SubstitutePath(sExportFileName)); string sFileContentNew = string.Empty; string[] sAllLines = sFileContentOld.Split('\n'); int nLineCnt = 0; foreach (string sTempLine in sAllLines) { nLineCnt++; string[] sCols = sTempLine.Split('\t'); if (sCols.Length >= 4 && nLineCnt > 2) { //get actual visible DT string _sOldDTVisible = sCols[4]; string _sNewDTVisible = null; //add line break (ONLY, if there is NO line-break already existing in visile DT) #region add line-break if (_sMode == "ADD" && !string.IsNullOrEmpty(_sOldDTVisible)) { if (!_sOldDTVisible.Contains(@"\n")) { _sNewDTVisible = _sOldDTVisible.Replace("==", "$").Replace("++", "%"); _sNewDTVisible = _sNewDTVisible.Replace("$", @"\n$").Replace("=", @"\n=").Replace("%", @"\n%").Replace("+", @"\n+").Replace("-", @"\n-").Replace("#", @"\n#"); _sNewDTVisible = _sNewDTVisible.Replace("$", "==").Replace("%", "++"); } } #endregion //remove line-breaks #region REMOVE line-break if (_sMode == "REMOVE" && !string.IsNullOrEmpty(_sOldDTVisible)) { _sNewDTVisible = _sOldDTVisible.Replace(@"\n", string.Empty); } #endregion //correct beginning line-break if (!string.IsNullOrEmpty(_sNewDTVisible)) { if (_sNewDTVisible.StartsWith(@"\n")) { _sNewDTVisible = _sNewDTVisible.Substring(2); } } //create new-text-content for import of external editing if (_sNewDTVisible != null) { sFileContentNew = sFileContentNew + sCols[0] + "\t" + sCols[1] + "\t" + sCols[2] + "\t" + sCols[3] + "\t" + _sNewDTVisible + System.Environment.NewLine; } else { sFileContentNew = sFileContentNew + sCols[0] + "\t" + sCols[1] + "\t" + sCols[2] + "\t" + sCols[3] + "\t" + _sOldDTVisible + System.Environment.NewLine; } } else { //create new-text-content for import of external editing sFileContentNew = sFileContentNew + sTempLine + System.Environment.NewLine; } } //veränderte Textdatei schreiben WriteFile(PathMap.SubstitutePath(sExportFileName), sFileContentNew); } else { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(Eplan.EplApi.Base.EnumDecisionType.eOkDecision, "Keine temporäre Importdatei\n'" + sExportFileName + "'\ngefunden !\n\n(Wurden passende Funktionen markiert ?)", "Eplan Decider", Eplan.EplApi.Base.EnumDecisionReturn.eOK, Eplan.EplApi.Base.EnumDecisionReturn.eOK); return(false); } #endregion //veränderte Text-Datei wieder in EPLAN einlesen oComLineInter.Execute("XMActionDCImport /DataConfigurationFile:" + sQuote + sExportFileName + sQuote + " /ProgressTitle:" + sQuote + "change visible DT..." + sQuote); #endregion return(true); }
//Button: Dokumente kopieren private void btnKopieren_Click(object sender, EventArgs e) { //gibt es das Ziel auch? if (!Directory.Exists(txtZielverzeichnis.Text)) { //Hinweis, Ziel gibt es nicht, anlegen? #if DEBUG DialogResult dialogResult = MessageBox.Show("Das Zielverzeichnis [" + txtZielverzeichnis.Text + "] ist nicht auf dem Datenträger vorhanden!\n\nSoll dieses nun angelegt werden?", "Documentation-Tool", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { Directory.CreateDirectory(txtZielverzeichnis.Text); } else if (dialogResult == DialogResult.No) { return; } #else Decider decider = new Decider(); EnumDecisionReturn decision = decider.Decide( EnumDecisionType.eYesNoDecision, // type "Das Zielverzeichnis [" + txtZielverzeichnis.Text + "] ist nicht auf dem Datenträger vorhanden!\n\nSoll dieses nun angelegt werden?", "Documentation-Tool", EnumDecisionReturn.eYES, // selected Answer EnumDecisionReturn.eYES); // Answer if quite-mode on if (decision == EnumDecisionReturn.eYES) { Directory.CreateDirectory(txtZielverzeichnis.Text); } else if (decision == EnumDecisionReturn.eNO) { return; } #endif } //Es gibt dasZiel if (Directory.Exists(txtZielverzeichnis.Text)) { ListView.CheckedListViewItemCollection checkedItems = listView.CheckedItems; #if !DEBUG Progress oProgress = new Progress("SimpleProgress"); oProgress.ShowImmediately(); oProgress.SetAllowCancel(true); oProgress.SetTitle("Documentation-Tool"); int nActionsPercent = 100 / checkedItems.Count; #endif foreach (ListViewItem item in checkedItems) { #if !DEBUG if (!oProgress.Canceled()) { oProgress.BeginPart(nActionsPercent, "Kopiere: " + item.Text); #endif string sTargetPath = txtZielverzeichnis.Text; //Hersteller-Verzeichnis hinzufügen if (toolStripMenuHerstellerVerzeichnis.Checked) { try { string sTemp = item.SubItems[2].Text; sTemp = RemoveIlegaleCharackter(sTemp); //Verzeichnisnamen von ungültigen Zeichen bereinigen sTargetPath = Path.Combine(sTargetPath, sTemp); if (!Directory.Exists(sTargetPath)) //Verzeichnis anlegen wenn noch nicht vorhanden { Directory.CreateDirectory(sTargetPath); } } catch (Exception exc) { String strMessage = exc.Message; MessageBox.Show("Exception: " + strMessage + "\n\n" + sTargetPath, "Documentation-Tool, btnKopieren", MessageBoxButtons.OK, MessageBoxIcon.Error); } } //Artikelnummer-Verzeichnis hinzufügen if (toolStripMenuArtikelnummerVerzeichnis.Checked) { try { string sTemp = item.SubItems[3].Text; sTemp = RemoveIlegaleCharackter(sTemp); //Verzeichnisnamen von ungültigen Zeichen bereinigen sTargetPath = Path.Combine(sTargetPath, sTemp); if (!Directory.Exists(sTargetPath)) //Verzeichnis anlegen wenn noch nicht vorhanden { Directory.CreateDirectory(sTargetPath); } } catch (Exception exc) { String strMessage = exc.Message; MessageBox.Show("Exception: " + strMessage + "\n\n" + sTargetPath, "Documentation-Tool, btnKopieren", MessageBoxButtons.OK, MessageBoxIcon.Error); } } DocumentCopy(item.Text, sTargetPath); #if !DEBUG oProgress.EndPart(); } #endif } #if !DEBUG oProgress.EndPart(true); #endif Close(); return; } }
public void Action() { try { string sSourceText = string.Empty; string sReturnText = string.Empty; string EplanCRLF = "¶"; //Zwischenablage leeren System.Windows.Forms.Clipboard.Clear(); //Zwischenablage füllen CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // Alles markieren oCLI.Execute("GfDlgMgrActionIGfWind /function:Copy"); // Kopieren if (System.Windows.Forms.Clipboard.ContainsText()) { sSourceText = System.Windows.Forms.Clipboard.GetText(); if (sSourceText != string.Empty) { string[] sAnschlussbezeichnungen = sSourceText.Split(new string[] { EplanCRLF }, StringSplitOptions.None); if (sAnschlussbezeichnungen.Length > 2) // Mehr als 2 Anschlussbezeichnungen { Decider eDecision = new Decider(); EnumDecisionReturn eAnswer = eDecision.Decide(EnumDecisionType.eYesNoDecision, "Sollen die Anschlussbezeichnungen paarweise gedreht werden?", "Reihenfolge drehen", EnumDecisionReturn.eYES, EnumDecisionReturn.eYES, "ConnectionPointDesignationReverse", true, EnumDecisionIcon.eQUESTION); if (eAnswer == EnumDecisionReturn.eYES) { // String neu aufbauen for (int i = 0; i < sAnschlussbezeichnungen.Length; i = i + 2) { sReturnText += sAnschlussbezeichnungen[i + 1] + EplanCRLF + sAnschlussbezeichnungen[i] + EplanCRLF; } } else { // String Array drehen Array.Reverse(sAnschlussbezeichnungen); // String neu aufbauen foreach (string sAnschluss in sAnschlussbezeichnungen) { sReturnText += sAnschluss + EplanCRLF; } } } else // Nur 2 Anschlussbezeichnungen { // String Array drehen Array.Reverse(sAnschlussbezeichnungen); // String neu aufbauen foreach (string sAnschluss in sAnschlussbezeichnungen) { sReturnText += sAnschluss + EplanCRLF; } } // letztes Zeichen wieder entfernen sReturnText = sReturnText.Substring(0, sReturnText.Length - 1); //Zwischenablage einfügen System.Windows.Forms.Clipboard.SetText(sReturnText); oCLI.Execute("GfDlgMgrActionIGfWind /function:SelectAll"); // Alles markieren oCLI.Execute("GfDlgMgrActionIGfWindDelete"); // Löschen oCLI.Execute("GfDlgMgrActionIGfWind /function:Paste"); // Einfügen } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Reihenfolge drehen, Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
public void Function() { // OK Decider deciderOk = new Decider(); deciderOk.Decide( EnumDecisionType.eOkDecision, "Ich sag mal OK!", "Decider", EnumDecisionReturn.eOK, EnumDecisionReturn.eOK); // YesNo Decider deciderYesNo = new Decider(); EnumDecisionReturn decisionYesNo = deciderYesNo.Decide( EnumDecisionType.eYesNoDecision, "Ja oder Nein?", "Decider", EnumDecisionReturn.eYES, EnumDecisionReturn.eYES); switch (decisionYesNo) { case EnumDecisionReturn.eYES: MessageBox.Show("Ja"); break; case EnumDecisionReturn.eNO: MessageBox.Show("Nein"); break; } // YesNoAll Decider deciderYesNoAll = new Decider(); EnumDecisionReturn decisionYesNoAll = deciderYesNoAll.Decide( EnumDecisionType.eYesAllNoAllDecision, "Ja oder Nein für alle?", "Decider", EnumDecisionReturn.eYES, EnumDecisionReturn.eYES); switch (decisionYesNoAll) { case EnumDecisionReturn.eYES: MessageBox.Show("Ja"); break; case EnumDecisionReturn.eNO: MessageBox.Show("Nein"); break; case EnumDecisionReturn.eYES_ALL: MessageBox.Show("Ja für alle"); break; case EnumDecisionReturn.eNO_ALL: MessageBox.Show("Nein für alle"); break; } // Icon and CheckBox Decider deciderIconAndCheckBox = new Decider(); EnumDecisionReturn decisionIconAndCheckBox = deciderIconAndCheckBox.Decide( EnumDecisionType.eRetryCancelDecision, "Icon und CheckBox. Toll, oder?", "Decider", EnumDecisionReturn.eRETRY, EnumDecisionReturn.eRETRY, "DecisionIconAndCheckBox", true, EnumDecisionIcon.eQUESTION); if (decisionIconAndCheckBox == EnumDecisionReturn.eRETRY) { MessageBox.Show("Einmal reicht..."); } }