Esempio n. 1
0
        internal void MoveItem(SearchPanelItem source, SearchPanelItem target)
        {
            var copy = (from object i in Items
                        select i).ToList();

            int sourceIndex = copy.IndexOf(source);

            copy.Remove(source);

            int targetIndex = copy.IndexOf(target);

            if (targetIndex >= sourceIndex)
            {
                targetIndex++;
            }

            copy.Insert(targetIndex, source);

            Items.Clear();

            foreach (object i in copy)
            {
                Items.Add(i);
            }

            UpdateItems();
        }
Esempio n. 2
0
        internal void RemoveItem(SearchPanelItem item)
        {
            if (item.Content is DependencyObject)
            {
                NullElement(item.Content as DependencyObject);
            }

            item.IsActive = false;

            UpdateItems();
        }
Esempio n. 3
0
        public override Style SelectStyle(object item, DependencyObject container)
        {
            SearchPanelItem searchItem = item as SearchPanelItem;

            if (searchItem != null)
            {
                if (searchItem.IsFixed)
                {
                    return(isFixedStyle);
                }
            }

            return(defaultStyle);
        }
        public override Style SelectStyle(object item, DependencyObject container)
        {
            SearchPanelItem searchItem = item as SearchPanelItem;

            if (searchItem != null)
            {
                if (searchItem.IsSeparator)
                {
                    return(separatorStyle);
                }
            }

            return(itemStyle);
        }
Esempio n. 5
0
        private void CriteriaCreatorSelectionChangedEventHandler(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                SearchPanelItem searchItem = e.AddedItems[0] as SearchPanelItem;

                searchItem.IsActive = true;

                Items.Remove(searchItem);
                Items.Add(searchItem);

                UpdateItems();
            }
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            SearchPanelItem searchItem = item as SearchPanelItem;

            if (searchItem != null)
            {
                if (searchItem.IsRemoveItem)
                {
                    return(removeTemplate);
                }
            }

            return(itemTemplate);
        }
Esempio n. 7
0
        public void ClearItems()
        {
            foreach (object item in Items)
            {
                SearchPanelItem searchItem = item as SearchPanelItem;

                if (searchItem != null)
                {
                    if (searchItem.Content is DependencyObject)
                    {
                        NullElement(searchItem.Content as DependencyObject);
                    }
                }
            }
        }
Esempio n. 8
0
        public void LoadUserSettings(SearchPanelSettingsRepository settings)
        {
            if (settings.Items != null)
            {
                var internalItems = new List <SearchPanelItemSetting>(settings.Items);

                for (int i = 0; i < Items.Count; i++)
                {
                    SearchPanelItem item = Items[i] as SearchPanelItem;

                    if (item != null)
                    {
                        var n = from x in settings.Items
                                where x.Name == item.Name
                                select x;

                        if (n.Count() == 0)
                        {
                            SearchPanelItemSetting setting = new SearchPanelItemSetting();
                            setting.Name     = item.Name;
                            setting.IsActive = item.IsActive;
                            setting.Sequence = i;
                            internalItems.Add(setting);
                        }
                    }
                }

                IList <SearchPanelItem> items = new List <SearchPanelItem>(Items.Cast <SearchPanelItem>());

                Items.Clear();

                foreach (SearchPanelItemSetting setting in internalItems.OrderBy <SearchPanelItemSetting, int>(x => x.Sequence))
                {
                    var n = (from x in items
                             where x.Name == setting.Name
                             select x).FirstOrDefault();

                    if (n != null)
                    {
                        n.IsActive = setting.IsActive;
                        Items.Add(n);
                    }
                }
            }

            UpdateItems();
        }
Esempio n. 9
0
        private void UpdateItems()
        {
            AvailableItems.Clear();
            AvailableItemsPlusRemove.Clear();

            if (Items != null)
            {
                foreach (object item in Items)
                {
                    SearchPanelItem searchItem = item as SearchPanelItem;

                    if (searchItem.IsActive)
                    {
                        if (searchItem.Container != null)
                        {
                            searchItem.Container.Visibility = Visibility.Visible;
                        }

                        InitializeElement(searchItem);
                    }
                    else
                    {
                        AvailableItems.Add(searchItem);
                        AvailableItemsPlusRemove.Add(searchItem);

                        if (searchItem.Container != null)
                        {
                            searchItem.Container.Visibility = Visibility.Collapsed;
                        }
                    }
                }

                SearchPanelItem separatorItem = new SearchPanelItem();
                separatorItem.IsSeparator = true;

                AvailableItemsPlusRemove.Add(separatorItem);

                SearchPanelItem removeItem = new SearchPanelItem();
                removeItem.IsRemoveItem = true;

                AvailableItemsPlusRemove.Add(removeItem);
            }

            CanAddItems = (AvailableItems.Count > 0);
        }
        private void SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                SearchPanelItem item = e.AddedItems[0] as SearchPanelItem;

                if (item.IsRemoveItem)
                {
                    searchPanel.RemoveItem(CurrentItem);
                }
                else if (!item.IsSeparator)
                {
                    CurrentItem.IsActive = false;
                    item.IsActive        = true;
                    searchPanel.ChangeItem(CurrentItem, item);
                }
            }
        }
Esempio n. 11
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            SearchPanelItemContainer container = element as SearchPanelItemContainer;

            SearchPanelItem searchItem = item as SearchPanelItem;

            container.CurrentItem = searchItem;
            searchItem.Container  = container;

            if (searchItem.IsActive)
            {
                container.Visibility = Visibility.Visible;
            }
            else
            {
                container.Visibility = Visibility.Collapsed;
            }
        }
Esempio n. 12
0
        public void SaveUserSettings(SearchPanelSettingsRepository settings)
        {
            settings.Items = new SearchPanelItemSetting[Items.Count];

            for (int i = 0; i < Items.Count; i++)
            {
                SearchPanelItem item = Items[i] as SearchPanelItem;

                if (item != null)
                {
                    SearchPanelItemSetting setting = new SearchPanelItemSetting();

                    setting.Name      = item.Name;
                    setting.IsActive  = item.IsActive;
                    setting.Sequence  = i;
                    settings.Items[i] = setting;
                }
            }
        }
Esempio n. 13
0
        internal void ChangeItem(SearchPanelItem source, SearchPanelItem target)
        {
            var copy = (from object i in Items
                        select i).ToList();

            int targetIndex = copy.IndexOf(target);
            int sourceIndex = copy.IndexOf(source);

            copy[sourceIndex] = target;
            copy[targetIndex] = source;

            Items.Clear();

            foreach (object i in copy)
            {
                Items.Add(i);
            }

            UpdateItems();
        }