Example #1
0
        /// <summary>
        /// Обработка для нового редактора
        /// </summary>
        /// <param name="newEditorItem">Элемент из нового редактора</param>
        /// <param name="oF">Функция</param>
        private void ExecuteForEditor(Editor.ITreeViewItem newEditorItem,
                                      Function oF)
        {
            if (newEditorItem.IsUseDevList)
            {
                string devName;
                bool   res = Device.DeviceManager.CheckDeviceName(oF.Name,
                                                                  out devName, out _, out _, out _, out _);

                if (res)
                {
                    string checkedDevices = newEditorItem.EditText[1];
                    string newDevices     = MakeNewCheckedDevices(devName,
                                                                  checkedDevices);
                    Editor.Editor.GetInstance().EditorForm
                    .SetNewVal(newDevices);

                    //Обновление списка устройств при его наличии.
                    string checkedDev = newEditorItem.EditText[1];
                    if (DFrm.GetInstance().IsVisible() == true)
                    {
                        Device.DeviceType[]    devTypes;
                        Device.DeviceSubType[] devSubTypes;
                        newEditorItem.GetDevTypes(out devTypes,
                                                  out devSubTypes);

                        DFrm.GetInstance().ShowDevices(
                            Device.DeviceManager.GetInstance(), devTypes,
                            devSubTypes, false, true, checkedDev, null);
                    }
                }
            }
        }
        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;
            }
        }
        /// <summary>
        /// Обработка для нового редактора
        /// </summary>
        /// <param name="editorItem">Элемент из редактора</param>
        /// <param name="oF">Функция</param>
        private void ExecuteForEditor(Editor.ITreeViewItem editorItem,
                                      Function oF)
        {
            if (editorItem.IsUseDevList)
            {
                string devName;
                bool   res = Device.DeviceManager.CheckDeviceName(oF.Name,
                                                                  out devName, out _, out _, out _, out _);

                if (res)
                {
                    string checkedDevices = editorItem.EditText[1];
                    string newDevices     = MakeNewCheckedDevices(devName,
                                                                  checkedDevices);
                    Editor.Editor.GetInstance().EditorForm
                    .SetNewVal(newDevices);

                    //Обновление списка устройств при его наличии.
                    if (DFrm.GetInstance().IsVisible() == true)
                    {
                        DFrm.OnSetNewValue onSetNewValue = null;
                        DFrm.GetInstance().ShowDisplayObjects(editorItem,
                                                              onSetNewValue);
                    }
                }
            }
        }
Example #4
0
        public void SaveAndClose()
        {
            EProjectManager.GetInstance().SyncAndSave();
            EProjectManager.GetInstance().StopEditModes();

            // Проверка и сохранение состояний окон.
            ModeFrm.CheckShown();
            ModeFrm.SaveCfg(ModeFrm.modeIsShown);
            DFrm.CheckShown();
            DFrm.SaveCfg(DFrm.deviceIsShown);
            Editor.EditorCtrl.CheckShown();
            Editor.EditorCtrl.SaveCfg();

            if (Editor.Editor.GetInstance().IsShown())
            {
                Editor.Editor.GetInstance().CloseEditor();
            }

            DFrm.GetInstance().CloseEditor();
        }
Example #5
0
        /// <summary>
        /// Сохранить данные и закончить работу с дополнением (при закрытии
        /// проекта или Eplan).
        /// </summary>
        public void SaveAndClose()
        {
            SyncAndSave();
            StopEditModes();

            ExcelRepoter.AutomaticExportExcelForSCADA(currentProject);

            // Проверка и сохранение состояний окон.
            ModeFrm.CheckShown();
            ModeFrm.SaveCfg(ModeFrm.modeIsShown);
            DFrm.CheckShown();
            DFrm.SaveCfg(DFrm.deviceIsShown);
            Editor.NewEditorControl.CheckShown();
            Editor.NewEditorControl.SaveCfg();

            if (Editor.Editor.GetInstance().IsShown())
            {
                Editor.Editor.GetInstance().CloseEditor();
            }

            ModeFrm.GetInstance().CloseEditor();
            DFrm.GetInstance().CloseEditor();
        }
Example #6
0
        public override RequestCode OnSelect(
            StorableObject[] arrSelectedObjects,
            SelectionContext oContext)
        {
            // Execute standard operation.
            base.OnSelect(arrSelectedObjects, oContext);

            if (EProjectManager.GetInstance().GetEditInteraction() != this)
            {
                return(RequestCode.Stop);
            }

            Function oF = null;

            if (arrSelectedObjects[0] is Rectangle)
            {
                string oFName =
                    (arrSelectedObjects[0] as Rectangle).Properties.get_PROPUSER_TEST(1);

                oF = Function.FromStringIdentifier(oFName) as Function;
            }

            if (arrSelectedObjects[0] is Function)
            {
                oF = arrSelectedObjects[0] as Function;
            }

            if (oF != null)
            {
                Editor.ITreeViewItem item = Editor.Editor.GetInstance().EForm.GetActiveItem();

                if (item == null)
                {
                    return(RequestCode.Nothing);
                }

                if (item.IsUseDevList)
                {
                    string devName;
                    string objectName;
                    int    objectNumber;
                    string deviceType;
                    int    deviceNumbe;

                    bool res = Device.DeviceManager.CheckDeviceName(oF.Name,
                                                                    out devName, out objectName, out objectNumber, out deviceType,
                                                                    out deviceNumbe);

                    if (res)
                    {
                        string oldDevices = " " + item.EditText[1] + " ";
                        string newDevices = "";
                        //Для корректного поиска отделяем пробелами.
                        devName = " " + devName + " ";

                        if (oldDevices.Contains(devName))
                        {
                            newDevices = oldDevices.Replace(devName, " ");
                        }
                        else
                        {
                            newDevices = oldDevices + devName.Trim();
                        }
                        Editor.Editor.GetInstance().EForm.SetNewVal(newDevices);

                        //Обновление списка устройств при его наличии.
                        if (DFrm.GetInstance().IsVisible() == true)
                        {
                            Device.DeviceType[]    devTypes;
                            Device.DeviceSubType[] devSubTypes;
                            item.GetDevTypes(out devTypes, out devSubTypes);

                            DFrm.GetInstance().ShowDevices(
                                Device.DeviceManager.GetInstance(),
                                devTypes, devSubTypes, false, true,
                                item.EditText[1], null);
                        }
                    }
                }
            }

            return(RequestCode.Select | RequestCode.NoPreselect | RequestCode.NoMultiSelect);
        }