Exemplo n.º 1
0
 private void StereoModeChoiceAction(ChoiceItem selected)
 {
     if (stereoModes.ContainsKey(selected.Label))
     {
         CurrentStereoMode = stereoModes[selected.Label];
     }
 }
Exemplo n.º 2
0
        public ActionResult DeleteChoiceItem(int id)
        {
            ChoiceItem dbChoiceItem = _pollService.GetChoiceItemById(id);

            if (dbChoiceItem == null)
            {
                return(EntityNotFoundView());
            }

            _pollService.DeleteChoiceItem(dbChoiceItem);

            bool isSaved;

            try
            {
                isSaved = _unitOfWork.SaveChanges() > 0;
            }
            catch
            {
                isSaved = false;
            }

            if (isSaved)
            {
                Logger.SaveLog(new DeleteChoiceItemProvider(dbChoiceItem.Id));
            }

            return(null);
        }
        public void ShouldBeEqual()
        {
            var choiceItem  = new ChoiceItem("1", "One");
            var choiceItem2 = new ChoiceItem("1", "Two");

            choiceItem.Equals(choiceItem2).Should().BeTrue();
        }
        public override void Configure(IFieldDefinition definition)
        {
            base.Configure(definition);
            var tdefinition = definition as ITaxonFieldDefinition;
            var tManager    = TaxonomyManager.GetManager();
            var tid         = tdefinition.TaxonomyId;
            var taxonomy    = tManager.GetTaxonomies <FlatTaxonomy>().Where(t => t.Id == tid).SingleOrDefault();

            if (taxonomy != null)
            {
                var countries = taxonomy.Taxa.OrderBy(c => c.Title.ToString());
                this.RenderChoicesAs = Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.CheckBoxes; //
                // or you can use Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.DropDown for dropdown

                this.Choices.Clear();
                foreach (var taxon in countries)
                {
                    var choice = new ChoiceItem();
                    choice.Value   = taxon.Id.ToString();
                    choice.Text    = taxon.Title;
                    choice.Enabled = true;
                    this.Choices.Add(choice);
                }
            }
        }
        public override void Configure(IFieldDefinition definition)
        {
            base.Configure(definition);
            var tdefinition = definition as ITaxonFieldDefinition;
            var tManager = TaxonomyManager.GetManager();
            var tid = tdefinition.TaxonomyId;
            var taxonomy = tManager.GetTaxonomies<FlatTaxonomy>().Where(t => t.Id == tid).SingleOrDefault();
            if (taxonomy != null)
            {
                var colorsTaxa = taxonomy.Taxa.OrderBy(c => c.Title.ToString());
                this.RenderChoicesAs = Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.DropDown;

                // or you can use Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.CheckBoxes for multiple choice

                this.Choices.Clear();
                foreach (var taxon in colorsTaxa)
                {
                    var choice = new ChoiceItem();
                    choice.Value = taxon.Id.ToString();
                    choice.Text = taxon.Title;
                    choice.Enabled = true;
                    this.Choices.Add(choice);
                }
            }
        }
Exemplo n.º 6
0
    private void Start()
    {
        if (PlayerChoices.Instance.canDash)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Agility";
            newItem.choiceDescription = "Your ability to teleport.";
        }

        if (PlayerChoices.Instance.canInfiniJump)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Flight";
            newItem.choiceDescription = "Your ability to fly.";
        }

        if (PlayerChoices.Instance.canSlowTime)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Reflex";
            newItem.choiceDescription = "Your ability to slow down time.";
        }

        if (PlayerChoices.Instance.canAttack)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Strength";
            newItem.choiceDescription = "Your ability to attack.";
        }

        if (PlayerChoices.Instance.hasFullVision)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Perception";
            newItem.choiceDescription = "Your ability to see far.";
        }

        if (transform.childCount == 0)
        {
            ChoiceItem newItem = Instantiate(itemPrefab.gameObject, transform).GetComponent <ChoiceItem>();
            newItem.choiceName        = "Resilience";
            newItem.choiceDescription = "Your spirit.";
        }

        ToggleGroup group = GetComponent <ToggleGroup>();
        bool        found = false;

        foreach (Transform t in transform)
        {
            Toggle toggle = t.GetComponent <Toggle>();
            toggle.group = group;
            if (!found)
            {
                toggle.isOn = true;
                found       = true;
            }
        }
    }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes all data members. Allows to set parent question and copy data from another choice item.
 /// </summary>
 /// <param name="oldInstance"><see cref="ChoiceItem"/> instance that constructor takes data from.</param>
 /// <param name="parent"><see cref="ExclusiveChoiceQuestion"/> instance that item belongs to.</param>
 public ChoiceItem(ChoiceItem oldInstance, Question parent)
 {
     Parent         = parent;
     Name           = oldInstance.Name;
     IsChosen       = oldInstance._isChosen;
     _isMoreDetails = oldInstance._isMoreDetails;
     _isSkipLogic   = oldInstance._isSkipLogic;
     _skipTo        = oldInstance._skipTo;
     _isInverse     = oldInstance._isInverse;
     MoreDetails    = string.Empty;
 }
