Esempio n. 1
0
 public NodePort(NodePortType _portType, NodeConnectionType _connectType, NodeBase _parentNode)
 {
     portType       = _portType;
     connectionType = _connectType;
     parentNode     = _parentNode;
     portRect       = new MyRect(0.0f, 0.0f, 0.0f, 0.0f);
 }
Esempio n. 2
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (!MyImage.raycastTarget)
            {
                return;
            }

            float maxScale = 50;
            float time     = 0.1f;

            if (!IsCenter)
            {
                IsCenter = true;
                Sequence sequence = DOTween.Sequence();
                sequence.Append(MyRect.DOScale(maxScale, time));
                sequence.Append(MyRect.DOScale(_showScale, time));
                sequence.OnComplete(() =>
                {
                    MyFadeEffect.PlayNeighbor(ID, 0);
                    MyFluctiateEffect.PlayNeighbor(ID);
                });
                transform.SetAsLastSibling();
            }
            else
            {
                IsCenter = false;
                Sequence sequence = DOTween.Sequence();
                sequence.Append(MyRect.DOScale(maxScale, time));
                sequence.Append(MyRect.DOScale(1, time));
                sequence.OnComplete(() => { MyFadeEffect.PlayNeighbor(ID, 1); });
                transform.SetAsFirstSibling();
            }
        }
Esempio n. 3
0
    public MyArea(MyVector2 dimensions, int spriteIndex, MyRect spriteRect, params MyColor[] colors)
    {
        _colors         = colors;
        Dimensions      = dimensions;
        Correlations    = new ConcurrentDictionary <int, MyAreaCoordinates>();
        CorrelationsBag = new ConcurrentBag <MyAreaCoordinates>();

        OpaquePixelsCount = 0;
        _hash             = 0;
        for (int i = 0; i < _colors.Length; i++)
        {
            if (_colors[i].A > 0f)
            {
                OpaquePixelsCount++;
            }
            _hash += (i + 1) * _colors[i].GetHashCode() * short.MaxValue;
        }
        _hash += dimensions.GetHashCode();
        _hash += spriteIndex.GetHashCode();
        _hash += spriteRect.GetHashCode();
        _hash += OpaquePixelsCount.GetHashCode();

        Score = (long)(Mathf.Pow(OpaquePixelsCount, 3f) / Dimensions.Square);

        SpriteIndex = spriteIndex;
        SpriteRect  = spriteRect;

        UniqueString = _hash.ToString();
    }
Esempio n. 4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     myLine   = new MyLine();
     myRect   = new MyRect();
     myCircle = new MyCircle();
     shape    = new Shape();
 }
Esempio n. 5
0
 public override void InitNode()
 {
     base.InitNode();
     nodeType       = NodeType.Bool;
     nodeTitle      = "Boolean";
     nodeRect       = new MyRect(50f, 50f, 100f, 80f);
     flowOutputSucc = NodePort.createPort(NodePortType.Out, NodeConnectionType.BOOL, this);
 }
Esempio n. 6
0
 public override void InitNode()
 {
     base.InitNode();
     nodeType       = NodeType.Start;
     nodeTitle      = "Start";
     nodeRect       = new MyRect(50f, 50f, 60f, 50f);
     flowOutputSucc = NodePort.createPort(NodePortType.Out, NodeConnectionType.FLOW, this);
 }
Esempio n. 7
0
 public override void InitNode()
 {
     base.InitNode();
     nodeType  = NodeType.End;
     nodeTitle = "End";
     nodeRect  = new MyRect(50f, 50f, 50f, 50f);
     flowInput = NodePort.createPort(NodePortType.In, NodeConnectionType.FLOW, this);
 }
 protected override void OnRender(System.Windows.Media.DrawingContext dc)
 {
     base.OnRender(dc);
     for (int i = 0; i < rects.Count; i++)
     {
         MyRect mRect = rects[i];
         dc.DrawRectangle(mRect.Brush, null, mRect.Rect);
     }
 }
Esempio n. 9
0
    void CreateTerrian()
    {
        FreeRects = new List <MyRect>();
        TerRects  = new List <MyRect>();
        var planeRect = new MyRect(Vector2.zero, Vector2.one * World.Size);

        FreeRects.Add(planeRect);

        while (FreeRects.Count > 0)
        {
            CreateTerrainRect(FreeRects[0]);
        }

        foreach (var rect in TerRects)
        {
            var yLev      = .5f; //for mountain
            var animDelay = 0f;

            var newMount = Instantiate(Cube, transform.parent);
            newMount.transform.localScale       = new Vector3(rect.width - .5f, 1, rect.height - .5f);
            newMount.transform.localPosition    = new Vector3(rect.Poz.x, .5f, rect.Poz.y);
            newMount.transform.localEulerAngles = Vector3.zero;
            newMount.layer = transform.gameObject.layer;

            iTween.ColorFrom(newMount, iTween.Hash("color", Color.clear, "time", .4f, "delay", animDelay += .2f));

            int floorCount = Random.Range(0, 4);
            var prevFloor  = newMount;
            for (int i = 0; i < floorCount; i++)
            {
                var prevSize = prevFloor.GetComponent <Renderer>().bounds.size;

                //skip
                //when size is low the skip poss increase
                var newFloor = Instantiate(Cube, transform.parent);
                newFloor.layer = transform.gameObject.layer;

                var xCut    = prevSize.x <= 6 ? Random.Range(prevSize.x / 10f, prevSize.x / 5f) : Random.Range(3f, prevSize.x / 2f);
                var zCut    = prevSize.z <= 6 ? Random.Range(prevSize.z / 10f, prevSize.z / 5f) : Random.Range(3f, prevSize.z / 2f);
                var newSize = new Vector3(prevSize.x - xCut, 1, prevSize.z - zCut);
                newFloor.transform.localScale = newSize;

                var xPozRange = (prevSize.x / 2f) - (newSize.x / 2f);
                var zPozRange = (prevSize.z / 2f) - (newSize.z / 2f);
                newFloor.transform.localPosition = new Vector3(
                    Random.Range(-xPozRange, xPozRange) + prevFloor.transform.localPosition.x,
                    ++yLev,
                    Random.Range(-zPozRange, zPozRange) + prevFloor.transform.localPosition.z
                    );

                iTween.ColorFrom(newFloor, iTween.Hash("color", Color.clear, "time", .7f, "delay", animDelay += .2f));

                prevFloor = newFloor;
            }
        }
    }
