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


C# Rectangle.GetValue方法代码示例

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


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

示例1: SetRectanglesStatus

        //设置直通和交换的rectangle中的不同显示
        public void SetRectanglesStatus(int flag, Rectangle rect)
        {
            Line line1 = new Line();
            line1.Stroke = new SolidColorBrush(Colors.Black);
            line1.SetValue(Canvas.TopProperty, (double)rect.GetValue(Canvas.TopProperty));
            line1.SetValue(Canvas.LeftProperty, (double)rect.GetValue(Canvas.LeftProperty));

            Line line2 = new Line();
            line2.Stroke = new SolidColorBrush(Colors.Black);
            line2.SetValue(Canvas.TopProperty, (double)rect.GetValue(Canvas.TopProperty));
            line2.SetValue(Canvas.LeftProperty, (double)rect.GetValue(Canvas.LeftProperty));

            //交换
            if (flag == 2)
            {
                line1.X1 = 0;
                line1.Y1 = rect.Height / 6;
                line1.X2 = rect.Width;
                line1.Y2 = (rect.Height * 5) / 6;

                line2.X1 = 0;
                line2.Y1 = (rect.Height * 5) / 6;
                line2.X2 = rect.Width;
                line2.Y2 = rect.Height / 6;

                MainWindow.mainwindow.canvas.Children.Add(line1);
                MainWindow.mainwindow.canvas.Children.Add(line2);

            }
            //直通
            else if (flag == 1)
            {

                line1.X1 = 0;
                line1.Y1 = rect.Height / 6;
                line1.X2 = rect.Width;
                line1.Y2 = rect.Height / 6;

                line2.X1 = 0;
                line2.Y1 = (rect.Height * 5) / 6;
                line2.X2 = rect.Width;
                line2.Y2 = (rect.Height * 5) / 6;
                MainWindow.mainwindow.canvas.Children.Add(line1);
                MainWindow.mainwindow.canvas.Children.Add(line2);

            }
        }
开发者ID:ForeverSc,项目名称:NewIOTSystem,代码行数:48,代码来源:CreateView.cs

示例2: Check_Default

		public void Check_Default ()
		{
			DependencyProperty property = DependencyProperty.Register ("MyProp", typeof (int), typeof(Rectangle), new PropertyMetadata (100));
			Rectangle r = new Rectangle ();
			r.SetValue (property, 10);
			Assert.AreEqual (10, r.GetValue (property), "#1");
			r.ClearValue (property);
			Assert.AreEqual (100, r.GetValue (property), "#2");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:DependencyPropertyAttachedTest.cs

示例3: Check_Default_Nullable

		public void Check_Default_Nullable ()
		{
			DependencyProperty property = DependencyProperty.Register ("MyPropNullable", typeof (int?), typeof(Rectangle), null);
			Rectangle r = new Rectangle ();
			r.SetValue (property, 10);
			Assert.AreEqual (10, r.GetValue (property), "#1");
			r.ClearValue (property);
			Assert.AreEqual (null, r.GetValue (property), "#2");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:DependencyPropertyAttachedTest.cs

示例4: ComplexTarget13

		public void ComplexTarget13 ()
		{
			bool complete = false;
			Storyboard sb = (Storyboard) XamlReader.Load (
@"<Storyboard xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
              xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
	<DoubleAnimation Duration=""0:0:0.05"" Storyboard.TargetName=""target"" Storyboard.TargetProperty=""(UIElement.Height)"" To=""50"" />
</Storyboard>");
			sb.Completed += delegate { complete = true; };
			Rectangle g = new Rectangle ();
			Storyboard.SetTarget (sb, g);
			Enqueue (() => { TestPanel.Children.Add (g); TestPanel.Resources.Add ("a", sb); });
			Enqueue (() => sb.Begin ());
			EnqueueConditional (() => complete);
			Enqueue (() => Assert.AreEqual (Double.NaN, g.GetValue (Rectangle.HeightProperty)));
			Enqueue (() => { TestPanel.Children.Clear (); TestPanel.Resources.Clear (); });
			EnqueueTestComplete ();
		}
开发者ID:snorp,项目名称:moon,代码行数:18,代码来源:StoryboardTest.cs

示例5: EncodeCanvas

        private void EncodeCanvas(Canvas canvas, Rectangle icon, string name, string filePath)
        {
            RenderTargetBitmap targetBitmap =
                new RenderTargetBitmap((int)canvas.Width,
                                       (int)canvas.Height,
                                       96d, 96d,
                                       PixelFormats.Pbgra32);
            var isolatedVisual = new DrawingVisual();
            var canvasLeft = (icon.GetValue(Canvas.LeftProperty) as double?) ?? 0d;
            canvasLeft = double.IsNaN(canvasLeft) ? 0d : canvasLeft;
            var canvasTop = (icon.GetValue(Canvas.TopProperty) as double?) ?? 0d;
            canvasTop = double.IsNaN(canvasTop) ? 0d : canvasTop;
            using (var drawing = isolatedVisual.RenderOpen())
            {
                drawing.DrawRectangle(new VisualBrush(icon), null, new Rect(new Point(canvasLeft, canvasTop), new Size((int)icon.Width, (int)icon.Height)));
            }
            targetBitmap.Render(isolatedVisual);

            // add the RenderTargetBitmap to a Bitmapencoder
            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(targetBitmap));

            // save file to disk
            string fileOut = filePath + "\\" + name;
            using (var fs = File.Open(fileOut, FileMode.OpenOrCreate))
            {
                encoder.Save(fs);
            }
        }
开发者ID:tanaka-takayoshi,项目名称:Metro-Icons-Maker,代码行数:29,代码来源:Window1.xaml.cs

示例6: DrawAnnotations

        public void DrawAnnotations()
        {
            RemoveAllAnnotations();
            var xAxis = Chart.XAxis as DateTimeAxis;
            if (xAxis == null || xAxis.ActualRange == null) return;
            foreach (var sensor in _viewModel.SensorsToCheckMethodsAgainst)
            {
                var lastLeft = -1d;
                foreach (var source in sensor.CurrentState.Changes.Where(change => change.Key >= xAxis.ActualRange.EffectiveMinimum && change.Key <= xAxis.ActualRange.EffectiveMaximum).OrderBy(x => x.Key))
                {
                    var changes = source.Value.Aggregate("",
                                                     (current, next) =>
                                                     string.Format("\r\n{0}",
                                                                   ChangeReason.ChangeReasons.FirstOrDefault(
                                                                       x => x.ID == next)));
                    var rect = new Rectangle
                                   {
                                       Width = 5,
                                       Height = 5,
                                       ToolTip =
                                       string.Format("[{0}] {1}{2}", sensor.Name, source.Key, changes),
                                       StrokeThickness = 0d,
                                       Fill = new SolidColorBrush(sensor.Colour),
                                       Opacity = 0.7d
                                   };
                    rect.SetValue(Canvas.TopProperty, 20d);
                    rect.SetValue(Canvas.LeftProperty, xAxis.GetDataValueAsRenderPositionWithoutZoom(source.Key) - rect.Width / 2);
                    if ((double)rect.GetValue(Canvas.LeftProperty) - lastLeft > 2d)
                    {
                        _annotations.Add(rect);
                        lastLeft = (double)rect.GetValue(Canvas.LeftProperty);
                    }

                }
            }
            Debug.Print("There are {0} annotations to draw", _annotations.Count);
            foreach (var annotation in _annotations)
            {
                _canvas.Children.Add(annotation);
            }
        }
开发者ID:rwlamont,项目名称:AllItUp,代码行数:41,代码来源:ChangesAnnotatorBehaviour.cs


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