<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.OperationsDashboard;
using client = ESRI.ArcGIS.Client;
using System.Windows.Input;
using System.Windows.Controls.Primitives;


namespace OOB.Config
{
    /// <summary>
    /// Interaction logic for OOBWidgetDialog.xaml
    /// </summary>

    public partial class OOBWidgetDialog : Window
    {
        public OOBCache cache = new OOBCache();
        public List<DataSource> DataSources { get; private set; }
        public String OOBName { get; private set; }
        public string Caption { get; private set; }
        private Dictionary<String, OOBDataSource> _datasources = new Dictionary<String, OOBDataSource>();
        public Dictionary<String, OOBDataSource> OOBDataSources { get { return _datasources; } }
        private String curLabelVal = "";
        private DescriptionType _currentDescType = DescriptionType.None;
        private String _currentBaseDesc = "";
        private DataSource _currentDS;
        private List<String> _currentLabelList = new List<String>();
        private List<String> _currentDescList = new List<String>();

        public Dictionary<String, String> OOBDsStrings = null;
        public String oobdsstring = null;
        public IEnumerable<IFeatureAction> SelectedFeatureActions { get; private set; }
        public Boolean ShowIcon
        {
            get
            {
                return _showIcon;
            }
            set
            {
                _showIcon = value;
            }
        }
        private Boolean _showIcon = false;
        readonly static IFeatureAction[] _configFeatureActions = { new ZoomToFeatureAction(), new PanToFeatureAction(), new FollowFeatureAction(), new HighlightFeatureAction(), new ShowPopupFeatureAction() };
        public OOBWidgetDialog(Dictionary<String, OOBDataSource> oobdatasources, string initialCaption, IEnumerable<IFeatureAction> selectedFeatureActions, OOBCache oobcache)
        {
            InitializeComponent();
            DataSourceSelector.IsEnabled = true;
            OKButton.IsEnabled = false;
            if (oobcache != null)
            {
                cache = oobcache;
            }
            if (initialCaption != null)
            {
                OOBName = initialCaption;
                tb_title.Text = OOBName;
            }
            if (oobdatasources.Count > 0)
            {
                InitializeDataSources(oobdatasources);
            }


            InitializeFeatureActions(selectedFeatureActions);
        }

        private void InitializeDataSources(Dictionary<String, OOBDataSource> oobdatasources)
        {
            _datasources = oobdatasources;
            foreach (KeyValuePair<String, OOBDataSource> p in oobdatasources)
            {
                listDs.Items.Add(p.Key);
            }
            tb_dsname.Text = "";
            tb_dsname.IsEnabled = true;
            listDs.SelectedIndex = -1;

        }

        private void lb_label_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lb_label.SelectedItem == null)
                return;
            String n = lb_label.SelectedItem.ToString();


            String lval = "{" + n + "} ";