Esempio n. 10
0
        /// <summary>
        /// Create object
        /// </summary>
        /// <param name="mainApp"></param>
        public MainAppViewModel(MainApp mainApp)
        {
            this.mainApp = mainApp;

            this.images   = new BlockingCollection <float[, ]>();
            this.bodyData = new BlockingCollection <BodyData>();

            Links = new ObservableCollection <ProcessLink>();
            LoadLinks();

            MyRect screen = new MyRect(
                0,
                0,
                (float)System.Windows.SystemParameters.PrimaryScreenWidth,
                (float)System.Windows.SystemParameters.PrimaryScreenHeight);



            MyRect moveArea = new MyRect(250, -50, 450, 100);

            HandPositionMapper mc = new HandPositionMapper(screen, moveArea);

            actionManager = new ActionManager(mc, this);

            Task.Factory.StartNew(() => { predictor = new MainCamera(images, bodyData); });


            //thread that take images from queue
            new Thread(() =>
            {
                while (isRunnig)
                {
                    // Debug.WriteLine("Count " + images.Count);
                    float[,] im = images.Take();

                    var data = bodyData.Take();

                    if (data.HandPosition.Y - 100 < data.ElvowPosition.Y)
                    {
                        actionManager.SetPosition(data.HandPosition);

                        actionManager.AddImage(im);
                    }
                    else
                    {
                        actionManager.SetNotReady();
                    }
                }
            }).Start();


            Messenger.Default.Register <UpdateListRequest>(
                this,
                UpdateList);
        }
Esempio n. 11
0
        public override void InitNode()
        {
            base.InitNode();
            nodeType  = NodeType.Dialog;
            nodeTitle = "Dialog";
            nodeRect  = new MyRect(10f, 10f, 200f, 200f);

            textData  = TextData.createAsset(this);
            options   = new List <DialogOption> ();
            flowInput = NodePort.createPort(NodePortType.In, NodeConnectionType.FLOW, this);
        }
Esempio n. 12
0
        public ServerForm()
        {
            InitializeComponent();
            shapeRows.ReadXml("panel_data.xml");

            foreach (var item in shapeRows)
            {
                Shape shape;
                if (item.Shape.Equals("Line"))
                {
                    MyLine myLine = new MyLine();
                    myLine.setPoint(new Point(item.x1, item.y1), new Point(item.x2, item.y2),
                                    new Pen(Color.FromArgb(item.Color), item.thick));
                    shape = myLine;
                }
                else if (item.Shape.Equals("Circle"))
                {
                    MyCircle myCircle = new MyCircle();
                    myCircle.setRectC(new Point(item.x1, item.y1),
                                      new Point(item.x1 + item.x2, item.y1 + item.y2),
                                      new Pen(Color.FromArgb(item.Color), item.thick),
                                      new SolidBrush(Color.FromArgb(item.Brush)));
                    shape = myCircle;
                }
                else// if (item.Shape.Equals("Rectangle"))
                {
                    MyRect myRect = new MyRect();
                    myRect.setRect(new Point(item.x1, item.y1),
                                   new Point(item.x1 + item.x2, item.y1 + item.y2),
                                   new Pen(Color.FromArgb(item.Color), item.thick),
                                   new SolidBrush(Color.FromArgb(item.Brush)));
                    shape = myRect;
                }
                shapes.Add(shape);
            }

            //shapeRows.Rows.Add(dr);
            //txt_Chat.AppendText(shapeRows.Last().Shape);
            //shapeRows.Rows.Add(dr);
            //txt_Chat.AppendText(shapeRows[0].Shape);
            //txt_Chat.AppendText(shapeRows[0].x1.ToString());

            ConnectModal connectModal = new ConnectModal();

            connectModal.ShowDialog();

            for (int i = 0; i < 10; i++)
            {
                serverThreads[i] = new ServerThread(this);
            }

            this.m_thServer = new Thread(new ThreadStart(ServerStart));
            this.m_thServer.Start();
        }
