示例#1
0
        private LayoutControl BuildEngineGroupControls(EngineGroup group)
        {
            var root = new LayoutControl {
                Direction = LayoutDirection.Horizontal
            };
            //root.Children.Add(new LabelControl { Text = group.GroupId, Width = 100.0f});
            var cbx = new ToggleControl {
                Text = group.GroupId, Width = 100.0f, IsChecked = group.IsEnabled
            };

            root.Children.Add(cbx);

            var valTextBox = new TextBoxControl {
                Enabled = false, Width = 40.0f, Text = group.Throttle.ToString("f0")
            };

            var slider = new SliderControl
            {
                Direction  = LayoutDirection.Horizontal,
                LeftValue  = 1.0f,
                RightValue = 100.0f,
                Width      = 140.0f,
                Height     = 10.0f,
                Value      = group.Throttle,
                Enabled    = group.IsEnabled,
            };

            slider.ValueChanged += x =>
            {
                group.Throttle        = x;
                group.ThrottleChanged = true;
                valTextBox.Text       = x.ToString("f0");
            };
            root.Children.Add(slider);
            root.Children.Add(valTextBox);

            cbx.CheckChanged += x =>
            {
                if (!x)
                {
                    group.Throttle        = 100.0f;
                    group.ThrottleChanged = true;

                    /*slider.Value = 100.0f;
                     * valTextBox.Text = "100";*/
                }
                else
                {
                    //slider.Enabled = true;
                    group.Throttle        = slider.Value;
                    group.ThrottleChanged = true;
                }
                slider.Enabled  = x;
                group.IsEnabled = x;
            };

            return(root);
        }
示例#2
0
    public void OnClickFirewall(GameObject panelLeft, GameObject panelRight, FireWall firewall)
    {
        this.data = data;
        currentLeftPanel.SetActive(false);
        currentLeftPanel = panelLeft;
        currentLeftPanel.SetActive(true);

        currentRightPanel.SetActive(false);
        currentRightPanel = panelRight;
        currentRightPanel.SetActive(true);


        //set the right firewall for rules management
        ToggleControl currentToggleControl = currentRightPanel.GetComponentInChildren <ToggleControl> ();

        currentToggleControl.firewall = firewall;
    }
示例#3
0
    public void AugmentationPreview()
    {
        int AugCode = ToggleControl.SelectedAug();

        if (AugCode == 1)
        {
            ImagePreview();
        }
        else if (AugCode == 2)
        {
            VideoPreview();
        }
        else
        {
            QuizDBPreview();
        }
    }
 // Start is called before the first frame update
 void Awake()
 {
     tControl = GetComponent <ToggleControl>();
     tControl.ToggleChangedEvent += CheckToggle;
 }
