| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370 |
- using Microsoft.VisualBasic.CompilerServices;
- using MuchInfo.Chart.Data.Interfaces;
- using System;
- using System.Runtime.CompilerServices;
- using System.Threading;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Input;
- using System.Windows.Media;
- namespace MuchInfo.Chart.Infrastructure.Helpers
- {
- public class ChartToolTip
- {
- //#region Fields
- //private static Border border;
- //private static object monitorObject = RuntimeHelpers.GetObjectValue(new object());
- //private static Popup popupDialog;
- //private static TextBlock textBlock;
- //private static ToolTipContent ToolTipContent;
- //private static Thread wbiToolTip_626;
- //#endregion Fields
- //#region Properties
- //#region Private Static Properties
- //private static Border Border
- //{
- // get
- // {
- // return border;
- // }
- // set
- // {
- // var sizeChangedEventHandler = new SizeChangedEventHandler(OnBorderSizeChanged);
- // if (border != null)
- // {
- // border.SizeChanged -= sizeChangedEventHandler;
- // }
- // border = value;
- // if (border != null)
- // {
- // border.SizeChanged += (sizeChangedEventHandler);
- // }
- // }
- //}
- //#endregion Private Static Properties
- //#endregion Properties
- //#region Methods
- //#region Public Static Methods
- ////public static void ShowTip(UIElement aCtrl, MouseEventArgs e, string txt, Panel rootPanel)
- ////{
- //// object obj = monitorObject;
- //// ObjectFlowControl.CheckForSyncLockOnValueType(obj);
- //// Monitor.Enter(obj);
- //// try
- //// {
- //// bool flag = ToolTipContent == null || !ToolTipContent.UIElement.Equals(aCtrl);
- //// if (flag)
- //// {
- //// Clean(rootPanel);
- //// }
- //// flag = (ToolTipContent != null);
- //// if (flag)
- //// {
- //// ToolTipContent.Flag = true;
- //// }
- //// ToolTipContent = new ToolTipContent
- //// {
- //// Point = e.GetPosition(rootPanel),
- //// Title = txt,
- //// UIElement = aCtrl
- //// };
- //// flag = (wbiToolTip_626 == null);
- //// if (flag)
- //// {
- //// wbiToolTip_626 = new Thread(new ThreadStart(wbiToolTip_1677)) {IsBackground = (true)};
- //// wbiToolTip_626.Start();
- //// }
- //// }
- //// finally
- //// {
- //// Monitor.Exit(obj);
- //// }
- ////}
- //public static void ShowTip(UIElement control, MouseEventArgs args, IToolTipControlProvider controlProvider, Panel rootPanel)
- //{
- // object obj = ChartToolTip.monitorObject;
- // //ObjectFlowControl.CheckForSyncLockOnValueType(obj);
- // Monitor.Enter(obj);
- // try
- // {
- // if (ToolTipContent == null || ToolTipContent.UIElement != control)
- // {
- // Clean(rootPanel);
- // }
- // if (ToolTipContent != null)
- // {
- // ToolTipContent.Flag = true;
- // }
- // ToolTipContent = new ToolTipContent
- // {
- // Point = args.GetPosition(rootPanel),
- // ControlProvider = controlProvider,
- // UIElement = control
- // };
- // if (wbiToolTip_626 == null)
- // {
- // wbiToolTip_626 = new Thread(new ThreadStart(CreateToolTipThread));
- // wbiToolTip_626.IsBackground = (true);
- // wbiToolTip_626.Start();
- // }
- // }
- // finally
- // {
- // Monitor.Exit(obj);
- // }
- //}
- //public static void HideTip(UIElement aCtrl, Panel rootPanel)
- //{
- // try
- // {
- // object obj = monitorObject;
- // ObjectFlowControl.CheckForSyncLockOnValueType(obj);
- // Monitor.Enter(obj);
- // try
- // {
- // bool flag = ToolTipContent != null && ToolTipContent.UIElement == aCtrl;
- // if (flag)
- // {
- // ToolTipContent.Flag = true;
- // ToolTipContent = null;
- // Clean(rootPanel);
- // }
- // }
- // finally
- // {
- // Monitor.Exit(obj);
- // }
- // }
- // catch (Exception expr_7D)
- // {
- // ProjectData.SetProjectError(expr_7D);
- // ProjectData.ClearProjectError();
- // }
- //}
- //private static void Clean(Panel rootPanel)
- //{
- // if (popupDialog != null)
- // {
- // rootPanel.Children.Remove(popupDialog);
- // popupDialog = null;
- // border = null;
- // textBlock = null;
- // }
- //}
- ////private static void wbiToolTip_1677()
- ////{
- //// while (true)
- //// {
- //// try
- //// {
- //// Thread.Sleep(100);
- //// PopupManager.PopupRoot.Dispatcher.BeginInvoke(new Action(CreateToolTip));
- //// }
- //// catch (Exception expr_4E)
- //// {
- //// ProjectData.SetProjectError(expr_4E);
- //// ProjectData.ClearProjectError();
- //// }
- //// }
- ////}
- //#endregion Public Static Methods
- //#region Private Static Methods
- //private static void CreatePopUp()
- //{
- // //object obj = monitorObject;
- // //ObjectFlowControl.CheckForSyncLockOnValueType(obj);
- // ////Monitor.Enter(obj);
- // //try
- // //{
- // popupDialog = new Popup();
- // popupDialog.Visibility = Visibility.Hidden;
- // popupDialog.Name = "ToolTip_Pop";
- // PopupManager.PopupRoot.Children.Add(popupDialog);
- // var border = new Border();
- // border.BorderBrush = (new SolidColorBrush(Colors.Black));
- // border.BorderThickness = new Thickness(1.0);
- // border.Padding = new Thickness(3.0);
- // border.Background = new SolidColorBrush(Colors.LightGray);
- // popupDialog.Child = border;
- // textBlock = new TextBlock();
- // border.Child = textBlock;
- // Border = border;
- // //}
- // //finally
- // //{
- // // Monitor.Exit(obj);
- // //}
- //}
- //private static void CreateToolTip()
- //{
- // //object obj = monitorObject;
- // ////ObjectFlowControl.CheckForSyncLockOnValueType(obj);
- // //try
- // //{
- // // Monitor.Enter(obj);
- // if (ToolTipContent != null && DateTime.Compare(ToolTipContent.Date, DateTime.Now) < 0 && popupDialog == null)
- // {
- // if (popupDialog == null)
- // {
- // CreatePopUp();
- // }
- // if (ToolTipContent.ControlProvider != null)
- // {
- // Border.BorderBrush = (null);
- // Thickness thickness = new Thickness();
- // Border.BorderThickness = (thickness);
- // Border.Padding = (thickness);
- // Border.Background = (null);
- // Border.Child = ((UIElement)ToolTipContent.ControlProvider.GetControl());
- // }
- // else
- // {
- // Border.BorderBrush = (new SolidColorBrush(Colors.Black));
- // Border.BorderThickness = new Thickness(1.0);
- // Border.Padding = new Thickness(3.0);
- // Border.Background = (new SolidColorBrush(Colors.LightGray));
- // Border.Child = textBlock;
- // textBlock.Text = ToolTipContent.Title;
- // }
- // popupDialog.HorizontalOffset = ToolTipContent.Point.X + 12.0;
- // popupDialog.VerticalOffset = ToolTipContent.Point.Y + 12.0;
- // popupDialog.Visibility = Visibility.Visible;
- // popupDialog.IsOpen = true;
- // textBlock.UpdateLayout();
- // GeometryHelper.EnsureControlInApplication(popupDialog);
- // }
- // else
- // {
- // if (popupDialog != null && ToolTipContent != null && popupDialog.IsOpen && DateTime.Compare(ToolTipContent.Date.AddSeconds(5.0), DateTime.Now) < 0)
- // {
- // ToolTipContent = null;
- // Clean();
- // }
- // else
- // {
- // if (popupDialog != null && popupDialog.IsOpen && ToolTipContent == null)
- // {
- // Clean();
- // }
- // }
- // }
- // //}
- // //finally
- // //{
- // // Monitor.Exit(obj);
- // //}
- //}
- ////private static void CreateToolTipThread()
- ////{
- //// while (true)
- //// {
- //// try
- //// {
- //// Thread.Sleep(100);
- //// PopupManager.PopupRoot.Dispatcher.BeginInvoke(new Action(CreateToolTip));
- //// }
- //// catch
- //// {
- //// }
- //// }
- ////}
- //private static void OnBorderSizeChanged(object sender, SizeChangedEventArgs e)
- //{
- // try
- // {
- // GeometryHelper.EnsureControlInApplication(popupDialog);
- // }
- // catch (Exception ex)
- // {
- // throw ex;
- // }
- //}
- //#endregion Private Static Methods
- //#endregion Methods
- }
- internal class ToolTipContent
- {
- #region Constructors
- public ToolTipContent()
- {
- this.Date = DateTime.Now.AddSeconds(0.6);
- this.Flag = false;
- }
- #endregion Constructors
- #region Properties
- #region Public Properties
- public IToolTipControlProvider ControlProvider
- {
- get;
- set;
- }
- public DateTime Date
- {
- get;
- set;
- }
- public bool Flag
- {
- get;
- set;
- }
- public Point Point
- {
- get;
- set;
- }
- public string Title
- {
- get;
- set;
- }
- public UIElement UIElement
- {
- get;
- set;
- }
- #endregion Public Properties
- #endregion Properties
- }
- }
|