Exemple #1
0
        public override void OnLoaded()
        {
            base.OnLoaded();
            networkOptions.Apply();
            fontsOptions.Apply();
            profiles.Add(defaultProfile);
            foreach (UserTranslateProfile pf in userProfiles)
            {
                pf.AfterLoad();
                if (pf.Position < profiles.Count)
                {
                    profiles.Insert(pf.Position, pf);
                }
                else
                {
                    profiles.Add(pf);
                }
            }

            foreach (TranslateProfile pf in profiles)
            {
                if (currentProfileName == pf.Name)
                {
                    currentProfile = pf;
                    break;
                }
            }
        }
 void ARemoveProfileUpdate(object sender, EventArgs e)
 {
     if (lvProfiles.SelectedItems.Count > 0)
     {
         TranslateProfile pf = lvProfiles.SelectedItems[0].Tag as TranslateProfile;
         aRemoveProfile.Enabled = pf != defaultProfile;
     }
     else
     {
         aRemoveProfile.Enabled = false;
     }
 }
        void ARemoveProfileExecute(object sender, EventArgs e)
        {
            ListViewItem lvi = lvProfiles.SelectedItems[0];

            if (MessageBox.Show(FindForm(), string.Format(TranslateString("The profile {0} will be deleted.\r\nAre you sure ?"), lvi.Text), Constants.AppName, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                TranslateProfile pf = lvi.Tag as TranslateProfile;
                profiles.Remove(pf);
                lvi.Selected = false;
                lvi.Focused  = false;
                lvProfiles.Items.Remove(lvi);
                lvProfiles.Items[0].Selected = true;
                lvProfiles.Items[0].Focused  = true;
                profilesHistory.DeleteProfile(pf.Name);
            }
        }
        void AMoveProfileDownExecute(object sender, EventArgs e)
        {
            ListViewItem lvi = lvProfiles.SelectedItems[0];

            lvi.Selected = false;
            lvi.Focused  = false;
            int idx = lvi.Index;

            lvProfiles.Items.RemoveAt(idx);
            lvProfiles.Items.Insert(idx + 1, lvi);
            lvi.Selected = true;
            lvi.Focused  = true;
            TranslateProfile pf = lvi.Tag as TranslateProfile;

            profiles.RemoveAt(idx);
            profiles.Insert(idx + 1, pf);
        }
Exemple #5
0
        public virtual object Clone()
        {
            TranslateProfile result = new TranslateProfile();

            result.Name     = Name;
            result.Position = Position;
            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);
            }
            return(result);
        }
        void LvProfilesSelectedIndexChanged(object sender, EventArgs e)
        {
            aEditServices.Enabled = false;
            if (lvProfiles.SelectedItems.Count == 0)
            {
                return;
            }
            TranslateProfile     pf  = lvProfiles.SelectedItems[0].Tag as TranslateProfile;
            UserTranslateProfile upf = pf as UserTranslateProfile;

            if (pf == defaultProfile)
            {
                if (!tcOptions.TabPages.Contains(tpDefaultOptions))
                {
                    tcOptions.TabPages.Add(tpDefaultOptions);
                }

                tcOptions.TabPages.Remove(tpOptions);
                tcOptions.TabPages.Remove(tpServices);
                tcOptions.TabPages.Remove(tpLanguageSelector);
            }
            else if (upf != null)
            {
                if (!tcOptions.TabPages.Contains(tpServices))
                {
                    tcOptions.TabPages.Add(tpServices);
                }

                if (!tcOptions.TabPages.Contains(tpOptions))
                {
                    tcOptions.TabPages.Add(tpOptions);
                }

                if (!tcOptions.TabPages.Contains(tpLanguageSelector))
                {
                    tcOptions.TabPages.Add(tpLanguageSelector);
                }

                tcOptions.TabPages.Remove(tpDefaultOptions);
                lProfileName.Text   = pf.Name;
                lvServices.Services = upf.Services;
            }

            aEditServices.Enabled = pf != defaultProfile;

            if (upf != null)
            {
                ignoreLanguageChange = true;
                for (int i = 0; i < cbFrom.Items.Count; i++)
                {
                    LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer;

                    if (ld.Language == upf.TranslationDirection.From)
                    {
                        cbFrom.SelectedItem = ld;
                    }

                    if (ld.Language == upf.TranslationDirection.To)
                    {
                        cbTo.SelectedItem = ld;
                    }
                }

                for (int i = 0; i < cbSubject.Items.Count; i++)
                {
                    SubjectContainer sc = cbSubject.Items[i] as SubjectContainer;
                    if (upf.Subject == sc.Subject)
                    {
                        cbSubject.SelectedItem = sc;
                        break;
                    }
                }

                cbShowServices.Checked  = upf.ShowServices;
                cbShowSubjects.Checked  = upf.ShowSubjects;
                cbShowLanguages.Checked = upf.ShowLanguages;

                ignoreLanguageChange = false;
            }
        }
Exemple #7
0
 public ServiceSettingComparerClass(TranslateProfile owner)
 {
     this.owner = owner;
 }