Пример #1
0
        protected override void FillItemToControls()
        {
            base.FillItemToControls();

            parentElementTextBox.Text =
                _projectFolder == null
                    ? _project.Name
                    : _projectFolder.NameIntelli;

            prefixTextBox.Text = FileGroup.DefaultTranslatedPrefix;

            // --

            var storage =
                (MainForm.Current.ProjectFilesControl.Project ?? Project.Empty).DynamicSettingsGlobalHierarchical;

            referenceLanguageComboBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            storage,
                            @"CreateNewFilesForm.referenceLanguageComboBox.SelectedIndex",
                            referenceLanguageComboBox.SelectedIndex)),
                    referenceLanguageComboBox.Properties.Items.Count - 1);

            DevExpressExtensionMethods.RestoreSettings(
                destinationLanguagesListBox,
                storage,
                @"CreateNewFilesForm.destinationLanguagesListBox");

            copyTextsCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFilesForm.copyTextsCheckBox.Checked",
                        copyTextsCheckBox.Checked));

            automaticallyTranslateCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFilesForm.automaticallyTranslateCheckBox.Checked",
                        automaticallyTranslateCheckBox.Checked));

            prefixTextBox.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFilesForm.prefixTextBox.Text",
                        prefixTextBox.Text));

            prefixCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFilesForm.prefixCheckBox.Checked",
                        prefixCheckBox.Checked));

            // --
            // Select defaults.

            if (referenceLanguageComboBox.SelectedIndex < 0 &&
                referenceLanguageComboBox.Properties.Items.Count > 0)
            {
                referenceLanguageComboBox.SelectedIndex = 0;
            }
        }
        protected override void FillItemToControls()
        {
            base.FillItemToControls();

            sourceLanguageComboBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            @"QuickTranslationForm.sourceLanguageComboBox.SelectedIndex",
                            sourceLanguageComboBox.SelectedIndex)),
                    sourceLanguageComboBox.Properties.Items.Count - 1);
            destinationLanguageComboBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            @"QuickTranslationForm.destinationLanguageComboBox.SelectedIndex",
                            destinationLanguageComboBox.SelectedIndex)),
                    destinationLanguageComboBox.Properties.Items.Count - 1);

            sourceTextTextBox.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        @"QuickTranslationForm.sourceTextTextBox.Text",
                        sourceTextTextBox.Text));

            copyDestinationTextToClipboardCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        @"QuickTranslationForm.copyDestinationTextToClipboardCheckBox.Checked",
                        copyDestinationTextToClipboardCheckBox.Checked));

            // --
            // Select defaults.

            if (sourceLanguageComboBox.SelectedIndex < 0 &&
                sourceLanguageComboBox.Properties.Items.Count > 0)
            {
                sourceLanguageComboBox.SelectedIndex = 0;
            }

            if (destinationLanguageComboBox.SelectedIndex < 0 &&
                destinationLanguageComboBox.Properties.Items.Count > 0)
            {
                foreach (TranslationLanguageInfo pair in destinationLanguageComboBox.Properties.Items)
                {
                    if (pair.LanguageCode.ToLowerInvariant() == @"en")
                    {
                        destinationLanguageComboBox.SelectedItem = pair;
                        break;
                    }
                }

                if (destinationLanguageComboBox.SelectedIndex < 0)
                {
                    destinationLanguageComboBox.SelectedIndex = 0;
                }
            }

            var ti = TranslationHelper.GetTranslationEngine(
                MainForm.Current.ProjectFilesControl.Project ?? Project.Empty);

            labelControl4.Text = ti.UserReadableName;
        }
        private static void restoreState(
            IPersistentPairStorage storage,
            SplitContainerControl c)
        {
            var prefix = c.Name;

            var o1 = PersistanceHelper.RestoreValue(storage, prefix + @".SplitterPosition");
            var o2 = PersistanceHelper.RestoreValue(storage, prefix + @".RealSplitterPosition");
            //var o3 = PersistanceHelper.RestoreValue(storage, prefix + @".PercentageSplitterPosition");
            var o4 = PersistanceHelper.RestoreValue(storage, prefix + @".PanelVisibility");

            if (o4 != null)
            {
                var s4 =
                    ConvertHelper.ToString(
                        o4,
                        SplitPanelVisibility.Both.ToString());

                c.PanelVisibility =
                    (SplitPanelVisibility)
                    Enum.Parse(typeof(SplitPanelVisibility), s4, true);
            }

            /*if (o3 != null)
             *          {
             *                  // New method, saving and restoring the percentage.
             *                  // See http://bytes.com/forum/thread616388.html.
             *
             *                  var percentageDistance = ConvertHelper.ToDouble(o3, CultureInfo.InvariantCulture);
             *
             *                  if (c.Horizontal)
             *                  {
             *                          var realDistance = (int) (c.Width*(percentageDistance/100.0));
             *                          if (realDistance > 0)
             *                          {
             *                                  c.SplitterPosition = realDistance;
             *                          }
             *                  }
             *                  else
             *                  {
             *                          var realDistance = (int) (c.Height*(percentageDistance/100.0));
             *                          if (realDistance > 0)
             *                          {
             *                                  c.SplitterPosition = realDistance;
             *                          }
             *                  }
             *          }
             *          else*/
            if (o1 != null && o2 != null)
            {
                var realDistance = Convert.ToInt32(o2);

                if (c.Horizontal)
                {
                    if (c.FixedPanel == SplitFixedPanel.Panel1 ||
                        c.FixedPanel == SplitFixedPanel.None)
                    {
                        if (realDistance > 0)
                        {
                            c.SplitterPosition = realDistance;
                        }
                    }
                    else
                    {
                        if (c.FixedPanel != SplitFixedPanel.Panel2)
                        {
                            throw new Exception(@"FixedPanel must be Panel2.");
                        }

                        if (c.Width - realDistance > 0)
                        {
                            c.SplitterPosition = c.Width - realDistance;
                        }
                    }
                }
                else
                {
                    if (c.FixedPanel == SplitFixedPanel.Panel1 ||
                        c.FixedPanel == SplitFixedPanel.None)
                    {
                        if (realDistance > 0)
                        {
                            c.SplitterPosition = realDistance;
                        }
                    }
                    else
                    {
                        if (c.FixedPanel != SplitFixedPanel.Panel2)
                        {
                            throw new Exception(@"You must set one panel inside a splitter to be fixed.");
                        }

                        if (c.Height - realDistance > 0)
                        {
                            c.SplitterPosition = c.Height - realDistance;
                        }
                    }
                }
            }
        }