Esempio n. 13
0
        public override void InitNode()
        {
            base.InitNode();
            nodeType  = NodeType.Text;
            nodeTitle = "Text";
            nodeRect  = new MyRect(10f, 10f, 150f, 150f);

            textData = TextData.createAsset(this);

            flowOutputSucc = NodePort.createPort(NodePortType.Out, NodeConnectionType.FLOW, this);
            flowInput      = NodePort.createPort(NodePortType.In, NodeConnectionType.FLOW, this);
        }
        /// <summary>
        /// Create the view model.
        /// </summary>
        public TutorialViewModel()
        {
            SetStrings(App.resdict);

            //get images pahts
            DirectoryInfo di = new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, @"Images/HandGestureIcons"));

            FileInfo[] imagesPath = di.GetFiles("*.png");

            // set all images path
            foreach (var i in imagesPath)
            {
                _imagesPaths.Add(i.FullName);
            }

            // sort images paths
            _imagesPaths.Sort();

            // start at page 0
            ChangePage(0);

            //Start queues.
            this.images   = new BlockingCollection <float[, ]>();
            this.bodyData = new BlockingCollection <BodyData>();

            // Screen windwos
            MyRect screen = new MyRect(
                0,
                0,
                (float)System.Windows.SystemParameters.PrimaryScreenWidth,
                (float)System.Windows.SystemParameters.PrimaryScreenHeight);

            // hand movin area
            MyRect moveArea = new MyRect(250, -50, 450, 100);

            // create action manageer
            am = new TutorialActionManager(this);

            //start and create predictor
            Task.Factory.StartNew(() => { predictor = new MainCamera(this.images, bodyData); });

            // start thread that take images from queue.
            new Thread(() =>
            {
                while (isRunning)
                {
                    float[,] im = images.Take();

                    //if (!isImage) continue;
                    am.AddImage(im);
                }
            }).Start();
        }
Esempio n. 15
0
 private void SetupMine()
 {
     for (int i = 0; i < 100; i++)
     {
         mypencil[i] = new MyPencil();
     }
     for (int i = 0; i < 100; i++)
     {
         mylines[i] = new MyLines();
     }
     for (int i = 0; i < 100; i++)
     {
         myrect[i] = new MyRect();
     }
     for (int i = 0; i < 100; i++)
     {
         mycircle[i] = new MyCircle();
     }
 }
    public static MyRect[,] RectToMyRect(Rect[,] r)
    {
        if (r == null)
        {
            return(null);
        }
        var w  = r.GetLength(0);
        var h  = r.GetLength(1);
        var re = new MyRect[w, h];

        for (int i = 0; i < w; i++)
        {
            for (int j = 0; j < h; j++)
            {
                var t = r[i, j];
                re[i, j] = new MyRect(t.x, t.y, t.width, t.height);
            }
        }
        return(re);
    }
Esempio n. 17
0
        private void Panel_board_MouseDown(object sender, MouseEventArgs e)
        {
            pen = new Pen(btn_lineColor.BackColor, lineSize);
            if (btn_Fill.BackColor == Color.Gray)
            {
                brush = new SolidBrush(btn_faceColor.BackColor);
            }
            else
            {
                brush = new SolidBrush(Color.Transparent);
            }
            isholding = true;
            switch (drawTool)
            {
            case 0:         //Hand
                break;

            case 1:         //Pencil
                break;

            case 2:         //Line
                myLine = new MyLine();
                shape  = myLine;
                break;

            case 3:         //Circle
                myCircle = new MyCircle();
                shape    = myCircle;
                break;

            case 4:         //Rectangle
                myRect = new MyRect();
                shape  = myRect;
                break;
            }
            point = e.Location;
        }
Esempio n. 18
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            MyRect[]       regions         = null;
            Emgu.CV.ML.SVM vSVM            = new Emgu.CV.ML.SVM();
            String         cExportFileName = txtFileName.Text;
            FileStorage    fileStorage     = new FileStorage(cExportFileName, FileStorage.Mode.Read);

            vSVM.Read(fileStorage.GetFirstTopLevelNode());

            int iHeight = vSVM.GetSupportVectors().Height;
            int iWidth  = vSVM.GetSupportVectors().Width;
            var svmMat  = new Matrix <float>(iWidth, iHeight);

            Matrix <float> resultMat = new Matrix <float>(1, iWidth);
            Matrix <float> alphaMat  = new Matrix <float>(1, iHeight);

            float[] mydetector = new float[iWidth + 1];
            for (int i = 0; i < iWidth; i++)
            {
                mydetector[i] = resultMat[0, i];
            }
            //mydetector[iWidth] = rhoValue;

            Mat           vImage = new Mat();
            HOGDescriptor hog    = new HOGDescriptor(new Size(36, 36), new Size(36, 36), new Size(6, 6), new Size(6, 6));

            hog.SetSVMDetector(mydetector);
            MCvObjectDetection[] results = hog.DetectMultiScale(vImage);
            regions = new MyRect[results.Length];
            for (int i = 0; i < results.Length; i++)
            {
                regions[i]       = new MyRect();
                regions[i].Rect  = results[i].Rect;
                regions[i].Score = results[i].Score;
            }
        }
