微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

silverlight code tmp

static public void AddClip(Canvas panel)         {             double width = double.IsNaN(panel.Width) ? panel.ActualWidth : panel.Width;             double height = double.IsNaN(panel.Height) ? panel.ActualHeight : panel.Height;             RectangleGeometry clippingRectangle = new RectangleGeometry();             clippingRectangle.Rect = new Rect(0,width,height);             panel.Clip = clippingRectangle;         } public class DragHandler     {         private UIElement _toDrag;         public DragHandler(UIElement toDrag)         {             toDrag.MouseLeftButtonDown += delegate(object sender,MouseButtonEventArgs e) { OnMouseLeftButtonDown(e); };             toDrag.MouseLeftButtonUp += delegate(object sender,MouseButtonEventArgs e) { OnMouseLeftButtonUp(e); };             toDrag.MouseMove += delegate(object sender,MouseEventArgs e) { OnMouseMove(e); };             this._toDrag = toDrag;         }         public bool IsDragging = false;           private void OnMouseLeftButtonDown(MouseButtonEventArgs e)         {             if (!IsDragging)             {                 e.Handled = true;                  _toDrag.CaptureMouse();                 IsDragging = true;                   _origin = _prevIoUsPosition = e.GetPosition((UIElement)((FrameworkElement)_toDrag).Parent);                  // Raise the DragStarted event                 bool success = false;                 try                 {                     DragEventHandler handler = DragStarted;                     if (handler != null)                     {                         handler(this,new DragEventArgs(_origin.X,_origin.Y));                     }                     success = true;                 }                 finally                 {                     // Cancel the drag if the DragStarted handler Failed                     if (!success)                     {                         CancelDrag();                     }                 }             }         }           private void OnMouseLeftButtonUp(MouseButtonEventArgs e)         {             if (IsDragging )             {                 e.Handled = true;                 IsDragging = false;                 _toDrag.ReleaseMouseCapture();                 RaiseDragCompleted(false);             }         }          private void OnMouseMove(MouseEventArgs e)         {             if (IsDragging)             {                   Point position = e.GetPosition((UIElement)((FrameworkElement)_toDrag).Parent);                  if (position != _prevIoUsPosition)                 {                     e.Handled = true;                      // Raise the DragDelta event                     DragEventHandler handler = DragDelta;                     if (handler != null)                     {                         handler(this,new DragEventArgs(position.X - _prevIoUsPosition.X,position.Y - _prevIoUsPosition.Y));                     }                      _prevIoUsPosition = position;                 }             }         }          public void CancelDrag()          {              if (IsDragging)              {                  IsDragging = false;                  RaiseDragCompleted(true);              }          }            private void RaiseDragCompleted(bool canceled)          {              DragEventHandler handler = DragCompleted;              if (handler != null)              {                  DragEventArgs args = new DragEventArgs(                      _prevIoUsPosition.X - _origin.X,_prevIoUsPosition.Y - _origin.Y);                  handler(this,args);              }          }          private Point _origin;           private Point _prevIoUsPosition;           public event DragEventHandler DragStarted;            public event DragEventHandler DragDelta;            public event DragEventHandler DragCompleted;     }     public class DragEventArgs : EventArgs     {          public double HorizontalOffset { get; private set; }                  public double VerticalOffset { get; private set; }                   public DragEventArgs(double horizontalOffset,double verticalOffset)         {             HorizontalOffset = horizontalOffset;             VerticalOffset = verticalOffset;         }     }        public delegate void DragEventHandler(object sender,DragEventArgs e);   }   { _rightDrag = new MChart.Common.DragHandler(_rightHandle);                          _leftHandle.Cursor = _rightHandle.Cursor = Cursors.SizeWE;               _leftDragDelta = delegate(object sender,MChart.Common.DragEventArgs e) { OnDragLeft(e); };             _rightDragDelta = delegate(object sender,MChart.Common.DragEventArgs e) { OnDragRight(e); };             _DragDoneWrap = delegate(object sender,MChart.Common.DragEventArgs e) { OnDragDoneWrap(e); };              _leftDrag.DragDelta += _leftDragDelta;             _rightDrag.DragDelta += _rightDragDelta;             _leftDrag.DragCompleted += _DragDoneWrap;             _rightDrag.DragCompleted += _DragDoneWrap;  static public string ZOOM = @"
 
 "; } //For show tip { this.Parent.MouseMove += new MouseEventHandler(Parent_MouseMove); this.Parent.MouseLeave += new MouseEventHandler(Parent_MouseLeave); } //TabButton { 
               
                   #FCFFFFFF 
                 
                   #F4FFFFFF 
                 
                   #E0FFFFFF 
                 
                   #B2FFFFFF 
                 
                   #7FFFFFFF 
                 
                   #FCFFFFFF 
                 
                   #EAFFFFFF 
                 
                   #D8FFFFFF 
                 
                   #4CFFFFFF 
                 
                   #B3FFFFFF 
                 
                   #3CFFFFFF 
                   } 
                                  

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