예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        /// <param name="selectedValue"></param>
        /// <param name="options"></param>
        public void AddMessage(string message, string selectedValue = null, params string[] options)
        {
            if (this.checkState())
            {
                var toAdd = new MessageAndOptions {
                    Message = (message ?? string.Empty), Options = (options ?? new string[0]), SelectedValue = selectedValue,
                };
                //Se non ci sono opzioni, siamo nel caso in cui deve essere visualizzata solamente una casella senza testo a fianco.
                if (toAdd.Options.Length < 1)
                {
                    toAdd.Options = new[] { string.Empty }
                }
                ;
                //Variabili per calcolare l'ampiezza del testo (messaggio ed eventuali opzioni) in base al font.
                var maxLunghezzaOpzione = 0.0f;
                var lunghezzaMessaggio  = 0.0f;

                if (toAdd.Options != null)
                {
                    var opzioniConteggiabili = toAdd.Options
                                               .Where(x => !string.IsNullOrEmpty(x));

                    if (opzioniConteggiabili.Count() > 0)
                    {
                        maxLunghezzaOpzione = opzioniConteggiabili
                                              .Max(x => this.font.GetWidthPoint(x, this.fontSize));
                    }
                }

                if (!string.IsNullOrEmpty(toAdd.Message))
                {
                    lunghezzaMessaggio = this.font.GetWidthPoint(toAdd.Message, this.fontSize);
                }

                if (maxLunghezzaOpzione > this.lunghezzaMassimaOpzione)
                {
                    this.lunghezzaMassimaOpzione = maxLunghezzaOpzione;
                }

                if (lunghezzaMessaggio > this.lunghezzaMassimaMessaggio)
                {
                    this.lunghezzaMassimaMessaggio = lunghezzaMessaggio;
                }

                this.msgWithOptions.Add(toAdd);
            }
        }
예제 #2
0
 public LayoutEventArgs()
 {
     MessagesWithOptions = new MessageAndOptions[0];
 }