Exemplo n.º 1
0
        /// <summary>
        /// Метод для отрисовки ковра Серпинского.
        /// </summary>
        /// <param name="x"> Левая координата квадрата. </param>
        /// <param name="y"> Верхняя координата квадрата. </param>
        /// <param name="len"> Длина стороны квадрата. </param>
        /// <param name="useless"> Бесполезный параметр(из-за наследования(не знаю как обойти это)). </param>
        public override void Draw(int x, int y, int len, double useless = 0)
        {
            if (_currStep++ < Steps)
            {
                // Расчет нового цвета.
                int r = StartRGB[0] + StepRBG[0] * _currStep;
                int g = StartRGB[1] + StepRBG[1] * _currStep;
                int b = StartRGB[2] + StepRBG[2] * _currStep;

                Pen pen = new Pen(Color.FromArgb(Alpha, r, g, b), 1);
                Gr.FillRectangle(pen.Brush, x - len / 2, y - len / 2, len, len);

                // Проверка на то имеет ли смысл рисовать дальше.
                if ((int)(len / Ratio) != 0)
                {
                    // Отрисовка квадратов вокруг текущего.
                    Draw(x - len, y - len, (int)(len / Ratio));
                    _currStep--;
                    Draw(x, y - len, (int)(len / Ratio));
                    _currStep--;
                    Draw(x + len, y - len, (int)(len / Ratio));
                    _currStep--;
                    Draw(x - len, y, (int)(len / Ratio));
                    _currStep--;
                    Draw(x + len, y, (int)(len / Ratio));
                    _currStep--;
                    Draw(x - len, y + len, (int)(len / Ratio));
                    _currStep--;
                    Draw(x, y + len, (int)(len / Ratio));
                    _currStep--;
                    Draw(x + len, y + len, (int)(len / Ratio));
                    _currStep--;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Метод для отрисовки множества Кантора.
        /// </summary>
        /// <param name="x"> Левая координата отрезка.</param>
        /// <param name="y"> Верхняя координата отрезка.</param>
        /// <param name="len"> Длина отрезка. </param>
        /// <param name="distance"> Дистанция между отрезками. </param>
        public override void Draw(int x, int y, int len, double distance)
        {
            if (_currStep++ < Steps)
            {
                // Конец текущего отрезка
                int x1 = x + len;

                // Расчет нового цвета.
                int r = StartRGB[0] + StepRBG[0] * _currStep;
                int g = StartRGB[1] + StepRBG[1] * _currStep;
                int b = StartRGB[2] + StepRBG[2] * _currStep;

                Pen pen = new Pen(Color.FromArgb(Alpha, r, g, b), Width);

                Gr.DrawLine(pen, x, y, x1, y);

                // Проверка на то имеет ли смысл рисовать дальше.
                if ((int)(len / Ratio) != 0)
                {
                    // Отрисовка левого отрезка.
                    Draw(x, y + (int)distance, (int)(len / Ratio), distance);
                    _currStep--;

                    // Отрисовка правого отрезка.
                    Draw(x + len * 2 / 3, y + (int)distance, (int)(len / Ratio), distance);
                    _currStep--;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Метод для отрисовки фрактального дерева.
        /// </summary>
        /// <param name="x"> Координата начала ветки которую надо отрисовать. </param>
        /// <param name="y"> Координата начала ветки которую надо отрисовать. </param>
        /// <param name="len"> Длина ветки. </param>
        /// <param name="angle"> Угол наклона текущей ветки. </param>
        public override void Draw(int x, int y, int len, double angle = 0)
        {
            if (_currStep++ < Steps)
            {
                // Координаты конца ветки.
                int x1 = x + (int)(len * Math.Sin(angle));
                int y1 = y + (int)(len * Math.Cos(angle));

                // Расчет нового цвета.
                int r = StartRGB[0] + StepRBG[0] * _currStep;
                int g = StartRGB[1] + StepRBG[1] * _currStep;
                int b = StartRGB[2] + StepRBG[2] * _currStep;

                Pen pen = new Pen(Color.FromArgb(Alpha, r, g, b), Width);

                Gr.DrawLine(pen, x, y, x1, y1);

                // Проверка на то имеет ли смысл рисовать дальше.
                if ((int)(len / Ratio) != 0)
                {
                    // Ветка "влево".
                    Draw(x1, y1, (int)(len / Ratio), angle + LeftAngle);
                    _currStep--;
                    // Ветка "вправо".
                    Draw(x1, y1, (int)(len / Ratio), angle + RightAngle);
                    _currStep--;
                }
            }
        }
Exemplo n.º 4
0
        public override void Draw(ref Bitmap bmp, PointF start, PointF end, float factor)
        {
            Factor.CountFactor(ref start, factor);
            Factor.CountFactor(ref end, factor);

            Gr = Graphics.FromImage(bmp);
            var redPen = new Pen(Color.Red, 1 * factor);

            Gr.DrawLine(redPen, start, end);
            var startD = start;
            var endD   = end;

            var dy = ((startD.Y - endD.Y) / Settings.Default.sizeReductionOfLine);
            var dx = ((startD.X - endD.X) / Settings.Default.sizeReductionOfLine);

            startD    = endD;
            startD.Y += dx;
            startD.X -= dy;

            var bluePen = new Pen(Color.Blue, 1 * factor);

            Gr.DrawLine(bluePen, startD, endD); //отрисовка на конце перпендикулярчика

            endD   = end;
            startD = start;
            endD   = startD;


            endD.Y += dx;
            endD.X -= dy;

            Gr.DrawLine(bluePen, startD, endD); //отрисовка на начале перпендикулярчика

            Gr.Dispose();
        }
Exemplo n.º 5
0
 public void dibujarPoligono(Poligono poligono, Punto factorCentro)
 {
     if (poligono.Tipo_Poligono == Poligono.TipoPoligono.Abierto)
     {
         Gr.DrawLines(Lapiz, getPointFArray(poligono, factorCentro));
     }
     else
     {
         Gr.DrawPolygon(Lapiz, getPointFArray(poligono, factorCentro));
     }
 }
Exemplo n.º 6
0
        public override void Draw(ref Bitmap bmp, PointF start, float factor)
        {
            Gr = Graphics.FromImage(bmp);
            var pn    = new Pen(Color.Black, 1 * factor);
            var sizeW = SizeW;
            var sizeH = SizeH;

            Factor.CountFactor(ref start, factor);
            Factor.CountFactor(ref sizeW, factor);
            Factor.CountFactor(ref sizeH, factor);

            Gr.DrawEllipse(pn, start.X, start.Y, sizeW, sizeH);
        }
Exemplo n.º 7
0
 public void TestPatellaImages()
 {
     // Open database(or create if not exits)
     using (var db = Gr.GetLiteDb())
     {
         const string fileLocation  = @"C: \Users\avierin\Documents\tmp\BoneImages\Patella\Patella_";
         var          patellaImages = db.GetCollection <BoneImage>("Patella");
         for (int i = 0; i < patellaImages.Count(); i++)
         {
             Assert.IsNotNull(patellaImages.FindOne(x => x.FilePath == fileLocation + i));
         }
     }
 }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            int      N   = 5;
            float    M   = 0;
            float    Cmx = 0;
            float    Cmy = 0;
            Bitmap   BM;
            Graphics Gr;

            float[]    X, Y, m;
            Random     rnd    = new Random();
            int        Lx     = pictureBox1.Width;
            int        Ly     = pictureBox1.Height;
            SolidBrush Brush1 = new SolidBrush(Color.Gray);
            SolidBrush Brush2 = new SolidBrush(Color.Red);

            BM = new Bitmap(Lx, Ly);
            Gr = Graphics.FromImage(BM);
            X  = new float[N];
            Y  = new float[N];
            m  = new float[N];
            // Задаем координаты и массы для тел в системе
            for (int i = 0; i < N; i++)
            {
                X[i] = Convert.ToSingle(rnd.Next(Lx));
                Y[i] = Convert.ToSingle(rnd.Next(Ly));
                m[i] = rnd.Next(0, 1000);
            }
            // Находим массу всей системы
            for (int i = 0; i < N; i++)
            {
                M += m[i];
            }
            // Находим центр масс
            for (int i = 0; i < N; i++)
            {
                Cmx += m[i] * X[i] / M;
                Cmy += m[i] * Y[i] / M;
            }
            // Отображаем материальные точки
            for (int i = 0; i < N; i++)
            {
                Gr.FillEllipse(Brush1, X[i], Y[i], 10, 10);
            }
            // Отображаем центр масс
            Gr.FillEllipse(Brush2, Cmx, Cmy, 10, 10);

            pictureBox1.Image = BM;
        }
Exemplo n.º 9
0
        public void RemplirLiteDB()
        {
            var boneSeeder = new BoneRepository();
            var boneSeeds  = boneSeeder.GetBones();

            // Open database(or create if not exits)
            using (var db = Gr.GetLiteDb())
            {
                // Get bones collection
                var bones = db.GetCollection <Bone>("bones");

                // Insert new bone document (Id will be auto-incremented)
                boneSeeds.ForEach(b => bones.Upsert(new Bone()
                {
                    Name = b
                }));


                // Index document using a document property
                bones.EnsureIndex(x => x.Name);

                // Use Linq to query documents
                var results = new List <Bone>(bones.Find(x => x.Name.StartsWith("P")));

                Assert.IsNotNull(results.Find(b => b.Name == "Patella"));


                var boneImages = db.GetCollection <BoneImage>("boneImages");

                var boneImageRep = new BoneImageFileRepository();
                foreach (var boneName in boneSeeds)
                {
                    var boneImagePaths = boneImageRep.GetAllFilePath(boneName);
                    Assert.IsFalse(boneImagePaths.Count == 0);

                    Bone bone = bones.FindOne(x => x.Name == boneName);
                    foreach (string path in boneImagePaths)
                    {
                        var boneImage = new BoneImage()
                        {
                            BoneId = bone.Id, FilePath = path
                        };
                        boneImages.Insert(boneImage);
                    }
                }

                boneImages.EnsureIndex(x => x.BoneId);
            }
        }
Exemplo n.º 10
0
 public PicChannelMixerWindow(BitmapSource bs)
 {
     InitializeComponent();
     this.bs             = bs;
     Content.DataContext = picChannelMixerControl;
     R.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Rg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Rb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Gr.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     G.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Gb.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Br.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     Bg.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
     B.AddHandler(Slider.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Slider_MouseLeftButtonUp), true);
 }
Exemplo n.º 11
0
        public BoneGame()
        {
            _score            = 0;
            _bones            = _boneRepository.GetBones();
            _pickedBoneNumber = new List <int>();
            _questions        = new List <WhatQuestion>();

            using (var db = Gr.GetLiteDb())
            {
                _questions.AddRange(db.GetCollection <WhatQuestion>("whatQuestions").FindAll());
            }

            _questions.Shuffle();
            _currentQuestion = _questions[0];
        }
Exemplo n.º 12
0
        public override void Draw(ref Bitmap bmp, PointF start, float factor)
        {
            var pen = new Pen(Color.Red, 1 * factor);

            if (Points != null && Points.Count > 0)
            {
                Gr = Graphics.FromImage(bmp);
                var past = FirstLocationPoint;
                foreach (var point in Points)
                {
                    Gr.DrawLine(pen, past, point);
                    past = point;
                }
            }
        }
Exemplo n.º 13
0
        public void DrawPoint(ref Bitmap bmp, PointF p, float factor)
        {
            Factor.CountFactor(ref p, factor);

            Gr = Graphics.FromImage(bmp);
            Gr.DrawLine(Pens.Red,
                        p.X + Settings.Default.sizeOfCross,
                        p.Y + Settings.Default.sizeOfCross,
                        p.X - Settings.Default.sizeOfCross,
                        p.Y - Settings.Default.sizeOfCross);
            Gr.DrawLine(Pens.Red,
                        p.X - Settings.Default.sizeOfCross,
                        p.Y + Settings.Default.sizeOfCross,
                        p.X + Settings.Default.sizeOfCross,
                        p.Y - Settings.Default.sizeOfCross);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Метод для отрисовки кривой Коха. Не понял почему не полностью стирается предыдущий
        /// отрезок.
        /// </summary>
        /// <param name="x"> Координата точки которая делит отрезок 1:2. </param>
        /// <param name="y"> Координата точки которая делит отрезок 1:2. </param>
        /// <param name="len"> Длина стороны треугольника. </param>
        /// <param name="directionAngle"> Направление в котором нужно рисовать. </param>
        public override void Draw(int x, int y, int len, double directionAngle = 0)
        {
            if (_currStep++ < Steps)
            {
                // Расчет нового цвета.
                int r = StartRGB[0] + StepRBG[0] * _currStep;
                int g = StartRGB[1] + StepRBG[1] * _currStep;
                int b = StartRGB[2] + StepRBG[2] * _currStep;

                Pen pen = new Pen(Color.FromArgb(Alpha, r, g, b), Width);

                // Первая прямая.
                if (_currStep == 1)
                {
                    Gr.DrawLine(pen, x, y, x + len, y);
                    Draw(x + (int)(len * Math.Cos(directionAngle) / Ratio), y, (int)(len / Ratio), directionAngle + Math.PI / 3);
                }
                else
                {
                    // Координаты точек для отрисовки треугольника.
                    int x1 = x + (int)(len * Math.Cos(directionAngle));
                    int y1 = y - (int)(len * Math.Sin(directionAngle));
                    int x2 = x + (int)(len * Math.Cos(directionAngle - Math.PI / 3));
                    int y2 = y - (int)(len * Math.Sin(directionAngle - Math.PI / 3));

                    // Рисуем, рисуем, стираем.
                    Gr.DrawLine(pen, x, y, x1, y1);
                    Gr.DrawLine(pen, x1, y1, x2, y2);
                    Gr.DrawLine(BackGroundPen, x, y, x2, y2);

                    // Проверка на то имеет ли смысл рисовать дальше.
                    if ((int)(len / Ratio) != 0)
                    {
                        // В фотографии koch попытался показать что происходит.
                        Draw(x + (int)((Ratio - 1) * len * Math.Cos(directionAngle + 2 * Math.PI / 3) / Ratio), y - (int)((Ratio - 1) * len * Math.Sin(directionAngle + 2 * Math.PI / 3) / Ratio), (int)(len / Ratio), directionAngle);
                        _currStep--;
                        Draw(x + (int)((x1 - x) / Ratio), y + (int)((y1 - y) / Ratio), (int)(len / Ratio), directionAngle + Math.PI / 3);
                        _currStep--;
                        Draw(x1 + (int)((x2 - x1) / Ratio), (int)(y1 + (y2 - y1) / Ratio), (int)(len / Ratio), directionAngle - Math.PI / 3);
                        _currStep--;
                        Draw(x + (int)((Ratio + 1) * len * Math.Cos(directionAngle - Math.PI / 3) / Ratio), y - (int)((Ratio + 1) * len * Math.Sin(directionAngle - Math.PI / 3) / Ratio), (int)(len / Ratio), directionAngle);
                        _currStep--;
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void FavPlaces_Click(object sender, RoutedEventArgs e)
        {
            var FavPlaces = Gr.FindName("FavPlaces") as SavedPlacesUserControl;

            if (FavPlaces == null)
            {
                if (MapView.MapControl.FindName("OrDesSelector") as DraggablePin == null)
                {
                    Gr.Children.Add(new SavedPlacesUserControl()
                    {
                        Name = "FavPlaces", Width = 180, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left
                    });
                }
            }
            else
            {
                Gr.Children.Remove(FavPlaces);
            }
        }
Exemplo n.º 16
0
 private string GetPartOfSpeechText(WordInfo info)
 {
     if (info != null)
     {
         if (info.flex == null && info.indent != null && info.nom != null)
         {
             info.flex = context.Flexes.FirstOrDefault(x => x.type == info.nom.type && x.flex == info.nom.reestr.Substring(info.nom.reestr.Length - info.indent.indent));
         }
         if (info.flex != null)
         {
             Gr gr = context.Gr.FirstOrDefault(x => x.id == info.indent.gr_id);
             if (gr != null)
             {
                 var grInfo = gr.GetType().GetProperty($"field{info.flex.field2 + 3}").GetValue(gr, null);
                 return(grInfo.ToString());
             }
         }
     }
     return("");
 }
Exemplo n.º 17
0
        private async void DirBtn_Click(object sender, RoutedEventArgs e)
        {
            var dir = Gr.FindName("DirectionUC") as View.DirectionsControls.DirectionsMainUserControl;

            if (dir == null)
            {
                if (MapView.MapControl.FindName("OrDesSelector") as DraggablePin == null)
                {
                    Gr.Children.Add(new View.DirectionsControls.DirectionsMainUserControl()
                    {
                        Name = "DirectionUC", VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left
                    });
                    await new MessageDialog("Navigate the point added on your screen to the Origin point and click on it. Then move it to Destination point and click on it again. Select navigation mode from top left menu and hit the navigate button.").ShowAsync();
                }
            }
            else
            {
                Gr.Children.Remove(dir);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Метод для отрисовки треугольника Серпинского.
        /// </summary>
        /// <param name="x"> Координата центра треугольника который надо отрисовать. </param>
        /// <param name="y"> Координата центра треугольника который надо отрисовать. </param>
        /// <param name="len"> Длина стороны треугольника. </param>
        /// <param name="upper"> Направление треугольника. </param>
        public override void Draw(int x, int y, int len, double upper = 1)
        {
            if (_currStep++ < Steps)
            {
                // Расчет нового цвета.
                int r = StartRGB[0] + StepRBG[0] * _currStep;
                int g = StartRGB[1] + StepRBG[1] * _currStep;
                int b = StartRGB[2] + StepRBG[2] * _currStep;

                Pen pen = new Pen(Color.FromArgb(Alpha, r, g, b), Width);

                // Рисуем треугольник направленный вверх.
                if (upper == 1)
                {
                    Gr.DrawLine(pen, x, (int)(y - len / Math.Sqrt(3)), x + len / 2, (int)(y + len / Math.Sqrt(3) / 2));
                    Gr.DrawLine(pen, x, (int)(y - len / Math.Sqrt(3)), x - len / 2, (int)(y + len / Math.Sqrt(3) / 2));
                    Gr.DrawLine(pen, x - len / 2, (int)(y + len / Math.Sqrt(3) / 2), x + len / 2, (int)(y + len / Math.Sqrt(3) / 2));

                    Draw(x, y, (int)(len / Ratio), upper - 1);
                    _currStep--;
                }
                // Рисуем треугольник направленный вниз.
                else
                {
                    Gr.DrawLine(pen, x, (int)(y + len / Math.Sqrt(3)), x + len / 2, (int)(y - len / Math.Sqrt(3) / 2));
                    Gr.DrawLine(pen, x, (int)(y + len / Math.Sqrt(3)), x - len / 2, (int)(y - len / Math.Sqrt(3) / 2));
                    Gr.DrawLine(pen, x - len / 2, (int)(y - len / Math.Sqrt(3) / 2), x + len / 2, (int)(y - len / Math.Sqrt(3) / 2));

                    // Проверка на то имеет ли смысл рисовать дальше.
                    if ((int)(len / Ratio) != 0)
                    {
                        Draw(x, (int)(y - len / Math.Sqrt(3)), (int)(len / Ratio), upper);
                        _currStep--;
                        Draw(x - len / 2, (int)(y + len / Math.Sqrt(3) / 2), (int)(len / Ratio), upper);
                        _currStep--;
                        Draw(x + len / 2, (int)(y + len / Math.Sqrt(3) / 2), (int)(len / Ratio), upper);
                        _currStep--;
                    }
                }
            }
        }
Exemplo n.º 19
0
        public void TestWhatQuestionAreUnique()
        {
            var boneListRep = new BoneRepository();
            var boneList    = boneListRep.GetBones();

            List <WhatQuestion> questions = new List <WhatQuestion>();

            using (var db = Gr.GetLiteDb())
            {
                var questionsRep = db.GetCollection <WhatQuestion>("whatQuestions");
                foreach (var bone in boneList)
                {
                    var boneQuestions = new List <WhatQuestion>(questionsRep.Find(q => q.Answer == bone));

                    for (int i = 1; i < boneQuestions.Count; i++)
                    {
                        questionsRep.Delete(boneQuestions[i].Id);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public override void Draw(ref Bitmap bmp, PointF start, PointF end, float factor)
        {
            Factor.CountFactor(ref start, factor);
            Factor.CountFactor(ref end, factor);
            if (start.X > end.X)
            {
                var x = start.X;
                start.X = end.X;
                end.X   = x;
            }
            if (start.Y > end.Y)
            {
                var y = start.Y;
                start.Y = end.Y;
                end.Y   = y;
            }
            Gr = Graphics.FromImage(bmp);
            var blackPen = new Pen(Color.Black, 1 * factor);

            Gr.DrawRectangle(blackPen, start.X, start.Y, end.X - start.X, end.Y - start.Y);
            Gr.Dispose();
        }
        //平均梯度
        private void button1_Click(object sender, EventArgs e)
        {
            double Gr, Gg, Gb;
            int    delt_xr, delt_yr, delt_xg, delt_yg, delt_xb, delt_yb;

            double map_r, map_g, map_b;

            map_r = map_g = map_b = 0;

            for (int i = 0; i < newBitmap.Width - 1; i++)
            {
                for (int j = 0; j < newBitmap.Height - 1; j++)
                {
                    Color pixel   = newBitmap.GetPixel(i, j);
                    Color pixel_x = newBitmap.GetPixel(i + 1, j);
                    Color pixel_y = newBitmap.GetPixel(i, j + 1);

                    delt_xr = (pixel_x.R - pixel.R) * (pixel_x.R - pixel.R);
                    delt_yr = (pixel_y.R - pixel.R) * (pixel_y.R - pixel.R);

                    delt_xg = (pixel_x.G - pixel.G) * (pixel_x.G - pixel.G);
                    delt_yg = (pixel_y.G - pixel.G) * (pixel_y.G - pixel.G);

                    delt_xb = (pixel_x.B - pixel.B) * (pixel_x.B - pixel.B);
                    delt_yb = (pixel_y.B - pixel.B) * (pixel_y.B - pixel.B);

                    map_r += Math.Sqrt(delt_xr + delt_yr);
                    map_g += Math.Sqrt(delt_xg + delt_yg);
                    map_b += Math.Sqrt(delt_xb + delt_yb);
                }
            }

            Gr = map_r / ((newBitmap.Width - 1) * (newBitmap.Height - 1));
            Gg = map_g / ((newBitmap.Width - 1) * (newBitmap.Height - 1));
            Gb = map_b / ((newBitmap.Width - 1) * (newBitmap.Height - 1));

            MessageBox.Show("融合图三通道平均梯度" + "\r\n" + "Gr:" + Gr.ToString() + "   " + "Gg:" + Gg.ToString() + "   " + "Gb:" + Gb.ToString());
        }
Exemplo n.º 22
0
 public void dibujarPunto(Punto punto)
 {
     Gr.DrawRectangle(Lapiz, (float)punto.X, (float)punto.Y, 1, 1);
 }
Exemplo n.º 23
0
 public ILemmaInfo CreateInfo(string[] grIndex)
 {
     return(new LemmaInfo(Lemma, Gr.Select(x => grIndex[x]).ToArray()));
 }
Exemplo n.º 24
0
        //private void Enable_Click(object sender, EventArgs e)
        //{

        //}

        //private void Disable_Click(object sender, EventArgs e)
        //{
        //    //Disable.Enabled = false;
        //    ////Enable.Enabled = true;

        //    //OutContext();
        //    //Digitizer.Context.Enabled = false;
        //}

        //private void Disconnect_Click(object sender, EventArgs e)
        //{
        //   // string RemoveCOntextID = "FirstContext";
        //   // if (Disable.Enabled)
        //   // {
        //   //     Disable.Enabled = false;
        //   //    // Enable.Enabled = true;
        //   //     OutContext();
        //   //     Digitizer.Context.Enabled = false;
        //   // }
        //   // Digitizer.Connected = false;
        //   // Digitizer.RemoveContext(ref RemoveCOntextID);
        //   // Disable.Enabled = false;
        //   // //Enable.Enabled = false;
        //   // Disconnect.Enabled = false;
        //   //// Connect.Enabled = true;
        //   // //chkDigitise.CheckState = CheckState.Unchecked;
        //   //// chkDigitise.Enabled = false;

        //   // // Disable the Digitizer



        //}

        //private void OutContext() //Cursor has moved out of the context
        //{

        //    lblX.Enabled = false;
        //    lblY.Enabled = false;
        //    lblZ.Enabled = false;
        //    lblCursor.Enabled = false;
        //    lblPressure.Enabled = false;
        //    lblTangentPressure.Enabled = false;
        //    lblAzimuth.Enabled = false;
        //    lblAltitude.Enabled = false;
        //    lblTwist.Enabled = false;
        //    lblPitch.Enabled = false;
        //    lblRoll.Enabled = false;
        //    lblYaw.Enabled = false;
        //    prgX.Enabled = false;
        //    prgY.Enabled = false;
        //    prgZ.Enabled = false;
        //    prgPressure.Enabled = false;
        //    prgTangentPressure.Enabled = false;
        //}

        //private void InContext() //Cursor has moved into context
        //{
        //    lblX.Enabled = true;
        //    lblY.Enabled = true;
        //    lblZ.Enabled = true;
        //    lblCursor.Enabled = true;
        //    lblPressure.Enabled = true;
        //    lblTangentPressure.Enabled = true;
        //    lblAzimuth.Enabled = true;
        //    lblAltitude.Enabled = true;
        //    lblTwist.Enabled = true;
        //    lblPitch.Enabled = true;
        //    lblRoll.Enabled = true;
        //    lblYaw.Enabled = true;
        //    prgX.Enabled = true;
        //    prgY.Enabled = true;
        //    prgZ.Enabled = true;
        //    prgPressure.Enabled = true;
        //    prgTangentPressure.Enabled = true;
        //    //If digitising Then timClear.Enabled = False
        //}

        //private void sldGranularity_Scroll(object sender, EventArgs e)
        //{
        //    Digitizer.PktGranularity = (short)sldGranularity.Value;

        //}

        //private void chkDigitise_CheckedChanged(object sender, EventArgs e)
        //{



        //}

        // Event Handlers for the Digitizer Object

        public void PacketArrival(ref IntPtr ContextHandle, ref int Cursor_Renamed, ref int X, ref int Y, ref int Z, ref int Buttons, ref int Pressure, ref int TangentPressure, ref int Azimuth, ref int Altitude, ref int Twist, ref int Pitch, ref int Roll, ref int Yaw, ref int PacketSerial, ref int PacketTim)
        {
            //Show current stats. Note that it's a good idea not to update
            //if not necessary - 100+ updates a second can really hurt performance

            //tmpl = System.Math.Abs(X);

            //if (tmpl != prgX.Value)
            //{
            //    if (tmpl <= prgX.Maximum)
            //        prgX.Value = tmpl;
            //}
            //tmpl = System.Math.Abs(Y);
            //if (tmpl != prgY.Value)
            //{
            //    if (tmpl <= prgY.Maximum)
            //        prgY.Value = tmpl;
            //}
            //tmpl = System.Math.Abs(Z);
            //if (tmpl != prgZ.Value)
            //{
            //    if (tmpl <= prgZ.Maximum)
            //        prgZ.Value = tmpl;
            //}
            //tmpl = System.Math.Abs(Pressure);
            //if (tmpl != prgPressure.Value)
            //    prgPressure.Value = tmpl;
            //tmpl = System.Math.Abs(TangentPressure);
            //if (tmpl != prgTangentPressure.Value)
            //    prgTangentPressure.Value = tmpl;

            //if (Convert.ToInt32(lblX.Text) != X)
            //    lblX.Text = X.ToString();
            //if (Convert.ToInt32(lblY.Text) != Y)
            //    lblY.Text = Y.ToString();
            //if (Convert.ToInt32(lblZ.Text) != Z)
            //    lblZ.Text = Z.ToString();
            //if (Convert.ToInt32(lblCursor.Text) != Cursor_Renamed)
            //    lblCursor.Text = Cursor_Renamed.ToString();
            //if (Convert.ToInt32(lblPressure.Text) != Pressure)
            //    lblPressure.Text = Pressure.ToString();
            //if (Convert.ToInt32(lblTangentPressure.Text) != TangentPressure)
            //    lblTangentPressure.Text = TangentPressure.ToString();
            //if (Convert.ToInt32(lblAzimuth.Text) != Azimuth)
            //    lblAzimuth.Text = Azimuth.ToString();
            //if (Convert.ToInt32(lblAltitude.Text) != Altitude)
            //    lblAltitude.Text = Altitude.ToString();
            //if (Convert.ToInt32(lblTwist.Text) != Twist)
            //    lblTwist.Text = Twist.ToString();
            //if (Convert.ToInt32(lblPitch.Text) != Pitch)
            //    lblPitch.Text = Twist.ToString();
            //if (Convert.ToInt32(lblRoll.Text) != Roll)
            //    lblRoll.Text = Roll.ToString();
            //if (Convert.ToInt32(lblYaw.Text) != Yaw)
            //    lblYaw.Text = Yaw.ToString();

            Pen      ppen = new Pen(Color.Black, 1);
            Graphics Gr;
            Graphics sh;

            if (Pressure > 0) // 'catch normalpressure and button 1
            {
                //if (Digitizer.Context.CursorIsInverted)
                //{
                //    ppen.Color = Color.Red;
                //    picDraw.Refresh();
                //}
                //else
                //{
                //    ppen.Color = Color.Blue;
                //}
                //tmpl = (int)Digitizer.Device.NormalPressure.get_Max(true);
                //RectWidth = (int)((Pressure / (float)tmpl) * 100);
                //if ((RectWidth >= 0) & (RectWidth <= 20))
                //    ppen.Color = Color.LawnGreen;
                //else if ((RectWidth >= 21) & (RectWidth <= 40))
                //    ppen.Color = Color.Blue;
                //else if ((RectWidth >= 41) & (RectWidth <= 100))
                //    ppen.Color = Color.Red;

                try
                {
                    //bmp = new Bitmap(picDraw.Image);
                    //Gr = Graphics.FromImage(picDraw.Image);
                    Gr = Graphics.FromImage(bmp);
                    sh = Graphics.FromImage(bmp);
                    sh = picDraw.CreateGraphics();
                    //Bitmap bmp = new Bitmap(picDraw.Width, picDraw.Height);
                    Gr.DrawLine(ppen, X, picDraw.Height - Y, Xold, picDraw.Height - Yold + 1);
                    sh.DrawLine(ppen, X, picDraw.Height - Y, Xold, picDraw.Height - Yold + 1);
                    //Gr.Flush();
                    //GraphicsState s = Gr.Save();
                    // Gr.DrawEllipse(ppen, X, picDraw.Height - Y, 1, 1);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            //   Application.DoEvents(); // Poor Data Capture & Rendering
            Xold = X;
            Yold = Y;
        }