コード例 #1
0
            /**
             * Creates a section model from the added widget.
             */
            private ListSection<ListItem> CreateSectionModelFromWidget(ListViewSection section)
            {
                ListSection<ListItem> currentSection = new ListSection<ListItem>();
                currentSection.Title = section.Title;
                currentSection.Header = section.Header;
                currentSection.Footer = section.Footer;
                currentSection.HeaderColor = section.GetHeaderBackgroundColor();
                currentSection.HeaderFontColor = section.GetHeaderFontColor();
                currentSection.HeaderFontFamily = section.GetHeaderFontFamily();
                currentSection.HeaderFontSize = section.GetHeaderFontSize();
                currentSection.HeaderFontStyle = section.GetHeaderFontStyle();
                currentSection.HeaderFontWeight = section.GetHeaderFontWeight();
                currentSection.HeaderTextHorizontalAlignment = section.GetHeaderHorizontalAlignment();
                currentSection.HeaderTextVerticalAlignment = section.GetHeaderVerticalAlignment();
                currentSection.Footer = section.Footer;
                currentSection.FooterColor = section.GetFooterBackgroundColor();
                currentSection.FooterFontColor = section.GetFooterFontColor();
                currentSection.FooterFontFamily = section.GetFooterFontFamily();
                currentSection.FooterFontSize = section.GetFooterFontSize();
                currentSection.FooterFontStyle = section.GetFooterFontStyle();
                currentSection.FooterFontWeight = section.GetFooterFontWeight();
                currentSection.FooterTextHorizontalAlignment = section.GetFooterHorizontalAlignment();
                currentSection.FooterTextVerticalAlignment = section.GetFooterVerticalAlignment();
                currentSection.GroupHeaderColor = section.GetGroupHeaderBackgroundColor();

                for (int i = 0; i < section.ChildrenCount; i++ )
                {
                    IWidget widget = section.GetChild(i);
                    if (widget is ListViewItem)
                    {
                        ListViewItem listItem = widget as ListViewItem;
                        ListItem newItem = new ListItem();
                        newItem.Height = listItem.Height;
                        newItem.Width = listItem.Width;
                        newItem.Title = listItem.Text;
                        newItem.Subtitle = listItem.Subtitle;
                        newItem.FontSize = listItem.GetFontSize();
                        newItem.FontColor = listItem.GetFontColor();
                        newItem.SubtitleFontColor = listItem.GetSubtitleFontColor();
                        if (mListViewStyle == ListViewStyle.NoSubtitle)
                        {
                            newItem.SubtitleVisibility = Visibility.Collapsed;
                        }
                        else
                        {
                            newItem.SubtitleVisibility = Visibility.Visible;
                        }
                        newItem.ImageSource = listItem.IconImageSource;

                        listItem.ItemsSourceItemIndex = currentSection.Count;

                        currentSection.Add(newItem);

                        mModelToItemWidgetMap.Add(newItem.UniqueID, listItem);
                    }
                }

                return currentSection;
            }
