예제 #1
0
        void ShowListBox(object sender, int count)
        {
            //int line = 0;
            //try {
            if (listBox == null)
            {
                listBox = new ListBox();
                if (count >= 5)
                {
                    ScrollViewer.SetVerticalScrollBarVisibility(listBox, ScrollBarVisibility.Visible);
                }
                listBox.SelectionChanged += (s, e) =>
                {
                    if (listBox.SelectedItem != null && listBox.Items.Contains(listBox.SelectedItem))
                    {
                        try
                        {
                            listBox.ScrollIntoView(listBox.SelectedItem);
                        }
                        catch { }
                    }
                };
                listBox.MinWidth = textBox.RenderSize.Width;

                ArmoryLoadDialog dialog = (ArmoryLoadDialog)sender;

                //var canvas = (Grid)System.Windows.Application.Current.RootVisual;
                var canvas    = (Grid)dialog.LayoutRoot;
                var transform = textBox.TransformToVisual(canvas);
                var topLeft   = transform.Transform(new Point(0, 0));

                Canvas.SetLeft(listBox, topLeft.X);
                Canvas.SetTop(listBox, topLeft.Y + textBox.RenderSize.Height);
                canvas.Children.Add(listBox);
            }

            if (count >= 5)
            {
                count = 5;
            }
            listBox.MaxHeight = count * 21;
            //} catch (Exception ex) {
            //new Rawr.DPSWarr.ErrorBoxDPSWarr("AutoComplete issue", ex.Message, "ShowListBox", "No Additional Info", ex.StackTrace, line);
            //}
        }
예제 #2
0
 void HideListBox(object sender)
 {
     //string info = "No Additional Info";
     //try {
     if (listBox != null)
     {
         //Grid sndr = (Grid)sender;
         //info = "\r\n- Name: " + sndr.Name + "\r\n- ParentType: " + sndr.Parent.GetType();
         //info += "\r\n- ControlType: " + sender.ToString() + "\r\n- Type: " + sender.GetType().ToString();
         ArmoryLoadDialog dialog = (ArmoryLoadDialog)((Grid)sender).Parent;
         //var canvas = (Grid)System.Windows.Application.Current.RootVisual;
         var canvas = (Grid)dialog.LayoutRoot;    // info = "No Additional Info";
         canvas.Children.Remove(listBox);
         listBox = null;
     }
     //} catch (Exception ex) {
     //new Rawr.DPSWarr.ErrorBoxDPSWarr("AutoComplete issue", ex.Message, "HideListBox", info, ex.StackTrace, 0);
     //}
 }