Exemplo n.º 8
0
        public ActionResult EditChoiceItem(int id)
        {
            ChoiceItem choiceItem = _pollService.GetChoiceItemById(id);

            if (choiceItem == null)
            {
                return(EntityNotFoundView());
            }

            return(ViewOrPartialView(choiceItem));
        }
Exemplo n.º 9
0
 private void AddModeChoiceAction(ChoiceItem selected)
 {
     if (selected.Label == "Add Static")
     {
         this.AddWithPhysics = false;
     }
     else if (selected.Label == "Add Dynamic")
     {
         this.AddWithPhysics = true;
     }
 }
Exemplo n.º 10
0
 private void FocusChoiceAction(ChoiceItem selected)
 {
     if (selected.Label == "AutoFocus")
     {
         AutoFocus = true;
     }
     else
     {
         AutoFocus = false;
     }
 }
Exemplo n.º 11
0
 private void ActionChoiceAction(ChoiceItem selected)
 {
     if (selected.Label == "Select")
     {
         ButtonAction = Action.Select;
     }
     else if (selected.Label == "Drag")
     {
         ButtonAction = Action.Drag;
     }
     else if (selected.Label == "Add")
     {
         ButtonAction = Action.Add;
     }
 }
Exemplo n.º 12
0
        public ActionResult CreateChoiceItem(int choiceId)
        {
            Choice choice = _pollService.GetChoiceById(choiceId);

            if (choice == null)
            {
                return(EntityNotFoundView());
            }

            var item = new ChoiceItem {
                Id = _unitOfWork.GetNextTableIdentity("ChoiceItems"), OwnerId = choice.Id
            };

            return(ViewOrPartialView(item));
        }
        private static WcfField BuildBooleanWcfField(Type contentType, string fieldName, bool isHidden)
        {
            WcfField wcfField = new WcfField()
            {
                Name         = fieldName,
                ContentType  = contentType.FullName,
                FieldTypeKey = UserFriendlyDataType.YesNo.ToString(),
                IsCustom     = true,

                //Database mapping
                DatabaseMapping = new WcfDatabaseMapping()
                {
                    ClrType    = typeof(bool).FullName,
                    ColumnName = fieldName.ToLower(),
                    Nullable   = true,
                    DbType     = "BIT"
                },

                //Field definition
                Definition = new WcfFieldDefinition()
                {
                    Title          = fieldName,
                    FieldName      = fieldName,
                    FieldType      = typeof(ChoiceField).FullName,
                    RenderChoiceAs = RenderChoicesAs.SingleCheckBox,
                    Hidden         = isHidden
                }
            };

            ChoiceItem yesNoItem = new ChoiceItem()
            {
                Text     = fieldName,
                Value    = "true",
                Selected = false
            };

            List <ChoiceItem> items = new List <ChoiceItem>();

            items.Add(yesNoItem);

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            wcfField.Definition.Choices = serializer.Serialize(items);

            CustomFieldsContext.Validate(wcfField, contentType);

            return(wcfField);
        }
Exemplo n.º 14
0
        public ActionResult CreateChoiceItem(int choiceId, ChoiceItem choiceItem)
        {
            Choice choice = _pollService.GetChoiceById(choiceId);

            if (choice == null)
            {
                return(EntityNotFoundView());
            }

            choiceItem.OwnerId = choice.Id;
            choiceItem.Owner   = choice;

            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("",
                                         ValidationResources.InvalidState);

                return(ViewOrPartialView(choice));
            }

            _pollService.SaveChoiceItem(choiceItem);

            bool isSaved;

            try
            {
                isSaved = _unitOfWork.SaveChanges() > 0;
            }
            catch
            {
                isSaved = false;
            }

            if (isSaved)
            {
                Logger.SaveLog(new CreateChoiceItemProvider(choiceItem));
            }
            else
            {
                ModelState.AddModelError("", ValidationResources.CreationFailure);

                return(ViewOrPartialView(choiceItem));
            }

            return(RedirectToAction("EditChoiceItem", new { choiceItem.Id }));
        }
Exemplo n.º 15
0
        public ActionResult EditChoiceItemPost(int id, FormCollection values)
        {
            ChoiceItem dbChoiceItem = _pollService.GetChoiceItemById(id);

            if (dbChoiceItem == null)
            {
                return(EntityNotFoundView());
            }

            TryUpdateModel(dbChoiceItem,
                           new[] { "Text" });

            if (!TryValidateModel(dbChoiceItem))
            {
                ModelState.AddModelError("",
                                         ValidationResources.InvalidState);

                return(ViewOrPartialView(dbChoiceItem));
            }

            bool isSaved;

            try
            {
                isSaved = _unitOfWork.SaveChanges() > 0;
            }
            catch
            {
                isSaved = false;
            }

            if (isSaved)
            {
                Logger.SaveLog(new UpdateChoiceItemProvider(dbChoiceItem));
            }
            if (!isSaved)
            {
                ModelState.AddModelError("", ValidationResources.UpdateFailure);

                return(ViewOrPartialView(dbChoiceItem));
            }

            return(RedirectToAction("EditChoiceItem", new { dbChoiceItem.Id }));
        }
