コード例 #1
0
ファイル: DlgInput.xaml.cs プロジェクト: tophyr/KML
        private DlgInput(string message, string title, Image image, string presetText)
        {
            InitializeComponent();

            if (title != null)
            {
                Title = title;
            }
            if (image != null)
            {
                Icon = image.Source;
            }
            if (presetText != null)
            {
                TextBoxInput.Text = presetText;
            }
            else
            {
                TextBoxInput.Text = "";
            }
            TextMessage.Text            = message;
            TextBoxInput.SelectionStart = TextBoxInput.Text.Length;
            TextBoxInput.Focus();

            // We need to measure the ActualHeight of TextBoxInput,
            // because it reads 0.0 if it's not set, unlesse Arrage is called.
            // And it's not set on purpose to use system default.
            TextBoxInput.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            TextBoxInput.Arrange(new Rect(TextBoxInput.DesiredSize));

            DlgHelper.Initialize(this);
            DlgHelper.CalcNeededSize(this, TextMessage, ButtonOk.Height + TextBoxInput.ActualHeight);
        }
コード例 #2
0
        private DlgConfirmation(string message, string title, Image image)
        {
            InitializeComponent();

            if (title != null)
            {
                Title = title;
            }
            if (image != null)
            {
                Icon = image.Source;
            }
            TextMessage.Text = message;

            DlgHelper.Initialize(this);
            DlgHelper.CalcNeededSize(this, TextMessage, ButtonOk.Height);
        }
コード例 #3
0
        private DlgSearch(string presetText)
        {
            InitializeComponent();

            SearchTimer          = new DispatcherTimer();
            SearchTimer.Interval = TimeSpan.FromSeconds(1.0);
            SearchTimer.Tick    += SearchTimer_Tick;

            DlgHelper.Initialize(this);

            if (presetText != null)
            {
                TextBoxInput.Text = presetText;
            }
            else
            {
                TextBoxInput.Text = _searchString;
            }
            // Select all
            TextBoxInput.SelectAll();
            TextBoxInput.Focus();

            CheckNodeTag.IsChecked     = _checkNodeTag;
            CheckNodeText.IsChecked    = _checkNodeText;
            CheckAttribName.IsChecked  = _checkAttribName;
            CheckAttribValue.IsChecked = _checkAttribValue;

            if (TextBoxInput.Text.Length > 2)
            {
                Search();
                foreach (TreeViewItem item in Tree.Items)
                {
                    if (item.DataContext == _selectedItem)
                    {
                        item.IsSelected = true;
                    }
                    foreach (TreeViewItem sub in item.Items)
                    {
                        if (sub.DataContext == _selectedItem)
                        {
                            sub.IsSelected = true;
                        }
                    }
                }
            }


            if (_width > 0 && _height > 0)
            {
                Width  = _width;
                Height = _height;
            }

            // Scroll to selected item
            if (Tree.SelectedItem is TreeViewItem)
            {
                (Tree.SelectedItem as TreeViewItem).BringIntoView();
            }

            // We need to measure the ActualHeight of TextBoxInput,
            // because it reads 0.0 if it's not set, unlesse Arrage is called.
            // And it's not set on purpose to use system default.
            //TextBoxInput.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            //TextBoxInput.Arrange(new Rect(TextBoxInput.DesiredSize));

            //DlgHelper.CalcNeededSize(this, TextMessage, ButtonOk.Height + TextBoxInput.ActualHeight);
        }