Пример #1
0
        void ARemoveServiceExecute(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            Application.DoEvents();
            LockUpdate(true);

            try
            {
                Language     from                 = (cbFrom.SelectedItem as LanguageDataContainer).Language;
                Language     to                   = (cbTo.SelectedItem as LanguageDataContainer).Language;
                LanguagePair languagePair         = new LanguagePair(from, to);
                string       subject              = (cbSubject.SelectedItem as SubjectContainer).Subject;
                LanguagePair selectedLanguagePair = lvCurrent.Selected.LanguagePair;
                if ((selectedLanguagePair == languagePair ||
                     (languagePair.From == Language.Any && selectedLanguagePair.To == languagePair.To) ||
                     (languagePair.To == Language.Any && selectedLanguagePair.From == languagePair.From) ||
                     (languagePair.From == Language.Any && languagePair.To == Language.Any)
                     ) &&
                    (lvCurrent.Selected.Subject == subject || subject == SubjectConstants.Any)
                    )
                {
                    ServiceItemsDataCollection services = new ServiceItemsDataCollection();
                    services.Add(lvCurrent.Selected);
                    lvSource.AddServices(services);
                }

                lvCurrent.RemoveSelected();
            }
            finally
            {
                UseWaitCursor = false;
                LockUpdate(false);
            }
        }
Пример #2
0
        public void AfterLoad()
        {
            ServiceItemsDataCollection sids_to_delete = new ServiceItemsDataCollection();

            foreach (ServiceItemData sid in services)
            {
                try
                {
                    sid.AttachToServiceItem();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Service not found with error : " +
                                    e.Message + System.Environment.NewLine +
                                    "Service will be deleted from profile." +
                                    System.Environment.NewLine +
                                    "Profile : " + Name +
                                    ", ServiceItem : " + sid.Name +
                                    ", Language pair : " + sid.LanguagePair.ToString() +
                                    ", Subject : " + sid.Subject,
                                    "Error on loading services",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    sids_to_delete.Add(sid);
                }
            }

            foreach (ServiceItemData sid in sids_to_delete)
            {
                services.Remove(sid);
            }
        }
Пример #3
0
        void LoadSources()
        {
            UseWaitCursor = true;
            Application.DoEvents();
            LockUpdate(true);
            try
            {
                lvSource.Services = null;

                ServiceItemsDataCollection services = new ServiceItemsDataCollection();

                Language     from         = (cbFrom.SelectedItem as LanguageDataContainer).Language;
                Language     to           = (cbTo.SelectedItem as LanguageDataContainer).Language;
                LanguagePair languagePair = new LanguagePair(from, to);
                string       subject      = (cbSubject.SelectedItem as SubjectContainer).Subject;


                foreach (KeyValuePair <LanguagePair, ServiceItemsCollection> kvp in Manager.LanguagePairServiceItems)
                {
                    if (
                        (kvp.Key.From == languagePair.From || languagePair.From == Language.Any) &&
                        (kvp.Key.To == languagePair.To || languagePair.To == Language.Any)
                        )
                    {
                        foreach (ServiceItem si in kvp.Value)
                        {
                            if (subject != SubjectConstants.Any)
                            {
                                if (si.SupportedSubjects.Contains(subject))
                                {
                                    ServiceItemData sid = new ServiceItemData(si, kvp.Key, subject);
                                    if (!profile.Services.Contains(sid))
                                    {
                                        services.Add(sid);
                                    }
                                }
                            }
                            else
                            {
                                foreach (string siSubject in si.SupportedSubjects)
                                {
                                    ServiceItemData sid = new ServiceItemData(si, kvp.Key, siSubject);
                                    if (!profile.Services.Contains(sid))
                                    {
                                        services.Add(sid);
                                    }
                                }
                            }
                        }
                    }
                }
                lvSource.Services = services;
            }
            finally
            {
                UseWaitCursor = false;
                LockUpdate(false);
            }
        }
