コード例 #1
0
        private void OnUserPreCloseProject(IEventParameter iEventParameter)
        {
            string projectName =
                (new EventParameterString(iEventParameter)).String;
            int dot_pos = projectName.LastIndexOf('\\');

            if (dot_pos > 0)
            {
                projectName = projectName.Substring(dot_pos + 1);
            }

            projectName = projectName.Remove(projectName.IndexOf('.'));

            string currentProjectName = EProjectManager.GetInstance()
                                        .GetCurrentProjectName();

            if (projectName == currentProjectName)
            {
                EProjectManager.GetInstance().SaveAndClose();

                DFrm.GetInstance().ShowNoDevices();

                EProjectManager.GetInstance().ResetCurrentPrj();
                EProjectManager.isPreCloseProjectComplete = true;
            }
        }
コード例 #2
0
    public void MyEventHandlerFunction(IEventParameter iEventParameter)
    {
        try
        {
            EventParameterString oEventParameterString = new EventParameterString(iEventParameter);
            string sProjectname = oEventParameterString.String;

            //Projekt Ordner ermitteln
            var    suffix         = ".elk";
            string sProjectFolder = sProjectname.Substring(0, sProjectname.Length - suffix.Length);
            sProjectFolder = sProjectFolder + ".edb";

            //Wenn Makroprojekt, dann abbrechen
            string sProjectart = string.Empty;
            GetProjectProperty(sProjectFolder, 10902, "de_DE", out sProjectart);
            if (sProjectart == "2")
            {
                return;
            }

            //Einstellungen durchgehen
            Settings oSettings = new Settings();
            for (int i = 1; i <= 5; i++)
            {
                if (i == 2)
                {
                    continue; // Projektgruppe 2 auslassen, da diese für Makroprojekte vorgesehen ist
                }
                string sProjectgroup = oSettings.GetStringSetting(SettingsPath, i);
                if (sProjectgroup == "frei")
                {
                    //Einstellung setzen
                    oSettings.SetStringSetting(SettingsPath, sProjectname, i);

                    //Projekteinstellung der Projektgruppe setzen
                    ActionCallingContext   acctranslate = new ActionCallingContext();
                    CommandLineInterpreter CLItranslate = new CommandLineInterpreter();
                    acctranslate.AddParameter("Project", sProjectname);
                    acctranslate.AddParameter("set", "SettingsMasterDialog.ProjectGroup.ColorMode");
                    acctranslate.AddParameter("value", i.ToString());
                    acctranslate.AddParameter("index", "0");
                    CLItranslate.Execute("XAfActionSettingProject", acctranslate);

                    //Schleife verlassen
                    break;
                }
            }
        }
        catch (InvalidCastException exc)
        {
            new Decider().Decide(EnumDecisionType.eOkDecision,
                                 exc.Message,
                                 "OnPostOpenProject, Fehler",
                                 EnumDecisionReturn.eOK,
                                 EnumDecisionReturn.eOK,
                                 string.Empty,
                                 false,
                                 EnumDecisionIcon.eFATALERROR);
        }
    }
コード例 #3
0
        private void OnNotifyPageChanged(IEventParameter eventParameter)
        {
            var interaction = EProjectManager.GetInstance()
                              .GetEditInteraction();

            if (interaction != null && interaction.IsFinish == false)
            {
                EProjectManager.GetInstance().StartEditModesWithDelay();
            }
        }
 public void MyEventHandlerFunction(IEventParameter iEventParameter)
 {
     try
     {
         EventParameterString oEventParameterString = new EventParameterString(iEventParameter);
         MessageBox.Show("Projekt öffnen:\n" + oEventParameterString.String, "OnPostOpenProject");
     }
     catch (System.InvalidCastException exc)
     {
         MessageBox.Show(exc.Message, "Fehler");
     }
 }
コード例 #5
0
        private void SymbolPartChangedEventListener_EplanNameEvent(IEventParameter eventParameter, string eventName)
        {
            this.LogEvent(eventParameter, eventName);

            SelectionSet selection = new SelectionSet();

            foreach (var function in selection.Selection.OfType <Function>())
            {
                if (function.IsMainFunction)
                {
                    FunctionImageExtension.DoImage(function);
                }
            }
        }
コード例 #6
0
ファイル: SimpleEventHandler.cs プロジェクト: musray/EPLAN
    public long OnActionStartStringEventHandlerFunction(IEventParameter iEventParameter)
    {
        try {
            EventParameterString eventParameterString = new EventParameterString(iEventParameter);
            string actionName = eventParameterString.String;

            MessageBox.Show("Action " + actionName + " was started!", "SimpleEventHandler");
        }
        catch (InvalidCastException exc) {
            String strExc = exc.Message;

            MessageBox.Show("Parameter Error: " + strExc, "SimpleEventHandler");
        }

        return(0);
    }
