Exemplo n.º 1
0
        void SbServiceDownClick(object sender, EventArgs e)
        {
            ServiceSettingsContainer sc  = serviceStatus.Status;
            ListViewItem             lvi = FindItem(disabledLVItems, sc);

            if (lvi != null && lvi.Index != lvServicesDisabled.Items.Count - 1)
            {
                ListViewItem             lvi_prev = lvServicesDisabled.Items[lvi.Index + 1];
                ServiceSettingsContainer sc_prev  = lvi_prev.Tag as ServiceSettingsContainer;
                profile.MoveAfter(sc_prev.Setting, sc.Setting);
            }
            else
            {
                lvi = FindItem(enabledLVItems, sc);
                if (lvi != null && lvi.Index != lvServicesEnabled.Items.Count - 1)
                {
                    ListViewItem             lvi_prev = lvServicesEnabled.Items[lvi.Index + 1];
                    ServiceSettingsContainer sc_prev  = lvi_prev.Tag as ServiceSettingsContainer;
                    profile.MoveAfter(sc_prev.Setting, sc.Setting);
                }
            }
            lvServicesEnabled.Sort();
            lvServicesDisabled.Sort();
            if (lvi != null)
            {
                LvServicesEnabledSelectedIndexChanged(lvi.ListView, new EventArgs());
            }
        }
Exemplo n.º 2
0
        void ServiceStatusButtonClick(object sender, EventArgs e)
        {
            skipselectingservices = true;
            ListViewItem lvi;

            try
            {
                ServiceSettingsContainer sc = serviceStatus.Status;
                lvi = FindItem(disabledByUserLVItems, sc);
                if (lvi != null)
                {
                    lvServicesDisabledByUser.Items.Remove(lvi);
                    disabledByUserLVItems.Remove(sc);
                }
                else
                {
                    lvi = FindItem(disabledLVItems, sc);
                    if (lvi != null)
                    {
                        lvServicesDisabled.Items.Remove(lvi);
                        disabledLVItems.Remove(sc);
                    }
                    else
                    {
                        lvi = FindItem(enabledLVItems, sc);
                        if (lvi != null)
                        {
                            lvServicesEnabled.Items.Remove(lvi);
                            enabledLVItems.Remove(sc);
                        }
                    }
                }


                sc.DisabledByUser = !sc.DisabledByUser;
                profile.EnableService(sc.Setting.ServiceItem.FullName, sc.Setting.LanguagePair, sc.Setting.Subject, !sc.DisabledByUser);

                lvi = AddListViewItem(sc);
                CalcServicesSizes();
                lvi.EnsureVisible();
                lvi.ListView.Focus();
                lvi.Selected         = true;
                serviceStatus.Status = sc;
                pServices.ScrollControlIntoView(lvi.ListView);
                Rectangle pos = lvi.Bounds;
                if (pServices.VerticalScroll.Value + pos.Top > pServices.VerticalScroll.Maximum)
                {
                    pServices.VerticalScroll.Value = pServices.VerticalScroll.Maximum;
                }
                else
                {
                    pServices.VerticalScroll.Value += pos.Top;
                }
            }
            finally
            {
                skipselectingservices = false;
            }
            LvServicesEnabledSelectedIndexChanged(lvi.ListView, e);
        }
Exemplo n.º 3
0
        public ReadOnlyServiceSettingCollection GetServiceSettings()
        {
            ServiceSettingCollection result = new ServiceSettingCollection();

            foreach (ListViewItem lvi in lvServicesEnabled.Items)
            {
                ServiceSettingsContainer sc       = lvi.Tag as ServiceSettingsContainer;
                ServiceItemSetting       tsetting = new ServiceItemSetting(sc.Setting.LanguagePair, sc.Setting.Subject, sc.Setting.ServiceItem, TranslateOptions.Instance.GetNetworkSetting(sc.Setting.ServiceItem.Service));
                result.Add(tsetting);
            }
            return(new ReadOnlyServiceSettingCollection(result));
        }
