示例#1
0
 public override void OnItemPlaced(List <UndoRedoAction> undoPipe)
 {
     lock (board.ParentControl)
     {
         base.OnItemPlaced(undoPipe);
         PointA.OnItemPlaced(undoPipe);
         PointB.OnItemPlaced(undoPipe);
         PointC.OnItemPlaced(undoPipe);
         PointD.OnItemPlaced(undoPipe);
     }
 }
示例#2
0
 public override void RemoveItem(List <UndoRedoAction> undoPipe)
 {
     lock (board.ParentControl)
     {
         base.RemoveItem(undoPipe);
         PointA.RemoveItem(undoPipe);
         PointB.RemoveItem(undoPipe);
         PointC.RemoveItem(undoPipe);
         PointD.RemoveItem(undoPipe);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = PointA.GetHashCode();
         hashCode = (hashCode * 397) ^ PointB.GetHashCode();
         hashCode = (hashCode * 397) ^ PointC.GetHashCode();
         hashCode = (hashCode * 397) ^ PointD.GetHashCode();
         return(hashCode);
     }
 }
示例#4
0
        /// <summary> 刷新显示最后的几条 </summary>
        public void ShowLast(List <string> collection, int xMargin = 150, int count = 600)
        {
            Func <int, double> convertFuncX = l =>
            {
                if (collection.Count < count)
                {
                    l = count - collection.Count + l;
                }

                return(((double)l / count) * xMargin + (150 - xMargin) / 2);
            };

            Func <double, double> convertFuncY = l =>
            {
                //return (50 * (l - 1848) + 0 * (2448 - l)) / (2448 - 1848);

                return(((l - 2048) / 150) * 10 + 50 / 2);
            };

            int total = collection.Count;

            int skip = total > count ? total - count : 0;

            Application.Current.Dispatcher.Invoke(() =>
            {
                var cs = collection.Skip(skip).ToList();

                List <ICurveEntitySource> collections = new List <ICurveEntitySource>();

                CardiogramCurveEntitySource entity = new CardiogramCurveEntitySource();

                for (int i = 0; i < cs.Count; i++)
                {
                    PointC point = new PointC();

                    point.X = convertFuncX(i);

                    double d;
                    bool result = double.TryParse(cs[i], out d);
                    if (result)
                    {
                        point.Y    = convertFuncY(d);
                        point.Text = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                        entity.Source.Add(point);
                    }
                }

                collections.Add(entity);

                this.CardiogramCollection = collections;
            });
        }
示例#5
0
        public void evalOut()
        {
            PointC p1;

            outParamTest(out p1);
            Assert.AreEqual("hello", p1.s);


            PointC p2 = new PointC(); //这里是否new不重要

            outParamTest(out p2);
            Assert.AreEqual("hello", p2.s);
        }
        /// <summary> 刷新显示最后的几条 </summary>
        public ICurveEntitySource ShowLast(List <string> collection, int xMargin = 150, int count = 600, int addValue = 0)
        {
            Func <int, double> convertFuncX = l =>
            {
                if (collection.Count < count)
                {
                    l = count - collection.Count + l;
                }

                return(((double)l / count) * xMargin + (150 - xMargin) / 2);
            };

            Func <double, double> convertFuncY = l =>
            {
                l = l + addValue;
                //return (50 * (l - 1848) + 0 * (2448 - l)) / (2448 - 1848);
                return(((l - 2048) / 150) * 10 + 50 / 2);
            };

            int total = collection.Count;

            int skip = total > count ? total - count : 0;

            //List<ICurveEntitySource> collections = new List<ICurveEntitySource>();



            var cs = collection.Skip(skip).ToList();

            CardiogramCurveEntitySource entity = new CardiogramCurveEntitySource();

            for (int i = 0; i < cs.Count; i++)
            {
                PointC point = new PointC();

                point.X = convertFuncX(i);

                double d;
                bool   result = double.TryParse(cs[i], out d);

                if (result)
                {
                    point.Y    = convertFuncY(d);
                    point.Text = i.ToString();;
                    entity.Source.Add(point);
                }
            }

            return(entity);
        }
