当前位置: 首页>>代码示例>>C#>>正文


C# Canvas.SetTop方法代码示例

本文整理汇总了C#中System.Windows.Controls.Canvas.SetTop方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SetTop方法的具体用法?C# Canvas.SetTop怎么用?C# Canvas.SetTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.Canvas的用法示例。


在下文中一共展示了Canvas.SetTop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoopControl

        public LoopControl(MainWindow window)
            : base()
        {
            InitializeComponent();

            Window = window;
            loopBody = new ExperimentGraph();

            Canvas = new Canvas()
            {
                AllowDrop = true,
                ClipToBounds = true,
                Style = (Style)this.FindResource("CanvasStyle")
            };

            Canvas.Drop += CanvasDrop;
            Canvas.MouseDown += Canvas_MouseDown;
            Canvas.MouseMove += Canvas_MouseMove;
            Canvas.MouseUp += Canvas_MouseUp;

            StartLoopNodeControl startNode = new StartLoopNodeControl() { Height = 30, Width = 30 };
            Canvas.SetTop(startNode, 50);
            Canvas.SetLeft(startNode, 50);

            startNode.MouseLeftButtonDown += Window.node_MouseLeftButtonDown;
            startNode.MouseLeftButtonUp += Window.node_MouseLeftButtonUp;
            startNode.MouseMove += Window.node_MouseMove;
            startNode.LostMouseCapture += Window.node_LostMouseCapture;

            Canvas.Children.Add(startNode);
            loopBody.Nodes.Add(startNode);
        }
开发者ID:AnDDen,项目名称:Hydrology,代码行数:32,代码来源:LoopControl.xaml.cs

示例2: GeoMap

        /// <summary>
        /// Initializes a new instance of the <see cref="GeoMap"/> class.
        /// </summary>
        public GeoMap()
        {
            Canvas = new Canvas();
            Map = new Canvas();
            Canvas.Children.Add(Map);
            Content = Canvas;

            Canvas.SetBinding(WidthProperty,
                new Binding { Path = new PropertyPath(ActualWidthProperty), Source = this });
            Canvas.SetBinding(HeightProperty,
                new Binding { Path = new PropertyPath(ActualHeightProperty), Source = this });

            Lands = new Dictionary<string, MapData>();

            SetCurrentValue(DefaultLandFillProperty, new SolidColorBrush(Color.FromArgb(200,255,255,255)));
            SetCurrentValue(LandStrokeProperty, new SolidColorBrush(Color.FromArgb(30, 55,55, 55)));
            SetCurrentValue(LandStrokeThicknessProperty, 1.3d);
            SetCurrentValue(AnimationsSpeedProperty, TimeSpan.FromMilliseconds(500));
            SetCurrentValue(BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 96, 125, 138)));
            SetCurrentValue(GradientStopCollectionProperty, new GradientStopCollection
            {
                new GradientStop(Color.FromArgb(100,2,119,188), 0d),
                new GradientStop(Color.FromRgb(2,119,188), 1d),
            });
            SetCurrentValue(HeatMapProperty, new Dictionary<string, double>());
            SetCurrentValue(GeoMapTooltipProperty, new DefaultGeoMapTooltip {Visibility = Visibility.Hidden});
            Canvas.Children.Add(GeoMapTooltip);

            SizeChanged += (sender, e) =>
            {
                Draw();
            };

            MouseWheel += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                e.Handled = true;
                var rt = Map.RenderTransform as ScaleTransform;
                var p = rt == null ? 1 : rt.ScaleX;
                p += e.Delta > 0 ? .05 : -.05;
                p = p < 1 ? 1 : p;
                var o = e.GetPosition(this);
                if (e.Delta > 0) Map.RenderTransformOrigin = new Point(o.X/ActualWidth,o.Y/ActualHeight);
                Map.RenderTransform = new ScaleTransform(p, p);
            };

            MouseDown += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                DragOrigin = e.GetPosition(this);
            };

            MouseUp += (sender, e) =>
            {
                if (!EnableZoomingAndPanning) return;

                var end = e.GetPosition(this);
                var delta = new Point(DragOrigin.X - end.X, DragOrigin.Y - end.Y);

                var l = Canvas.GetLeft(Map) - delta.X;
                var t = Canvas.GetTop(Map) - delta.Y;

                if (DisableAnimations)
                {
                    Canvas.SetLeft(Map, l);
                    Canvas.SetTop(Map, t);
                }
                else
                {
                    Map.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation(l, AnimationsSpeed));
                    Map.BeginAnimation(Canvas.TopProperty, new DoubleAnimation(t, AnimationsSpeed));
                }
            };
        }
开发者ID:beto-rodriguez,项目名称:Live-Charts,代码行数:79,代码来源:GeoMap.cs


注:本文中的System.Windows.Controls.Canvas.SetTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。