コード例 #2
0
ファイル: MoSyncListView.cs プロジェクト: N00bKefka/MoSync
            /**
             * Creates a section model from the added widget.
             */
            private ListSection<ListItem> CreateSectionModelFromWidget(ListViewSection section)
            {
                ListSection<ListItem> currentSection = new ListSection<ListItem>();
                currentSection.Title = section.Title;
                currentSection.Header = section.Header;
                currentSection.Footer = section.Footer;
                currentSection.HeaderColor = section.GetHeaderBackgroundColor();
                currentSection.HeaderFontColor = section.GetHeaderFontColor();
                currentSection.HeaderFontFamily = section.GetHeaderFontFamily();
                currentSection.HeaderFontSize = section.GetHeaderFontSize();
                currentSection.HeaderFontStyle = section.GetHeaderFontStyle();
                currentSection.HeaderFontWeight = section.GetHeaderFontWeight();
                currentSection.HeaderTextHorizontalAlignment = section.GetHeaderHorizontalAlignment();
                currentSection.HeaderTextVerticalAlignment = section.GetHeaderVerticalAlignment();
                currentSection.Footer = section.Footer;
                currentSection.FooterColor = section.GetFooterBackgroundColor();
                currentSection.FooterFontColor = section.GetFooterFontColor();
                currentSection.FooterFontFamily = section.GetFooterFontFamily();
                currentSection.FooterFontSize = section.GetFooterFontSize();
                currentSection.FooterFontStyle = section.GetFooterFontStyle();
                currentSection.FooterFontWeight = section.GetFooterFontWeight();
                currentSection.FooterTextHorizontalAlignment = section.GetFooterHorizontalAlignment();
                currentSection.FooterTextVerticalAlignment = section.GetFooterVerticalAlignment();
                currentSection.GroupHeaderColor = section.GetGroupHeaderBackgroundColor();

                for (int i = 0; i < section.ChildrenCount; i++ )
                {
                    IWidget widget = section.GetChild(i);
                    if (widget is ListViewItem)
                    {
                        ListViewItem listItem = widget as ListViewItem;
                        ListItem newItem = new ListItem();
                        newItem.Height = listItem.Height;
                        newItem.Width = listItem.Width;
                        newItem.Title = listItem.Text;
                        newItem.Subtitle = listItem.Subtitle;
                        newItem.FontSize = listItem.GetFontSize();
                        newItem.FontColor = listItem.GetFontColor();
                        newItem.SubtitleFontColor = listItem.GetSubtitleFontColor();
                        if (mListViewStyle == ListViewStyle.NoSubtitle)
                        {
                            newItem.SubtitleVisibility = Visibility.Collapsed;
                        }
                        else
                        {
                            newItem.SubtitleVisibility = Visibility.Visible;
                        }
                        newItem.ImageSource = listItem.IconImageSource;

                        listItem.ItemsSourceItemIndex = currentSection.Count;

                        currentSection.Add(newItem);

                        mModelToItemWidgetMap.Add(newItem.UniqueID, listItem);
                    }
                }

                return currentSection;
            }
コード例 #3
0
            /**
             * Outputs the index of the section in focus and the index of the selected item
             * within that section.
             */
            private void GetSectionAndSelectedItemIndex(out int sectionIndex, out int itemIndex)
            {
                // we need to find the selected item through the LongListSelector
                // items source and through the child widgets aswell in order to
                // set its selected state
                sectionIndex = -1;
                itemIndex = -1;

                // we need to first find the selected item index and its section index
                // within the long list selector items source
                int itemsSourceSectionIndex = -1;
                int itemsSourceItemIndex = -1;

                for (int i = 0; i < mListSections.Count; i++)
                {
                    ListSection<ListItem> section = mListSections[i];

                    int index = section.IndexOf(mLongListSelector.SelectedItem as ListItem);
                    if ( index >= 0)
                    {
                        itemsSourceSectionIndex = i;
                        itemsSourceItemIndex = index;
                    }

                    // deselect all the items
                    for (int j = 0; j < section.Count; j++)
                    {
                        section[j].FontColor = mModelToItemWidgetMap[section[j].UniqueID].GetFontColor();
                        section[j].SubtitleFontColor = mModelToItemWidgetMap[section[j].UniqueID].GetSubtitleFontColor();
                    }
                }

                // select the current item
                SolidColorBrush phoneAccentBrush = Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
                (mLongListSelector.SelectedItem as ListItem).FontColor = phoneAccentBrush;
                (mLongListSelector.SelectedItem as ListItem).SubtitleFontColor = phoneAccentBrush;

                // set the coresponding list view item widget selection status
                ListViewItem selectedItem = mModelToItemWidgetMap[(mLongListSelector.SelectedItem as ListItem).UniqueID];
                selectedItem.ItemSelected = true;

                if (mLastSelectedItemWidget != null)
                {
                    mLastSelectedItemWidget.ItemSelected = false;
                }
                mLastSelectedItemWidget = selectedItem;

                // then we need to go through the widget children and find
                // the section/item that match the section/item indexes within
                // the items source
                for (int i = 0; i < mChildren.Count; i++)
                {
                    if (mChildren[i] is ListViewSection)
                    {
                        ListViewSection section = mChildren[i] as ListViewSection;
                        if (section.ItemsSourceSectionIndex == itemsSourceSectionIndex)
                        {
                            for (int j = 0; j < section.ChildrenCount; j++)
                            {
                                if (section.GetChild(j) is ListViewItem)
                                {
                                    ListViewItem item = section.GetChild(j) as ListViewItem;
                                    if (item.ItemsSourceItemIndex == itemsSourceItemIndex)
                                    {
                                        sectionIndex = i;
                                        itemIndex = j;
                                    }
                                }
                            }
                        }
                    }
                }
            }