示例#7
0
文件: Program.cs 项目: aodlf/CS
        static void Main(string[] args)
        {
            PointS p1 = new PointS(1, 2);
            PointC p2 = new PointC(1, 2);
            PointS p3 = p1; // 값에 의한 복사
            PointC p4 = p2; // 참조에 의한 복사

            //Console.WriteLine("{0} {1}", p1.x, p1.y);
            //Console.WriteLine("{0} {1}", p2.x, p2.y);

            p3.x = 11;
            p4.x = 11;

            Console.WriteLine("{0} {1}", p1.x, p3.x);
            Console.WriteLine("{0} {1}", p2.x, p4.x);
        }
示例#8
0
        public void RefreshCurveData()
        {
            List <ICurveEntitySource> collection = new List <ICurveEntitySource>();

            CurveEntitySource entity = new CurveEntitySource();

            entity.Text   = "长度(km)";
            entity.Color  = Brushes.Red;
            entity.Marker = new CirclePointMarker();

            entity.Marker.Fill = Brushes.Red;

            for (int i = 0; i < 20; i++)
            {
                PointC point = new PointC();
                point.X    = i;
                point.Y    = i * i;
                point.Text = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                entity.Source.Add(point);

                this.MinValue = this.MinValue > point.X ? point.X : this.MinValue;
                this.MaxValue = this.MaxValue < point.X ? point.X : this.MaxValue;
            }
            collection.Add(entity);

            entity        = new CurveEntitySource();
            entity.Text   = "重量(kg)";
            entity.Color  = Brushes.Orange;
            entity.Marker = new T5PointMarker();

            entity.Marker.Fill = Brushes.Orange;

            for (int i = 0; i < 20; i++)
            {
                PointC point = new PointC();
                point.X    = i;
                point.Y    = (20 - i) * (20 - i);
                point.Text = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                entity.Source.Add(point);

                this.MinValue = this.MinValue > point.X ? point.X : this.MinValue;
                this.MaxValue = this.MaxValue < point.X ? point.X : this.MaxValue;
            }
            collection.Add(entity);

            this.Collection = collection;
        }
示例#9
0
        public void ConditionalOperators_Test()
        {
            PointC point1 = null;
            PointC point2 = null;
            var    point3 = new PointC();

            //null conditional
            Check.That(point1?.message).IsNull();
            point1 = new PointC();
            Check.That(point1?.message?.Append("")).IsNull();
            var stringBuilder = new StringBuilder("1er message");

            point1.message = stringBuilder;
            Check.That(point1.message).IsNotNull().And.IsEqualTo(stringBuilder);
            //null coalescing
            Check.That(point2 ?? point3).IsEqualTo(point3);
            Check.That(point1 ?? point3).IsEqualTo(point1);
        }
示例#10
0
        public void Methods_Test()
        {
            //default values
            var cSharp6Class = new CSharp6Class();

            cSharp6Class.MethodWithDefaultValues();
            Check.That(cSharp6Class.Param1).IsEqualTo("param1 default value");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("param3 default value");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //optional parameters
            cSharp6Class.MethodWithOptionalParameter("parameter 0", "parameter 1");
            Check.That(cSharp6Class.Param0).IsEqualTo("parameter 0");
            Check.That(cSharp6Class.Param1).IsEqualTo("parameter 1");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("param3 default value");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //named parameters
            cSharp6Class.MethodWithOptionalParameter(param3: "Paramètre 3", param1: "Paramètre 1", param0: "Paramètre 0");
            Check.That(cSharp6Class.Param0).IsEqualTo("Paramètre 0");
            Check.That(cSharp6Class.Param1).IsEqualTo("Paramètre 1");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("Paramètre 3");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //by reference
            var    point1 = new PointC();
            PointC point2 = cSharp6Class.MethodParameterByRef(ref point1);

            Check.That(point1).IsEqualTo(point2).And.IsNull();
            //by value
            var    point3 = new PointC();
            PointC point4 = cSharp6Class.MethodParameterByValue(point3);

            Check.That(point4).IsNotEqualTo(point3).And.IsNull();
            Check.That(point3).IsNotNull();
            //out : if point5 is not changed by method, then a compilation error is raised
            var point5 = new PointC();

            cSharp6Class.MethodParameterOut(out point5);
            Check.That(point5).IsNull();
        }
