Esempio n. 1
0
        /// <summary>
        /// Update the UI when the selected datasource changes
        /// </summary>
        private void DataSourceSelector_SelectionChanged(object sender, EventArgs e)
        {
            //list all fields from the datasource
            DataSource dataSource = DataSourceSelector.SelectedDataSource;

            if (FieldNameAliasMap == null)
            {
                FieldNameAliasMap = new ObservableCollection <StringItems2>();

                foreach (var field in dataSource.Fields)
                {
                    StringItems2 si2 = new StringItems2(field.Name, new List <string>()
                    {
                        field.Alias, field.Alias
                    });
                    si2.FieldType = getFieldType(field.Type);
                    FieldNameAliasMap.Add(si2);
                }

                fieldListControl.FieldNameAliasMap = FieldNameAliasMap;
            }
            //filterControl.UseAliasNameSelected = UseAliasNameSelected;
            //filterControl.NoteFields = NoteFields;
            filterControl.FieldNameAliasMap = FieldNameAliasMap;
            filterControl.dataSource        = dataSource;
        }
Esempio n. 2
0
 private void chkBox_Click(object sender, RoutedEventArgs e)
 {
     if (!bypassCheck)
     {
         if (!((CheckBox)sender).IsChecked.Value)
         {
             chkBoxSelectAll.IsChecked = false;
             StringItems2 item = (StringItems2)((CheckBox)sender).DataContext;
             if (!chkBoxUseAliasName.IsChecked.Value)
             {
                 item.displayNameValue = false;
             }
         }
         else
         {
             foreach (StringItems2 item in chkBoxListView.Items)
             {
                 if (!item.isChecked)
                 {
                     chkBoxSelectAll.IsChecked = false;
                     return;
                 }
             }
             chkBoxSelectAll.IsChecked = true;
         }
     }
 }
        ListViewItem GetListViewItem(StringItems2 dataItem)
        {
            if (this.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
            {
                return(null);
            }

            return(this.ItemContainerGenerator.ContainerFromItem(dataItem) as ListViewItem);
        }
        void PerformDragOperation()
        {
            StringItems2    selectedItem   = this.listView.SelectedItem as StringItems2;
            DragDropEffects allowedEffects = DragDropEffects.Move | DragDropEffects.Move | DragDropEffects.Link;

            if (DragDrop.DoDragDrop(this, selectedItem, allowedEffects) != DragDropEffects.None)
            {
                // The item was dropped into a new location,
                // so make it the new selected item.
                this.listView.SelectedItem = selectedItem;
            }
        }
Esempio n. 5
0
        private void chkBox_Checked(object sender, RoutedEventArgs e)
        {
            StringItems2 item = (StringItems2)((CheckBox)sender).DataContext;

            if (chkBoxUseAliasName.IsChecked.Value)
            {
                item.displayAliasValue = true;
            }
            else
            {
                item.displayNameValue = true;
            }
        }
        void lv_Drop(object sender, DragEventArgs e)
        {
            if (this.ItemUnderDragCursor != null)
            {
                this.ItemUnderDragCursor = null;
            }

            e.Effects = DragDropEffects.None;

            if (!e.Data.GetDataPresent(typeof(StringItems2)))
            {
                return;
            }

            // Get the data object which was dropped.
            StringItems2 data = e.Data.GetData(typeof(StringItems2)) as StringItems2;

            if (data == null)
            {
                return;
            }

            // Get the ObservableCollection<ItemType> which contains the dropped data object.
            ObservableCollection <StringItems2> itemsSource = this.listView.ItemsSource as ObservableCollection <StringItems2>;

            if (itemsSource == null)
            {
                throw new Exception(
                          "A ListView managed by ListViewDragManager must have its ItemsSource set to an ObservableCollection<ItemType>.");
            }

            int oldIndex = itemsSource.IndexOf(data);
            int newIndex = this.IndexUnderDragCursor;

            if (newIndex < 0)
            {
                // The drag started somewhere else, and our ListView is empty
                // so make the new item the first in the list.
                if (itemsSource.Count == 0)
                {
                    newIndex = 0;
                }

                // The drag started somewhere else, but our ListView has items
                // so make the new item the last in the list.
                else if (oldIndex < 0)
                {
                    newIndex = itemsSource.Count;
                }

                // The user is trying to drop an item from our ListView into
                // our ListView, but the mouse is not over an item, so don't
                // let them drop it.
                else
                {
                    return;
                }
            }

            // Dropping an item back onto itself is not considered an actual 'drop'.
            if (oldIndex == newIndex)
            {
                return;
            }

            if (this.ProcessDrop != null)
            {
                // Let the client code process the drop.
                ProcessDropEventArgs <StringItems2> args = new ProcessDropEventArgs <StringItems2>(itemsSource, data, oldIndex, newIndex, e.AllowedEffects);
                //this.ProcessDrop(this, args);
                this.ProcessDrop(sender, args);//TODO
                e.Effects = args.Effects;
            }
            else
            {
                // Move the dragged data object from it's original index to the
                // new index (according to where the mouse cursor is).  If it was
                // not previously in the ListBox, then insert the item.
                if (oldIndex > -1)
                {
                    itemsSource.Move(oldIndex, newIndex);
                }
                else
                {
                    itemsSource.Insert(newIndex, data);
                }

                // Set the Effects property so that the call to DoDragDrop will return 'Move'.
                e.Effects = DragDropEffects.Move;
            }
        }