Exemplo n.º 1
0
        private void AddFilterGS_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedIndex == -1)
            {
                return;
            }

            var filter = new BuildFilterItemData {
                AvailableProperties = new List <DDOItemProperty>(DatasetManager.Dataset.SlotExclusiveItemProperties[SlotType.None]), Include = "Include"
            };

            if (cb.SelectedIndex == 0)
            {
                lbFiltersGS.Items.Insert(0, filter);
                int i = 1;
                foreach (BuildFilterItemData b in lbFiltersGS.Items)
                {
                    b.Priority = i++;
                }
            }
            else
            {
                filter.Priority = lbFiltersGS.Items.Count + 1;
                lbFiltersGS.Items.Add(filter);
            }

            Action a = () => cb.Text = "Add Filter";

            Dispatcher.BeginInvoke(a);
        }
Exemplo n.º 2
0
        void AddFilterToSlotListBox(BuildFilterItemData filter)
        {
            ListBox lb;

            if (SlotListBoxes.ContainsKey(filter.Slot) && SlotListBoxes[filter.Slot] != null)
            {
                lb = SlotListBoxes[filter.Slot];
            }
            else
            {
                GroupBox gb = new GroupBox();
                gb.Header = filter.Slot.ToString();
                if (IsSlotLocked(filter.Slot))
                {
                    gb.Foreground  = Brushes.Red;
                    gb.BorderBrush = Brushes.Red;
                }
                lb = new ListBox();
                lb.BorderThickness = new Thickness(0);
                lb.ItemTemplate    = SlotListBoxDT;
                lb.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
                lb.ItemContainerStyle      = ItemContainerStyle;
                gb.Content                 = lb;
                SlotListBoxes[filter.Slot] = lb;
                spFiltersSlots.Children.Add(gb);
            }

            filter.Priority = lb.Items.Count + 1;
            lb.Items.Add(filter);
        }
Exemplo n.º 3
0
        private void FiltersGSDelete_Clicked(object sender, RoutedEventArgs e)
        {
            BuildFilterItemData bfid = (sender as Button).DataContext as BuildFilterItemData;

            lbFiltersGS.Items.Remove(bfid);
            for (int i = bfid.Priority - 1; i < lbFiltersGS.Items.Count; i++)
            {
                (lbFiltersGS.Items[i] as BuildFilterItemData).Priority = i + 1;
            }
        }
Exemplo n.º 4
0
        private void FilterAvailableProperties_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox            cb   = sender as ComboBox;
            BuildFilterItemData bfid = cb.DataContext as BuildFilterItemData;

            if (bfid != null)
            {
                SetAvailableTypes(bfid);
                if (!bfid.AvailableTypes.Contains(bfid.Type))
                {
                    bfid.Type = ALL_TYPES;
                }
            }
        }
Exemplo n.º 5
0
        private void FiltersSlotDelete_Clicked(object sender, RoutedEventArgs e)
        {
            BuildFilterItemData bfid = (sender as Button).DataContext as BuildFilterItemData;
            ListBox             lb   = SlotListBoxes[bfid.Slot];

            lb.Items.Remove(bfid);
            if (lb.Items.Count == 0)
            {
                SlotListBoxes[bfid.Slot] = null;
                spFiltersSlots.Children.Remove(lb.Parent as GroupBox);
            }
            else
            {
                for (int i = bfid.Priority - 1; i < lb.Items.Count; i++)
                {
                    (lb.Items[i] as BuildFilterItemData).Priority = i + 1;
                }
            }
        }
Exemplo n.º 6
0
        private void AddFilterSlot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedIndex == -1)
            {
                return;
            }

            SlotType slot = (SlotType)cb.SelectedValue;

            var filter = new BuildFilterItemData {
                Slot = slot, AvailableProperties = new List <DDOItemProperty>(DatasetManager.Dataset.SlotExclusiveItemProperties[slot]), Include = "Include"
            };

            AddFilterToSlotListBox(filter);

            Action a = () => cb.Text = "Add Filter";

            Dispatcher.BeginInvoke(a);
        }
Exemplo n.º 7
0
        void Filters_Drop(object sender, DragEventArgs e)
        {
            BuildFilterItemData droppedData = e.Data.GetData(typeof(BuildFilterItemData)) as BuildFilterItemData;
            BuildFilterItemData target      = ((ListBoxItem)(sender)).DataContext as BuildFilterItemData;

            if (droppedData == target)
            {
                return;
            }
            if (droppedData.Slot != target.Slot)
            {
                return;
            }
            ListBox lb = lbFiltersGS;

            if (droppedData.Slot != SlotType.None)
            {
                lb = SlotListBoxes[droppedData.Slot];
            }

            if (droppedData.Priority < target.Priority)
            {
                lb.Items.Insert(target.Priority, droppedData);
                lb.Items.RemoveAt(droppedData.Priority - 1);
            }
            else
            {
                lb.Items.RemoveAt(droppedData.Priority - 1);
                lb.Items.Insert(target.Priority - 1, droppedData);
            }

            int i = 1;

            foreach (BuildFilterItemData bfid in lb.Items)
            {
                bfid.Priority = i++;
            }
        }
Exemplo n.º 8
0
        private void FiltersReset_Clicked(object sender, RoutedEventArgs e)
        {
            FiltersClear_Clicked(null, null);

            foreach (var lbf in CurrentBuild.Filters)
            {
                for (int i = 0; i < lbf.Value.Count; i++)
                {
                    var filter = new BuildFilterItemData {
                        Slot = lbf.Key, Priority = i + 1, ItemProperty = DatasetManager.Dataset.ItemProperties[lbf.Value[i].Property], AvailableProperties = new List <DDOItemProperty>(DatasetManager.Dataset.SlotExclusiveItemProperties[lbf.Key]), Type = string.IsNullOrWhiteSpace(lbf.Value[i].Type) ? ALL_TYPES : lbf.Value[i].Type, Include = lbf.Value[i].Include ? "Include" : "Exclude"
                    };
                    SetAvailableTypes(filter);
                    if (lbf.Key == SlotType.None)
                    {
                        lbFiltersGS.Items.Add(filter);
                    }
                    else
                    {
                        AddFilterToSlotListBox(filter);
                    }
                }
            }
        }
Exemplo n.º 9
0
        void SetAvailableTypes(BuildFilterItemData bfid)
        {
            if (string.IsNullOrWhiteSpace(bfid.ItemProperty?.Property))
            {
                return;
            }

            List <string> values = new List <string> {
                ALL_TYPES
            };

            foreach (var t in bfid.ItemProperty.Types)
            {
                if (string.IsNullOrWhiteSpace(t))
                {
                    values.Add("untyped");
                }
                else
                {
                    values.Add(t);
                }
            }
            bfid.AvailableTypes = values;
        }