Exemplo n.º 4
0
        void LvServicesEnabledSelectedIndexChanged(object sender, EventArgs e)
        {
            LockUpdate(true);
            try
            {
                if (skipselectingservices)
                {
                    return;
                }
                ListView lv = sender as ListView;
                if (lv.SelectedItems.Count == 0)
                {
                    return;
                }

                ListViewItem             lvi = lv.SelectedItems[0];
                ServiceSettingsContainer sc  = lvi.Tag as ServiceSettingsContainer;
                serviceStatus.ShowLanguage = selection.From == Language.Any || selection.To == Language.Any;
                serviceStatus.Status       = sc;

                if (sc.DisabledByUser)
                {
                    sbEnableService.Text = LangPack.TranslateString("Enable");
                }
                else
                {
                    sbEnableService.Text = LangPack.TranslateString("Disable");
                }
                miEnableService.Text = sbEnableService.Text;
                //ttMain.SetToolTip(sbEnableService, sbEnableService.Text);

                if ((lvServicesEnabled == lv || lv == lvServicesDisabled) &&
                    lv.Items.Count > 1 &&
                    (selection.From != Language.Any && selection.To != Language.Any))
                {
                    sbServiceUp.Enabled   = lv.SelectedIndices[0] != 0;
                    sbServiceDown.Enabled = lv.SelectedIndices[0] != lv.Items.Count - 1;
                }
                else
                {
                    sbServiceUp.Enabled   = false;
                    sbServiceDown.Enabled = false;
                }

                miMoveServiceDown.Enabled = sbServiceDown.Enabled;
                miMoveServiceUp.Enabled   = sbServiceUp.Enabled;
            }
            finally
            {
                LockUpdate(false);
            }
        }
Exemplo n.º 5
0
            void GenerateData()
            {
                name = "";
                if (!string.IsNullOrEmpty(serviceItemData.ServiceItem.Description))
                {
                    name = LangPack.TranslateString(serviceItemData.ServiceItem.Description) + " - ";
                }
                name += LangPack.TranslateString(serviceItemData.ServiceItem.Service.FullName);

                type         = ServiceSettingsContainer.GetServiceItemType(serviceItemData.ServiceItem);
                languagePair = LangPack.TranslateLanguage(serviceItemData.LanguagePair.From) +
                               "->" +
                               LangPack.TranslateLanguage(serviceItemData.LanguagePair.To);

                subject = LangPack.TranslateString(serviceItemData.Subject);
            }
Exemplo n.º 6
0
        public static string GetServiceIconCellHtml(ServiceItem serviceItem, bool useOuterIconUrl)
        {
            if (serviceItem == null)
            {
                throw new ArgumentNullException("service");
            }

            string result = string.Format(CultureInfo.InvariantCulture,
                                          IconFormat,
                                          serviceItem.Service.Url,
                                          serviceItem.Service.Copyright,
                                          ServiceSettingsContainer.GetServiceItemType(serviceItem),
                                          useOuterIconUrl ? serviceItem.Service.IconUrl :
                                          WebUI.ResultsWebServer.GetIconUrl(serviceItem.Service.Name));

            return(result);
        }
Exemplo n.º 7
0
 void ShowStatus(ServiceItemData serviceItemData, ServiceStatusControl statusControl)
 {
     if (serviceItemData == null)
     {
         statusControl.Visible = false;
     }
     else
     {
         statusControl.Visible      = true;
         statusControl.ShowLanguage = true;
         ServiceSettingsContainer sc = new ServiceSettingsContainer(
             new ServiceItemSetting(serviceItemData.LanguagePair,
                                    serviceItemData.Subject, serviceItemData.ServiceItem,
                                    null),
             true);
         statusControl.Status = sc;
     }
 }
 void ServiceStatusControlLoad(object sender, EventArgs e)
 {
     Clear();
     Status = Status;
 }
 void ShowStatus(ServiceItemData serviceItemData, ServiceStatusControl statusControl)
 {
     if(serviceItemData == null)
     {
         statusControl.Visible = false;
     }
     else
     {
         statusControl.Visible = true;
         statusControl.ShowLanguage = true;
         ServiceSettingsContainer sc = new ServiceSettingsContainer(
             new ServiceItemSetting(serviceItemData.LanguagePair,
                                 serviceItemData.Subject, serviceItemData.ServiceItem,
                                 null),
             true);
         statusControl.Status = sc;
     }
 }