示例#11
0
        public void Arrays_Struct_Test()
        {
            //Arrays
            var vowels = new char[5];

            vowels[0] = 'a';
            vowels[1] = 'e';
            vowels[2] = 'i';
            vowels[3] = 'o';
            vowels[4] = 'u';
            Check.That(vowels).HasSize(5).And.ContainsExactly('a', 'e', 'i', 'o', 'u');
            //Default values, values vs references
            var ps = new PointS[100];

            Check.That(ps[0].x).IsEqualTo(0);
            var pc = new PointC[100];

            Check.ThatCode(() =>
            {
                var a1 = pc[0].x;
            }).Throws <NullReferenceException>();
        }
示例#12
0
        public void RefreshCurveBigData(bool init = false)
        {
            List <ICurveEntitySource> collection = new List <ICurveEntitySource>();

            CurveEntitySource entity = new CurveEntitySource();

            entity.Text  = "Y";
            entity.Color = Brushes.Red;
            //entity.Marker = new CirclePointMarker();
            entity.Marker = null;

            entity.IsAnimal = false;
            //entity.Marker.Fill = Brushes.Red;

            for (int i = 0; i < 2000; i++)
            {
                PointC point = new PointC();
                point.X = i;


                point.Y = (Math.Sin(i * 0.02) + Math.Cos(i * 0.5) + Math.Sin(i * 0.1) + Math.Sin(i * 0.01)) * 50 + 200;

                //point.Y = Math.Cos(i * 0.006)*150+ (Math.Cos(i * 0.5) + Math.Sin(i * 0.1) + Math.Sin(i * 0.01))*50 + 200;

                point.Text = i.ToString();
                entity.Source.Add(point);

                if (init)
                {
                    this.MinValueBig = this.MinValueBig > point.X ? point.X : this.MinValueBig;
                    this.MaxValueBig = this.MaxValueBig < point.X ? point.X : this.MaxValueBig;
                }
            }
            collection.Add(entity);


            this.CollectionData = collection;
        }
示例#13
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <param name="sTime"></param>
        /// <param name="eTime"></param>
        private void ProcessDataQuery <T>(int id, DateTime sTime, DateTime eTime)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var result = HisDataManager.Manager.GetQueryService(mDatabase).ReadAllValue <T>(id, sTime, eTime);

            sw.Stop();

            OpMessage = string.Format(Res.Get("OpMsgFormate"), result.Count, sw.ElapsedMilliseconds);

            //Debug.Print("查询耗时:" + sw.ElapsedMilliseconds);

            CurveEntitySource entity = new CurveEntitySource();

            entity.Text              = this.SelectTag;
            entity.Color             = System.Windows.Media.Brushes.Red;
            entity.Marker            = new CirclePointMarker();
            entity.Marker.Fill       = System.Windows.Media.Brushes.Red;
            entity.Marker.Visibility = Visibility.Hidden;


            double maxx = double.MinValue, maxy = double.MinValue, minx = double.MaxValue, miny = double.MaxValue;

            List <HisDataPoint> ltmp = new List <HisDataPoint>();

            for (int i = 0; i < result.Count; i++)
            {
                object   value;
                DateTime time;
                byte     qu = 0;
                value = result.GetValue(i, out time, out qu);

                minx = minx > i ? i : minx;
                maxx = maxx < i ? i : maxx;

                double dtmp = ConvertValue(value);

                miny = miny > dtmp ? dtmp : miny;
                maxy = maxy < dtmp ? dtmp : maxy;

                PointC point = new PointC();
                point.X    = i;
                point.Y    = dtmp;
                point.Text = time.ToString("dd HH:mm:ss");
                entity.Source.Add(point);

                ltmp.Add(new HisDataPoint()
                {
                    DateTime = time, Quality = qu, Value = value
                });
                /// mDatas.Add(new HisDataPoint() { DateTime = time, Quality = qu, Value = value });
            }
            Datas = ltmp;

            List <SplitItem> yitems  = new List <SplitItem>(5);

            maxy = maxy * 1.2;
            miny = miny - Math.Abs(miny) * 0.2;

            MaxXValue   = maxx;
            MaxYValue   = maxy;
            MinXValue   = minx;
            MinYValue   = miny;
            ChartSource = new List <ICurveEntitySource>()
            {
                entity
            };

            var dval = (maxy - miny) / 5;

            for (int i = 1; i <= 5; i++)
            {
                yitems.Add(new SplitItem()
                {
                    SpliteType = SplitItemType.Normal, Text = (miny + i * dval).ToString("f2"), IsShowText = true, Value = miny + i * dval, Color = System.Windows.Media.Brushes.SkyBlue
                });
            }
            yitems.Add(new SplitItem()
            {
                SpliteType = SplitItemType.HeighLight, Text = (miny + (maxy - miny) / 2).ToString("f2"), IsShowText = true, Value = miny + (maxy - miny) / 2, Color = System.Windows.Media.Brushes.DeepSkyBlue, IsShowTrangle = true
            });

            YLineItems = yitems;
            result.Dispose();
        }
