Ejemplo n.º 1
0
 public TranslateOptions()
 {
     //UseSoapSerialization = true;
     defaultProfile = new DefaultTranslateProfile();
     currentProfile = defaultProfile;
     defaultProfile.Subjects.Add("Common");
 }
        void BLanguageFilterClick(object sender, EventArgs e)
        {
            DefaultTranslateProfile pf = defaultProfile;

            DefaultProfileLanguagesForm form = new DefaultProfileLanguagesForm(pf);

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                SubjectCollection subjects         = pf.GetSupportedSubjects();
                SubjectCollection subjectsToDelete = new SubjectCollection();

                foreach (string subject in pf.Subjects)
                {
                    if (!subjects.Contains(subject))
                    {
                        subjectsToDelete.Add(subject);
                    }
                }

                foreach (string subject in subjectsToDelete)
                {
                    pf.Subjects.Remove(subject);
                }

                LanguagePairCollection toDelete = new LanguagePairCollection();
                foreach (LanguagePair lp in pf.History)
                {
                    if (pf.DisabledSourceLanguages.Contains(lp.From) ||
                        pf.DisabledTargetLanguages.Contains(lp.To))
                    {
                        toDelete.Add(lp);
                    }
                }

                foreach (LanguagePair lp in toDelete)
                {
                    pf.History.Remove(lp);
                }
            }
            form.Dispose();
            changed = true;
        }
Ejemplo n.º 3
0
        public override object Clone()
        {
            DefaultTranslateProfile result = new DefaultTranslateProfile();

            result.Name     = Name;
            result.Position = Position;
            result.IncludeMonolingualDictionaryInTranslation = IncludeMonolingualDictionaryInTranslation;
            result.Subjects.AddRange(Subjects);
            result.History.AddRange(History);
            result.SelectedLanguagePair = SelectedLanguagePair;
            foreach (ServiceItemsSortDataCollection d in SortData)
            {
                result.SortData.Add(d);
            }
            foreach (ServiceItemData d in DisabledServiceItems)
            {
                result.DisabledServiceItems.Add(d);
            }
            result.DisabledSourceLanguages.AddRange(DisabledSourceLanguages);
            result.DisabledTargetLanguages.AddRange(DisabledTargetLanguages);
            result.DisabledLanguagesAlreadySet = DisabledLanguagesAlreadySet;
            return(result);
        }
 public DefaultProfileLanguagesForm(DefaultTranslateProfile profile)
 {
     InitializeComponent();
     this.profile = profile;
     RegisterLanguageEvent(OnLanguageChanged);
 }
        public override void Init()
        {
            defaultProfile = (DefaultTranslateProfile)TranslateOptions.Instance.DefaultProfile.Clone();
            cbIncludeMonolingualDictionaryInTranslation.Checked = defaultProfile.IncludeMonolingualDictionaryInTranslation;

            currentProfileName = TranslateOptions.Instance.CurrentProfile.Name;

            profiles.Clear();

            foreach(TranslateProfile pf in TranslateOptions.Instance.Profiles)
            {
                if(pf == TranslateOptions.Instance.DefaultProfile)
                    profiles.Add(defaultProfile);
                else
                    profiles.Add((TranslateProfile)pf.Clone());
            }

            profilesHistory.Clear();
            foreach(ProfilesHistoryData phd in TranslateOptions.Instance.ProfilesHistory)
            {
                profilesHistory.Add((ProfilesHistoryData)phd.Clone());
            }

            lvProfiles.Items.Clear();
            foreach(TranslateProfile pf in profiles)
            {
                ListViewItem lvi = new ListViewItem();
                if(pf == defaultProfile)
                    lvi.Text = TranslateString(pf.Name);
                else
                    lvi.Text = pf.Name;
                lvi.Tag = pf;

                UserTranslateProfile upf = pf as UserTranslateProfile;
                if(upf != null)
                {
                    lvi.SubItems.Add(LangPack.TranslateLanguage(upf.TranslationDirection.From) +
                         " -> " +
                         LangPack.TranslateLanguage(upf.TranslationDirection.To)
                        );
                    lvi.SubItems.Add(LangPack.TranslateString(upf.Subject));
                }
                else
                {
                    lvi.SubItems.Add("");
                    lvi.SubItems.Add("");
                }
                lvProfiles.Items.Add(lvi);
            }
            lvProfiles.Focus();
            lvProfiles.Items[0].Selected = true;
            lvProfiles.Items[0].Focused = true;

            InitUserProfileControls();

            chDirection.Width = -2;
            chSubject.Width = -2;
        }
 public DefaultProfileLanguagesForm(DefaultTranslateProfile profile)
 {
     InitializeComponent();
     this.profile = profile;
     RegisterLanguageEvent(OnLanguageChanged);
 }