Esempio n. 19
0
        private void SetupMine()
        {
            for (int i = 0; i < 100; i++)
            {
                mypencil[i] = new MyPencil();
            }
            for (int i = 0; i < 100; i++)
            {
                mylines[i] = new MyLines();
            }
            for (int i = 0; i < 100; i++)
            {
                myrect[i] = new MyRect();
            }
            for (int i = 0; i < 100; i++)
            {
                mycircle[i] = new MyCircle();
            }
            parentForm.Init();

            // Make Thread to process Panel Receive
            thread = new Thread(new ThreadStart(parentForm.ReceiveFromServer));
            thread.Start();
        }
Esempio n. 20
0
        public StoreShape()
        {
            mypencil = new MyPencil[100];
            mylines  = new MyLines[100];
            myrect   = new MyRect[100];
            mycircle = new MyCircle[100];

            for (int i = 0; i < 100; i++)
            {
                mypencil[i] = new MyPencil();
            }
            for (int i = 0; i < 100; i++)
            {
                mylines[i] = new MyLines();
            }
            for (int i = 0; i < 100; i++)
            {
                myrect[i] = new MyRect();
            }
            for (int i = 0; i < 100; i++)
            {
                mycircle[i] = new MyCircle();
            }
        }
Esempio n. 21
0
    public MyArea(MyVector2 dimensions, int spriteIndex, MyRect spriteRect, string uniqueString, params MyColor[] colors)
    {
        _colors         = colors;
        Dimensions      = dimensions;
        Correlations    = new ConcurrentDictionary <int, MyAreaCoordinates>();
        CorrelationsBag = new ConcurrentBag <MyAreaCoordinates>();

        OpaquePixelsCount = 0;
        for (int i = 0; i < _colors.Length; i++)
        {
            if (_colors[i].A > 0)
            {
                OpaquePixelsCount++;
            }
        }

        Score = (long)(Mathf.Pow(OpaquePixelsCount, 3f) / Dimensions.Square);

        SpriteIndex = spriteIndex;
        SpriteRect  = spriteRect;

        UniqueString = uniqueString;
        _hash        = uniqueString.GetHashCode();
    }
Esempio n. 22
0
        public static string make_data_from_line(string line, out string name, out object val, Dictionary <string, object> dic)
        {
            name = "";
            val  = null;
            string strPatten = @"^\s*(?<name>\S+)\s+(?<type>\S+)\s+(?<rawtxt>.+)";
            Regex  rex       = new Regex(strPatten);
            //MatchCollection matches = rex.Matches(cur_line);
            Match m = rex.Match(line);

            if (m == null)
            {
                throw new Exception("错误的行");
            }

            //根据type写入值 进入dic
            if ("float" == m.Groups["type"].Value)
            {
                //dic.Add(m.Groups["name"].Value, Convert.ToDouble(m.Groups["rawtxt"].Value));
                name = m.Groups["name"].Value;
                val  = Convert.ToDouble(m.Groups["rawtxt"].Value);
                return("s");
            }
            else if ("string" == m.Groups["type"].Value)
            {
                //dic.Add(m.Groups["name"].Value, Convert.ToString(m.Groups["rawtxt"].Value));
                name = m.Groups["name"].Value;
                val  = Convert.ToString(m.Groups["rawtxt"].Value);
                return("s");
            }
            else if ("vector" == m.Groups["type"].Value)
            {
                string[] strs = m.Groups["rawtxt"].Value.Split(',');
                if (3 != strs.Length)
                {
                    throw new Exception("vector应该有三个数");
                }
                name = m.Groups["name"].Value;
                val  = new Vector3D(Convert.ToDouble(strs[0]),
                                    Convert.ToDouble(strs[1]),
                                    Convert.ToDouble(strs[2]));
                return("s");
                //dic.Add(m.Groups["name"].Value, new Vector3D(Convert.ToDouble(strs[0]),
                //                                            Convert.ToDouble(strs[1]),
                //                                            Convert.ToDouble(strs[2])));
            }
            else if ("rect" == m.Groups["type"].Value)
            {
                string[] strs = m.Groups["rawtxt"].Value.Split(',');
                if (4 == strs.Length)
                {
                    if (!dic.ContainsKey(strs[0]))
                    {
                        throw new Exception("未找到向量名");
                    }
                    double   w = Convert.ToDouble(strs[1]);
                    double   h = Convert.ToDouble(strs[2]);
                    double   r = Convert.ToDouble(strs[3]);
                    Vector3D v = (Vector3D)dic[strs[0]] + new Vector3D(w, h);
                    name = m.Groups["name"].Value;
                    val  = new MyRect((Vector3D)dic[strs[0]], v);
                    return("s");
                }
                else if (6 == strs.Length)//指定两个角点
                {
                    Vector3D v1 = new Vector3D(Convert.ToDouble(strs[0]), Convert.ToDouble(strs[1]), Convert.ToDouble(strs[2]));
                    Vector3D v2 = new Vector3D(Convert.ToDouble(strs[3]), Convert.ToDouble(strs[4]), Convert.ToDouble(strs[5]));
                    name = m.Groups["name"].Value;
                    val  = new MyRect(v1, v2);
                    return("s");
                }
                else
                {
                    throw new Exception("错误的rect格式");
                }


                //dic.Add(m.Groups["name"].Value, new MyRect((Vector3D)dic[strs[0]], v));
            }
            else if ("bool" == m.Groups["type"].Value)
            {
                bool f = true;
                if ("0" == m.Groups["rawtxt"].Value)
                {
                    f = false;
                }
                name = m.Groups["name"].Value;
                val  = f;
                return("s");
                //dic.Add(m.Groups["name"].Value, f);
            }
            else if ("arc" == m.Groups["type"].Value)
            {
                string[] strs = m.Groups["rawtxt"].Value.Split(',');
                if (strs.Length != 6)
                {
                    throw new Exception("错误的arc格式");
                }
                Vector3D center  = new Vector3D(Convert.ToDouble(strs[0]), Convert.ToDouble(strs[1]), Convert.ToDouble(strs[2]));
                double   radius  = Convert.ToDouble(strs[3]);
                double   angle1  = Convert.ToDouble(strs[4]);
                double   da      = Convert.ToDouble(strs[5]);
                double   normalz = 1.0;
                if (da < 0)
                {
                    normalz = -1.0;
                }
                name = m.Groups["name"].Value;
                val  = new MyArc(center, radius, angle1, angle1 + da, normalz);
                return("s");
            }
            else if ("polyline" == m.Groups["type"].Value)
            {
                int hang = Convert.ToInt32(m.Groups["rawtxt"].Value);//得到下面的接续行个数 行数放在val中返回
                name = m.Groups["name"].Value;
                val  = hang;
                return("m");
            }
            else if ("lineseg" == m.Groups["type"].Value)
            {
                string[] strs = m.Groups["rawtxt"].Value.Split(',');
                if (strs.Length != 6)
                {
                    throw new Exception("错误的lineseg格式");
                }
                Vector3D    v1  = new Vector3D(Convert.ToDouble(strs[0]), Convert.ToDouble(strs[1]), Convert.ToDouble(strs[2]));
                Vector3D    v2  = new Vector3D(Convert.ToDouble(strs[3]), Convert.ToDouble(strs[4]), Convert.ToDouble(strs[5]));
                LineSegment elo = new LineSegment(v1, v2);
                name = m.Groups["name"].Value;
                val  = elo;
                return("s");
            }
            else if ("cadop" == m.Groups["type"].Value)
            {
                name = m.Groups["name"].Value;
                val  = Convert.ToString(m.Groups["rawtxt"].Value);
                return("s");
            }
            else
            {
                throw new Exception("错误的类型");
            }
        }
 public static Rect MyRectToRect(MyRect r)
 {
     return(new Rect(r.x, r.y, r.w, r.h));
 }
