Hallo zusammen
Ich versuche mich wieder einmal mit dem Tool "Grafik Schnelleigenschaften"
Dank eines Hinweises habe ich es geschaft ein lauffähiges Skript zu basteln. Jetzt stehe ich etwas vor dem Berg, denn ich möchte eigentlich wieder ein solches Auswahl-Menü haben, wie es mal war. Es ist mir bewusst, das sowas wohl nur mit einem Formulareditor gebaut werden kann, aber ich begreife das irgendwie nicht.
Wenn ich richtig verstanden habe, müsste ich ein Formular bauen, das mir aus den Auswahlen, dann meine Variablen füllen kann?
Gibt es da irgendwelche Vorlagen oder ähnliches?
Vielen Dank
Andi
Code:
//Grafikformat anpassen
//2016.10.21 A.Braun
using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;
using System.Drawing;
using System.Diagnostics;
public class Grafikformat
{
//[DeclareAction("Grafikformat")]
[Start]
public void Demo_InputBox()
{
//Abfrage Farbe
string color = "-16002";
if (InputBox.Show("Farbe", "'-16002'= Aus Ebene, '0'=schwarz, '252'=dunkelgrau, '253'=grau, '254'=hellgrau", ref color) == DialogResult.OK)
{
}
//Abfrage Linienstärke
string linie = "-16002";
if (InputBox.Show("Linienstärke", "'-16002'= Aus Ebene, 'xx'= in mm", ref linie) == DialogResult.OK)
{
}
//Abfrage Linientyp
string typ = "-16002";
if (InputBox.Show("Linientyp", "'-16002'= Aus Ebene, '0'= Durchgezogen, '1'= Gestrichelt", ref typ) == DialogResult.OK)
{
}
//Abfrage Sichtbarkeit
string sicht = "2";
if (InputBox.Show("Sichtbarkeit", "'2'= Aus Ebene, '0'= unsichtbar, '1'= sichtbar", ref sicht) == DialogResult.OK)
{
}
// Grafik bearbeitung
Progress oProgress = new Progress("SimpleProgress");
oProgress.SetAllowCancel(true);
oProgress.SetAskOnCancel(true);
oProgress.BeginPart(100, "");
oProgress.ShowImmediately();
CommandLineInterpreter oCLI = new CommandLineInterpreter();
ActionCallingContext acc = new ActionCallingContext();
acc.AddParameter("Name", "XGedIaFormatGraphic");
acc.AddParameter("width", linie);
acc.AddParameter("color", color);
acc.AddParameter("type", typ);
acc.AddParameter("patternlength", "-16002");
acc.AddParameter("visible", sicht);
acc.AddParameter("lineendstyle", "2");
oCLI.Execute("XGedStartInteractionAction", acc);
oProgress.EndPart(true);
return;
}
}
public class InputBox
{
/// <summary>
/// Displays a dialog with a prompt and textbox where the user can enter information
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="promptText">Dialog prompt</param>
/// <param name="value">Sets the initial value and returns the result</param>
/// <returns>Dialog result</returns>
public static DialogResult Show(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Abbrechen";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 18, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
}
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP