Ejemplo n.º 1
0
        /// <summary>
        /// Initializes question values
        /// </summary>
        /// <param name="name">Question name</param>
        /// <param name="top">Top position on parent canvas</param>
        /// <param name="left">Left position on parent canvas</param>
        /// <param name="width">Question's width</param>
        /// <param name="height">Question's height</param>
        private void InitializeValues(string name, double top, double left, double width, double height)
        {
            this.Bubbles        = new ObservableCollection <BubbleViewModel>();
            this.AnswersMapping = new ObservableCollection <string>(AnswersMappingHelper.GetAnswersMappings());

            this.Name   = name;
            this.Top    = top;
            this.Left   = left;
            this.Width  = width;
            this.Height = height;

            this.AddCustomMappingCommand = new RelayCommand(x => this.OnAddCustomMapping());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Open window to add custom mapping
        /// </summary>
        private void OnAddCustomMapping()
        {
            new CustomMappingViewModel();

            var newItem = AnswersMappingHelper.GetAnswersMappings()
                          .FirstOrDefault(x => !this.AnswersMapping.Contains(x));

            if (newItem != null)
            {
                this.AnswersMapping.Insert(0, newItem);
                this.SelectedMapping = newItem;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates bubble names according to selected mapping
        /// </summary>
        private void UpdateBubblesNames()
        {
            string[] answerValues = AnswersMappingHelper.GetMappingByKey(this.SelectedMapping);

            for (int i = 0, j = 0; i < this.Bubbles.Count; i++, j++)
            {
                if (answerValues.Length <= j)
                {
                    j -= answerValues.Length;
                }

                this.Bubbles[i].Name = answerValues[j];
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Open window to add custom mapping
        /// </summary>
        private void OnAddCustomMapping()
        {
            CustomMappingViewModel vm = new CustomMappingViewModel();

            if (!vm.CustomMappingAdded)
            {
                return;
            }

            this.OnPropertyChanged(nameof(this.AnswersMapping));

            string newItem = AnswersMappingHelper.GetAnswersMappings()
                             .FirstOrDefault(x => x.Equals(vm.CustomMappingName));

            if (newItem != null)
            {
                this.SelectedMapping = newItem;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Applies changes and closes window
        /// </summary>
        private void OnOkCommand()
        {
            if (string.IsNullOrEmpty(this.CustomMappingName))
            {
                // show error
                DialogManager.ShowErrorDialog("Mapping name cannot be empty!");
                return;
            }

            if (AnswersMappingHelper.CheckMappingExists(this.CustomMappingName))
            {
                // already exists, should be unique
                DialogManager.ShowErrorDialog("Mapping name already exists! Make sure mapping name is unique.");
                return;
            }

            string[] resArray = this.MappingValues.Select(x => x.StringValue).ToArray();
            AnswersMappingHelper.AddCustomMapping(this.CustomMappingName, resArray);

            this.view.Close();
        }