Пример #4
0
        private void restoreState(
            IPersistentPairStorage storage)
        {
            _ignoreReferenceLanguageChanges = true;

            destinationFileTextEdit.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.destinationFilePathTextEdit.Text"));

            DevExpressExtensionMethods.RestoreSettingsByName(
                fileGroupsListBox,
                storage,
                @"sendFileToTranslator.fileGroupsListBox");

            DevExpressExtensionMethods.RestoreSettingsByName(
                languagesToExportCheckListBox,
                storage,
                @"sendFileToTranslator.languagesToExportCheckListBox");

            referenceLanguageGroupBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            storage,
                            @"sendFileToTranslator.referenceLanguageComboBoxEdit.SelectedIndex",
                            referenceLanguageGroupBox.SelectedIndex)),
                    referenceLanguageGroupBox.Properties.Items.Count - 1);

            openFileAfterGeneratingCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.openFileAfterGeneratingCheckEdit.Checked",
                        openFileAfterGeneratingCheckEdit.Checked));
            openFolderAfterGeneratingCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.openAfterGeneratingCheckEdit.Checked",
                        openFolderAfterGeneratingCheckEdit.Checked));

            eliminateDuplicateRowsCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.eliminateDuplicateRowsCheckEdit.Checked",
                        eliminateDuplicateRowsCheckEdit.Checked));

            exportWithoutDestinationTranslationOnlyCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportWithoutDestinationTranslationOnlyCheckEdit.Checked",
                        exportWithoutDestinationTranslationOnlyCheckEdit.Checked));

            exportCompletelyEmptyRowsCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportCompletelyEmptyRowsCheckEdit.Checked",
                        exportCompletelyEmptyRowsCheckEdit.Checked));

            exportGroupsAsOneWorkSheetCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportGroupsAsOneWorkSheetCheckEdit.Checked",
                        exportGroupsAsOneWorkSheetCheckEdit.Checked));
            exportGroupsAsWorkSheetsCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportGroupsAsWorkSheetsCheckEdit.Checked",
                        exportGroupsAsWorkSheetsCheckEdit.Checked));
            exportGroupsAsExcelFilesCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportGroupsAsExcelFilesCheckEdit.Checked",
                        exportGroupsAsExcelFilesCheckEdit.Checked));
            exportNameColumnCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportNameColumnCheckEdit.Checked",
                        exportNameColumnCheckEdit.Checked));
            exportCommentColumnCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportCommentColumnCheckEdit.Checked",
                        exportCommentColumnCheckEdit.Checked));
            exportReferenceLanguageColumnCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportReferenceLanguageColumnCheckEdit.Checked",
                        exportReferenceLanguageColumnCheckEdit.Checked));
            exportFileGroupColumnCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportFileGroupColumnCheckEdit.Checked",
                        exportFileGroupColumnCheckEdit.Checked));
            exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked",
                        exportEachLanguageIntoSeparateExcelFileCheckEdit.Checked));
            useCrypticExcelExportSheetNamesCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.useCrypticExcelExportSheetNamesCheckEdit.Checked",
                        useCrypticExcelExportSheetNamesCheckEdit.Checked));

            sendFilesToEMailReceiversCheckEdit.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.sendFilesToEMailReceivers2CheckEdit.Checked",
                        sendFilesToEMailReceiversCheckEdit.Checked));
            zulReceiversTextEdit.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.zulReceiversTextEdit.Text",
                        zulReceiversTextEdit.Text));
            zulSubjectTextEdit.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.zulSubjectTextEdit.Text",
                        zulSubjectTextEdit.Text));
            zulBodyTextEdit.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"sendFileToTranslator.zulBodyTextEdit.Text",
                        zulBodyTextEdit.Text));

            _ignoreReferenceLanguageChanges = false;

            // --

            referenceLanguageGroupBox_SelectedIndexChanged(null, null);
        }
        public override void FillItemToControls()
        {
            base.FillItemToControls();

            fileGroupTextBox.Text =
                _fileGroup.GetNameIntelligent(
                    MainForm.Current.ProjectFilesControl.Project ?? Project.Empty);

            prefixTextBox.Text = FileGroup.DefaultTranslatedPrefix;

            // --

            var storage =
                (MainForm.Current.ProjectFilesControl.Project ?? Project.Empty).DynamicSettingsGlobalHierarchical;

            referenceLanguageComboBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            storage,
                            @"CreateNewFileForm.referenceLanguageComboBox.SelectedIndex",
                            referenceLanguageComboBox.SelectedIndex)),
                    referenceLanguageComboBox.Properties.Items.Count - 1);

            newLanguageComboBox.SelectedIndex =
                Math.Min(
                    ConvertHelper.ToInt32(
                        PersistanceHelper.RestoreValue(
                            storage,
                            @"CreateNewFileForm.newLanguageComboBox.SelectedIndex",
                            newLanguageComboBox.SelectedIndex)),
                    newLanguageComboBox.Properties.Items.Count - 1);

            copyTextsCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFileForm.copyTextsCheckBox.Checked",
                        copyTextsCheckBox.Checked));

            automaticallyTranslateCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFileForm.automaticallyTranslateCheckBox.Checked",
                        automaticallyTranslateCheckBox.Checked));

            prefixTextBox.Text =
                ConvertHelper.ToString(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFileForm.prefixTextBox.Text",
                        prefixTextBox.Text));

            prefixCheckBox.Checked =
                ConvertHelper.ToBoolean(
                    PersistanceHelper.RestoreValue(
                        storage,
                        @"CreateNewFileForm.prefixCheckBox.Checked",
                        prefixCheckBox.Checked));

            // --
            // Select defaults.

            if (referenceLanguageComboBox.SelectedIndex < 0 &&
                referenceLanguageComboBox.Properties.Items.Count > 0)
            {
                referenceLanguageComboBox.SelectedIndex = 0;
            }
        }