コード例 #7
0
        private void OnMainEnd(IEventParameter iEventParameter)
        {
            if (EProjectManager.GetInstance().GetCurrentPrj() != null)
            {
                EProjectManager.GetInstance().SaveAndClose();

                ////Проверяю, закрыт ли проект(выполнено ли PreCloseProject)
                //// Или же он закрыт "варварски"
                if (EProjectManager.isPreCloseProjectComplete == false)
                {
                    // Если проект закрыт варварски, то при новом открытия окна не открывать
                    DFrm.SaveCfg(false);
                    ModeFrm.SaveCfg(false);
                    Editor.EditorCtrl.SaveCfg(false);
                }
            }
        }
コード例 #8
0
 public long MyEventHandlerFunction2(IEventParameter iEventParameter)
 {
     try
     {
         EventParameterString oEventParameterString = new EventParameterString(iEventParameter);
         String strActionName = oEventParameterString.String;
         StreamWriter sw;
         FileInfo fi = new FileInfo(@"C:\Test\Events.txt");
         sw = fi.AppendText();
         sw.WriteLine("oCLI.Execute(\"onActionEnd.String.{0}\");", strActionName);
         sw.Close();
     }
     catch (InvalidCastException exc)
     {
         System.Windows.Forms.MessageBox.Show("Parameter error: " + exc.Message, "MyEventHandler");
     }
     return 0;
 }
コード例 #9
0
 public long MyEventHandlerFunction2(IEventParameter iEventParameter)
 {
     try
     {
         EventParameterString oEventParameterString = new EventParameterString(iEventParameter);
         String       strActionName = oEventParameterString.String;
         StreamWriter sw;
         FileInfo     fi = new FileInfo(@"C:\Test\Events.txt");
         sw = fi.AppendText();
         sw.WriteLine("oCLI.Execute(\"onActionEnd.String.{0}\");", strActionName);
         sw.Close();
     }
     catch (InvalidCastException exc)
     {
         System.Windows.Forms.MessageBox.Show("Parameter error: " + exc.Message, "MyEventHandler");
     }
     return(0);
 }
コード例 #10
0
    private void Event(IEventParameter eventParameter, string eventName)
    {
        // Check Blacklist
        List <string> blackList = new List <string>
        {
            "onIdle.Bool.App",
            "onLastIdle.Bool.App",
            "onTimer.UInt.App"
        };

        if (blackList.Contains(eventName))
        {
            return;
        }

        // Get Parameter
        string parameter;

        try
        {
            EventParameterString eventParameterString = new EventParameterString(eventParameter);
            parameter = eventParameterString.String;
        }
        catch
        {
            parameter = string.Empty;
        }

        // Write log
        FileInfo fileInfo = new FileInfo(@"C:\Test\Events.txt");

        using (StreamWriter streamWriter = fileInfo.AppendText())
        {
            string line = string.Format("{1}{0}{2}{0}{3}",
                                        "\t",
                                        DateTime.Now.ToString("HH:mm:ss"),
                                        eventName,
                                        parameter);

            streamWriter.WriteLine(line);
        }
    }
コード例 #11
0
        private void OnMainEnd(IEventParameter iEventParameter)
        {
            if (EProjectManager.GetInstance().GetCurrentPrj() != null)
            {
                EProjectManager.GetInstance().SaveAndClose();

                // Проверяю, закрыт ли проект(выполнено ли PreCloseProject)
                // или же он закрыт через закрытие окна Eplan
                if (EProjectManager.isPreCloseProjectComplete == false)
                {
                    // Если проект закрыт через крестик
                    // при новом открытии Eplan не открывать окна
                    DFrm.SaveCfg(false);
                    ModeFrm.SaveCfg(false);
                    Editor.NewEditorControl.SaveCfg(false);
                }
            }

            idleTimeModule.Stop();
        }
コード例 #12
0
        private void LogEvent(IEventParameter eventParameter, string eventName)
        {
            if (this._logger == null)
            {
                return;
            }

            string parameter = string.Empty;

            try
            {
                EventParameterString oEventParameterString = new EventParameterString(eventParameter);
                parameter = oEventParameterString.String;

                this._logger.AppendText(string.Format("{0}: {1}\t{2}{3}", DateTime.Now.ToString("s"), eventName, parameter, Environment.NewLine));
            }
            catch (System.InvalidCastException exc)
            {
                this._logger.AppendText(string.Format("{0}: {1}\t{2}{3}", DateTime.Now.ToString("s"), eventName, exc.Message, Environment.NewLine));
            }
        }
