Interaction logic for HintWindow.xaml
示例#1
0
 void HintWindowClosed(object sender, EventArgs e)
 {
     _hintSource.UnSubClass();
     _hintSource = null;
     _hintWindow = null;
     Closed?.Invoke(this);
 }
示例#2
0
        private void Show()
        {
            if (InputManager.Current.IsInMenuMode)
            {
                return;
            }

            if (_hintWindow != null)
            {
                throw new NotSupportedException("Hint already shown");
            }

            // subclass
            _hintSource           = new HintSource();
            _hintSource.Activate += Close;
            _hintSource.SubClass();

            // create hint window
            var ht = HintRoot.Create(PlacementRect, _hintSource);

            _hintWindow = new HintWindow(this, ht)
            {
                Text = _text
            };

            if (BackgroundResourceReference != null)
            {
                _hintWindow.border.SetResourceReference(Border.BackgroundProperty, BackgroundResourceReference);
            }

            if (ForegroundResourceReference != null)
            {
                _hintWindow._textBlock.SetResourceReference(TextBlock.ForegroundProperty, ForegroundResourceReference);
            }

            _hintSource.HintWindow = _hintWindow;
            //new WindowInteropHelper(_hintWindow) { Owner = _hintSource.Owner };
            _hintWindow.Closed   += HintWindowClosed;
            _hintWindow.MaxHeight = 1200.0;//System.Windows.Forms.Screen.FromRectangle(PlacementRect).WorkingArea.
            _wrapWidth            = 1200.0;

            _hintWindow.WrapWidth = _wrapWidth;
            _hintWindow.Show();
        }
示例#3
0
        public static Window ShowSubHint(Hint hint, FrameworkElement el, string hintText, Window owner)
        {
            var ht = HintRoot.Create(el);

            if (owner != null)
            {
                foreach (HintWindow window in owner.OwnedWindows)
                {
                    if (!window._hintRoot.Equals(ht))
                    {
                        window.Close();
                        continue;
                    }

                    ht.Dispose();
                    return(null);
                }
            }

            var wnd = new HintWindow(hint, ht)
            {
                Text = hintText, Owner = owner
            };

            if (hint.BackgroundResourceReference != null)
            {
                wnd.border.SetResourceReference(Border.BackgroundProperty, hint.BackgroundResourceReference);
            }

            if (hint.ForegroundResourceReference != null)
            {
                wnd._textBlock.SetResourceReference(TextBlock.ForegroundProperty, hint.ForegroundResourceReference);
            }

            wnd.Show();

            return(wnd);
        }
示例#4
0
文件: Hint.cs 项目: JetBrains/Nitra
        private void Show(IntPtr owner)
        {
            if (InputManager.Current.IsInMenuMode)
            return;

              if (_hintWindow != null)
            throw new NotSupportedException("Hint already shown");

              // subclass
              _hintSource = new HintSource();
              _hintSource.Activate += Close;
              _hintSource.SubClass(owner);

              // create hint window
              var ht = HintRoot.Create(PlacementRect, _hintSource);
              _hintWindow = new HintWindow(this, ht) { Text = _text };

              if (BackgroundResourceReference != null)
            _hintWindow.border.SetResourceReference(Border.BackgroundProperty, BackgroundResourceReference);

              if (ForegroundResourceReference != null)
            _hintWindow._textBlock.SetResourceReference(TextBlock.ForegroundProperty, ForegroundResourceReference);

              _hintSource.HintWindow = _hintWindow;
              //new WindowInteropHelper(_hintWindow) { Owner = _hintSource.Owner };
              _hintWindow.Closed += HintWindowClosed;
              _hintWindow.MaxHeight = 1200.0;//System.Windows.Forms.Screen.FromRectangle(PlacementRect).WorkingArea.
              _wrapWidth = 1200.0;

              _hintWindow.WrapWidth = _wrapWidth;
              _hintWindow.Show();
        }
示例#5
0
文件: Hint.cs 项目: JetBrains/Nitra
 void HintWindowClosed(object sender, EventArgs e)
 {
     _hintSource.UnSubClass();
       _hintSource = null;
       _hintWindow = null;
       if (Closed != null) Closed(this);
 }
示例#6
0
        private void ShowSubHint(FrameworkElement el, string hintText)
        {
            var ht = HintRoot.Create(el);

            foreach (HintWindow window in OwnedWindows)
            {
                if (!window._hintRoot.Equals(ht))
                {
                    window.Close();
                    continue;
                }

                ht.Dispose();
                return;
            }

            var wnd = new HintWindow(_hint, ht) { Text = hintText, Owner = this };

              if (_hint.BackgroundResourceReference != null)
            wnd.border.SetResourceReference(Border.BackgroundProperty, _hint.BackgroundResourceReference);

              if (_hint.ForegroundResourceReference != null)
            wnd._textBlock.SetResourceReference(TextBlock.ForegroundProperty, _hint.ForegroundResourceReference);

              wnd.Show();
        }
示例#7
0
 public Window ShowSubHint(FrameworkElement el, string hintText, Window owner)
 {
     return(HintWindow.ShowSubHint(this, el, hintText, owner));
 }