Esempio n. 1
0
        private void MainListbox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (viewType != ViewType.Tree)
            {
                int objid = -1;

                switch (codetype)
                {
                case Codetype.Unit:
                {
                    UnitDataBinding list = (UnitDataBinding)MainListbox.SelectedItem;
                    if (list != null)
                    {
                        objid = list.ObjectID;
                    }
                }
                break;

                case Codetype.Upgrade:
                {
                    UpgradeDataBinding list = (UpgradeDataBinding)MainListbox.SelectedItem;
                    if (list != null)
                    {
                        objid = list.ObjectID;
                    }
                }
                break;

                case Codetype.Tech:
                {
                    TechDataBinding list = (TechDataBinding)MainListbox.SelectedItem;
                    if (list != null)
                    {
                        objid = list.ObjectID;
                    }
                }
                break;

                case Codetype.Sprite:
                {
                    SpriteDataBinding list = (SpriteDataBinding)MainListbox.SelectedItem;
                    if (list != null)
                    {
                        objid = list.ObjectID;
                    }
                }
                break;
                }
                if (objid != -1)
                {
                    SelectIndex = objid;
                }
                SelectionChanged.Invoke(objid, e);
            }
        }
Esempio n. 2
0
        private void MainTreeview_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (viewType == ViewType.Tree)
            {
                int objid = -1;


                TreeViewItem list = (TreeViewItem)MainTreeview.SelectedItem;
                if (list != null)
                {
                    if (list.Items.Count == 0)
                    {
                        switch (codetype)
                        {
                        case Codetype.Unit:
                        {
                            UnitDataBinding binding = (UnitDataBinding)list.DataContext;
                            if (binding != null)
                            {
                                objid = binding.ObjectID;
                            }
                        }
                        break;

                        case Codetype.Upgrade:
                        {
                            UpgradeDataBinding binding = (UpgradeDataBinding)list.DataContext;
                            if (binding != null)
                            {
                                objid = binding.ObjectID;
                            }
                        }
                        break;

                        case Codetype.Tech:
                        {
                            TechDataBinding binding = (TechDataBinding)list.DataContext;
                            if (binding != null)
                            {
                                objid = binding.ObjectID;
                            }
                        }
                        break;

                        case Codetype.Sprite:
                        {
                            SpriteDataBinding binding = (SpriteDataBinding)list.DataContext;
                            if (binding != null)
                            {
                                objid = binding.ObjectID;
                            }
                        }
                        break;
                        }
                    }
                }
                if (objid != -1)
                {
                    SelectIndex = objid;
                }
                SelectionChanged.Invoke(objid, e);
            }
        }
Esempio n. 3
0
        private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            string searchText = SearchBox.Text;

            if (viewType == ViewType.Tree)
            {
                for (int i = 0; i < treeViews.Count; i++)
                {
                    TreeViewItem list = treeViews[i];
                    string       str  = "";
                    switch (codetype)
                    {
                    case Codetype.Unit:
                    {
                        UnitDataBinding binding = (UnitDataBinding)list.DataContext;
                        if (binding != null)
                        {
                            str = binding.AlphaName;
                        }
                    }
                    break;

                    case Codetype.Upgrade:
                    {
                        UpgradeDataBinding binding = (UpgradeDataBinding)list.DataContext;
                        if (binding != null)
                        {
                            str = binding.AlphaName;
                        }
                    }
                    break;

                    case Codetype.Tech:
                    {
                        TechDataBinding binding = (TechDataBinding)list.DataContext;
                        if (binding != null)
                        {
                            str = binding.AlphaName;
                        }
                    }
                    break;

                    case Codetype.Sprite:
                    {
                        SpriteDataBinding binding = (SpriteDataBinding)list.DataContext;
                        if (binding != null)
                        {
                            str = binding.AlphaName;
                        }
                    }
                    break;
                    }


                    if (!String.IsNullOrEmpty(str))
                    {
                        int index = str.IndexOf(searchText, 0);

                        if (index > -1)
                        {
                            //보이게하기
                            list.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            //안보이게하기
                            list.Visibility = Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        //안보이게하기
                        list.Visibility = Visibility.Collapsed;
                    }
                }


                TreeviewFliter(MainTreeview.Items, searchText);
            }
            else
            {
                MainListbox.Items.Filter = delegate(object obj)
                {
                    string str = "";
                    switch (codetype)
                    {
                    case Codetype.Unit:
                    {
                        UnitDataBinding unitdata = (UnitDataBinding)obj;
                        str = unitdata.AlphaName;
                    }
                    break;

                    case Codetype.Upgrade:
                    {
                        UpgradeDataBinding unitdata = (UpgradeDataBinding)obj;
                        str = unitdata.AlphaName;
                    }
                    break;

                    case Codetype.Tech:
                    {
                        TechDataBinding unitdata = (TechDataBinding)obj;
                        str = unitdata.AlphaName;
                    }
                    break;

                    case Codetype.Sprite:
                    {
                        SpriteDataBinding unitdata = (SpriteDataBinding)obj;
                        str = unitdata.AlphaName;
                    }
                    break;
                    }



                    if (String.IsNullOrEmpty(str))
                    {
                        return(false);
                    }
                    int index = str.IndexOf(searchText, 0);

                    return(index > -1);
                };
            }

            //ListItemRefresh();
        }