Exemple #1
0
        public RadioViewModel(string key, string label, string required, RadioControl control)
            : base(key, label, required, control)
        {
            _control = control;

            Orientation = _control.Orientation == Template.Orientation.Horizontal
                ? Orientation.Horizontal
                : Orientation.Vertical;

            _filterProperty = new BindableVariableExpression <string>(this, nameof(Filter));
        }
        void SetBackgroundImage(RadioControl radioButton)
        {
            UIImage _radioButtonImage;

            if (radioButton.IsChecked)
            {
                var _checkedImg = radioButton.CheckedImage;
                _radioButtonImage = UIImage.FromBundle(_checkedImg);
            }
            else
            {
                var _unCheckedImg = radioButton.UnCheckedImage;
                _radioButtonImage = UIImage.FromBundle(_unCheckedImg);
            }
            Control.SetBackgroundImage(_radioButtonImage, UIControlState.Normal);
        }
Exemple #3
0
        public static Runner[] ParseXmlData(byte[] xml, LogMessageDelegate logit, bool deleteFile, out RadioControl[] definedRadioControls)
        {
            var runners = new List<Runner>();
            definedRadioControls = null;
            var defRadios = new List<RadioControl>();

            var xmlDoc = new XmlDocument();
            using (var ms = new MemoryStream(xml))
            {
                var setts = new XmlReaderSettings();
                setts.XmlResolver = null;
                setts.ProhibitDtd = false;
                using (XmlReader xr = XmlReader.Create(ms, setts))
                {
                    xmlDoc.Load(xr);
                }
            }

            foreach (XmlNode classNode in xmlDoc.GetElementsByTagName("ClassStart"))
            {
                XmlNode classNameNode = classNode.SelectSingleNode("ClassShortName");
                if (classNameNode == null)
                    continue;

                string className = classNameNode.InnerText;
                var personNodes = classNode.SelectNodes("PersonStart");
                if (personNodes != null)
                {
                    foreach (XmlNode personNode in personNodes)
                    {
                        string familyname;
                        string givenname;
                        long pid;
                        string club;
                        if (!ParseNameClubAndId(personNode, out familyname, out givenname, out pid, out club)) continue;

                        var startTimeNode = personNode.SelectSingleNode("Start/StartTime/Clock");
                        var ccCardNode = personNode.SelectSingleNode("Start/CCard/CCardId");

                        if (startTimeNode == null || ccCardNode == null)
                            continue;
                        string starttime = startTimeNode.InnerText;
                        string si = ccCardNode.InnerText;
                        var dbid = CalculateIDFromSiCard(logit, si, familyname, givenname, pid);

                        var runner = new Runner(dbid, givenname + " " + familyname, club, className);

                        if (!string.IsNullOrEmpty(starttime))
                        {
                            int istarttime = ParseTime(starttime);
                            runner.SetStartTime(istarttime);
                        }

                        runners.Add(runner);
                    }
                }
            }

            foreach (XmlNode classNode in xmlDoc.GetElementsByTagName("ClassResult"))
            {
                XmlNode classNameNode = classNode.SelectSingleNode("ClassShortName");
                if (classNameNode == null)
                    continue;

                string className = classNameNode.InnerText;

                var personNodes = classNode.SelectNodes("PersonResult");
                if (personNodes != null)
                {
                    foreach (XmlNode personNode in personNodes)
                    {
                        string familyname;
                        string givenname;
                        long pid;
                        string club;
                        if (!ParseNameClubAndId(personNode, out familyname, out givenname, out pid, out club)) continue;

                        var competitorStatusNode = personNode.SelectSingleNode("Result/CompetitorStatus");
                        var resultTimeNode = personNode.SelectSingleNode("Result/Time");
                        var startTimeNode = personNode.SelectSingleNode("Result/StartTime/Clock");
                        var ccCardNode = personNode.SelectSingleNode("Result/CCard/CCardId");
                        if (competitorStatusNode == null || competitorStatusNode.Attributes == null || competitorStatusNode.Attributes["value"] == null ||
                            resultTimeNode == null || startTimeNode == null || ccCardNode == null)
                            continue;
                        if (familyname == "* Radio controls definition *")
                        {
                            //Special handling of SportSoftware way of telling what RadioControls will appear for this class
                            XmlNodeList pSplittimes = personNode.SelectNodes("Result/SplitTime");
                            if (pSplittimes != null)
                            {

                            }

                            continue;
                        }

                        string status = competitorStatusNode.Attributes["value"].Value;
                        string time = resultTimeNode.InnerText;
                        string starttime = startTimeNode.InnerText;
                        string si = ccCardNode.InnerText;
                        var dbid = CalculateIDFromSiCard(logit, si, familyname, givenname, pid);

                        var runner = new Runner(dbid, givenname + " " + familyname, club, className);

                        if (!string.IsNullOrEmpty(starttime))
                        {
                            int istarttime = ParseTime(starttime);
                            runner.SetStartTime(istarttime);
                        }

                        int itime = ParseTime(time);
                        int istatus = 10;

                        switch (status)
                        {
                            case "MisPunch":
                                istatus = 3;
                                break;

                            case "Disqualified":
                                istatus = 4;
                                break;
                            case "DidNotFinish":
                                istatus = 3;
                                itime = -3;
                                break;
                            case "DidNotStart":
                                istatus = 1;
                                itime = -3;
                                break;
                            case "Overtime":
                                istatus = 5;
                                break;
                            case "OK":
                                istatus = 0;
                                break;
                            case "NotCompeting":
                                //Does not compete, exclude
                                continue;
                        }

                        runner.SetResult(itime, istatus);

                        var lsplitCodes = new List<int>();
                        var lsplitTimes = new List<int>();

                        XmlNodeList splittimes = personNode.SelectNodes("Result/SplitTime");
                        if (splittimes != null)
                        {
                            foreach (XmlNode splitNode in splittimes)
                            {
                                XmlNode splitcode = splitNode.SelectSingleNode("ControlCode");
                                XmlNode splittime = splitNode.SelectSingleNode("Time");
                                if (splittime == null || splitcode == null)
                                    continue;

                                int iSplitcode;
                                string sSplittime = splittime.InnerText;
                                if (int.TryParse(splitcode.InnerText, out iSplitcode) && sSplittime.Length > 0)
                                {
                                    if (iSplitcode == 999)
                                    {
                                        if (istatus == 0 && itime == -1)
                                        {
                                            //Målstämpling
                                            itime = ParseTime(sSplittime);
                                            runner.SetResult(itime, 0);
                                        }
                                    }
                                    else
                                    {
                                        iSplitcode += 1000;
                                        while (lsplitCodes.Contains(iSplitcode))
                                        {
                                            iSplitcode += 1000;
                                        }

                                        int iSplittime = ParseTime(sSplittime);
                                        lsplitCodes.Add(iSplitcode);
                                        lsplitTimes.Add(iSplittime);

                                        runner.SetSplitTime(iSplitcode, iSplittime);
                                    }
                                }
                            }
                        }

                        runners.Add(runner);
                    }
                }
            }

            return runners.ToArray();
        }