Esempio n. 24
0
        public void initInputControls(IniData data, ref short[] initialResults)
        {
            chgContext = new ChangerContext();

            resetResults(ref initialResults);

            //------------------------------------------------


            throttleCurveChanger = new MultiRangeChanger(
                new RangeMapping {
                minFrom = 0, maxFrom = 255, minTo = 0, maxTo = 255
            },
                7,
                new int[] {
                // quick and ugly
                int.Parse(data["THROTTLE"]["t0"]),
                int.Parse(data["THROTTLE"]["t1"]),
                int.Parse(data["THROTTLE"]["t2"]),
                int.Parse(data["THROTTLE"]["t3"]),
                int.Parse(data["THROTTLE"]["t4"]),
                int.Parse(data["THROTTLE"]["t5"]),
                int.Parse(data["THROTTLE"]["t6"])
            }
                );


            ThrottleHardLimitChanger = new LimiterChanger(int.Parse(data["SPEED"]["min"]),
                                                          int.Parse(data["SPEED"]["max"])
                                                          );
            throttleLimitChanger = new MultiRangeChanger(new[] {
                new MapRangeChanger(new RangeMapping {
                    minFrom = 0, maxFrom = 127, minTo = ThrottleHardLimitChanger.Min, maxTo = 127
                }),
                new MapRangeChanger(new RangeMapping {
                    minFrom = 128, maxFrom = 255, minTo = 128, maxTo = ThrottleHardLimitChanger.Max
                })
            });


            SteerHardLimitChanger = new LimiterChanger(0, 255);

            brakeChanger = new BrakeChanger(126, int.Parse(data["BRAKE"]["previousMotionThreshold"]), int.Parse(data["BRAKE"]["reversePreviousMotionThreshold"]), int.Parse(data["BRAKE"]["cycles"]));

            //------------------------------------------------

            centrR = new MyRect(0, 0, int.Parse(data["CENTER"]["w"]), int.Parse(data["CENTER"]["h"]));
            bordrR = new MyRect(int.Parse(data["BORDER"]["x"]), int.Parse(data["BORDER"]["y"]), int.Parse(data["BORDER"]["w"]), int.Parse(data["BORDER"]["h"]));

            deadZoneR = new MyRect(0, 0, bordrR.w - 2 * int.Parse(data["DEADZONE"]["x"]), bordrR.h - 2 * int.Parse(data["DEADZONE"]["y"]));

            setArmed(false);

            // TODO make configurable. Reason: poor quality of cheap gamepads
            gamepadRangeMapping = new RangeMapping
            {
                minFrom = -65535,
                maxFrom = 65535,
                minTo   = 0,
                maxTo   = 255
            };



            chgInputSteer = new InputChanger();
            chgSteer      = chgInputSteer
                            //.Chain(new MapRangeChanger(gamepadRangeMapping))
                            .Chain(SteerHardLimitChanger)
            ;
            chgInputThrottle = new InputChanger();
            chgThrottle      = chgInputThrottle
                               //.Chain(new MapRangeChanger(gamepadRangeMapping))
                               .Chain(throttleCurveChanger)
                               .Chain(throttleLimitChanger)
                               .Chain(ThrottleHardLimitChanger)
                               .Chain(new ThrottleStatisticChanger(20))
                               .Chain(brakeChanger)
            ;
        }
