// PopUpの初期化 protected void SetPopupItem(PanelItem popInfo) { PopPanel.PopUpMode = true; PopPanel.SetBorderStyleFromSettings(); UpdatePopupPosition(popInfo); Popup.Width = Math.Max(popInfo.Width, PopWidth) + PopPanel.WidthMarginRight; if (popInfo.TopPos < scroll.ContentVerticalOffset) { Popup.MinHeight = Math.Max(0, popInfo.BottomPos - scroll.ContentVerticalOffset); } else { Popup.MinHeight = Math.Max(0, Math.Min(scroll.ContentVerticalOffset + scroll.ViewportHeight - popInfo.TopPos - PopPanel.HeightMarginBottom, popInfo.Height)); } PopPanel.Item = Activator.CreateInstance(popInfo.GetType(), popInfo.Data) as PanelItem; PopPanel.Item.Width = Popup.Width - PopPanel.WidthMarginRight; PopPanel.Item.Height = Math.Max(PopPanel.GetMaxRenderHeight(9999), Popup.MinHeight); Popup.Height = PopPanel.Item.Height + PopPanel.HeightMarginBottom; SetPopupItemEx(popInfo); UpdatePopupReDraw(); }
protected virtual void TooltipClear() { cnvs.Children.Remove(Tooltip); Tooltip.ToolTip = null; lastToolInfo = null; toolTipTimer.Stop(); }
protected virtual void TooltipWork() { if (IsTooltipEnabled == false) { return; } try { PanelItem toolInfo = GetTooltipItem(Mouse.GetPosition(cnvs)); if (toolInfo != lastToolInfo) { TooltipClear(); if (toolInfo == null) { return; } lastToolInfo = toolInfo; //ToolTipService.SetBetweenShowDelay()がいまいち思い通り動かないので、タイマーを挟む toolTipTimer.Interval = TimeSpan.FromMilliseconds(TooltipViweWait); toolTipTimer.Start(); } } catch (Exception ex) { TooltipClear(); MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
protected virtual void SetPopPanel(PanelItem popInfo) { PopPanel.PopUpMode = true; PopPanel.SetBorderStyleFromSettings(); PopPanel.Item = Activator.CreateInstance(popInfo.GetType(), popInfo.Data) as PanelItem; PopPanel.Item.Width = PopWidth - PopPanel.WidthMarginRight; PopPanel.Item.Height = Math.Max(PopPanel.GetMaxRenderHeight(9999), Popup.MinHeight); Popup.Height = PopPanel.Item.Height + PopPanel.HeightMarginBottom; UpdatePopupReDraw(); }
//Tooltipの初期化 protected void SetTooltipItem(PanelItem toolInfo) { Tooltip.Width = toolInfo.Width; Tooltip.Height = toolInfo.Height; Canvas.SetLeft(Tooltip, toolInfo.LeftPos); Canvas.SetTop(Tooltip, toolInfo.TopPos); Tooltip.ToolTip = null; SetTooltip(toolInfo); return; }
public static void SetItemVerticalPos(List <DateTime> timeList, PanelItem item, DateTime startTime, UInt32 duration, double MinutesHeight, bool NeedTimeOnly) { item.Height = duration * MinutesHeight / 60; var chkStartTime = NeedTimeOnly == false ? timeList[0] : startTime.Date.AddHours(startTime.Hour); int offset = NeedTimeOnly == false ? 0 : 60 * timeList.BinarySearch(chkStartTime); if (offset >= 0) { item.TopPos = (offset + (startTime - chkStartTime).TotalMinutes) * MinutesHeight; } }
// PopUpの初期化 protected void SetPopupItem(PanelItem popInfo) { UpdatePopupPosition(popInfo); Popup.Width = Math.Max(popInfo.Width, PopWidth); if (popInfo.TopPos < scroll.ContentVerticalOffset) { Popup.MinHeight = Math.Max(0, popInfo.TopPos + popInfo.Height - scroll.ContentVerticalOffset); } else { Popup.MinHeight = Math.Max(0, Math.Min(scroll.ContentVerticalOffset + scroll.ViewportHeight - popInfo.TopPos - PopPanel.HeightMarginBottom, popInfo.Height)); } SetPopup(popInfo); }
// PopUp が画面内に収まるように調整する protected void UpdatePopupPosition(PanelItem popInfo) { // offsetHが正のとき右にはみ出している double offsetH = popInfo.LeftPos + Popup.ActualWidth - (scroll.ContentHorizontalOffset + scroll.ViewportWidth); // 右にはみ出した分だけ左にずらす double left = popInfo.LeftPos - Math.Max(0, offsetH); // 左にはみ出てる場合はscrollエリアの左端から表示する Canvas.SetLeft(Popup, Math.Max(left, scroll.ContentHorizontalOffset)); // offsetVが正のとき下にはみ出している double offsetV = popInfo.TopPos + Popup.ActualHeight - (scroll.ContentVerticalOffset + scroll.ViewportHeight); // 下にはみ出した分だけ上にずらす double top = popInfo.TopPos - Math.Max(0, offsetV); // 上にはみ出てる場合はscrollエリアの上端から表示する Canvas.SetTop(Popup, Math.Max(top, scroll.ContentVerticalOffset)); UpdatePopupReDraw(); }
protected virtual void PopUpWork(bool onClick = false) { if (IsPopEnabled == false || PopOnOver == false && PopOnClick == false) { return; } try { Point cursorPos = Mouse.GetPosition(scroll); if (PopOnOver == false && onClick == true && lastPopInfo != null || cursorPos.X < 0 || cursorPos.Y < 0 || scroll.ViewportWidth < cursorPos.X || scroll.ViewportHeight < cursorPos.Y) { PopupClear(); return; } PanelItem popInfo = GetPopupItem(Mouse.GetPosition(cnvs), onClick); if (popInfo != lastPopInfo) { lastPopInfo = popInfo; if (popInfo == null || PopOnOver == false && onClick == false) { PopupClear(); return; } SetPopupItem(popInfo); Popup.Visibility = Visibility.Visible; } } catch (Exception ex) { PopupClear(); MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
protected virtual void SetTooltip(PanelItem toolInfo) { }
public virtual void ScrollToFindItem(PanelItem target_item, JumpItemStyle style = JumpItemStyle.None) { try { if (target_item == null) { return; } if ((style & JumpItemStyle.PanelNoScroll) == 0) { scroll.ScrollToHorizontalOffset(target_item.LeftPos - 100); scroll.ScrollToVerticalOffset(target_item.TopPos - 100); } style &= ~JumpItemStyle.PanelNoScroll; if (style == JumpItemStyle.None) { return; } //マーキング要求のあるとき if (style == JumpItemStyle.JumpTo) { var rect = new Rectangle(); rect.Stroke = Brushes.Red; rect.StrokeThickness = 5; rect.Opacity = 1; rect.Fill = Brushes.Transparent; rect.Effect = new System.Windows.Media.Effects.DropShadowEffect() { BlurRadius = 10 }; rect.Width = target_item.Width + 20; rect.Height = target_item.Height + 20; rect.IsHitTestVisible = false; Canvas.SetLeft(rect, target_item.LeftPos - 10); Canvas.SetTop(rect, target_item.TopPos - 10); Canvas.SetZIndex(rect, 20); // 一定時間枠を表示する var notifyTimer = new System.Windows.Threading.DispatcherTimer(); notifyTimer.Interval = TimeSpan.FromSeconds(0.1); int Brinks = 2 * 3; cnvs.Children.Add(rect); var sw = System.Diagnostics.Stopwatch.StartNew(); notifyTimer.Tick += (sender, e) => { if (sw.ElapsedMilliseconds > Settings.Instance.DisplayNotifyJumpTime * 1000) { notifyTimer.Stop(); cnvs.Children.Remove(rect); } else if (--Brinks >= 0) { rect.Visibility = (Brinks % 2) == 0 ? Visibility.Visible : Visibility.Hidden; } }; notifyTimer.Start(); } else if (style == JumpItemStyle.MoveTo && (Popup.Visibility != Visibility.Visible || target_item.IsPicked(Mouse.GetPosition(cnvs)) == false)) { var rect = new Rectangle(); rect.Stroke = target_item.BorderBrush; rect.StrokeThickness = 3; rect.Opacity = 2; rect.Fill = Brushes.Transparent; rect.Width = target_item.Width + 7; rect.Height = target_item.Height + 7; rect.IsHitTestVisible = false; Canvas.SetLeft(rect, target_item.LeftPos - 3); Canvas.SetTop(rect, target_item.TopPos - 3); Canvas.SetZIndex(rect, 20); // 一定時間枠を表示する var notifyTimer = new System.Windows.Threading.DispatcherTimer(); notifyTimer.Interval = TimeSpan.FromSeconds(0.1); cnvs.Children.Add(rect); var sw = System.Diagnostics.Stopwatch.StartNew(); notifyTimer.Tick += (sender, e) => { if (sw.ElapsedMilliseconds > Settings.Instance.DisplayNotifyJumpTime * 1000 || rect.Opacity < 0.2) { notifyTimer.Stop(); cnvs.Children.Remove(rect); } else { rect.Opacity *= 0.8; } }; notifyTimer.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
protected virtual Pen BorderPen(PanelItem info) { return(null); }
protected virtual Rect BorderRect(PanelItem info) { return(new Rect(info.LeftPos - selfLeft, info.TopPos - selfTop, info.Width + borderThickness.Right, info.Height + borderThickness.Bottom)); }
protected virtual Rect BorderPenRect(PanelItem info) { return(new Rect(info.LeftPos - selfLeft + borderMax / 2, info.TopPos - selfTop + borderMax / 2, info.Width + borderThickness.Right - borderMax, info.Height + borderThickness.Bottom - borderMax)); }
protected virtual Rect ContentRect(PanelItem info) { return(new Rect(info.LeftPos - selfLeft + borderMargin.Left, info.TopPos - selfTop + borderMargin.Top, Math.Max(0, info.Width - borderMargin.Width), Math.Max(0, info.Height - borderMargin.Height))); }
protected virtual void SetPopupItemEx(PanelItem popInfo) { }
protected virtual Rect TextRenderRect(PanelItem info) { return(new Rect(info.LeftPos + txtMargin.Left, info.TopPos + txtMargin.Top, Math.Max(0, info.Width - txtMargin.Width), Math.Max(0, info.Height - txtMargin.Height))); }
protected virtual void PopupClear() { Popup.Visibility = Visibility.Hidden; lastPopInfo = null; }