Esempio n. 1
0
        private void OnComboBoxSelectedIndexChanged(NValueChangeEventArgs args)
        {
            if (m_bSelectionUpdating)
            {
                m_bSelectionUpdating = false;
                return;
            }

            // Get the list box and the other list box
            int       selectedIndex = (int)args.NewValue;
            NComboBox comboBox      = (NComboBox)args.TargetNode;
            NComboBox otherComboBox = comboBox == m_ComboBox ? m_AdvancedComboBox : m_ComboBox;

            // Log the selection
            NComboBoxItem selectedItem = comboBox.SelectedItem;
            NCountry      country      = NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> .GetDataBoundItem(selectedItem);

            m_EventsLog.LogEvent("'" + country.Name + "' selected");

            // Synchronize the selection between the two list boxes
            m_bSelectionUpdating        = true;
            otherComboBox.SelectedIndex = selectedIndex;
        }
Esempio n. 2
0
        private void OnListBoxItemSelected(NSelectEventArgs <NListBoxItem> args)
        {
            if (m_bSelectionUpdating)
            {
                m_bSelectionUpdating = false;
                return;
            }

            // Get the list box and the other list box
            NListBox listBox      = (NListBox)args.Item.OwnerListBox;
            NListBox otherListBox = listBox == m_ListBox ? m_AdvancedListBox : m_ListBox;

            // Log the selection
            NListBoxItem selectedItem = listBox.Selection.FirstSelected;
            NCountry     country      = NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> .GetDataBoundItem(selectedItem);

            m_EventsLog.LogEvent("'" + country.Name + "' selected");

            // Synchronize the selection between the two list boxes
            m_bSelectionUpdating = true;
            int selectedIndex = listBox.Items.IndexOf(selectedItem);

            otherListBox.Selection.SingleSelect(otherListBox.Items[selectedIndex]);
        }
Esempio n. 3
0
        protected override NWidget CreateExampleContent()
        {
            NStackPanel stack = new NStackPanel();

            stack.HorizontalPlacement = ENHorizontalPlacement.Left;
            stack.VerticalPlacement   = ENVerticalPlacement.Top;
            stack.VerticalSpacing     = 10;

            // Load the contry data
            NList <NCountry> countries = LoadCountryData();

            // Create the simple combo box
            m_ComboBox = new NComboBox();
            NPairBox pairBox = CreatePairBox("Select country:", m_ComboBox);

            stack.Add(new NGroupBox("Data source items -> Labels", pairBox));

            // Create the simple data binding
            NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> countryNameDataBinding =
                new NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry>();

            NDataBinding.SetDataBinding(m_ComboBox.Items, countryNameDataBinding);
            countryNameDataBinding.DataSource      = countries;
            countryNameDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NComboBoxItem, NCountry> >(OnCountryNameDataBindingCreateItemNode);
            countryNameDataBinding.RebuildTarget();

            // Create the advanced combo box
            m_AdvancedComboBox = new NComboBox();
            pairBox            = CreatePairBox("Select country:", m_AdvancedComboBox);
            stack.Add(new NGroupBox("Data source items -> Custom widgets", pairBox));

            // Create the advanced data binding
            NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry> countryDataBinding =
                new NNodeCollectionDataBinding <NComboBoxItemCollection, NComboBoxItem, NCountry>();

            NDataBinding.SetDataBinding(m_AdvancedComboBox.Items, countryDataBinding);
            countryDataBinding.DataSource      = countries;
            countryDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NComboBoxItem, NCountry> >(OnCountryDataBindingCreateItemNode);
            countryDataBinding.RebuildTarget();

            // Select the first country
            m_ComboBox.SelectedIndex         = 0;
            m_AdvancedComboBox.SelectedIndex = 0;

            // Subscribe to the selected index changed events
            m_ComboBox.SelectedIndexChanged         += new Function <NValueChangeEventArgs>(OnComboBoxSelectedIndexChanged);
            m_AdvancedComboBox.SelectedIndexChanged += new Function <NValueChangeEventArgs>(OnComboBoxSelectedIndexChanged);

            return(stack);
        }
Esempio n. 4
0
        protected override NWidget CreateExampleContent()
        {
            NStackPanel stack = new NStackPanel();

            stack.Direction         = ENHVDirection.LeftToRight;
            stack.HorizontalSpacing = 10;

            // Load the contry data
            NList <NCountry> countries = LoadCountryData();

            // Create the simple list box
            m_ListBox = new NListBox();
            m_ListBox.Selection.Selected += new Function <NSelectEventArgs <NListBoxItem> >(OnListBoxItemSelected);
            stack.Add(new NGroupBox("Data source items -> Labels", m_ListBox));

            // Create the simple data binding
            NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> countryNameDataBinding =
                new NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry>();

            NDataBinding.SetDataBinding(m_ListBox.Items, countryNameDataBinding);
            countryNameDataBinding.DataSource      = countries;
            countryNameDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NListBoxItem, NCountry> >(OnCountryNameDataBindingCreateItemNode);
            countryNameDataBinding.RebuildTarget();

            // Create the advanced list box
            m_AdvancedListBox = new NListBox();
            m_AdvancedListBox.Selection.Selected += new Function <NSelectEventArgs <NListBoxItem> >(OnListBoxItemSelected);
            stack.Add(new NGroupBox("Data source items -> Custom widgets", m_AdvancedListBox));

            // Create the advanced data binding
            NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry> countryDataBinding =
                new NNodeCollectionDataBinding <NListBoxItemCollection, NListBoxItem, NCountry>();

            NDataBinding.SetDataBinding(m_AdvancedListBox.Items, countryDataBinding);
            countryDataBinding.DataSource      = countries;
            countryDataBinding.CreateItemNode += new Function <NCreateItemNodeEventArgs <NListBoxItem, NCountry> >(OnCountryDataBindingCreateItemNode);
            countryDataBinding.RebuildTarget();

            return(stack);
        }