Exemple #1
0
        //Set properties based on user inputs
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            Caption            = txtTitle.Text;
            SelectedDataSource = DataSourceSelector.SelectedDataSource;
            SelectedField      = (client.Field)FieldComboBox.SelectedItem;

            SelectedStatistics.Clear();
            if (ShowMax)
            {
                SelectedStatistics.Add(Statistic.Max);
            }
            if (ShowAvg)
            {
                SelectedStatistics.Add(Statistic.Average);
            }
            if (ShowMin)
            {
                SelectedStatistics.Add(Statistic.Min);
            }
            if (ShowSum)
            {
                SelectedStatistics.Add(Statistic.Sum);
            }

            LeadingText  = txtLeading.Text;
            TrailingText = txtTrailing.Text;

            DialogResult = true;
        }
Exemple #2
0
        public StatisticsSummaryDialog(
            string initialCaption,
            string initialDataSourceId,
            string initialField,
            List <Statistic> statistics,
            string leadingText,
            string trailingText)
        {
            InitializeComponent();

            // When re-configuring, initialize the widget config dialog from the existing settings.
            txtTitle.Text = initialCaption;
            if (!string.IsNullOrEmpty(initialDataSourceId))
            {
                DataSource dataSource = OperationsDashboard.Instance.DataSources.FirstOrDefault(ds => ds.Id == initialDataSourceId);
                if (dataSource != null)
                {
                    DataSourceSelector.SelectedDataSource = dataSource;

                    if (!string.IsNullOrEmpty(initialField))
                    {
                        client.Field field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == initialField);
                        FieldComboBox.SelectedItem = field;
                    }
                }
            }

            //Instantized SelectedStatistics or set it with the exsting statistics
            SelectedStatistics = statistics == null ? new List <Statistic>() : statistics;
            ShowMax            = SelectedStatistics.Contains(Statistic.Max);
            ShowAvg            = SelectedStatistics.Contains(Statistic.Average);
            ShowMin            = SelectedStatistics.Contains(Statistic.Min);
            ShowSum            = SelectedStatistics.Contains(Statistic.Sum);

            LeadingText  = leadingText;
            TrailingText = trailingText;

            DataContext = this;
        }