Exemple #4
0
    void updateRacasts()
    {
        bool tryReconect = false;

        RadioControl.RadioRaycastData current = null;
        if (connectedTo != null && connectedTo.isActiveAndEnabled)
        {
            current = connectedTo.checkLineOfSight();
            //print(current);
            if (current.hit == false || current.mode != RadioControl.STATE_IN_RANGE)
            {
                tryReconect = true;
            }
        }
        else
        {
            tryReconect = true;
        }

        if (tryReconect)
        {
            RadioControl.RadioRaycastData best = null;
            RadioControl bestConnection        = null;
            if (current != null)
            {
                best           = current;
                bestConnection = connectedTo;
            }
            foreach (RadioControl r in radioControlList)
            {
                if (r.isActiveAndEnabled)
                {
                    RadioControl.RadioRaycastData data = r.checkLineOfSight();

                    /*if(best!=null){
                     *      print(data.ToString() + ">" + best.ToString());
                     *      print (data>best);
                     *
                     * }*/
                    if (best == null || data > best)
                    {
                        best           = data;
                        bestConnection = r;
                    }
                }
            }
            connectedTo = bestConnection;
            current     = best;
        }

        if (!current.hit || current.mode == RadioControl.STATE_OUT_OF_RANGE)
        {
            connectionLost();
        }
        if (current.mode == RadioControl.STATE_ON_BORDER)
        {
            connectionBoarder(current.fadeRatio);
        }

        if (current.mode == RadioControl.STATE_IN_RANGE && current.hit)
        {
            connectionCreated();
        }
    }