Exemplo n.º 10
0
        public void SetResult(Result result, LanguagePair languagePair)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            if (result.ResultNotFound &&
                string.IsNullOrEmpty(result.EditArticleUrl) &&
                TranslateOptions.Instance.ResultWindowOptions.HideWithoutResult)
            {
                return;                 //skip
            }
            string htmlString = "";

            if (TranslateOptions.Instance.ResultWindowOptions.ShowServiceName)
            {
                string name = "";
                if (!string.IsNullOrEmpty(result.ServiceItem.Description))
                {
                    name = LangPack.TranslateString(result.ServiceItem.Description) + " - ";
                }

                name += LangPack.TranslateString(result.ServiceItem.Service.FullName);

                htmlString += string.Format(CultureInfo.InvariantCulture,
                                            HtmlHelper.ServiceNameFormat,
                                            result.ServiceItem.Service.Url,
                                            HttpUtility.HtmlEncode(name));

                htmlString += ", ";
                htmlString += LangPack.TranslateString("Type") + " : " + ServiceSettingsContainer.GetServiceItemType(result.ServiceItem);
            }

            if (result.Subject != SubjectConstants.Common)
            {
                if (htmlString.Length > 0)
                {
                    htmlString += ", ";
                }
                htmlString += LangPack.TranslateString("Subject") + " : " + LangPack.TranslateString(result.Subject);
            }

            if (languagePair.From == Language.Any || languagePair.To == Language.Any || TranslateOptions.Instance.ResultWindowOptions.ShowTranslationDirection)
            {
                if (htmlString.Length > 0)
                {
                    htmlString += ", ";
                }

                if (result.ServiceItem is MonolingualDictionary)
                {
                    htmlString += LangPack.TranslateLanguage(result.LanguagePair.From);
                }
                else
                {
                    htmlString += LangPack.TranslateLanguage(result.LanguagePair.From) +
                                  "->" +
                                  LangPack.TranslateLanguage(result.LanguagePair.To);
                }
            }

            if (htmlString.Length > 0)
            {
                htmlString += "<hr style=\"width: 100%; height: 1px;\">";
            }


            string resultHtml = GetResultHtml(result);

            if (!string.IsNullOrEmpty(result.ArticleUrl) && result.Error == null)
            {
                string icon = "";
                if (result.HasAudio)
                {
                    icon = " " + string.Format(HtmlHelper.IconOfAudioFormat,
                                               LangPack.TranslateString("Pronunciation"));
                }

                htmlString += GetParagraphFormat(0, result);
                if (string.IsNullOrEmpty(result.ArticleUrlCaption))
                {
                    htmlString += string.Format("<a href=\"{0}\" title=\"{0}\">{0}{1}</a>",
                                                result.ArticleUrl, icon
                                                );
                }
                else
                {
                    htmlString += string.Format("<a href=\"{0}\" title=\"{0}\"><b>{1}</b>{2}</a>",
                                                result.ArticleUrl,
                                                result.ArticleUrlCaption, icon
                                                );
                }



                htmlString += "</p>";
                if (!resultHtml.StartsWith("<br>"))
                {
                    htmlString += "<br>";
                }

                htmlString += resultHtml;
            }
            else
            {
                if (!resultHtml.StartsWith("<br>"))
                {
                    htmlString += resultHtml;
                }
                else
                {
                    htmlString += resultHtml.Substring(4);
                }
            }

            if (!string.IsNullOrEmpty(result.ArticleUrl) && result.MoreEntriesCount != 0)
            {
                htmlString += "<br>";
                htmlString += GetParagraphFormat(0, result);
                htmlString += string.Format("<a href=\"{0}\" title=\"{0}\">&gt;&gt;&gt; {1}</a>",
                                            result.ArticleUrl,
                                            string.Format(LangPack.TranslateString("{0} more entries found"),
                                                          result.MoreEntriesCount)
                                            );
                htmlString += "</p>";
            }

            if (result.QueryTicks != 0 && TranslateOptions.Instance.ResultWindowOptions.ShowQueryStatistics)
            {
                htmlString += "<hr style=\"width: 100%; height: 1px;\">";
                htmlString += "<span style=\"" + HtmlHelper.InfoTextStyle + "\">";
                htmlString += string.Format(CultureInfo.InvariantCulture,
                                            LangPack.TranslateString("Query time : {0} s, Queries count : {1}, Bytes sent : {2}, Bytes received : {3}"),
                                            new DateTime(result.QueryTicks).ToString("ss.fffffff", CultureInfo.InvariantCulture),
                                            result.RetryCount,
                                            result.BytesSent,
                                            result.BytesReceived);
                htmlString += "</span>";
            }

            if (!TranslateOptions.Instance.ResultWindowOptions.ShowAccents)
            {
                htmlString = htmlString.Replace("́", "");
            }

            Wait();
            HtmlHelper.AddTranslationCell(wBrowser, isClean, htmlString, result.ServiceItem);
            isClean = false;
            RecalcSizes();
        }
