private void ProcessMove(DragDeltaEventArgs e) { AdornerLayer layer = AdornerLayer.GetAdornerLayer(Target); UIElementAdorner <Control> adorner = layer.GetAdorners(Target).OfType <UIElementAdorner <Control> >().First(); adorner.SetOffsets(adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange); }
private void RemoveOverlayContent() { if (m_adorner != null) { AdornerLayer parentAdorner = AdornerLayer.GetAdornerLayer(this); parentAdorner.Remove(m_adorner); m_adorner.Remove(); m_adorner = null; } }
private void AddOverlayContent() { if (OverlayContent != null) { m_adorner = new UIElementAdorner(this, OverlayContent); m_adorner.Add(); AdornerLayer parentAdorner = AdornerLayer.GetAdornerLayer(this); parentAdorner.Add(m_adorner); } }
private void AddOverlayContent() { if (OverlayContent != null) { m_adorner = new UIElementAdorner(this, OverlayContent); m_adorner.Add(); AdornerLayer parentAdorner = AdornerLayer.GetAdornerLayer(this); parentAdorner.Add(m_adorner); } }
/// <summary> /// Attaches a FormatBar to a RichtextBox /// </summary> /// <param name="richTextBox">The RichtextBox to attach to.</param> /// <param name="formatBar">The Formatbar to attach.</param> private void AttachFormatBarToRichtextBox(global::System.Windows.Controls.RichTextBox richTextBox, IRichTextBoxFormatBar formatBar) { _richTextBox = richTextBox; //we cannot use the PreviewMouseLeftButtonUp event because of selection bugs. //we cannot use the MouseLeftButtonUp event because it is handled by the RichTextBox and does not bubble up to here, so we must //add a hander to the MouseUpEvent using the Addhandler syntax, and specify to listen for handled events too. _richTextBox.AddHandler(Mouse.MouseUpEvent, new MouseButtonEventHandler(RichTextBox_MouseButtonUp), true); _richTextBox.TextChanged += RichTextBox_TextChanged; _adorner = new UIElementAdorner <Control>(_richTextBox); formatBar.Target = _richTextBox; _toolbar = formatBar; }
/// <summary> /// Initializes a new instance of SmartTextBox. /// </summary> public SmartTextBox() { // Make sure that spellchecking is active for this TextBox. SpellCheck.SetIsEnabled(this, true); // Initialize the ListBox which displays suggestions. this.suggestionList = new ListBox(); ScrollViewer.SetVerticalScrollBarVisibility(this.suggestionList, ScrollBarVisibility.Hidden); this.suggestionList.IsKeyboardFocusWithinChanged += suggestionList_IsKeyboardFocusWithinChanged; this.suggestionList.ItemContainerGenerator.StatusChanged += suggestionList_ItemContainerGenerator_StatusChanged; this.suggestionList.MouseDoubleClick += suggestionList_MouseDoubleClick; this.suggestionList.PreviewKeyDown += suggestionList_PreviewKeyDown; // Initialize the adorner which shows the Listbox. this.adorner = new UIElementAdorner(this, this.suggestionList); }
/// <summary> /// 显示装饰器 /// </summary> /// <param name="viewItem"></param> private void AddAdorner(TreeViewItem viewItem) { if (_tempAdornerDic.ContainsKey(viewItem)) { _tempAdornerDic[viewItem].ShowAdorner(); } else { var ele = Util.Util.GetChildObject <ContentPresenter>(viewItem, "PART_Header"); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(ele); if (adornerLayer != null) { var adorner = new UIElementAdorner(ele); adornerLayer.Add(adorner); _tempAdornerDic.Add(viewItem, adorner); } } }
internal void CreateAdorner(string content, double width) { if (appointmentAdorner == null && ReferenceElement != null) { currentAdornerWidth = width; adornerViewModel = new AppointmentViewDragAdornerViewModel(content); var adornerView = new AppointmentViewDragAdorner { DataContext = adornerViewModel, Height = 30, Width = width }; appointmentAdorner = new UIElementAdorner(ReferenceElement, adornerView, AdornerLayer.GetAdornerLayer(ReferenceElement)); } }
/// <summary> /// Attaches a FormatBar to a RichtextBox /// </summary> /// <param name="richTextBox">The RichtextBox to attach to.</param> /// <param name="formatBar">The Formatbar to attach.</param> private void AttachFormatBarToRichtextBox( global::System.Windows.Controls.RichTextBox richTextBox, IRichTextBoxFormatBar formatBar ) { _richTextBox = richTextBox; _richTextBox.PreviewMouseMove += RichTextBox_PreviewMouseMove; //we cannot use the PreviewMouseLeftButtonUp event because of selection bugs. //we cannot use the MouseLeftButtonUp event because it is handled by the RichTextBox and does not bubble up to here, so we must //add a hander to the MouseUpEvent using the Addhandler syntax, and specify to listen for handled events too. _richTextBox.AddHandler( Mouse.MouseUpEvent, new MouseButtonEventHandler( RichTextBox_MouseButtonUp ), true ); _richTextBox.TextChanged += RichTextBox_TextChanged; _adorner = new UIElementAdorner<Control>( _richTextBox ); formatBar.Target = _richTextBox; _toolbar = formatBar; }
internal void DisposeAdorner() { appointmentAdorner?.Destroy(); appointmentAdorner = null; }
private void RemoveOverlayContent() { if (m_adorner != null) { AdornerLayer parentAdorner = AdornerLayer.GetAdornerLayer(this); parentAdorner.Remove(m_adorner); m_adorner.Remove(); m_adorner = null; } }