示例#1
0
        private void AddProvider(RecogEngine entry)
        {
            var         id = entry.RecogEngineID;
            RecogEngine oldServer;

            if (ProviderAdded.TryRemove(id, out oldServer))
            {
                this.ProviderList.Remove(oldServer);
            }
            var priorInfo = this.ProviderAdded.GetOrAdd(id, entry);

            if (Object.ReferenceEquals(priorInfo, entry))
            {
                this.ProviderList.Add(entry);
            }
        }
示例#2
0
 private void SelectedProvider_Event(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0)
     {
         var item = e.AddedItems[0] as RecogEngine;
         this.CurrentProvider.Text = item.RecogEngineName;
         var idx = ProviderList.IndexOf(item);
         var cnt = ProviderList.Count;
         if (idx >= 0)
         {
             var minShow = MinItemShowed;
             var maxShow = MinItemShowed + NumberItemShowed - 1;
             var midShow = (minShow + maxShow) / 2;
             var diff    = idx - midShow;
             if (diff != 0)
             {
                 var         newMinShow = MinItemShowed;
                 RecogEngine scrollItem = null;
                 if (diff < 0)
                 {
                     newMinShow = Math.Max(0, MinItemShowed + diff);
                 }
                 else
                 {
                     maxShow    = Math.Min(cnt - 1, MinItemShowed + diff + NumberItemShowed - 1);
                     newMinShow = Math.Max(0, maxShow - NumberItemShowed + 1);
                 }
                 if (newMinShow != MinItemShowed)
                 {
                     int scrollidx = 0;
                     if (diff < 0)
                     {
                         scrollItem = ProviderList[newMinShow];
                         scrollidx  = newMinShow;
                     }
                     else
                     {
                         scrollItem = ProviderList[maxShow];
                         scrollidx  = maxShow;
                     }
                     MinItemShowed = newMinShow;
                     this.ViewOfProvider.ScrollIntoView(scrollItem);
                 }
             }
         }
     }
 }
示例#3
0
        private void findSelectedProvider()
        {
            RecogEngine selected = null;

            foreach (var item in ProviderAdded)
            {
                if (String.Compare(this.CurrentProvider.Text, item.Value.RecogEngineName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    selected = item.Value;
                }
            }

            if (!Object.ReferenceEquals(selected, null))
            {
                var currentApp = (App)App.Current;
                currentApp.CurrentProvider = selected;
            }
        }