Anbei ein kleines Script um die Projektsprache komfortabel umzuschalten.

27-12-2012

Ich hatte erst versucht ein dynamisches Menü zu machen, leider funktioniert dies aufgrund der eingeschränkten Funktionalität in EPLAN nicht.

Die Auflistung zeigt nur die im Projekt eingestellten Sprachen.

 

 

SetLanguageGui (1825 Downloads )

 

[DeclareAction("SetLanguageGui")]
public void Function()
{
	SetLanguageGui frm = new SetLanguageGui();
	frm.ShowDialog();
	return;
}

private void SetLanguageGui_Load(object sender, System.EventArgs e)
{
	string ActionReturnParameterValue = string.Empty;

	// Languagelist
	oCLI.Execute("GetProjectLanguages", acc);
	acc.GetParameter("LANGUAGELIST", ref ActionReturnParameterValue);
	string[] ProjectLanguages = ActionReturnParameterValue.Split(';');

	// VariableLanguage
	oCLI.Execute("GetVariableLanguage", acc);
	acc.GetParameter("LANGUAGELIST", ref ActionReturnParameterValue);
	string VariableLanguage = ActionReturnParameterValue;

	// Add languages
	foreach (string CurrentLanguage in ProjectLanguages)
	{
		if (CurrentLanguage != "")
		{
			ListViewItem liviItem = new ListViewItem();

			// Check if current language
			if (CurrentLanguage.Equals(VariableLanguage))
			{
				liviItem.Selected = true;
			}

			liviItem.Text = CurrentLanguage;

			// LanguageMapping
			foreach(string line in EplanLanguageList)
			{
				if(line.StartsWith(CurrentLanguage))
				{
					if (line.Split(';').Length > 1) liviItem.SubItems.Add(line.Split(';')[1]);
				}
			}
			liviLanguages.Items.Add(liviItem);
		}
	}

	// Sort & resize
	liviLanguages.Sorting = SortOrder.Ascending;
	liviLanguages.Sort();
}

private void btnCancel_Click(object sender, EventArgs e)
{
	this.Close();
}

private void liviLanguages_MouseDoubleClick(object sender, MouseEventArgs e)
{
	SetLanguage();
}

private void btnOk_Click(object sender, EventArgs e)
{
	SetLanguage();
}

private void SetLanguage()
{
	if (liviLanguages.SelectedItems.Count > 0)
	{
		string CurrentLanguage = liviLanguages.SelectedItems[0].Text;

		// Bug
		//acc.AddParameter("varLANGUAGE", CurrentLanguage);
		//acc.AddParameter("dispLANGUAGE", CurrentLanguage);
		//oCLI.Execute("ChangeLanguage", acc);
		oCLI.Execute("ChangeLanguage /varLANGUAGE:" + CurrentLanguage + " /dispLANGUAGE:\"" + CurrentLanguage + ";\"");

		this.Close();
	}
	else
	{
		MessageBox.Show("Keine Sprache gewählt");
	}

}