Exemplo n.º 11
0
        void LoadServices(bool phraseChanged)
        {
            if(selection == null || ignoreServicesLoading)
                return;
            if(serviceItemsSettings == null || !phraseChanged)
            {
                lock(serviceItemsContainers)
                {
                    serviceItemsSettings = profile.GetServiceSettings(phrase, selection);
                    lvServicesEnabled.Items.Clear();
                    lvServicesDisabled.Items.Clear();
                    lvServicesDisabledByUser.Items.Clear();
                    serviceItemsContainers.Clear();
                    enabledLVItems.Clear();
                    disabledLVItems.Clear();
                    disabledByUserLVItems.Clear();
                    bool showLanguage = selection.From == Language.Any || selection.To == Language.Any;
                    foreach(ServiceItemSetting ss in serviceItemsSettings)
                    {
                        ServiceSettingsContainer sc = new ServiceSettingsContainer(ss, showLanguage);
                        sc.DisabledByUser = !profile.IsServiceEnabled(ss.ServiceItem.FullName, ss.LanguagePair, ss.Subject);
                        serviceItemsContainers.Add(sc);
                    }
                }
            }

            try
            {
                tpServices.SuspendLayout();
                lvServicesEnabled.SuspendLayout();
                lvServicesEnabled.BeginUpdate();
                lvServicesDisabled.SuspendLayout();
                lvServicesDisabled.BeginUpdate();
                lvServicesDisabledByUser.SuspendLayout();
                lvServicesDisabledByUser.BeginUpdate();

                lvServicesEnabled.FocusedItem = null;
                lvServicesDisabled.FocusedItem = null;
                lvServicesDisabledByUser.FocusedItem = null;

                lock(serviceItemsContainers)
                {
                    PrepareAddingServicesBatch();
                    foreach(ServiceSettingsContainer sc in serviceItemsContainers)
                    {
                        AddListViewItem(sc, true);
                    }
                    ApplyAddingServicesBatch();
                }
                CalcServicesSizes();
                try
                { //try to avoid unrepeatable bug
                    if(lvServicesEnabled.Items.Count > 0)
                    {
                        lvServicesEnabled.Items[0].Focused = true;
                        lvServicesEnabled.Items[0].Selected = true;
                    }
                    else if(lvServicesDisabled.Items.Count > 0)
                    {
                        lvServicesDisabled.Items[0].Focused = true;
                        lvServicesDisabled.Items[0].Selected = true;
                    }
                    else if(lvServicesDisabledByUser.Items.Count > 0)
                    {
                        lvServicesDisabledByUser.Items[0].Focused = true;
                        lvServicesDisabledByUser.Items[0].Selected = true;
                    }

                }
                catch
                {
                    try
                    {
                        if(lvServicesEnabled.Items.Count > 0)
                        {
                            lvServicesEnabled.Items[0].Focused = true;
                            lvServicesEnabled.Items[0].Selected = true;
                        }
                        else if(lvServicesDisabled.Items.Count > 0)
                        {
                            lvServicesDisabled.Items[0].Focused = true;
                            lvServicesDisabled.Items[0].Selected = true;
                        }
                        else if(lvServicesDisabledByUser.Items.Count > 0)
                        {
                            lvServicesDisabledByUser.Items[0].Focused = true;
                            lvServicesDisabledByUser.Items[0].Selected = true;
                        }

                    }
                    catch
                    {

                    }

                }
            }
            finally
            {
                lvServicesEnabled.EndUpdate();
                lvServicesEnabled.ResumeLayout();
                lvServicesDisabled.EndUpdate();
                lvServicesDisabled.ResumeLayout();
                lvServicesDisabledByUser.EndUpdate();
                lvServicesDisabledByUser.ResumeLayout();
                tpServices.ResumeLayout();
                Refresh();
            }
        }
