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


C# Tuple.Min方法代码示例

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


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

示例1: NNResultsVisual

            public NNResultsVisual(double width, double height, Tuple<Point, double, bool>[] values, bool shouldOutlineNonMatches)
            {
                #region Min/Max Value, Colors

                bool hasNegative = values.Any(o => o.Item2 < 0);
                double maxValue = Math.Max(Math.Abs(values.Min(o => o.Item2)), Math.Abs(values.Max(o => o.Item2)));
                if (maxValue < 1d)      // should never be greater, but leave alone if it is
                {
                    maxValue = 1d;
                }

                Color positiveColor = hasNegative ? Colors.Blue : Colors.Black;
                Color negativeColor = Colors.Red;

                #endregion
                #region XY Scale

                double radius = ((width + height) / 2) / 100;

                bool hasNegativePosition = values.Any(o => o.Item1.X < 0 || o.Item1.Y < 0);
                double maxX = Math.Max(Math.Abs(values.Min(o => o.Item1.X)), Math.Abs(values.Max(o => o.Item1.X)));
                double maxY = Math.Max(Math.Abs(values.Min(o => o.Item1.Y)), Math.Abs(values.Max(o => o.Item1.Y)));

                // If they are somewhat near 1, then cap at 1
                if (maxX > .5 && maxX < 1) maxX = 1;
                if (maxY > .5 && maxY < 1) maxY = 1;

                double offsetX = hasNegativePosition ? (width / 2) : 0;
                double offsetY = hasNegativePosition ? (height / 2) : 0;

                double scaleX = maxX > 0d ? (width - offsetX) / maxX : 1;
                double scaleY = maxY > 0d ? (height - offsetY) / maxY : 1;

                #endregion

                Pen matchPen = new Pen(Brushes.Lime, radius * .32);
                Pen otherPen = shouldOutlineNonMatches ? new Pen(new SolidColorBrush(Color.FromArgb(192, 192, 192, 192)), radius * .18) : null;

                _visual = new DrawingVisual();
                using (DrawingContext dc = _visual.RenderOpen())
                {
                    foreach (var value in values)
                    {
                        Color color = value.Item2 < 0 ? negativeColor : positiveColor;
                        double alpha = Math.Abs(value.Item2) / maxValue;
                        Color finalColor = Color.FromArgb(Convert.ToByte(alpha * 255), color.R, color.G, color.B);

                        Point point = new Point(offsetX + (value.Item1.X * scaleX), offsetY + (value.Item1.Y * scaleY));

                        Pen pen = value.Item3 ? matchPen : otherPen;

                        dc.DrawEllipse(new SolidColorBrush(finalColor), pen, point, radius, radius);
                    }
                }
            }
开发者ID:charlierix,项目名称:AsteroidMiner,代码行数:55,代码来源:EncogXOR.xaml.cs

示例2: ShortMinOnTwoTuple

 public void ShortMinOnTwoTuple()
 {
     var sut = new Tuple<short, short>(1, 2);
       short expected = sut.AsEnumerable().Cast<short>().Min();
       short actual = sut.Min(x => (short) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleMinTests.Short.cs

示例3: IntegerMinOnTwoTuple

 public void IntegerMinOnTwoTuple()
 {
     var sut = new Tuple<int, int>(1, 2);
       int expected = sut.AsEnumerable().Cast<int>().Min();
       int actual = sut.Min(x => (int) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleMinTests.Integer.cs

示例4: DecimalMinOnTwoTuple

 public void DecimalMinOnTwoTuple()
 {
     var sut = new Tuple<decimal, decimal>(1, 2);
       decimal expected = sut.AsEnumerable().Cast<decimal>().Min();
       decimal actual = sut.Min(x => (decimal) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleMinTests.Decimal.cs

示例5: DoubleMinOnTwoTuple

 public void DoubleMinOnTwoTuple()
 {
     var sut = new Tuple<double, double>(1, 2);
       double expected = sut.AsEnumerable().Cast<double>().Min();
       double actual = sut.Min(x => (double) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleMinTests.Double.cs

示例6: LongMinOnTwoTuple

 public void LongMinOnTwoTuple()
 {
     var sut = new Tuple<long, long>(1, 2);
       long expected = sut.AsEnumerable().Cast<long>().Min();
       long actual = sut.Min(x => (long) x);
       Assert.AreEqual(expected, actual);
 }
开发者ID:nicenemo,项目名称:Noaber,代码行数:7,代码来源:TupleMinTests.Long.cs


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