            if (curLabelVal.Length > 0)
            {
                curLabelVal += " ";
            }
            curLabelVal += lval;
            tbLabel.Text = curLabelVal;
            if (!_currentLabelList.Contains(n))
            {
                _currentLabelList.Add(n);
            }
            if (listDs.SelectedIndex > -1)
            {
                OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
                if (ods != null)
                {
                    if (!ods.LabelFields.Contains(n))
                    {
                        ods.LabelFields.Add(n);
                    }
                    if (ods.UseIcon)
                    {
                        rb_Symbol.IsChecked = true;
                    }
                    if (ods.DescType != null)  // <-- TODO: Remove this warning (this is always true)
                    {
                        setDescType(ods.DescType);
                    }
                }
            }
        }

        private void setDescType(DescriptionType dtype)
        {
            if (dtype == DescriptionType.None)
            {
                rb_descNone.IsChecked = true;
            }
            else if (dtype == DescriptionType.SingleField)
            {
                rb_descSinglefld.IsChecked = true;
            }
            else if (dtype == DescriptionType.Custom)
            {
                rb_descCustom.IsChecked = true;
            }
        }

        private void updateCurrentDatasource(object sender, RoutedEventArgs e)
        {<commit_msg>Update OOBWidgetDialog.xaml.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using ESRI.ArcGIS.OperationsDashboard;
using client = ESRI.ArcGIS.Client;
using System.Windows.Input;
using System.Windows.Controls.Primitives;


namespace OOB.Config
{
    /// <summary>
    /// Interaction logic for OOBWidgetDialog.xaml
    /// </summary>

    public partial class OOBWidgetDialog : Window
    {
        public OOBCache cache = new OOBCache();
        public List<DataSource> DataSources { get; private set; }
        public String OOBName { get; private set; }
        public string Caption { get; private set; }
        private Dictionary<String, OOBDataSource> _datasources = new Dictionary<String, OOBDataSource>();
        public Dictionary<String, OOBDataSource> OOBDataSources { get { return _datasources; } }
        private String curLabelVal = "";
        private DescriptionType _currentDescType = DescriptionType.None;
        private String _currentBaseDesc = "";
        private DataSource _currentDS;
        private List<String> _currentLabelList = new List<String>();
        private List<String> _currentDescList = new List<String>();

        public Dictionary<String, String> OOBDsStrings = null;
        public String oobdsstring = null;
        public IEnumerable<IFeatureAction> SelectedFeatureActions { get; private set; }
        public Boolean ShowIcon
        {
            get
            {
                return _showIcon;
            }
            set
            {
                _showIcon = value;
            }
        }
        private Boolean _showIcon = false;
        readonly static IFeatureAction[] _configFeatureActions = { new ZoomToFeatureAction(), new PanToFeatureAction(), new FollowFeatureAction(), new HighlightFeatureAction(), new ShowPopupFeatureAction() };
        public OOBWidgetDialog(Dictionary<String, OOBDataSource> oobdatasources, string initialCaption, IEnumerable<IFeatureAction> selectedFeatureActions, OOBCache oobcache)
        {
            InitializeComponent();
            DataSourceSelector.IsEnabled = true;
            OKButton.IsEnabled = false;
            if (oobcache != null)
            {
                cache = oobcache;
            }
            if (initialCaption != null)
            {
                OOBName = initialCaption;
                tb_title.Text = OOBName;
            }
            if (oobdatasources.Count > 0)
            {
                InitializeDataSources(oobdatasources);
            }


            InitializeFeatureActions(selectedFeatureActions);
        }

        private void InitializeDataSources(Dictionary<String, OOBDataSource> oobdatasources)
        {
            _datasources = oobdatasources;
            foreach (KeyValuePair<String, OOBDataSource> p in oobdatasources)
            {
                listDs.Items.Add(p.Key);
            }
            tb_dsname.Text = "";
            tb_dsname.IsEnabled = true;
            listDs.SelectedIndex = -1;

        }

        private void lb_label_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lb_label.SelectedItem == null)
                return;
            String n = lb_label.SelectedItem.ToString();


            String lval = "{" + n + "} ";

            if (curLabelVal.Length > 0)
            {
                curLabelVal += " ";
            }
            curLabelVal += lval;
            tbLabel.Text = curLabelVal;
            if (!_currentLabelList.Contains(n))
            {
                _currentLabelList.Add(n);
            }
            if (listDs.SelectedIndex > -1)
            {
                OOBDataSource ods = OOBDataSources[listDs.SelectedItem.ToString()];
                if (ods != null)
                {
                    if (!ods.LabelFields.Contains(n))
                    {
                        ods.LabelFields.Add(n);
                    }
                    if (ods.UseIcon)
                    {
                        rb_Symbol.IsChecked = true;
                    }
                    
                }
            }
        }

        private void setDescType(DescriptionType dtype)
        {
            if (dtype == DescriptionType.None)
            {
                rb_descNone.IsChecked = true;
            }
            else if (dtype == DescriptionType.SingleField)
            {
                rb_descSinglefld.IsChecked = true;
            }
            else if (dtype == DescriptionType.Custom)
            {
                rb_descCustom.IsChecked = true;
            }
        }

        private void updateCurrentDatasource(object sender, RoutedEventArgs e)
        {
{'fraction_non_alphanumeric': 0.0811979005866008, 'fraction_numerical': 0.0008232993722342287, 'mean_word_length': 1.6457936291859516, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2496633', 'n_tokens_mistral': 2502, 'n_tokens_neox': 2386, 'n_words': 531}