コード例 #13
0
        /// <summary>
        /// That is the function that is called to the event processing.  
        /// </summary>
        /// <param name="iEventParameter">Event parameter</param>
        private void PlaceHolderAssign_EplanEvent(IEventParameter iEventParameter)
        {
            //Check the selection, and if we have one or more placeholders selected,
            //iterate over their "assigned objects", and when we find cables,
            //call "Reassign All" on them.

            SelectionSet sel = new SelectionSet();

            var PHs = sel.Selection.OfType<PlaceHolder>();
            if (PHs.Count() == 0)
                return;

            CableService CblService = new CableService();

            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                foreach (PlaceHolder ph in PHs)
                {

                    var cables = ph.AssignedObjects.OfType<Cable>().Where(c => c.IsMainFunction);

                    foreach (Cable cbl in cables)
                    {
                        CblService.DoReassignWires(cbl, true, null);
                    }
                }
            }
            catch (Exception)
            {
                //Do nothing
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }
        }
コード例 #14
0
        public void Execute(List <ParameterClass> eventParameters)
        {
            MethodPointer mp  = (MethodPointer)ActionMethod;
            MethodBase    mif = mp.MethodDef;

            ParameterInfo[] pifs = mp.Info;
            object[]        vs   = new object[mp.ParameterCount];
            if (_parameterValues == null)
            {
                _parameterValues = new ParameterValueCollection();
            }
            mp.ValidateParameterValues(_parameterValues);
            for (int k = 0; k < mp.ParameterCount; k++)
            {
                vs[k] = null;
                IEventParameter iep = _parameterValues[k].AsEventParameter();
                if (iep != null)
                {
                    if (eventParameters != null)
                    {
                        foreach (ParameterClass p in eventParameters)
                        {
                            if (iep.IsSameParameter(p))
                            {
                                vs[k] = p.ObjectInstance;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    vs[k] = _parameterValues[k].ObjectInstance;
                }
                if (vs[k] != null)
                {
                    if (!pifs[k].ParameterType.Equals(vs[k].GetType()))
                    {
                        vs[k] = ValueTypeUtil.ConvertValueByType(pifs[k].ParameterType, vs[k]);
                    }
                }
            }
            object ret;

            if (mif.IsStatic)
            {
                ret = mif.Invoke(null, vs);
            }
            else
            {
                ret = mif.Invoke(mp.ObjectInstance, vs);
            }
            MethodInfo minfo = mif as MethodInfo;

            if (minfo != null)
            {
                if (!typeof(void).Equals(minfo.ReturnType))
                {
                    ReturnValue = ret;
                }
            }
        }
コード例 #15
0
 private void OnMainStart(IEventParameter iEventParameter)
 {
 }
コード例 #16
0
 public bool MyEventHandlerFunction4(IEventParameter iEventParameter)
 {
     PageZoomAll();
     return true;
 }
コード例 #17
0
 private void OnMainStart(IEventParameter iEventParameter)
 {
     IdleModule.Start();
 }
コード例 #18
0
        private void OnPostOpenProject(IEventParameter iEventParameter)
        {
            //Если нет активного проекта, считываем описание и работаем с ним.
            if (EProjectManager.GetInstance().GetCurrentPrj() == null)
            {
                //Получение текущего проекта.
                Eplan.EplApi.HEServices.SelectionSet selection =
                    new Eplan.EplApi.HEServices.SelectionSet();
                selection.LockSelectionByDefault = false;
                selection.LockProjectByDefault   = false;

                EProjectManager.GetInstance().SetCurrentPrj(
                    selection.GetCurrentProject(true));

                String        strAction = "LoadDescriptionAction";
                ActionManager oAMnr     = new ActionManager();
                Eplan.EplApi.ApplicationFramework.Action oAction =
                    oAMnr.FindAction(strAction);
                ActionCallingContext ctx = new ActionCallingContext();

                if (oAction != null)
                {
                    oAction.Execute(ctx);
                }

                strAction = "ShowTechObjectsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна редактора.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_obj_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowDevicesAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна устройств.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_dev_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                strAction = "ShowOperationsAction";
                oAction   = oAMnr.FindAction(strAction);

                if (oAction != null)
                {
                    //Восстановление при необходимости окна операций.
                    string path = Environment.GetFolderPath(
                        Environment.SpecialFolder.ApplicationData) +
                                  @"\Eplan\eplan.cfg";
                    PInvoke.IniFile ini = new PInvoke.IniFile(path);
                    string          res = ini.ReadString("main", "show_oper_window",
                                                         "false");

                    if (res == "true")
                    {
                        oAction.Execute(ctx);
                    }
                }

                // Проект открыт, ставим флаг в изначальное состояние.
                EProjectManager.isPreCloseProjectComplete = false;
            }
        }
コード例 #19
0
 private void OnMainStart(IEventParameter iEventParameter)
 {
     idleTimeModule.BeforeClosingProject +=
         EProjectManager.GetInstance().SyncAndSave;
     idleTimeModule.Start(AddInModule.OriginalAssemblyPath);
 }
コード例 #20
0
 public bool MyEventHandlerFunction4(IEventParameter iEventParameter)
 {
     PageZoomAll();
     return(true);
 }
コード例 #21
0
 private void SetParameterName(IWriteSession session, IEvent @event, IEventParameter parameter, string name)
 {
     parameter.Name = name;
     session.SaveHierarchy(@event);
 }