Esempio n. 25
0
        private void Receive()
        {
            m_Write.WriteLine("New Client");
            m_Write.WriteLine(id);
            m_Write.Flush();
            string receive;

            while (m_bConnect)
            {
                //this.Invoke(new Action(delegate ()
                //{
                //    txt_Chat.AppendText("dddddddd\r\n");
                //}));
                receive = m_Read.ReadLine();
                if (receive.Equals("Message"))
                {
                    string message = m_Read.ReadLine();
                    this.Invoke(new Action(delegate()
                    {
                        txt_Chat.AppendText(message + "\r\n");
                    }));
                }
                else if (receive.Equals("Line"))
                {
                    int    x1    = int.Parse(m_Read.ReadLine());
                    int    y1    = int.Parse(m_Read.ReadLine());
                    int    x2    = int.Parse(m_Read.ReadLine());
                    int    y2    = int.Parse(m_Read.ReadLine());
                    int    thick = int.Parse(m_Read.ReadLine());
                    int    Argb  = int.Parse(m_Read.ReadLine());
                    MyLine ml    = new MyLine();
                    ml.setPoint(new Point(x1, y1), new Point(x2, y2), new Pen(Color.FromArgb(Argb), thick));
                    shape = ml;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Circle"))
                {
                    int      x1    = int.Parse(m_Read.ReadLine());
                    int      y1    = int.Parse(m_Read.ReadLine());
                    int      wid   = int.Parse(m_Read.ReadLine());
                    int      hei   = int.Parse(m_Read.ReadLine());
                    int      thick = int.Parse(m_Read.ReadLine());
                    int      Argb  = int.Parse(m_Read.ReadLine());
                    int      brush = int.Parse(m_Read.ReadLine());
                    MyCircle mc    = new MyCircle();
                    mc.setRectC(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    shape = mc;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Rectangle"))
                {
                    int    x1    = int.Parse(m_Read.ReadLine());
                    int    y1    = int.Parse(m_Read.ReadLine());
                    int    wid   = int.Parse(m_Read.ReadLine());
                    int    hei   = int.Parse(m_Read.ReadLine());
                    int    thick = int.Parse(m_Read.ReadLine());
                    int    Argb  = int.Parse(m_Read.ReadLine());
                    int    brush = int.Parse(m_Read.ReadLine());
                    MyRect mr    = new MyRect();
                    mr.setRect(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    shape = mr;
                    shapes.Add(shape);
                }
                else if (receive.Equals("Bitmap"))
                {
                    int    length = int.Parse(m_Read.ReadLine());
                    byte[] buf    = m_bRead.ReadBytes(length);
                    txt_Chat.AppendText(length + "\r\n");
                    ms     = new MemoryStream(buf);
                    bitmap = new Bitmap(ms);
                    //bitmap.Save("C:/Users/junhwa/source/repos/Application_Software_3rdPractice/Client/bin/Debug/abc.bmp");
                }
                Draw();
            }
        }
Esempio n. 26
0
    void CreateTerrainRect(MyRect surRect)
    {
        //ter for terrain

        FreeRects.RemoveAt(0);

        //make the new rect
        MyRect makeTerRect()
        {
            //min size for surRect is 2 in both dimensions
            var size      = new Vector2(Random.Range(2, surRect.width - .5f), Random.Range(2, surRect.height - .5f));
            var xPozRange = new Vector2(surRect.xMin + (size.x / 2), surRect.xMax - (size.x / 2));
            var yPozRange = new Vector2(surRect.yMin + (size.y / 2), surRect.yMax - (size.y / 2));
            var poz       = new Vector2(Random.Range(xPozRange.x, xPozRange.y), Random.Range(yPozRange.x, yPozRange.y));

            return(new MyRect(poz, size));
        }

        var terRect = makeTerRect();

        TerRects.Add(terRect);

        var interPoints = new Vector2[4];

        for (int i = 0; i < 4; i++)
        {
            //make random line, get intersections
            interPoints[i] = Random.Range(0, 2) == 0 ?
                             new Vector2(terRect.Points[i].x, surRect.Points[i].y) :
                             new Vector2(surRect.Points[i].x, terRect.Points[i].y);
        }//pick intersection points, create surRects

        for (int i = 1; i <= 4; i++)
        {
            var curInd = i % 4; var prevInd = i - 1;
            var s = new Vector2(); var e = new Vector2();
            if (interPoints[curInd].x != interPoints[prevInd].x && interPoints[curInd].y != interPoints[prevInd].y)
            {
                s = interPoints[curInd]; e = interPoints[prevInd];
            }//adjacent
            else if (interPoints[curInd].x == interPoints[prevInd].x)
            {
                if (IsClose(Mathf.Abs(interPoints[curInd].y - interPoints[prevInd].y), terRect.height, .1f))
                {
                    s = terRect.Points[prevInd];
                    e = interPoints[curInd];
                }//parallel
                else
                {
                    s = interPoints[prevInd];
                    e = surRect.Points[curInd]; //corner
                }//same
            }//either inter with same border, or parallel borders
            else if (interPoints[curInd].y == interPoints[prevInd].y)
            {
                if (IsClose(Mathf.Abs(interPoints[curInd].x - interPoints[prevInd].x), terRect.width, .1f))
                {
                    s = terRect.Points[prevInd];
                    e = interPoints[curInd];
                }//parallel
                else
                {
                    s = interPoints[prevInd];
                    e = surRect.Points[curInd]; //corner
                }//same
            }//either inter with same border, or parallel borders

            var poz        = Vector2.Lerp(s, e, .5f);
            var size       = new Vector2(Mathf.Abs(s.x - e.x), Mathf.Abs(s.y - e.y));
            var newSurRect = new MyRect(poz, size);

            if (size.y >= 3 && size.x >= 3)
            {
                FreeRects.Add(newSurRect);
            }
        }//get diameter points and more
    }
Esempio n. 27
0
        public void Receive()
        {
            string Request;

            while (m_bConnect)
            {
                Request = m_Read.ReadLine();
                if (Request.Equals("New Client"))
                {
                    connectedClient = m_Read.ReadLine();
                    serverForm.printChat(connectedClient + "이(가) 입장했습니다.");
                }
                else if (Request.Equals("Message"))
                {
                    serverForm.Receive_Message(m_Read.ReadLine());
                }
                else if (Request.Equals("Line"))
                {
                    int    x1     = int.Parse(m_Read.ReadLine());
                    int    y1     = int.Parse(m_Read.ReadLine());
                    int    x2     = int.Parse(m_Read.ReadLine());
                    int    y2     = int.Parse(m_Read.ReadLine());
                    int    thick  = int.Parse(m_Read.ReadLine());
                    int    Argb   = int.Parse(m_Read.ReadLine());
                    MyLine myLine = new MyLine();
                    myLine.setPoint(new Point(x1, y1), new Point(x2, y2), new Pen(Color.FromArgb(Argb), thick));
                    Shape shape = myLine;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Line(x1, y1, x2, y2, thick, Argb);
                }
                else if (Request.Equals("Circle"))
                {
                    int      x1       = int.Parse(m_Read.ReadLine());
                    int      y1       = int.Parse(m_Read.ReadLine());
                    int      wid      = int.Parse(m_Read.ReadLine());
                    int      hei      = int.Parse(m_Read.ReadLine());
                    int      thick    = int.Parse(m_Read.ReadLine());
                    int      Argb     = int.Parse(m_Read.ReadLine());
                    int      brush    = int.Parse(m_Read.ReadLine());
                    MyCircle myCircle = new MyCircle();
                    myCircle.setRectC(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    Shape shape = myCircle;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Circle(x1, y1, wid, hei, thick, Argb, brush);
                }
                else if (Request.Equals("Rectangle"))
                {
                    int    x1     = int.Parse(m_Read.ReadLine());
                    int    y1     = int.Parse(m_Read.ReadLine());
                    int    wid    = int.Parse(m_Read.ReadLine());
                    int    hei    = int.Parse(m_Read.ReadLine());
                    int    thick  = int.Parse(m_Read.ReadLine());
                    int    Argb   = int.Parse(m_Read.ReadLine());
                    int    brush  = int.Parse(m_Read.ReadLine());
                    MyRect myRect = new MyRect();
                    myRect.setRect(new Point(x1, y1), new Point(x1 + wid, y1 + hei), new Pen(Color.FromArgb(Argb), thick), new SolidBrush(Color.FromArgb(brush)));
                    Shape shape = myRect;
                    serverForm.shapes.Add(shape);
                    serverForm.Draw();

                    serverForm.all_Send_Rectangle(x1, y1, wid, hei, thick, Argb, brush);
                }
                else if (Request.Equals("Disconnect"))
                {
                    serverForm.printChat(connectedClient + "이(가) 퇴장했습니다.");
                    m_bConnect = false;
                    return;
                }
            }
            serverForm.ServerThreadExit(this);
        }
Esempio n. 28
0
        private void DrawShapes(Graphics g)
        {
            try
            {
                string errMessage = "";
                //ListXMLShapes.Clear();
                XmlNodeList    xml_lines, xml_arrows, xml_rects, xml_regions;
                XmlDocument    xmlDoc = new XmlDocument();
                RecognizerInfo ri     = RecognizerBusiness.Instance.GetRecognizerInfoByCameraId(ref errMessage, _cameraID);
                if (ri == null)
                {
                    //if (XtraMessageBox.Show("对不起,您使用的照片没有对应的识别器,请另选", "提示", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
                    {
                        return;
                    }
                }
                string name = @"c:\" + ri.Id.ToString() + "." + _cameraID + "admin" + ".xml";
                xmlDoc.Load(@name);
                //直线
                xml_lines = xmlDoc.SelectSingleNode("/pr/cameras/camera/lines").ChildNodes;

                float xScale = (float)this.Width / _currentImage.Width;
                float yScale = (float)(this.Height) / _currentImage.Height;

                foreach (XmlNode lineitem in xml_lines)
                {
                    MyLine line = new MyLine();
                    line.MyPen = new Pen(Color.Red, 1);
                    XmlElement xe = (XmlElement)lineitem;
                    line.P1.X        = Convert.ToInt32(xe.GetAttribute("X1"));
                    line.P1.X        = (int)(line.P1.X * xScale);
                    line.P1.Y        = Convert.ToInt32(xe.GetAttribute("Y1"));
                    line.P1.Y        = (int)(line.P1.Y * yScale);
                    line.P2.X        = Convert.ToInt32(xe.GetAttribute("X2"));
                    line.P2.X        = (int)(line.P2.X * xScale);
                    line.P2.Y        = Convert.ToInt32(xe.GetAttribute("Y2"));
                    line.P2.Y        = (int)(line.P2.Y * yScale);
                    line.MyPen.Color = ColorTranslator.FromHtml(xe.GetAttribute("PenColor"));
                    line.MyPen.Width = Convert.ToInt32(xe.GetAttribute("PenWidth"));
                    g.DrawLine(line.MyPen, line.P1, line.P2);
                    //ListXMLShapes.Add(line);
                }
                //箭头
                xml_arrows = xmlDoc.SelectSingleNode("/pr/cameras/camera/arrows").ChildNodes;
                foreach (XmlNode arrowitem in xml_arrows)
                {
                    MyArrow arrow = new MyArrow();
                    arrow.MyPen = new Pen(Color.Red, 1);
                    XmlElement xa = (XmlElement)arrowitem;
                    arrow.P1.X        = Convert.ToInt32(xa.GetAttribute("X1"));
                    arrow.P1.X        = (int)(arrow.P1.X * xScale);
                    arrow.P1.Y        = Convert.ToInt32(xa.GetAttribute("Y1"));
                    arrow.P1.Y        = (int)(arrow.P1.Y * yScale);
                    arrow.P2.X        = Convert.ToInt32(xa.GetAttribute("X2"));
                    arrow.P2.X        = (int)(arrow.P2.X * xScale);
                    arrow.P2.Y        = Convert.ToInt32(xa.GetAttribute("Y2"));
                    arrow.P2.Y        = (int)(arrow.P2.Y * yScale);
                    arrow.MyPen.Color = ColorTranslator.FromHtml(xa.GetAttribute("PenColor"));
                    arrow.MyPen.Width = Convert.ToInt32(xa.GetAttribute("PenWidth"));
                    g.DrawLine(arrow.MyPen, arrow.P1, arrow.P2);
                    //ListXMLShapes.Add(arrow);
                }
                //矩形
                xml_rects = xmlDoc.SelectSingleNode("/pr/cameras/camera/rects").ChildNodes;
                foreach (XmlNode rectitem in xml_rects)
                {
                    MyRect rect = new MyRect();
                    rect.MyPen = new Pen(Color.Red, 1);
                    XmlElement xr = (XmlElement)rectitem;
                    rect.P1.X        = Convert.ToInt32(xr.GetAttribute("X"));
                    rect.P1.X        = (int)(rect.P1.X * xScale);
                    rect.P1.Y        = Convert.ToInt32(xr.GetAttribute("Y"));
                    rect.P1.Y        = (int)(rect.P1.Y * yScale);
                    rect.Width       = Convert.ToInt32(xr.GetAttribute("W"));
                    rect.Width       = (int)(rect.Width * xScale);
                    rect.Height      = Convert.ToInt32(xr.GetAttribute("H"));
                    rect.Height      = (int)(rect.Height * yScale);
                    rect.MyPen.Color = ColorTranslator.FromHtml(xr.GetAttribute("PenColor"));
                    rect.MyPen.Width = Convert.ToInt32(xr.GetAttribute("PenWidth"));
                    g.DrawRectangle(rect.MyPen, rect.P1.X, rect.P1.Y, rect.Width, rect.Height);
                    //ListXMLShapes.Add(rect);
                }
                //多边形
                xml_regions = xmlDoc.SelectSingleNode("/pr/cameras/camera/regions").ChildNodes;
                foreach (XmlNode regionitem in xml_regions)
                {
                    MyPoly poly = new MyPoly();
                    poly.MyPen = new Pen(Color.Red, 1);
                    XmlElement xp = (XmlElement)regionitem;
                    poly.MyPen.Color = ColorTranslator.FromHtml(xp.GetAttribute("PenColor"));
                    poly.MyPen.Width = Convert.ToInt32(xp.GetAttribute("PenWidth"));
                    XmlNodeList pointlist = regionitem.ChildNodes;
                    foreach (XmlNode pitem in pointlist)
                    {
                        Point      p    = new Point();
                        XmlElement test = (XmlElement)pitem;
                        p.X = Convert.ToInt32(test.GetAttribute("X"));
                        p.X = (int)(p.X * xScale);
                        p.Y = Convert.ToInt32(test.GetAttribute("Y"));
                        p.Y = (int)(p.Y * yScale);
                        poly.ListPoint.Add(p);
                    }
                    //IsFinished=true
                    poly.IsFinished = true;
                    g.DrawPolygon(poly.MyPen, poly.ListPoint.ToArray());
                    //ListXMLShapes.Add(poly);
                }
            }
            catch (Exception)
            {
                ;
            }
        }
Esempio n. 29
0
 public static extern bool GetWindowRect(IntPtr hWnd, ref MyRect rect);