示例#5
0
        void CreateUIElement(Type t, PropertyInfo p, string name)
        {
            DropdownAttribute             dp   = p.GetCustomAttribute <DropdownAttribute>();
            LevelEditorAttribute          le   = p.GetCustomAttribute <LevelEditorAttribute>();
            CurveEditorAttribute          ce   = p.GetCustomAttribute <CurveEditorAttribute>();
            SliderAttribute               sl   = p.GetCustomAttribute <SliderAttribute>();
            FileSelectorAttribute         fsl  = p.GetCustomAttribute <FileSelectorAttribute>();
            HidePropertyAttribute         hp   = p.GetCustomAttribute <HidePropertyAttribute>();
            ColorPickerAttribute          cp   = p.GetCustomAttribute <ColorPickerAttribute>();
            TitleAttribute                ti   = p.GetCustomAttribute <TitleAttribute>();
            TextInputAttribute            tinp = p.GetCustomAttribute <TextInputAttribute>();
            GraphParameterEditorAttribute gpe  = p.GetCustomAttribute <GraphParameterEditorAttribute>();
            ParameterMapEditorAttribute   pme  = p.GetCustomAttribute <ParameterMapEditorAttribute>();
            PromoteAttribute              pro  = p.GetCustomAttribute <PromoteAttribute>();

            //handle very special stuff
            //exposed constant parameter variable names
            if (gpe != null)
            {
                if (node is Graph)
                {
                    Graph g = node as Graph;

                    GraphParameterEditor inp = new GraphParameterEditor(g, g.Parameters);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
            }
            //for graph instance exposed parameters from underlying graph
            else if (pme != null)
            {
                if (node is GraphInstanceNode)
                {
                    GraphInstanceNode gin = node as GraphInstanceNode;
                    ParameterMap      pm  = new ParameterMap(gin.GraphInst, gin.Parameters);
                    Stack.Children.Add(pm);
                    elementLookup[name] = pm;
                }
            }

            string title = name;

            if (ti != null)
            {
                title = ti.Title;
            }

            PropertyInfo op = null;

            //we don't create an element for this one
            //as it is hidden
            if (hp != null)
            {
                return;
            }

            try
            {
                if (ce != null)
                {
                    op = node.GetType().GetProperty(ce.OutputProperty);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }

            if (t.Equals(typeof(Vector4)))
            {
                if (cp != null)
                {
                    PropertyLabel l = null;
                    if (pro != null && node is Node)
                    {
                        l = new PropertyLabel(title, node as Node, name);
                    }
                    else
                    {
                        l       = new PropertyLabel();
                        l.Title = title;
                    }

                    labels.Add(l);
                    Stack.Children.Add(l);

                    ColorSelect cs = new ColorSelect(p, node);
                    Stack.Children.Add(cs);
                    elementLookup[name] = cs;
                }
            }
            else if (t.Equals(typeof(string[])))
            {
                if (dp != null)
                {
                    PropertyLabel l = new PropertyLabel();
                    l.Title = title;
                    labels.Add(l);
                    Stack.Children.Add(l);

                    DropDown inp = new DropDown((string[])p.GetValue(node), node, p, dp.OutputProperty);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
            }
            else if (t.Equals(typeof(bool)))
            {
                PropertyLabel l = null;
                if (pro != null && node is Node)
                {
                    l = new PropertyLabel(title, node as Node, name);
                }
                else
                {
                    l       = new PropertyLabel();
                    l.Title = title;
                }

                labels.Add(l);
                Stack.Children.Add(l);

                ToggleControl tg = new ToggleControl(name, p, node);
                Stack.Children.Add(tg);
                elementLookup[name] = tg;
            }
            else if (t.Equals(typeof(string)))
            {
                if (tinp != null)
                {
                    PropertyLabel l = new PropertyLabel();
                    l.Title = title;
                    labels.Add(l);
                    Stack.Children.Add(l);

                    PropertyInput ip = new PropertyInput(p, node);
                    Stack.Children.Add(ip);
                    elementLookup[name] = ip;
                }
                else if (fsl != null)
                {
                    PropertyLabel l = new PropertyLabel();
                    l.Title = title;
                    labels.Add(l);
                    Stack.Children.Add(l);

                    FileSelector inp = new FileSelector(p, node, fsl.Filter);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
                else if (dp != null)
                {
                    PropertyLabel l = new PropertyLabel();
                    l.Title = title;
                    labels.Add(l);
                    Stack.Children.Add(l);

                    object[] names = dp.Values;
                    DropDown inp   = new DropDown(names, node, p, dp.OutputProperty);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
            }
            if (t.Equals(typeof(float)))
            {
                if (sl != null)
                {
                    PropertyLabel l = null;
                    if (pro != null && node is Node)
                    {
                        l = new PropertyLabel(title, node as Node, name);
                    }
                    else
                    {
                        l       = new PropertyLabel();
                        l.Title = title;
                    }

                    labels.Add(l);
                    Stack.Children.Add(l);

                    NumberSlider inp = new NumberSlider(sl, p, node);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
                else
                {
                    PropertyLabel l = null;
                    if (pro != null && node is Node)
                    {
                        l = new PropertyLabel(title, node as Node, name);
                    }
                    else
                    {
                        l       = new PropertyLabel();
                        l.Title = title;
                    }

                    labels.Add(l);
                    Stack.Children.Add(l);

                    NumberInput inp = new NumberInput(NumberInputType.Float, node, p);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
            }
            else if (t.Equals(typeof(int)))
            {
                if (dp != null)
                {
                    PropertyLabel l = new PropertyLabel();
                    l.Title = title;
                    labels.Add(l);
                    Stack.Children.Add(l);

                    //do a dropdown
                    object[] names = dp.Values;
                    DropDown inp   = new DropDown(names, node, p, dp.OutputProperty);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
                else if (sl != null)
                {
                    PropertyLabel l = null;
                    if (pro != null && node is Node)
                    {
                        l = new PropertyLabel(title, node as Node, name);
                    }
                    else
                    {
                        l       = new PropertyLabel();
                        l.Title = title;
                    }

                    labels.Add(l);
                    Stack.Children.Add(l);

                    NumberSlider inp = new NumberSlider(sl, p, node);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
                else
                {
                    PropertyLabel l = null;
                    if (pro != null && node is Node)
                    {
                        l = new PropertyLabel(title, node as Node, name);
                    }
                    else
                    {
                        l       = new PropertyLabel();
                        l.Title = title;
                    }

                    labels.Add(l);
                    Stack.Children.Add(l);

                    NumberInput inp = new NumberInput(NumberInputType.Int, node, p);
                    Stack.Children.Add(inp);
                    elementLookup[name] = inp;
                }
            }
            else if (t.Equals(typeof(MultiRange)))
            {
                if (le != null)
                {
                    UILevels lv = null;
                    if (node is Node)
                    {
                        Node nd = (Node)node;
                        if (nd.Inputs.Count > 0 && nd.Inputs[0].Input != null)
                        {
                            var    n      = nd.Inputs[0].Input.Node;
                            byte[] result = n.GetPreview(n.Width, n.Height);

                            RawBitmap bit = null;

                            if (result != null)
                            {
                                bit = new RawBitmap(n.Width, n.Height, result);
                            }

                            lv = new UILevels(bit, node, p);
                        }
                        else
                        {
                            lv = new UILevels(null, node, p);
                        }
                        Stack.Children.Add(lv);
                        elementLookup[name] = lv;
                    }
                }
            }
            else if (op != null && ce != null)
            {
                UICurves cv = new UICurves(p, op, node);
                Stack.Children.Add(cv);
                elementLookup[name] = cv;
            }
            else if (t.IsEnum)
            {
                PropertyLabel l = new PropertyLabel();
                l.Title = title;
                labels.Add(l);
                Stack.Children.Add(l);

                string[] names = Enum.GetNames(t);
                DropDown inp   = new DropDown(names, node, p);
                Stack.Children.Add(inp);
                elementLookup[name] = inp;
            }
        }
示例#6
0
    public string GenerateMetaData()
    {
        int    type     = ToggleControl.SelectedAug();
        string metadata = "" + type;

        if (type == 1 || type == 2)     //Type 1 corresponds to Images and Type 2 corresponds to Videos while Type 3 Corresponds to Quiz
        {
            if (!AugLinkField.text.Equals(""))
            {
                if (type == 1)
                {
                    if (!AugLinkField.text.EndsWith(".jpg") && !AugLinkField.text.EndsWith(".png") && !AugLinkField.text.EndsWith(".jpeg"))    //check if the image ends with .jpeg or .png
                    {
                        LogMessage("Please provide a downloadable link of image of type (jpg/jpeg/png)");
                        return(null);
                    }
                }
                else
                {
                    if (!AugLinkField.text.EndsWith(".mp4") && !AugLinkField.text.EndsWith(".mkv"))     // check if tvideo ends with .mkv or .mp4
                    {
                        LogMessage("Please provide a downloadable link of video of type (.mp4/.mkv)");
                        return(null);
                    }
                }
                metadata += " " + AugLinkField.text;  //SetMetaData Metadata accordingly
                Debug.Log(metadata);
            }
            else
            {
                string errormsg = "";
                if (type == 1)
                {
                    errormsg += "Please specify link of Image";
                }
                else
                {
                    errormsg += "Please specify link of Video";
                }
                LogMessage(errormsg);
                return(null);
            }
        }
        else
        {
            if (NoOfQuestions.text.Equals(""))
            {
                LogMessage("Please Enter the No of Questions!");
                return(null);
            }
            else
            {
                metadata += " " + NoOfQuestions.text;
            }
            string SelectedDomain = DomainDropDown.options[DomainDropDown.value].text;
            if (SelectedDomain.Equals("Select Domain"))
            {
                LogMessage("Please Select the Domain!");
                return(null);
            }
            else
            {
                metadata += " " + username + SelectedDomain;
            }
        }

        return(metadata);
    }