Пример #1
0
        public void UpdateProfiles()
        {
            LockUpdate(true);
            try
            {
                ignoreProfileReposition = true;
                currentProfile = TranslateOptions.Instance.CurrentProfile;
                languageSelector.Profile = currentProfile;
                checkedProfileButton = null;

                foreach(FreeCL.UI.Actions.Action a in profileSwitchOnCtrl1Actions)
                    a.Tag = null;

                while(tsTranslate.Items.Count > SpecialButtonsCount)
                    tsTranslate.Items.RemoveAt(tsTranslate.Items.Count - 1);

                if(TranslateOptions.Instance.Profiles.Count > 1)
                {
                    tsTranslate.Items.Add(tsSeparatorTranslate);
                    int actionIdx = 0;
                    foreach(TranslateProfile pf in TranslateOptions.Instance.Profiles)
                    {
                        ToolStripButton tsButton = new ToolStripButton();
                        if(pf == TranslateOptions.Instance.DefaultProfile)
                        {
                            tsButton.Text = TranslateString(pf.Name);
                            tsButton.ToolTipText = tsButton.Text;
                        }
                        else
                        {
                            tsButton.Text = pf.Name;
                            tsButton.ToolTipText = GetProfileName(pf as UserTranslateProfile);
                        }

                        if(actionIdx < 9)
                        {
                            profileSwitchOnCtrl1Actions[actionIdx].Tag = tsButton;
                            string displayString =	System.ComponentModel.TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(profileSwitchOnCtrl1Actions[actionIdx].Shortcut);
                            tsButton.ToolTipText += " (" + displayString + ")";
                        }
                        actionIdx++;

                        tsButton.Tag = pf;
                        tsButton.DisplayStyle = ToolStripItemDisplayStyle.Text;
                        tsButton.TextAlign = ContentAlignment.MiddleCenter;
                        tsButton.Click +=  OnProfileButtonClick;
                        tsButton.LocationChanged += TsbTranslateLocationChanged;
                        tsButton.MouseDown += OnProfileMouseDown;

                        if(pf == currentProfile)
                        {
                            checkedProfileButton = tsButton;
                            tsButton.Checked = true;
                        }

                        tsTranslate.Items.Add(tsButton);
                    }
                }
                UpdateLanguageSelector();
                tsTranslate.AllowItemReorder = tsTranslate.Items.Count > SpecialButtonsCount;
                ignoreProfileReposition = false;
                profilePositionChanged = false;
            }
            finally
            {
                LockUpdate(false);
            }

            tbFrom.Focus();
        }
Пример #2
0
        void ActivateProfile(TranslateProfile profile)
        {
            if(currentProfile == profile)
                return;

            foreach(ToolStripItem tsi in tsTranslate.Items)
            {
                if(tsi.Tag == profile)
                {
                    OnProfileButtonClick(tsi, new EventArgs());
                    return;
                }
            }
        }
Пример #3
0
 public MenuTranslateData(TranslateProfile translateProfile, string selection, LanguagePair languagePair)
 {
     this.translateProfile = translateProfile;
     this.selection = selection;
     this.languagePair = languagePair;
 }
Пример #4
0
        void OnProfileButtonClick(object sender, EventArgs e)
        {
            if(checkedProfileButton == sender)
                return;

            LockUpdate(true);
            try
            {
                if(checkedProfileButton != null)
                    checkedProfileButton.Checked = false;

                ToolStripButton tsButton = sender as ToolStripButton;
                tsButton.Checked = true;
                checkedProfileButton = tsButton;

                TranslateProfile pf = tsButton.Tag as TranslateProfile;

                TranslateOptions.Instance.CurrentProfile = pf;
                currentProfile = TranslateOptions.Instance.CurrentProfile;

                languageSelector.Profile = currentProfile;
                UpdateLanguageSelector();
            }
            finally
            {
                LockUpdate(false);
            }

            tbFrom.Focus();
        }
Пример #5
0
 public TranslateOptions()
 {
     //UseSoapSerialization = true;
     defaultProfile = new DefaultTranslateProfile();
     currentProfile = defaultProfile;
     defaultProfile.Subjects.Add("Common");
 }
Пример #6
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;
                }
            }
        }
Пример #7
0
 protected TranslateOptions(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     currentProfile = defaultProfile;
 }