Exemple #1
0
        /// <summary>
        /// Локализовать форму
        /// </summary>
        private void LocalizeForm()
        {
            string errMsg;

            if (Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaData", out errMsg))
            {
                CommonPhrases.Init();
            }
            else
            {
                log.WriteError(errMsg);
            }

            if (Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaScheme", out errMsg))
            {
                SchemePhrases.Init();
            }
            else
            {
                log.WriteError(errMsg);
            }

            if (Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaSchemeEditor", out errMsg))
            {
                Translator.TranslateForm(this, "Scada.Scheme.Editor.FrmMain");
                AppPhrases.Init();
                ofdScheme.Filter = sfdScheme.Filter = AppPhrases.SchemeFileFilter;
            }
            else
            {
                log.WriteError(errMsg);
            }
        }
Exemple #2
0
        /// <summary>
        /// Локализовать форму.
        /// </summary>
        private void LocalizeForm()
        {
            if (!Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaData", out string errMsg))
            {
                log.WriteError(errMsg);
            }

            if (!Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaScheme", out errMsg))
            {
                log.WriteError(errMsg);
            }

            bool appDictLoaded = Localization.LoadDictionaries(appData.AppDirs.LangDir, "ScadaSchemeEditor", out errMsg);

            if (!appDictLoaded)
            {
                log.WriteError(errMsg);
            }

            CommonPhrases.Init();
            SchemePhrases.Init();
            AppPhrases.Init();

            if (appDictLoaded)
            {
                Translator.TranslateForm(this, "Scada.Scheme.Editor.FrmMain");
                ofdScheme.SetFilter(AppPhrases.SchemeFileFilter);
                sfdScheme.SetFilter(AppPhrases.SchemeFileFilter);
            }
        }
Exemple #3
0
        /// <summary>
        /// Applies localization to the form.
        /// </summary>
        private void LocalizeForm()
        {
            Localization.LoadDictionaries(langDir, "ScadaData", out string errMsg);
            Localization.LoadDictionaries(langDir, "ScadaScheme", out errMsg);
            bool appDictLoaded = Localization.LoadDictionaries(langDir, "TemplateBindingEditor", out errMsg);

            CommonPhrases.Init();
            SchemePhrases.Init();
            AppPhrases.Init();

            if (appDictLoaded)
            {
                Translator.TranslateForm(this, GetType().FullName, null);
                ofdBindings.SetFilter(AppPhrases.BindingsFileFilter);
                sfdBindings.SetFilter(AppPhrases.BindingsFileFilter);
            }
        }
Exemple #4
0
        private void FrmMain_Load(object sender, EventArgs e)
        {
            // определение директории исполняемого файла приложения
            exeDir = ScadaUtils.NormalDir(Path.GetDirectoryName(Application.ExecutablePath));

            // локализация приложения
            string langDir = exeDir + "lang\\";
            string errMsg;

            if (Localization.LoadingRequired(langDir, "ScadaData"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaData", out errMsg))
                {
                    CommonPhrases.Init();
                }
                else
                {
                    ScadaUtils.ShowError(errMsg);
                }
            }

            if (Localization.LoadingRequired(langDir, "ScadaSchemeEditor"))
            {
                if (Localization.LoadDictionaries(langDir, "ScadaSchemeEditor", out errMsg))
                {
                    Localization.TranslateForm(this, "Scada.Scheme.Editor.FrmMain");
                    SchemePhrases.InitStatic();
                    openFileDialog.Filter = saveFileDialog.Filter = SchemePhrases.FileFilter;
                }
                else
                {
                    ScadaUtils.ShowError(errMsg);
                }
            }

            // инициализация данных
            SchemeApp schemeApp = SchemeApp.InitSchemeApp(SchemeApp.WorkModes.Edit);

            schemeUrl  = exeDir + "web\\ScadaScheme.html?editMode=true";
            editorData = schemeApp.EditorData;
            editorData.SelectElement = SelectElement;
            editorData.SetFormTitle  = SetFormTitle;
            log            = schemeApp.Log;
            elemClipboard  = null;
            schemeSvcHost  = null;
            domainSvcHost  = null;
            schemeExThread = null;

            // проверка запуска второй копии программы
            try
            {
                bool createdNew;
                mutex = new Mutex(true, "ScadaSchemeEditorMutex", out createdNew);

                if (!createdNew)
                {
                    ScadaUtils.ShowInfo("SCADA-Редактор схем уже запущен.\nВторая копия будет закрыта.");
                    Close();
                    return;
                }
            }
            catch (Exception ex)
            {
                log.WriteAction("Ошибка при проверке запуска второй копии программы: " + ex.Message,
                                Log.ActTypes.Exception);
            }

            // запуск WCF-служб
            if (StartWCF())
            {
                // создание и запуск потока для обмена данными со схемой
                schemeExThread = new Thread(SchemeExchange);
                schemeExThread.Start();

                // настройка элементов управления
                miEditCut.Enabled             = btnEditCut.Enabled = false;
                miEditCopy.Enabled            = btnEditCopy.Enabled = false;
                miEditPaste.Enabled           = btnEditPaste.Enabled = false;
                miSchemeCancelAddElem.Enabled = btnSchemeCancelAddElem.Enabled = false;
                miSchemeDelElem.Enabled       = btnSchemeDelElem.Enabled = false;

                // создание новой схемы
                miFileNew_Click(null, null);
            }
            else
            {
                // блокировка элементов управления
                foreach (ToolStripItem item in miFile.DropDown.Items)
                {
                    item.Enabled = item == miFileExit;
                }
                foreach (ToolStripItem item in miEdit.DropDown.Items)
                {
                    item.Enabled = false;
                }
                foreach (ToolStripItem item in miScheme.DropDown.Items)
                {
                    item.Enabled = false;
                }
                foreach (ToolStripItem item in toolMain.Items)
                {
                    item.Enabled = false;
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public SchemeSettings()
 {
     RefrFreq      = 5;
     CmdEnabled    = true;
     SchemePhrases = new SchemePhrases();
 }
Exemple #6
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public SchemeSettings()
 {
     RefrFreq = 5;
     CmdEnabled = true;
     SchemePhrases = new SchemePhrases();
 }