Archiv für den Monat: August 2013

BetterDesktopTool

Heute mal aus der Sammlung Programme-welche-ich-benutze … BetterDesktopTool.

Ist kostenlos erhältlich. Es teilt alle offenen Programmfenster übersichtlich auf und das ist, meiner Meinung nach, die schnellste Art zwischen Applikationen zu wechseln.

1

In der Professional-Edition (kostenpflichtig) werden mehrere Virtuelle Desktops unterstützt.

Endlich ein bisschen Mac-Feeling unter Windows  :tongue:

Von |2013-08-13T12:13:01+02:002013-08-13|Allgemein|

CopyMode

Um die Modi des Kopierens schnell und einfach zu wechseln, hat Luc Morin ein Script geschrieben. Vielen Dank an dieser Stelle nach Kanada!

12-08-2013 12-15-57

CopyMode (1987 Downloads )

 

/*
Copyright (c) 2013 STLM Inc.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using Eplan.EplApi.Scripting;

public class STLMCopy
{
    //Add the two actions as menu points under Utilities
    [DeclareMenu]
    public void CopyNormalMenu()
    {
        Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
        oMenu.AddMenuItem("Copy (Normal Mode)", "NormalCopyAction");
        oMenu.AddMenuItem("Copy (Design Mode)", "DesignCopyAction");
    }

    //Declare the action to force copy in normal mode
    [DeclareAction("NormalCopyAction")]
    public void NormalCopyAction()
    {
        bool toggled = false;

        if (DesignModeState)
        {
            ToggleDesignMode();
            toggled = true;
        }

        Copy();

        if (toggled)
            ToggleDesignMode();
    }

    //Declare the action to force copy in design mode
    [DeclareAction("DesignCopyAction")]
    public void DesignCopyAction()
    {
        bool toggled = false;

        if (!DesignModeState)
        {
            ToggleDesignMode();
            toggled = true;
        }

        Copy();

        if (toggled)
            ToggleDesignMode();
    }

    //Helper functions and properties

    private bool DesignModeState
    {
        get
        {
            return new Eplan.EplApi.Base.Settings().GetBoolSetting("USER.GedViewer.ConstructionMode", 0);
        }
    }

    private void ToggleDesignMode()
    {
        Eplan.EplApi.ApplicationFramework.ActionManager mgr = new Eplan.EplApi.ApplicationFramework.ActionManager();

        Eplan.EplApi.ApplicationFramework.Action act = mgr.FindAction("XGedActionToggleConstructionMode");
        if (act != null)
        {
            Eplan.EplApi.ApplicationFramework.ActionCallingContext ictx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
            act.Execute(ictx);
        }
    }

    private void Copy()
    {
        Eplan.EplApi.ApplicationFramework.ActionManager mgr = new Eplan.EplApi.ApplicationFramework.ActionManager();

        Eplan.EplApi.ApplicationFramework.Action act = mgr.FindAction("XGedStartInteractionAction");
        if (act != null)
        {
            Eplan.EplApi.ApplicationFramework.ActionCallingContext CopyCtx = new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
            CopyCtx.AddParameter("Name", "XMIaClipboardCopy");
            act.Execute(CopyCtx);
        }
    }

}
Von |2017-11-09T12:23:43+01:002013-08-12|EPLAN, EPLAN-Scripts|

CustomPropertyEditor

Heute gibts mal wieder ein Schmankerl. Gleich am Anfang vielen Dank an Birdo für die Bereitstellung.

Die versteckte Action RegisterCustomPropertyEditorAction welche nicht dokumentiert ist, kann uns das Leben leichter machen. Mit Hilfe dieser Action könnt ihr eigene Auswahldialoge für Projekteigenschaften erstellen.

CustomPropertyEditor

Birdo hat das ganze auch offen gehalten, um dynamisch über eine INI-Datei, diese für einzelne Property-Ids zu setzen.

Einfach die INI-Dateien mit dem Schema PropertyId.Index.Schreibgeschütz.txt erstellen. Der Inhalt ist Tab-getrennt Value[TAB]Description.

CustomPropertyEditor (2713 Downloads )

 

using System.IO;
using System.Linq;
using System.Windows.Forms;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Base;
using Eplan.EplApi.Scripting;

public class CustomPropertyEditor : System.Windows.Forms.Form
{
    public string PathIni = @"C:\Test\CustomPropertyEditor\";

    public static CustomPropertyEditor frm = new CustomPropertyEditor();
    public static string ValueNew = string.Empty;

    // Setup on startup EPLAN
    [DeclareEventHandler("onMainStart")]
    public void Startup()
    {
        RegisterCustomPropertyEditor();
    }

    [DeclareRegister]
    public void RegisterCustomPropertyEditor()
    {
        LoadScript("true");
    }

    [DeclareUnregister]
    public void UnregisterCustomPropertyEditor()
    {
        LoadScript("false");
    }

    private void LoadScript(string register)
    {
        foreach (string FullFilename in Directory.GetFiles(PathIni))
        {
            try
            {
                string Filename = Path.GetFileNameWithoutExtension(FullFilename);
                if (Filename != null)
                {
                    string[] parameters = Filename.Split('.');

                    Eplan.EplApi.ApplicationFramework.ActionCallingContext acc =
                        new Eplan.EplApi.ApplicationFramework.ActionCallingContext();
                    acc.AddParameter("Register", register);
                    acc.AddParameter("Action", "CustomPropertyEditor");
                    acc.AddParameter("PropertyId", parameters[0]);
                    acc.AddParameter("PropertyIndex", parameters[1]);
                    acc.AddParameter("Editable", parameters[2]);
                    new CommandLineInterpreter().Execute("RegisterCustomPropertyEditorAction", acc);

                    BaseExceptionMessage("RegisterCustomPropertyEditorAction: " +
                                         "PropertyId:" + parameters[0] +
                                         " PropertyIndex:" + parameters[1] +
                                         " Editable:" + parameters[2]);
                }
            }
            catch (System.Exception ex)
            {
                BaseExceptionError("RegisterCustomPropertyEditorAction: " + ex.Message);
            }
        }
    }

    [DeclareAction("CustomPropertyEditor")]
    public void Function(int PropertyId, int PropertyIndex, int DbObjectId, ref string Value, out int DialogModalResult, out string DialogModified)
    {
        // form     
        frm.lblPropertyId.Text = PropertyId.ToString();
        frm.lblPropertyIndex.Text = PropertyIndex.ToString();
        frm.lblDbObjectId.Text = DbObjectId.ToString();
        frm.lblCurrentValue.Text = Value;
        frm.ShowDialog();

        // values
        DialogModified = "1";

        if (frm.DialogResult == DialogResult.OK)
        {
            DialogModalResult = 1;
            Value = ValueNew;
        }
        else
        {
            DialogModalResult = 0;
        }
    }

    private static void BaseExceptionMessage(string message)
    {
        Eplan.EplApi.Base.BaseException bexMessage = new BaseException(message, MessageLevel.Message);
        bexMessage.FixMessage();
    }

    private static void BaseExceptionError(string error)
    {
        Eplan.EplApi.Base.BaseException bexMessage = new BaseException(error, MessageLevel.Error);
        bexMessage.FixMessage();
    }

    private void CustomPropertyEditor_Load(object sender, System.EventArgs e)
    {
        // Search for INI-File
        string FileIni = string.Empty;
        foreach (string file in Directory.GetFiles(PathIni).Where(file => file.StartsWith(PathIni + lblPropertyId.Text + "." + lblPropertyIndex.Text)))
        {
            FileIni = file;
            break;
        }

        // Listview
        if (File.Exists(FileIni))
        {
            livi.Items.Clear();
            string[] lines = File.ReadAllLines(FileIni, Encoding.UTF8);
            foreach (string line in lines)
            {
                string[] items = line.Split('\t');
                ListViewItem item = new ListViewItem(items[0]);
                item.SubItems.Add(items[1]);
                livi.Items.Add(item);
            }
            livi.Sorting = SortOrder.Ascending;
            livi.Sort();
            livi.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }
        else
        {
            MessageBox.Show("INI-File not found:\n" + FileIni, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

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

    private void btnOk_Click(object sender, System.EventArgs e)
    {
        Ok();
    }

    private void Ok()
    {        
        try
        {
            ValueNew = livi.SelectedItems[0].SubItems[0].Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        catch (System.Exception)
        {
            MessageBox.Show("No value selected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

    }

    private void livi_DoubleClick(object sender, System.EventArgs e)
    {
        Ok();
    }

}
Von |2017-11-09T12:23:44+01:002013-08-06|EPLAN, EPLAN-Scripts|
Nach oben