Exemplo n.º 1
0
        private void DownClick(object sender, RoutedEventArgs e)
        {
            FrameworkElement ele = sender as FrameworkElement;

            if (ele == null)
            {
                return;
            }

            var          alp   = (AlphabetItem)ele.DataContext;
            var          index = Alphabets.IndexOf(alp);
            AlphabetItem tmp   = null;

            if (ActiveAlphabet == alp)
            {
                tmp = alp;
            }
            index--;
            if (index > -1)
            {
                Alphabets.Remove(alp);
                Alphabets.Insert(index, alp);
                if (tmp != null)
                {
                    ActiveAlphabet = alp;
                }
            }


            AlphabetCollectionView.Refresh();
        }
Exemplo n.º 2
0
        private void AddItemClick(object sender, RoutedEventArgs e)
        {
            var item = new AlphabetItem();

            addItem(item);
            SelectedAlphabet = item;
        }
Exemplo n.º 3
0
        private static void OnActiveAlphabetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            AlphabetPresentation b       = (AlphabetPresentation)d;
            AlphabetItem         newItem = (AlphabetItem)e.NewValue;
            AlphabetItem         oldItem = (AlphabetItem)e.OldValue;

            if (newItem != null)
            {
                newItem.IsSelected = true;
            }

            if (oldItem != null)
            {
                oldItem.IsSelected = false;
            }
        }
Exemplo n.º 4
0
        public void SetAlphabetItems(List <AlphabetItemData> data)
        {
            if (Alphabets != null)
            {
                var x = Alphabets.Count - 1;
                for (int i = x; i >= 0; --i)
                {
                    var item = Alphabets[i];
                    item.PropertyChanged -= new PropertyChangedEventHandler(item_PropertyChanged);
                }
            }

            Alphabets.Clear();

            foreach (var item in data)
            {
                var tmp = new AlphabetItem(item);
                addItem(tmp);
                if (tmp.IsSelected == true)
                {
                    ActiveAlphabet = tmp;
                }
            }
        }
Exemplo n.º 5
0
 public AlphabetItem(AlphabetItem item)
 {
     this.Data = item.Data;
 }
Exemplo n.º 6
0
 private void removeItem(AlphabetItem item)
 {
     item.PropertyChanged -= new PropertyChangedEventHandler(item_PropertyChanged);
     Alphabets.Remove(item);
     saveToSettings();
 }
Exemplo n.º 7
0
 private void addItem(AlphabetItem item)
 {
     item.PropertyChanged += new PropertyChangedEventHandler(item_PropertyChanged);
     Alphabets.Add(item);
     saveToSettings();
 }