Exemplo n.º 16
0
 private void ProjectionChoiceAction(ChoiceItem selected)
 {
     if (selected.Label == "Vertical")
     {
         sceneManager.Camera.Projection.ProjectionType = ProjectionType.PerspectiveVertical;
     }
     else if (selected.Label == "Horizontal")
     {
         sceneManager.Camera.Projection.ProjectionType = ProjectionType.PerspectiveHorizontal;
     }
     else if (selected.Label == "V. Stereo")
     {
         sceneManager.Camera.Projection.ProjectionType = ProjectionType.StereoscopicVertical;
     }
     else if (selected.Label == "H. Stereo")
     {
         sceneManager.Camera.Projection.ProjectionType = ProjectionType.StereoscopicHorizontal;
     }
 }
Exemplo n.º 17
0
        private void LightConfigAction(ChoiceItem selected)
        {
            if (selected.Label == CurrentLightConfig)
            {
                return;
            }

            CurrentLightConfig = selected.Label;

            if (selected.Label == "AO")
            {
                sceneManager.ClearLights();
                sceneManager.AddAOLights(13);
            }
            else if (selected.Label == "Basic")
            {
                sceneManager.ClearLights();
                sceneManager.AddBasicLights();
            }
            Reset();
        }
        public void ShouldImplicitConvertToSelectListItem(string value, string text, string group, bool disabled)
        {
            var choiceItem     = new ChoiceItem(value, text, group, disabled);
            var selectListItem = new SelectListItem
            {
                Value    = value,
                Text     = text,
                Disabled = disabled,
            };

            if (!string.IsNullOrWhiteSpace(group))
            {
                selectListItem.Group = new SelectListGroup {
                    Name = group
                };
            }

            var convertedChoiceItem = (SelectListItem)choiceItem;

            convertedChoiceItem.Should().BeEquivalentTo(selectListItem);
        }
        public override void Configure(IFieldDefinition definition)
        {
            base.Configure(definition);
            var aManager = AgentsManager.GetManager();
            var agents = aManager.GetAgents().OrderBy(a => a.Title).Where(a => a.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
            if (agents != null)
            {
                this.RenderChoicesAs = Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.DropDown; //
                // or you can use Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.CheckBoxes for multiple choice

                this.Choices.Clear();
                foreach (var agent in agents)
                {
                    var choice = new ChoiceItem();
                    choice.Value = agent.Id.ToString();
                    choice.Text = agent.Title;
                    choice.Enabled = true;
                    this.Choices.Add(choice);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Method creating an example Questionnaire datastructure for test purpose4s.
        /// </summary>
        /// <returns> example Questionnaire datastructure </returns>
        internal QuestionnaireData createExampleQuestionnaireData()
        {
            QuestionItem q1 = new QuestionItem(1, "How do you feel?");

            q1.group = "A";
            QuestionItem q2 = new QuestionItem(2, "Do you like games?");

            q2.group = "A";
            QuestionItem q3 = new QuestionItem(3, "Do you like fast cars?");

            q3.group = "A";
            QuestionItem q4 = new QuestionItem(4, "Do you enjoy silence?");

            q4.group = "A";
            QuestionItem q5 = new QuestionItem(5, "Do you like swimming?");

            q5.group = "A";
            QuestionItem[]      qia = { q1, q2, q3, q4, q5 };
            List <QuestionItem> qil = new List <QuestionItem>(qia);

            ChoiceItem c1 = new ChoiceItem(0, "Very good/much.");
            ChoiceItem c2 = new ChoiceItem(1, "I do not know.");
            ChoiceItem c3 = new ChoiceItem(2, "Very bad/Not very much.");

            ChoiceItem[]      cia = { c1, c2, c3 };
            List <ChoiceItem> cil = new List <ChoiceItem>(cia);

            QuestionnaireData qd = new QuestionnaireData(qil, cil);

            qd.title        = "Fancy questionnaire:";
            qd.instructions = "Please fill in the following form.";
            qd.groupList    = new QuestionnaireGroupList();

            QuestionnaireGroup qg1 = new QuestionnaireGroup("A", "SUM/5");

            QuestionnaireGroup[] qga = { qg1 };
            qd.groupList.groups = new List <QuestionnaireGroup>(qga);

            return(qd);
        }
Exemplo n.º 21
0
        private Area Materials()
        {
            if (materialManager == null)
            {
                return(null);
            }

            var list = new MenuList(renderer, Orientation.Vertical);

            list.ChildLayoutStyle = Area.AreaLayoutStyle.ExtendHorizontal;

            var choice = new Choice(Orientation.Vertical);

            choice.Style  = Style.NullPadding;
            choice.Action = MaterialChoiceAction;
            string[] materials = { "pearl", "gold", "red", "green", "cyan", "blue", "magenta", "noisy", "pink", "EdgeLines", "transparent", "Grid" };

            foreach (var name in materials)
            {
                var item = new ChoiceItem(renderer, name);
                choice.Add(item);
                if (name == CurrentMaterial)
                {
                    choice.Selected = item;
                }
            }
            roughness = new Slider(renderer, "Roughness", null, 0, 0.0f, 1.0f, 0.0f, 1.0f);
            roughness.IsLogarithmic = true;
            ChooseMaterial();

            //var colorPicker = new ColorPicker(materialManager, renderer);
            //list.Add(colorPicker);
            list.Add(roughness);
            list.Add(choice);

            var expand = new Button(renderer, "Materials", SetActive);

            expand.Link = list;
            return(expand);
        }
Exemplo n.º 22
0
        public override void Configure(IFieldDefinition definition)
        {
            base.Configure(definition);
            var aManager = AgentsManager.GetManager();
            var agents   = aManager.GetAgents().OrderBy(a => a.Title).Where(a => a.Status == Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);

            if (agents != null)
            {
                this.RenderChoicesAs = Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.DropDown; //
                // or you can use Telerik.Sitefinity.Web.UI.Fields.Enums.RenderChoicesAs.CheckBoxes for multiple choice

                this.Choices.Clear();
                foreach (var agent in agents)
                {
                    var choice = new ChoiceItem();
                    choice.Value   = agent.Id.ToString();
                    choice.Text    = agent.Title;
                    choice.Enabled = true;
                    this.Choices.Add(choice);
                }
            }
        }
Exemplo n.º 23
0
        private void MaterialChoiceAction(ChoiceItem selected)
        {
            if (CurrentMaterial == selected.Label)
            {
                return;
            }

            CurrentMaterial = selected.Label;
            ChooseMaterial();
            UpdateNoise();
            try
            {
                foreach (Model model in selectionManager.Models)
                {
                    sceneManager.RemoveModel(model);
                    model.Batch.Material = materialManager[selected.Label];
                    sceneManager.AddModel(model);
                }
            }
            catch (System.Exception)
            {
            }
        }
Exemplo n.º 24
0
    public static ConversationItem FromXml(XmlNode node)
    {
        var newItem = new ChoiceItem();
        newItem.Text = node.Value.Trim();

        var options = new List<Option>();

        var optionNodes = node.ChildNodes.OfType<XmlNode>().Where(x => x.Name == "option");

        foreach (var on in optionNodes)
        {
            var text = on.Value.Trim();
            var branch = on["confirm-branch"].Value;

            options.Add(new Option(text, branch));
        }

        newItem.SetBranch(node);

        newItem.Options = options.ToArray();

        return newItem;
    }
Exemplo n.º 25
0
    public void MakeChoice()
    {
        ToggleGroup group = GetComponent <ToggleGroup>();

        foreach (Toggle t in group.ActiveToggles())
        {
            ChoiceItem item = t.GetComponent <ChoiceItem>();
            switch (item.choiceName)
            {
            case "Agility":
                PlayerChoices.Instance.canDash = false;
                break;

            case "Flight":
                PlayerChoices.Instance.canInfiniJump = false;
                break;

            case "Strength":
                PlayerChoices.Instance.canAttack = false;
                break;

            case "Perception":
                PlayerChoices.Instance.hasFullVision = false;
                break;

            case "Reflex":
                PlayerChoices.Instance.canSlowTime = false;
                break;

            case "Resilience":
                PlayerChoices.Instance.SacrificeSelf();
                return;
            }
        }
        PlayerChoices.Instance.FinishedChoosing();
    }
Exemplo n.º 26
0
        private Area Palette()
        {
            if (brushManager == null)
            {
                return(null);
            }

            var list = new MenuList(renderer, Orientation.Vertical);

            var palette = new Palette(brushManager, materialManager, renderer);

            palette.Name = "Brush palette";

            list.Add(palette);
            CurrentPalette = brushManager.Dictionaries.First().Key;

            var choice = new Choice(Orientation.Vertical);

            choice.Style  = Style.NullPadding;
            choice.Action = PaletteChoiceAction;
            foreach (var kvp in brushManager.Dictionaries)
            {
                var item = new ChoiceItem(renderer, kvp.Key);
                choice.Add(item);
                if (kvp.Key == "cupola")
                {
                    choice.Selected = item;
                }
            }
            list.Add(choice);

            var expand = new Button(renderer, "Palette", SetActive);

            expand.Link = list;
            return(expand);
        }
Exemplo n.º 27
0
        public ActionResult <string> Get(int id)
        {
            con = new SqlConnection("Server=localhost;Database=" + databaseName + ";Integrated Security=SSPI");
            string qry = "getScene " + id;

            da = new SqlDataAdapter(qry, con);
            ds = new DataSet();
            da.Fill(ds);
            SceneItem item = new SceneItem
            {
                SceneContent  = ds.Tables[0].Rows[0].ItemArray[0].ToString(),
                SceneImage    = ds.Tables[0].Rows[0].ItemArray[1].ToString(),
                SceneId       = (int)ds.Tables[0].Rows[0].ItemArray[2],
                EndingType    = ds.Tables[0].Rows[0].ItemArray[3].ToString(),
                SceneLocation = ds.Tables[0].Rows[0].ItemArray[4].ToString()
            };

            qry = "getChoicesFromScene " + id;
            da  = new SqlDataAdapter(qry, con);
            ds  = new DataSet();
            da.Fill(ds);
            List <ChoiceItem> choices = new List <ChoiceItem>();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                ChoiceItem choice = new ChoiceItem();
                choice.Consequent = (int)ds.Tables[0].Rows[i].ItemArray[0];
                choice.Text       = ds.Tables[0].Rows[i].ItemArray[1].ToString();
                choices.Add(choice);
            }
            item.Choices = choices;

            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(item);

            return(jsonString);
        }
Exemplo n.º 28
0
 public void AddChoiceItem(ChoiceItem newItem)
 {
     _choiceItemList.Add(newItem);
 }
Exemplo n.º 29
0
 private void PaletteChoiceAction(ChoiceItem selected)
 {
     CurrentPalette = selected.Label;
 }
Exemplo n.º 30
0
 private static StepikApiChoiceOption ConvertUlearnChoiceItemIntoStepikChoiceOption(ChoiceItem item)
 {
     return(new StepikApiChoiceOption(item.Description, item.IsCorrect.IsTrueOrMaybe(), item.Explanation));
 }
Exemplo n.º 31
0
 public void SaveChoiceItem(ChoiceItem choiceItem)
 {
     _choiceItems.Add(choiceItem);
 }
Exemplo n.º 32
0
 public void DeleteChoiceItem(ChoiceItem choiceItem)
 {
     _choiceItems.Remove(choiceItem);
 }
Exemplo n.º 33
0
    private void CreateChoiceItem()
    {
        _choiceNum++;
        List<Person> listOne = _splitPoint.newPaths[0].pathPoints[2].GetComponent<PersonPoint>().GetPeopleList();
        List<Person> listTwo =_splitPoint.newPaths[1].pathPoints[2].GetComponent<PersonPoint>().GetPeopleList();

        _currentChoiceItem = new ChoiceItem(_choiceNum,listOne,listTwo);
        scoreManager.AddChoiceItem(_currentChoiceItem);
    }
Exemplo n.º 34
0
        public List <ChoiceItem> getChoiceData(string query)
        {
            List <ChoiceItem> list       = null;
            SqlConnection     connection = new SqlConnection(CONN_STRING);

            try
            {
                connection.Open();

                SqlCommand command = new SqlCommand(query, connection);
                try
                {
                    SqlDataReader reader = command.ExecuteReader();
                    try
                    {
                        list = new List <ChoiceItem>();
                        int fieldCount = reader.FieldCount;
                        while (reader.Read())
                        {
                            ChoiceItem item = new ChoiceItem();

                            string kode = "";
                            if (!reader.IsDBNull(0))
                            {
                                kode = reader[0].ToString();
                            }
                            item.Kode = kode;


                            string name = "";
                            if (fieldCount > 1)
                            {
                                string second = reader[1].ToString();
                                if (second != null && second.Length > 0 && second != kode)
                                {
                                    name = second + "-" + kode;
                                }
                                else
                                {
                                    name = kode;
                                }
                            }
                            else
                            {
                                name = kode;
                            }
                            item.Value = name;


                            list.Add(item);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e.Message);
                        errorMessage = e.Message;
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    errorMessage = e.Message;
                }
                finally
                {
                    command.Dispose();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                errorMessage = e.Message;
            }
            finally
            {
                connection.Dispose();
            }

            return(list);
        }
        private void CreateContactForms()
        {
            var formId = new Guid(SampleConstants.ContactUsFormId);
            Dictionary<string, object> localizedProperties = new Dictionary<string, object>();

            var result = SampleUtilities.CreateLocalizedForm(formId, SampleConstants.ContactUsFormName, SampleConstants.ContactUsFormTitle, SampleConstants.ContactUsFormSuccessMessage, "en");

            if (result)
            {
                SampleUtilities.CreateLocalizedForm(new Guid(SampleConstants.ContactUsFormId), string.Empty, SampleConstants.ContactUsFormTitleGerman, SampleConstants.ContactUsFormSuccessMessageGerman, "de");

                #region Instructional text

                FormInstructionalText instructionalText = new FormInstructionalText();
                instructionalText.Html = @"Send us a message below and we will get back to you as soon as possible (* denotes required responses in the contact form)";

                var controlID = SampleUtilities.AddControlToLocalizedForm(formId, instructionalText, "Body", "Instructional text", "en");

                instructionalText.Html = @"Senden Sie uns eine Nachricht aus und wir werden uns umgehend mit Ihnen so bald wie m&ouml;glich (* kennzeichnet erforderliche Reaktionen in das Kontaktformular)";

                localizedProperties.Clear();
                localizedProperties.Add("Html", @"Senden Sie uns eine Nachricht aus und wir werden uns umgehend mit Ihnen so bald wie m&ouml;glich (* kennzeichnet erforderliche Reaktionen in das Kontaktformular)");

                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Main layout

                LayoutControl mainLayout = new LayoutControl();

                List<ColumnDetails> mainLayoutColumns = new List<ColumnDetails>();

                ColumnDetails mainLayoutColumn1 = new ColumnDetails()
                {
                    ColumnSpaces = new ColumnSpaces(0, 15, 0, 0),
                    PlaceholderId = "Left"
                };
                mainLayoutColumns.Add(mainLayoutColumn1);

                ColumnDetails mainLayoutColumn2 = new ColumnDetails()
                {
                    ColumnSpaces = new ColumnSpaces(0, 0, 0, 15),
                    PlaceholderId = "Right"
                };
                mainLayoutColumns.Add(mainLayoutColumn2);

                mainLayout.Layout = SampleUtilities.GenerateLayoutTemplate(mainLayoutColumns, string.Empty);
                mainLayout.ID = "Main";
                SampleUtilities.AddControlToLocalizedForm(formId, mainLayout, "Body", "50% + 50% (custom)", "en");

                #endregion

                #region Name box

                FormTextBox nameBox = new FormTextBox();
                nameBox.Title = "Your Name*";
                nameBox.TextBoxSize = FormControlSize.Medium;
                nameBox.ValidatorDefinition.Required = true;
                nameBox.ValidatorDefinition.MaxLength = 40;
                controlID = SampleUtilities.AddControlToLocalizedForm(formId, nameBox, "Main_Left", "Textbox", "en");

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Ihr Name*");
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Email box
                FormTextBox emailBox = new FormTextBox();
                emailBox.Title = "Your Email*";
                emailBox.TextBoxSize = FormControlSize.Medium;
                emailBox.ValidatorDefinition.Required = true;
                emailBox.ValidatorDefinition.MaxLength = 40;
                controlID = SampleUtilities.AddControlToLocalizedForm(formId, emailBox, "Main_Left", "Textbox", "en");

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Ihr Email*");
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Categories list
                FormDropDownList categoriesList = new FormDropDownList();
                categoriesList.Title = "Category";
                categoriesList.Choices.Clear();

                ChoiceItem athleticsItem = new ChoiceItem()
                {
                    Text = "Athletics",
                    Value = "Athletics",
                    Description = "Athletics"
                };
                categoriesList.Choices.Add(athleticsItem);

                ChoiceItem admissionsItem = new ChoiceItem()
                {
                    Text = "Admissions",
                    Value = "Admissions",
                    Description = "Admissions"
                };
                categoriesList.Choices.Add(admissionsItem);

                ChoiceItem shopItem = new ChoiceItem()
                {
                    Text = "Shop",
                    Value = "Shop",
                    Description = "Shop"
                };
                categoriesList.Choices.Add(shopItem);

                controlID = SampleUtilities.AddControlToLocalizedForm(formId, categoriesList, "Main_Left", "Dropdown list", "en");

                athleticsItem.Text = "Sport";
                athleticsItem.Description = "Sport";
                admissionsItem.Text = "Zulassung";
                admissionsItem.Description = "Zulassung";
                shopItem.Text = "E-Shop";
                shopItem.Description = "E-Shop";

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Kategorie");
                localizedProperties.Add("Choices", categoriesList.Choices);
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Message box

                FormParagraphTextBox messageBox = new FormParagraphTextBox();
                messageBox.Title = "Message*";
                messageBox.ParagraphTextBoxSize = FormControlSize.Medium;
                messageBox.ValidatorDefinition.Required = true;
                messageBox.ValidatorDefinition.MaxLength = 400;

                controlID = SampleUtilities.AddControlToLocalizedForm(formId, messageBox, "Main_Left", "Paragraph textbox", "en");

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Meldung*");
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region SubmitButton

                FormSubmitButton submitButton = new FormSubmitButton();
                submitButton.Text = "Send";
                submitButton.ButtonSize = FormControlSize.Small;

                controlID = SampleUtilities.AddControlToLocalizedForm(formId, submitButton, "Main_Left", "Submit button", "en");

                submitButton.Text = "Senden";

                localizedProperties.Clear();
                localizedProperties.Add("Text", "Senden");
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Multiple choice

                FormMultipleChoice genderMultipleChoice = new FormMultipleChoice();
                genderMultipleChoice.Title = "Sex";
                genderMultipleChoice.Choices.Clear();

                ChoiceItem maleItem = new ChoiceItem()
                {
                    Text = "Male",
                    Value = "Male",
                    Description = "Male"
                };
                genderMultipleChoice.Choices.Add(maleItem);

                ChoiceItem femaleItem = new ChoiceItem()
                {
                    Text = "Female",
                    Value = "Female",
                    Description = "Female"
                };
                genderMultipleChoice.Choices.Add(femaleItem);

                controlID = SampleUtilities.AddControlToLocalizedForm(formId, genderMultipleChoice, "Main_Right", "Multiple choice", "en");

                genderMultipleChoice.Title = "Geschlecht";
                maleItem.Text = "Männlich";
                maleItem.Description = "Männlich";
                femaleItem.Text = "Weiblich";
                femaleItem.Description = "Weiblich";

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Geschlecht");
                localizedProperties.Add("Choices", genderMultipleChoice.Choices);
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");

                #endregion

                #region Major checkboxes

                FormCheckboxes majorCheckboxes = new FormCheckboxes();
                majorCheckboxes.Title = "What major are you interested in?";
                majorCheckboxes.Choices.Clear();

                ChoiceItem artHistory = new ChoiceItem()
                {
                    Text = "Art History",
                    Value = "Art History",
                    Description = "Art History"
                };
                majorCheckboxes.Choices.Add(artHistory);

                ChoiceItem asianStudies = new ChoiceItem()
                {
                    Text = "Asian Studies",
                    Value = "Asian Studies",
                    Description = "Asian Studies"
                };
                majorCheckboxes.Choices.Add(asianStudies);

                ChoiceItem astronomy = new ChoiceItem()
                {
                    Text = "Astronomy",
                    Value = "Astronomy",
                    Description = "Astronomy"
                };
                majorCheckboxes.Choices.Add(astronomy);

                ChoiceItem biochemistry = new ChoiceItem()
                {
                    Text = "Biochemistry and Molecular Biology",
                    Value = "Biochemistry and Molecular Biology",
                    Description = "Biochemistry and Molecular Biology"
                };
                majorCheckboxes.Choices.Add(biochemistry);

                ChoiceItem biology = new ChoiceItem()
                {
                    Text = "Biology",
                    Value = "Biology",
                    Description = "Biology"
                };
                majorCheckboxes.Choices.Add(biology);

                ChoiceItem chemistry = new ChoiceItem()
                {
                    Text = "Chemistry",
                    Value = "Chemistry",
                    Description = "Chemistry"
                };
                majorCheckboxes.Choices.Add(chemistry);

                ChoiceItem chinese = new ChoiceItem()
                {
                    Text = "Chinese",
                    Value = "Chinese",
                    Description = "Chinese"
                };
                majorCheckboxes.Choices.Add(chinese);

                ChoiceItem classics = new ChoiceItem()
                {
                    Text = "Classics",
                    Value = "Classics",
                    Description = "Classics"
                };
                majorCheckboxes.Choices.Add(classics);

                ChoiceItem computerScience = new ChoiceItem()
                {
                    Text = "Computer Science",
                    Value = "Computer Science",
                    Description = "Computer Science"
                };
                majorCheckboxes.Choices.Add(computerScience);

                ChoiceItem economics = new ChoiceItem()
                {
                    Text = "Economics",
                    Value = "Economics",
                    Description = "Economics"
                };
                majorCheckboxes.Choices.Add(economics);

                controlID = SampleUtilities.AddControlToLocalizedForm(formId, majorCheckboxes, "Main_Right", "Checkboxes", "en");

                majorCheckboxes.Title = "Welche Fächer interessieren Sie?";

                artHistory.Text = "Kunstgeschichte";
                artHistory.Description = "Kunstgeschichte";
                asianStudies.Text = "Asiatische Lehren";
                asianStudies.Description = "Asiatische Lehren";
                astronomy.Text = "Astronomie";
                astronomy.Description = "Astronomie";
                biology.Text = "Biologie";
                biology.Description = "Biologie";
                biochemistry.Text = "Biochemie und Molekularbiologie";
                biochemistry.Description = "Biochemie und Molekularbiologie";
                chinese.Text = "Chinesisch";
                chinese.Description = "Chinesisch";
                classics.Text = "Klassische Lehren";
                classics.Description = "Klassische Lehren";
                computerScience.Text = "Informatik";
                computerScience.Description = "Informatik";
                economics.Text = "Wirtschaft";
                economics.Description = "Wirtschaft";
                chemistry.Text = "Chemie";
                chemistry.Description = "Chemie";

                localizedProperties.Clear();
                localizedProperties.Add("Title", "Welche Fächer interessieren Sie?");
                localizedProperties.Add("Choices", majorCheckboxes.Choices);
                SampleUtilities.UpdateControlInLocalizedForm(controlID, formId, localizedProperties, "de");
                #endregion
            }
        }
 /// <summary>
 /// Initializes all data members. Allows to set parent question and copy data from another choice item.
 /// </summary>
 /// <param name="oldInstance"><see cref="ChoiceItem"/> instance that constructor takes data from.</param>
 /// <param name="parent"><see cref="ExclusiveChoiceQuestion"/> instance that item belongs to.</param>
 public ChoiceItem(ChoiceItem oldInstance, Question parent)
 {
     Parent = parent;
     Name = oldInstance.Name;
     IsChosen = oldInstance._isChosen;
     _isMoreDetails = oldInstance._isMoreDetails;
     _isSkipLogic = oldInstance._isSkipLogic;
     _skipTo = oldInstance._skipTo;
     _isInverse = oldInstance._isInverse;
     MoreDetails = string.Empty;
 }
Exemplo n.º 37
0
        private Area Camera()
        {
            var list = new MenuList(renderer, Orientation.Vertical);

            list.Name             = "list";
            list.ChildLayoutStyle = Area.AreaLayoutStyle.ExtendHorizontal;

            Camera           camera = sceneManager.Camera;
            StereoParameters stereo = camera.Projection.StereoParameters;

            list.ChildLayoutStyle   = Area.AreaLayoutStyle.ExtendHorizontal;
            stereo.ViewportCenter.Z = 4.0f;
            list.Add(new Slider(renderer, "Fov X", camera.Projection.FovXParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));
            list.Add(new Slider(renderer, "Fov Y", camera.Projection.FovYParameter, 0, 0.0f, (float)(System.Math.PI), 0.0f, 180.0f));
            if (Configuration.stereo)
            {
                list.Add(new Slider(renderer, "Eye Separation", stereo.EyeSeparation, 0, -1.0f, 1.0f, -1.0f, 1.0f));
                list.Add(new Slider(renderer, "Perspective", stereo.Perspective, 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Center X", stereo.ViewportCenter, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Y", stereo.ViewportCenter, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Center Z", stereo.ViewportCenter, 2, 0.0f, 20.0f,   0.0f, 20.0f));
                list.Add(new Slider(renderer, "Eye X", stereo.EyePosition, 0, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Y", stereo.EyePosition, 1, -4.0f, 4.0f, -4.0f, 4.0f));
                list.Add(new Slider(renderer, "Eye Z", stereo.EyePosition, 2, -20.0f, 20.0f, -20.0f, 20.0f));
                //list.Add(new Slider(renderer, "Near",           camera.NearParameter,   0,    0.0f,  10.0f,    0.0f,  10.0f));
                //list.Add(new Slider(renderer, "Far",            camera.FarParameter,    0,    0.0f, 100.0f,    0.0f, 100.0f));
            }

            if (Configuration.stereo)
            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "Focus choice";
                choice.Style = Style.NullPadding;
                choice.Add(new ChoiceItem(renderer, "AutoFocus"));
                choice.Add(new ChoiceItem(renderer, "Manual"));
                choice.Action   = FocusChoiceAction;
                choice.Selected = choice.Items.First();
                list.Add(choice);
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "FOV choice";
                choice.Style = Style.NullPadding;
                var dict = new Dictionary <string, ProjectionType>();
                dict["Vertical"]   = ProjectionType.PerspectiveVertical;
                dict["Horizontal"] = ProjectionType.PerspectiveHorizontal;
                dict["V. Stereo"]  = ProjectionType.StereoscopicVertical;
                dict["H. Stereo"]  = ProjectionType.StereoscopicHorizontal;
                foreach (var kvp in dict)
                {
                    var choiceItem = choice.Add(new ChoiceItem(renderer, kvp.Key));
                    if (kvp.Value == sceneManager.Camera.Projection.ProjectionType)
                    {
                        choice.Selected = choiceItem;
                    }
                }
                choice.Action = ProjectionChoiceAction;
                list.Add(choice);
            }

            {
                Choice choice = new Choice(Orientation.Horizontal);
                choice.Name  = "StereoMode choice";
                choice.Style = Style.NullPadding;
                foreach (var kvp in stereoModes)
                {
                    ChoiceItem choiceItem = choice.Add(new ChoiceItem(renderer, kvp.Key));
                    if (kvp.Value == CurrentStereoMode)
                    {
                        choice.Selected = choiceItem;
                    }
                }
                choice.Action = StereoModeChoiceAction;
                list.Add(choice);
            }

#if false
            // \todo stereo material
            if (Configuration.stereo)
            {
                list.Add(new Slider(renderer, "Saturation", renderer.Global.Floats("saturation"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Contrast", renderer.Global.Floats("contrast"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
                list.Add(new Slider(renderer, "Deghost", renderer.Global.Floats("deghost"), 0, 0.0f, 1.0f, 0.0f, 1.0f));
            }
#endif

            {
                Dock dock = new Dock(Orientation.Horizontal);
                dock.Name  = "Reset Home dock";
                dock.Style = Style.NullPadding;

                Button reset = new Button(renderer, "Reset");
                reset.Action = ResetCamera;
                dock.Add(reset);

                /*Button reference = new Button(renderer, "Reference");
                 * reference.Action = ReferenceStereo;
                 * dock.Add(reference);*/

                Button home = new Button(renderer, "Home");
                home.Action = HomeCamera;
                dock.Add(home);

                list.Add(dock);
            }

            var expand = new Button(renderer, "Camera", SetActive);
            expand.Link = list;
            return(expand);
        }