Ejemplo n.º 7
0
 public TranslateOptions()
 {
     //UseSoapSerialization = true;
     defaultProfile = new DefaultTranslateProfile();
     currentProfile = defaultProfile;
     defaultProfile.Subjects.Add("Common");
 }
 public override object Clone()
 {
     DefaultTranslateProfile result = new DefaultTranslateProfile();
     result.Name = Name;
     result.Position = Position;
     result.IncludeMonolingualDictionaryInTranslation = IncludeMonolingualDictionaryInTranslation;
     result.Subjects.AddRange(Subjects);
     result.History.AddRange(History);
     result.SelectedLanguagePair = SelectedLanguagePair;
     foreach(ServiceItemsSortDataCollection d in SortData)
         result.SortData.Add(d);
     foreach(ServiceItemData d in DisabledServiceItems)
         result.DisabledServiceItems.Add(d);
     result.DisabledSourceLanguages.AddRange(DisabledSourceLanguages);
     result.DisabledTargetLanguages.AddRange(DisabledTargetLanguages);
     result.DisabledLanguagesAlreadySet = DisabledLanguagesAlreadySet;
     return result;
 }
        public override void Init()
        {
            defaultProfile = (DefaultTranslateProfile)TranslateOptions.Instance.DefaultProfile.Clone();
            cbIncludeMonolingualDictionaryInTranslation.Checked = defaultProfile.IncludeMonolingualDictionaryInTranslation;

            currentProfileName = TranslateOptions.Instance.CurrentProfile.Name;

            profiles.Clear();

            foreach (TranslateProfile pf in TranslateOptions.Instance.Profiles)
            {
                if (pf == TranslateOptions.Instance.DefaultProfile)
                {
                    profiles.Add(defaultProfile);
                }
                else
                {
                    profiles.Add((TranslateProfile)pf.Clone());
                }
            }

            profilesHistory.Clear();
            foreach (ProfilesHistoryData phd in TranslateOptions.Instance.ProfilesHistory)
            {
                profilesHistory.Add((ProfilesHistoryData)phd.Clone());
            }


            lvProfiles.Items.Clear();
            foreach (TranslateProfile pf in profiles)
            {
                ListViewItem lvi = new ListViewItem();
                if (pf == defaultProfile)
                {
                    lvi.Text = TranslateString(pf.Name);
                }
                else
                {
                    lvi.Text = pf.Name;
                }
                lvi.Tag = pf;

                UserTranslateProfile upf = pf as UserTranslateProfile;
                if (upf != null)
                {
                    lvi.SubItems.Add(LangPack.TranslateLanguage(upf.TranslationDirection.From) +
                                     " -> " +
                                     LangPack.TranslateLanguage(upf.TranslationDirection.To)
                                     );
                    lvi.SubItems.Add(LangPack.TranslateString(upf.Subject));
                }
                else
                {
                    lvi.SubItems.Add("");
                    lvi.SubItems.Add("");
                }
                lvProfiles.Items.Add(lvi);
            }
            lvProfiles.Focus();
            lvProfiles.Items[0].Selected = true;
            lvProfiles.Items[0].Focused  = true;

            InitUserProfileControls();

            chDirection.Width = -2;
            chSubject.Width   = -2;
        }