Exemplo n.º 12
0
 ListViewItem FindItem(Dictionary<ServiceSettingsContainer, ListViewItem> itemsDictionary, ServiceSettingsContainer sc)
 {
     ListViewItem result;
     itemsDictionary.TryGetValue(sc, out result);
     return result;
 }
Exemplo n.º 13
0
        ListViewItem AddListViewItem(ServiceSettingsContainer sc, bool batchMode)
        {
            if(!sc.DisabledByUser)
                sc.Check(phrase);

            ListViewItem lvi;
            if(sc.DisabledByUser)
            {
                lvi = FindItem(enabledLVItems, sc);
                if(lvi != null)
                {
                    lvServicesEnabled.Items.Remove(lvi);
                    enabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledLVItems, sc);
                if(lvi != null)
                {
                    lvServicesDisabled.Items.Remove(lvi);
                    disabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if(lvi == null)
                {
                    lvi = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if(batchMode)
                        batchDisabledByUserLVItems.Add(lvi);
                    else
                        lvServicesDisabledByUser.Items.Add(lvi);
                    disabledByUserLVItems.Add(sc, lvi);
                }
            }
            else if(sc.Enabled)
            {
                lvi = FindItem(disabledLVItems, sc);
                if(lvi != null)
                {
                    lvi.Focused = false;
                    lvi.Selected = false;
                    lvServicesDisabled.Items.Remove(lvi);
                    disabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if(lvi != null)
                {
                    lvServicesDisabledByUser.Items.Remove(lvi);
                    disabledByUserLVItems.Remove(sc);
                }

                lvi = FindItem(enabledLVItems, sc);
                if(lvi == null)
                {
                    lvi = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if(batchMode)
                        batchEnabledLVItems.Add(lvi);
                    else
                        lvServicesEnabled.Items.Add(lvi);
                    enabledLVItems.Add(sc, lvi);
                }
            }
            else
            {
                lvi = FindItem(enabledLVItems, sc);
                if(lvi != null)
                {
                    lvServicesEnabled.Items.Remove(lvi);
                    enabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if(lvi != null)
                {
                    lvServicesDisabledByUser.Items.Remove(lvi);
                    disabledByUserLVItems.Remove(sc);
                }

                lvi = FindItem(disabledLVItems, sc);
                if(lvi == null)
                {
                    lvi = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if(batchMode)
                        batchDisabledLVItems.Add(lvi);
                    else
                        lvServicesDisabled.Items.Add(lvi);
                    disabledLVItems.Add(sc, lvi);
                }
                else if(lvi.Selected)
                { //reload error
                    serviceStatus.Status = sc;
                }
            }
            return lvi;
        }
Exemplo n.º 14
0
 ListViewItem AddListViewItem(ServiceSettingsContainer sc)
 {
     return AddListViewItem(sc, false);
 }
Exemplo n.º 15
0
        void LoadServices(bool phraseChanged)
        {
            if (selection == null || ignoreServicesLoading)
            {
                return;
            }
            if (serviceItemsSettings == null || !phraseChanged)
            {
                lock (serviceItemsContainers)
                {
                    serviceItemsSettings = profile.GetServiceSettings(phrase, selection);
                    lvServicesEnabled.Items.Clear();
                    lvServicesDisabled.Items.Clear();
                    lvServicesDisabledByUser.Items.Clear();
                    serviceItemsContainers.Clear();
                    enabledLVItems.Clear();
                    disabledLVItems.Clear();
                    disabledByUserLVItems.Clear();
                    bool showLanguage = selection.From == Language.Any || selection.To == Language.Any;
                    foreach (ServiceItemSetting ss in serviceItemsSettings)
                    {
                        ServiceSettingsContainer sc = new ServiceSettingsContainer(ss, showLanguage);
                        sc.DisabledByUser = !profile.IsServiceEnabled(ss.ServiceItem.FullName, ss.LanguagePair, ss.Subject);
                        serviceItemsContainers.Add(sc);
                    }
                }
            }

            try
            {
                tpServices.SuspendLayout();
                lvServicesEnabled.SuspendLayout();
                lvServicesEnabled.BeginUpdate();
                lvServicesDisabled.SuspendLayout();
                lvServicesDisabled.BeginUpdate();
                lvServicesDisabledByUser.SuspendLayout();
                lvServicesDisabledByUser.BeginUpdate();

                lvServicesEnabled.FocusedItem        = null;
                lvServicesDisabled.FocusedItem       = null;
                lvServicesDisabledByUser.FocusedItem = null;

                lock (serviceItemsContainers)
                {
                    PrepareAddingServicesBatch();
                    foreach (ServiceSettingsContainer sc in serviceItemsContainers)
                    {
                        AddListViewItem(sc, true);
                    }
                    ApplyAddingServicesBatch();
                }
                CalcServicesSizes();
                try
                {                 //try to avoid unrepeatable bug
                    if (lvServicesEnabled.Items.Count > 0)
                    {
                        lvServicesEnabled.Items[0].Focused  = true;
                        lvServicesEnabled.Items[0].Selected = true;
                    }
                    else if (lvServicesDisabled.Items.Count > 0)
                    {
                        lvServicesDisabled.Items[0].Focused  = true;
                        lvServicesDisabled.Items[0].Selected = true;
                    }
                    else if (lvServicesDisabledByUser.Items.Count > 0)
                    {
                        lvServicesDisabledByUser.Items[0].Focused  = true;
                        lvServicesDisabledByUser.Items[0].Selected = true;
                    }
                }
                catch
                {
                    try
                    {
                        if (lvServicesEnabled.Items.Count > 0)
                        {
                            lvServicesEnabled.Items[0].Focused  = true;
                            lvServicesEnabled.Items[0].Selected = true;
                        }
                        else if (lvServicesDisabled.Items.Count > 0)
                        {
                            lvServicesDisabled.Items[0].Focused  = true;
                            lvServicesDisabled.Items[0].Selected = true;
                        }
                        else if (lvServicesDisabledByUser.Items.Count > 0)
                        {
                            lvServicesDisabledByUser.Items[0].Focused  = true;
                            lvServicesDisabledByUser.Items[0].Selected = true;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                lvServicesEnabled.EndUpdate();
                lvServicesEnabled.ResumeLayout();
                lvServicesDisabled.EndUpdate();
                lvServicesDisabled.ResumeLayout();
                lvServicesDisabledByUser.EndUpdate();
                lvServicesDisabledByUser.ResumeLayout();
                tpServices.ResumeLayout();
                Refresh();
            }
        }
        static void GenerateServiceItemSell(WebBrowser wBrowser, ServiceItem si, string parentName, bool first, bool generateLangs)
        {
            StringBuilder htmlString = new StringBuilder();

            htmlString.AppendFormat(CultureInfo.InvariantCulture,
                                    HtmlHelper.ServiceNameFormat,
                                    si.Service.Url,
                                    HttpUtility.HtmlEncode(si.Service.Url.AbsoluteUri));

            htmlString.Append(", ");

            if (!string.IsNullOrEmpty(si.Description))
            {
                htmlString.Append(LangPack.TranslateString(si.Description) + " - ");
            }

            htmlString.Append(LangPack.TranslateString(si.Service.FullName));


            if (si is MonolingualDictionary)
            {
                htmlString.Append(", ");
                htmlString.Append(LangPack.TranslateLanguage(si.SupportedTranslations[0].From));
            }

            htmlString.Append(", ");
            htmlString.Append(ServiceSettingsContainer.GetServiceItemType(si));

            if (si.SupportedSubjects.Count > 1)
            {
                htmlString.Append(", " + LangPack.TranslateString("Subjects") + " : ");
                htmlString.Append(LangPack.TranslateString(SubjectConstants.Common));
                foreach (string subject in si.SupportedSubjects)
                {
                    if (subject != SubjectConstants.Common)
                    {
                        htmlString.Append(", ");
                        htmlString.Append(LangPack.TranslateString(subject));
                    }
                }
            }

            htmlString.Append(", ");
            htmlString.Append(HttpUtility.HtmlEncode(si.Service.Copyright));

            if (si is MonolingualDictionary || !generateLangs)
            {
                HtmlHelper.AddTranslationCell(wBrowser, parentName, first, htmlString.ToString(), si, true);
                return;
            }

            //count langs without gb\us english
            int pairsCount = 0;

            foreach (LanguagePair lp in si.SupportedTranslations)
            {
                if (lp.From != Language.English_GB && lp.From != Language.English_US &&
                    lp.To != Language.English_GB && lp.To != Language.English_US)
                {
                    pairsCount++;
                }
            }

            string langNodeName = si.FullName + "_langs";

            htmlString.Append("<br>" + GenerateTopNode(langNodeName, LangPack.TranslateString("Languages") + GetLangsPairsCount(pairsCount), 0.5));
            HtmlHelper.AddTranslationCell(wBrowser, parentName, first, htmlString.ToString(), si, true);

            SortedDictionary <string, SortedDictionary <string, string> > langs = new SortedDictionary <string, SortedDictionary <string, string> >();

            foreach (LanguagePair lp in si.SupportedTranslations)
            {
                if (lp.From == Language.English_GB || lp.From == Language.English_US ||
                    lp.To == Language.English_GB || lp.To == Language.English_US)
                {
                    continue;
                }

                string fromlang = LangPack.TranslateLanguage(lp.From);
                SortedDictionary <string, string> inner_list;
                if (!langs.TryGetValue(fromlang, out inner_list))
                {
                    inner_list = new SortedDictionary <string, string>();
                    langs.Add(fromlang, inner_list);
                }
                inner_list.Add(LangPack.TranslateLanguage(lp.To), "");
            }

            if (si.SupportedTranslations.Count <= 10)
            {
                htmlString = new StringBuilder();
                foreach (KeyValuePair <string, SortedDictionary <string, string> > kvp_langs in langs)
                {
                    foreach (KeyValuePair <string, string> kvp_to_langs in kvp_langs.Value)
                    {
                        htmlString.Append("<li>" + kvp_langs.Key + "->" + kvp_to_langs.Key + "</li>");
                    }
                }
                HtmlHelper.SetNodeInnerHtml(wBrowser, langNodeName, htmlString.ToString());
            }
            else
            {
                htmlString = new StringBuilder();
                foreach (KeyValuePair <string, SortedDictionary <string, string> > kvp_langs in langs)
                {
                    string nodeName = si.FullName + "_lang_" + kvp_langs.Key;
                    nodeName = nodeName.Replace("'", "_");
                    htmlString.Append(GenerateTopNode(nodeName, kvp_langs.Key + "->" + GetLangsPairsCount(kvp_langs.Value.Count), 1));
                }
                HtmlHelper.SetNodeInnerHtml(wBrowser, langNodeName, htmlString.ToString());


                foreach (KeyValuePair <string, SortedDictionary <string, string> > kvp_langs in langs)
                {
                    string nodeName = si.FullName + "_lang_" + kvp_langs.Key;
                    nodeName   = nodeName.Replace("'", "_");
                    htmlString = new StringBuilder();
                    foreach (KeyValuePair <string, string> kvp_to_langs in kvp_langs.Value)
                    {
                        htmlString.Append("<li>" + kvp_to_langs.Key + "</li>");
                    }
                    HtmlHelper.SetNodeInnerHtml(wBrowser, nodeName, htmlString.ToString());
                }
            }
        }
Exemplo n.º 17
0
 ListViewItem AddListViewItem(ServiceSettingsContainer sc)
 {
     return(AddListViewItem(sc, false));
 }
Exemplo n.º 18
0
        ListViewItem FindItem(Dictionary <ServiceSettingsContainer, ListViewItem> itemsDictionary, ServiceSettingsContainer sc)
        {
            ListViewItem result;

            itemsDictionary.TryGetValue(sc, out result);
            return(result);
        }
Exemplo n.º 19
0
        ListViewItem AddListViewItem(ServiceSettingsContainer sc, bool batchMode)
        {
            if (!sc.DisabledByUser)
            {
                sc.Check(phrase);
            }

            ListViewItem lvi;

            if (sc.DisabledByUser)
            {
                lvi = FindItem(enabledLVItems, sc);
                if (lvi != null)
                {
                    lvServicesEnabled.Items.Remove(lvi);
                    enabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledLVItems, sc);
                if (lvi != null)
                {
                    lvServicesDisabled.Items.Remove(lvi);
                    disabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if (lvi == null)
                {
                    lvi             = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag         = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if (batchMode)
                    {
                        batchDisabledByUserLVItems.Add(lvi);
                    }
                    else
                    {
                        lvServicesDisabledByUser.Items.Add(lvi);
                    }
                    disabledByUserLVItems.Add(sc, lvi);
                }
            }
            else if (sc.Enabled)
            {
                lvi = FindItem(disabledLVItems, sc);
                if (lvi != null)
                {
                    lvi.Focused  = false;
                    lvi.Selected = false;
                    lvServicesDisabled.Items.Remove(lvi);
                    disabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if (lvi != null)
                {
                    lvServicesDisabledByUser.Items.Remove(lvi);
                    disabledByUserLVItems.Remove(sc);
                }

                lvi = FindItem(enabledLVItems, sc);
                if (lvi == null)
                {
                    lvi             = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag         = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if (batchMode)
                    {
                        batchEnabledLVItems.Add(lvi);
                    }
                    else
                    {
                        lvServicesEnabled.Items.Add(lvi);
                    }
                    enabledLVItems.Add(sc, lvi);
                }
            }
            else
            {
                lvi = FindItem(enabledLVItems, sc);
                if (lvi != null)
                {
                    lvServicesEnabled.Items.Remove(lvi);
                    enabledLVItems.Remove(sc);
                }

                lvi = FindItem(disabledByUserLVItems, sc);
                if (lvi != null)
                {
                    lvServicesDisabledByUser.Items.Remove(lvi);
                    disabledByUserLVItems.Remove(sc);
                }

                lvi = FindItem(disabledLVItems, sc);
                if (lvi == null)
                {
                    lvi             = new ListViewItem(sc.Name, sc.Setting.ServiceItem.Service.Name);
                    lvi.Tag         = sc;
                    lvi.ToolTipText = sc.GetServiceTooltipText();
                    if (batchMode)
                    {
                        batchDisabledLVItems.Add(lvi);
                    }
                    else
                    {
                        lvServicesDisabled.Items.Add(lvi);
                    }
                    disabledLVItems.Add(sc, lvi);
                }
                else if (lvi.Selected)
                {                 //reload error
                    serviceStatus.Status = sc;
                }
            }
            return(lvi);
        }