Пример #4
0
        public void AddServices(ServiceItemsDataCollection servicesToAdd)
        {
            SuspendLayout();
            lvMain.SuspendLayout();
            lvMain.BeginUpdate();
            try
            {
                //bool saveSorted = Sorted;
                //Sorted = false;

                foreach (ServiceItemData sd in servicesToAdd)
                {
                    services.Add(sd);
                    ServiceItemDataContainer sid = new ServiceItemDataContainer(sd);
                    ListViewItem             lvi = new ListViewItem();
                    lvi.Text     = sid.Name;
                    lvi.Tag      = sid;
                    lvi.ImageKey = sd.ServiceItem.Service.Name;
                    lvi.SubItems.Add(sid.Type);
                    lvi.SubItems.Add(sid.LanguagePair);
                    lvi.SubItems.Add(sid.Subject);
                    lvi.ToolTipText = sid.Name;
                    lvMain.Items.Add(lvi);
                }
                //Sorted = saveSorted;
                lvMain.Focus();
                if (lvMain.Items.Count > 0)
                {
                    lvMain.Items[0].Selected = true;
                    lvMain.Items[0].Focused  = true;

                    chName.Width         = 200;
                    chType.Width         = -1;
                    chLanguagePair.Width = 150;
                    chSubject.Width      = -2;
                }
                else
                {
                    if (ServiceItemChangedEvent != null)
                    {
                        ServiceItemChangedEvent(this, new ServiceItemChangedEventArgs(null));
                    }

                    chName.Width         = 200;
                    chType.Width         = -2;
                    chLanguagePair.Width = 150;
                    chSubject.Width      = -2;
                }
            }
            finally
            {
                lvMain.EndUpdate();
                lvMain.ResumeLayout();
                ResumeLayout();
            }
        }
Пример #5
0
        void BOkClick(object sender, EventArgs e)
        {
            ServiceItemsDataCollection services = new ServiceItemsDataCollection();

            foreach (ServiceItemData sid in lvCurrent.Services)
            {
                services.Add(sid);
            }
            profile.Services = services;
        }
Пример #6
0
        void AAddSelectedExecute(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            Application.DoEvents();
            LockUpdate(true);

            try
            {
                ServiceItemsDataCollection services = new ServiceItemsDataCollection();
                services.Add(lvSource.Selected);
                lvCurrent.AddServices(services);
                lvSource.RemoveSelected();
            }
            finally
            {
                UseWaitCursor = false;
                LockUpdate(false);
            }
        }
Пример #7
0
        void AAddAllExecute(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            Application.DoEvents();
            LockUpdate(true);

            try
            {
                ServiceItemsDataCollection services = new ServiceItemsDataCollection();
                foreach (ServiceItemData sid in lvSource.Services)
                {
                    services.Add(sid);
                }
                lvCurrent.AddServices(services);
                lvSource.RemoveAll();
            }
            finally
            {
                UseWaitCursor = false;
                LockUpdate(false);
            }
        }
Пример #8
0
        public CustomProfileServicesForm(UserTranslateProfile profile)
        {
            InitializeComponent();

            RegisterLanguageEvent(OnLanguageChanged);

            this.profile = profile;
            ServiceItemsDataCollection services = new ServiceItemsDataCollection();

            foreach (ServiceItemData sid in profile.Services)
            {
                services.Add(sid);
            }
            lvCurrent.Services = services;

            cbFrom.Items.Clear();
            cbTo.Items.Clear();

            for (int i = 0; i < (int)Language.Last; i++)
            {
                LanguageDataContainer ld = new LanguageDataContainer((Language)i, LangPack.TranslateLanguage((Language)i));
                cbFrom.Items.Add(ld);
                cbTo.Items.Add(ld);
            }

            cbFrom.SelectedIndex = 0;
            cbTo.SelectedIndex   = 0;

            //cbSubject
            foreach (string subject in Manager.Subjects)
            {
                SubjectContainer sc = new SubjectContainer(subject, LangPack.TranslateString(subject));
                cbSubject.Items.Add(sc);
            }

            SubjectContainer sc1 = new SubjectContainer(SubjectConstants.Any, "+" + LangPack.TranslateString(SubjectConstants.Any));

            cbSubject.Items.Add(sc1);

            cbSubject.SelectedIndex = 0;

            for (int i = 0; i < cbFrom.Items.Count; i++)
            {
                LanguageDataContainer ld = cbFrom.Items[i] as LanguageDataContainer;

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

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

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

            serviceStatusSource.Visible  = false;
            serviceStatusCurrent.Visible = false;

            initialized = true;
            CbFromSelectedIndexChanged(null, new EventArgs());
        }