示例#14
0
 public PointC MethodParameterByRef(ref PointC point)
 {
     point = null;
     return(point);
 }
示例#15
0
 public PointC MethodParameterByValue(PointC point)
 {
     point = null;
     return(point);
 }
示例#16
0
        public Triangle(Vector2 a, Vector2 b, Vector2 c)
        {
            m_originalPositions = new Vector2[] { a, b, c };
            m_centerOfMassShift = Vector2.Zero;

            // At first I used Heron's Formula to find the area of the triangle, but this
            // used a lot of square roots (a total of four). Then I realized that I already
            // have the code for finding the height of the triangle by using the triangle's
            // extent over the normal unit axis of the base vector for the height. This
            // cuts down the number of square root operations down to one. Using doubles to
            // run the calculations of Heron's Formula as my base case, I tested this method
            // and compared it to using floats to calculate Heron's Formula. This is XNA,
            // we're supposed to use floats instead of doubles. Long story short, the error
            // on this method was about an order of magnitude smaller than the Heron Formula
            // with floats. To be honest, the error of Heron's Formula with floats was
            // really small to begin with.

            // In this case, I'm going to normalize the normal vector into a unit vector
            // myself. The reason I'm doing this is because we need to caluculate the length
            // of a vector to turn it into a unit vector. This adds a square root operation,
            // which isn't needed because the already got that measurement when we grabed the
            // length of the base.
            Vector2 baseVector = a - b;                                                 // Use points a & b to create the base of the triangle
            float   baseLength = baseVector.Length();                                   // Get the length of the base
            Vector2 unitVert   = baseVector.NormalVector(false) / baseLength;           // Get the perpendicular unit axis of the base
            float   height     = Range.FindExtent(unitVert, a, c).Length;               // a is on the base line, and

            // c is the only missing point
            // one half base times height
            m_area = 0.5f * baseLength * height;


            // The center of mass of a triangle with uniform density is the median point
            // of the triangle. This was the easiest way I was able to find to give me
            // the position bases on the points making up the triangle's bounds. Since
            // all shapes have a center of mass at (0, 0), we need to set the center of
            // mass shift to the negative of the center of mass of the original points
            // that created the triangle.
            Vector2 centerOfMass = (a + b + c) / 3f;

            m_centerOfMassShift = -centerOfMass;

            PointA = a + CenterOfMassShift;
            PointB = b + CenterOfMassShift;
            PointC = c + CenterOfMassShift;


            // Find a radius from the center of mass that contains
            // all points in the triangle.
            Vector2 l = PointA;

            if (l.LengthSquared() < PointB.LengthSquared())
            {
                l = PointB;
            }
            if (l.LengthSquared() < PointC.LengthSquared())
            {
                l = PointC;
            }

            m_quickRadius = l.Length() + 1f;
        }