Exemple #5
0
        public TestState()
            : base()
        {
            //*
            ScrollPanel scrollPanel = new ScrollPanel(10, 400, 400, 400, Panel.BarMode.Close_Drag, this);

            scrollPanel.SetScrollDimensions(1000, 1000);

            TextBox textBox = new TextBox(10, 10, 290, 310, this);

            scrollPanel.AddControl(textBox);

            Button button = new Button("Button", 420, 10, 80, 32, this);

            button.OnTrigger += ButtonPress;
            scrollPanel.AddControl(button);

            TextField textField = new TextField(420, 52, 100, 32, this);

            scrollPanel.AddControl(textField);

            NumberControl numberControl = new NumberControl(420, 94, this);

            numberControl.SetMinimum(10);
            numberControl.SetMaximum(20);
            scrollPanel.AddControl(numberControl);

            RadioButton radioButton = new RadioButton(520, 100, this);

            scrollPanel.AddControl(radioButton);

            string[] items = new string[]
            {
                "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10", "Item 11"
            };
            DropDownBox dropDownBox = new DropDownBox(420, 146, 120, items, this);

            scrollPanel.AddControl(dropDownBox);

            string[] menuOptions = new string[]
            {
                "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10"
            };
            DropDownMenu dropDownMenu = new DropDownMenu(560, 146, 120, "Test Menu", menuOptions, this);

            scrollPanel.AddControl(dropDownMenu);

            ListBox listBox = new ListBox(310, 10, 100, 200, 10, this);

            scrollPanel.AddControl(listBox);

            string[] radioItems = new string[]
            {
                "option 1", "option 2", "option 3"
            };
            RadioControl radioControl = new RadioControl(550, 10, radioItems, this);

            scrollPanel.AddControl(radioControl);

            Label label = new Label(550, 80, 100, 60, this);

            label.SetText("A label." + '\n' + "Line 2.");
            scrollPanel.AddControl(label);

            this.AddControl(scrollPanel);

            string message = "";

            for (int i = 0; i < 20; i++)
            {
                message += "this is a message box" + '\n';
            }
            MessageBox messageBox = new MessageBox(message, this);

            this.AddControl(messageBox);

            Entity entity = Entity.CreateInstance(this.EntityManager, Vector3.Zero);

            this.EntityManager.AddEntity(entity);

            Entity entity2 = Entity.CreateInstance(this.EntityManager, new Vector3(400, 600, 0));

            spriteComponent = new SpriteComponent(entity2);
            spriteComponent.SetXFrames(3);
            spriteComponent.Transform.Parent = entity.GetTransform();
            //spriteComponent.SetTexture(Assets.GetTexture("sprite.png"));
            //spriteComponent.SetSpriteCenter(SpriteComponent.SpriteCenter.Top);

            //*/

            Entity particleEntity            = Entity.CreateInstance(this.EntityManager, new Vector3(400, 400, 0));
            ParticleEmitterData particleData = new ParticleEmitterData();

            particleData.EmitterShape    = PaticleEmitterShape.Rectangle;
            particleData.ParticleTexture = "smoke.png";
            particleData.EmissionRate    = 1000;
            particleData.AngleMin        = 0;
            particleData.AngleMax        = 360;
            particleData.OffsetMin       = 10;
            particleData.OffsetMax       = 120;
            particleData.StartVelocity   = 10;
            particleData.EndVelocity     = 100;
            particleData.StartScale      = 3;
            particleData.EndScale        = 50;
            particleData.RotationSpeed   = 45f;
            particleData.StartColour     = Color4.White;
            particleData.EndColour       = Color4.Transparent;
            //particleData.EndColour.A = 0f;
            particleData.MaxLife = 5;

            new ParticleEmitterComponent(particleEntity, particleData);
            this.EntityManager.AddEntity(particleEntity);
        }