示例#17
0
        private void ProcessDataQuery <T>(int id, List <DateTime> times)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var result = HisDataManager.Manager.GetQueryService(mDatabase).ReadValue <T>(id, times, Cdy.Tag.QueryValueMatchType.Linear);

            sw.Stop();



            OpMessage = string.Format(Res.Get("OpMsgFormate"), result.Count, sw.ElapsedMilliseconds);

            CurveEntitySource entity = new CurveEntitySource();

            entity.Text              = this.SelectTag;
            entity.Color             = System.Windows.Media.Brushes.Red;
            entity.Marker            = new CirclePointMarker();
            entity.Marker.Fill       = System.Windows.Media.Brushes.Red;
            entity.Marker.Visibility = Visibility.Hidden;


            double maxx = double.MinValue, maxy = double.MinValue, minx = double.MaxValue, miny = double.MaxValue;

            Dictionary <DateTime, Tuple <object, int> > vtmps = new Dictionary <DateTime, Tuple <object, int> >();

            List <HisDataPoint> ltmp = new List <HisDataPoint>();

            int i = 0;

            for (i = 0; i < result.Count; i++)
            {
                object   value;
                DateTime time;
                byte     qu = 0;
                value = result.GetValue(i, out time, out qu);
                vtmps.Add(time, new Tuple <object, int>(value, qu));
            }
            i = 0;
            foreach (var vv in times)
            {
                object   value = 0;
                DateTime time  = vv;
                byte     qu    = 255;
                if (vtmps.ContainsKey(vv))
                {
                    value = vtmps[vv].Item1;
                    qu    = (byte)vtmps[vv].Item2;
                }

                minx = minx > i ? i : minx;
                maxx = maxx < i ? i : maxx;

                miny = miny > Convert.ToDouble(value) ? Convert.ToDouble(value) : miny;
                maxy = maxy < Convert.ToDouble(value) ? Convert.ToDouble(value) : maxy;

                PointC point = new PointC();
                point.X    = i;
                point.Y    = Convert.ToDouble(value);
                point.Text = time.ToString("dd HH:mm:ss");
                entity.Source.Add(point);

                ltmp.Add(new HisDataPoint()
                {
                    DateTime = time, Quality = qu, Value = value
                });
                i++;
            }

            Datas = ltmp;

            List <SplitItem> yitems = new List <SplitItem>(5);

            maxy = maxy * 1.2;
            miny = miny - Math.Abs(miny) * 0.2;

            MaxXValue   = maxx;
            MaxYValue   = maxy;
            MinXValue   = minx;
            MinYValue   = miny;
            ChartSource = new List <ICurveEntitySource>()
            {
                entity
            };

            var dval = (maxy - miny) / 5;

            for (i = 1; i <= 5; i++)
            {
                yitems.Add(new SplitItem()
                {
                    SpliteType = SplitItemType.Normal, Text = (miny + i * dval).ToString("f2"), IsShowText = true, Value = miny + i * dval, Color = System.Windows.Media.Brushes.SkyBlue
                });
            }
            yitems.Add(new SplitItem()
            {
                SpliteType = SplitItemType.HeighLight, Text = (miny + (maxy - miny) / 2).ToString("f2"), IsShowText = true, Value = miny + (maxy - miny) / 2, Color = System.Windows.Media.Brushes.DeepSkyBlue, IsShowTrangle = true
            });



            YLineItems = yitems;
        }
 public bool Equals(Rectangle other)
 {
     return(PointA.Equals(other.PointA) && PointB.Equals(other.PointB) && PointC.Equals(other.PointC) && PointD.Equals(other.PointD));
 }
示例#19
0
 public PointC MethodParameterOut(out PointC point)
 {
     point = null; //je suis obligé de faire une modification sur l'objet out
     return(point);
 }