コード例 #1
0
        /// <summary>
        /// Generate NavGroup
        /// </summary>
        /// <param name="localizeItemSelector"></param>
        /// <param name="item"></param>
        private void SetNavBarGroup(LocalizeItemSelector localizeItemSelector, SystemMenuTreeList item)
        {
            NavGroup = new OutlookSection();
            //NavGroup.PageUri = item.PageUri;
            NavGroup.Header = localizeItemSelector.setLocalizeValue(NavGroup, HeaderedContentControl.HeaderProperty);
            if (item.ImageIcon != null)
            {
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.CreateOptions = BitmapCreateOptions.None;
                bitmap.CacheOption   = BitmapCacheOption.Default;
                var imageSource = item.ImageIcon;
                bitmap.StreamSource = new MemoryStream((byte[])imageSource.ToArray());
                bitmap.EndInit();
                Image image = new Image();
                image.Source   = bitmap;
                NavGroup.Image = image.Source;
            }
            //NavGroup.Click += NavGroup_Click;
            NavigationBar.Sections.Add(NavGroup);
            objtree          = new TreeView();
            NavGroup.Margin  = new Thickness(0, 0, 0, 0);
            objtree.Margin   = new Thickness(0, 5, 0, 0);
            NavGroup.Content = objtree;
            //NavigationBar.Items.Add(objtree);
            TreeViewItemEx AreapageItem = new TreeViewItemEx()
            {
                Style = objtemplate, IsAreaPageTreeItem = true
            };                                                                                                    //
            LocalizeItemSelector localizeItemSelector1 = new LocalizeItemSelector();

            CommonMethods.AddLocalizeItem(localizeItemSelector1, "en", "Area Page");
            CommonMethods.AddLocalizeItem(localizeItemSelector1, "ja", "エリアページ");
            CommonMethods.AddLocalizeItem(localizeItemSelector1, "th", "หน้าบริเวณ");
            CommonMethods.AddLocalizeItem(localizeItemSelector1, "zh", "區頁");
            //AreapageItem.PageUri = item.PageUri;
            localizeItemSelector1.setLocalizeValue(AreapageItem, TreeViewItemEx.HeaderProperty);
            AreapageItem.Header = localizeItemSelector1.setLocalizeValue(AreapageItem, TreeViewItemEx.HeaderProperty);
            //AreapageItem.MouseLeftButtonUp += new MouseButtonEventHandler(AreapageItem_MouseLeftButtonUp);
            objtree.Items.Add(AreapageItem);
        }
コード例 #2
0
        public void GenerateNavControlTreeStructure(IEnumerable <SystemMenuTreeList> table)
        {
            LocalizeItemSelector localizeItemSelector;

            foreach (var item in table)
            {
                localizeItemSelector = new LocalizeItemSelector();
                CommonMethods.AddLocalizeItem(localizeItemSelector, "ja", item.NameJa != null ? item.NameJa : "PropertyValueNotSet");
                CommonMethods.AddLocalizeItem(localizeItemSelector, "en", item.NameEn != null ? item.NameEn : "PropertyValueNotSet");
                CommonMethods.AddLocalizeItem(localizeItemSelector, "th", item.NameTh != null ? item.NameTh : "PropertyValueNotSet");
                CommonMethods.AddLocalizeItem(localizeItemSelector, "zn", item.NameCh != null ? item.NameCh : "PropertyValueNotSet");

                if (item.PId == 0)
                {
                    SetNavBarGroup(localizeItemSelector, item);
                    var parentid = StructureItemsSource.OrderBy(a => a.DisplayIndex).Where(p => p.PId == item.Id);
                    GenerateNavControlTreeStructure(parentid);
                }
                else
                {
                    SetNavGroupSubItem(localizeItemSelector, item);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Generate BarCrum Tree Items
        /// </summary>
        /// <param name="objlist">TreeItem Collection</param>
        private void GenerateBar(IEnumerable <SystemMenuTreeList> objlist)
        {
            try
            {
                Binding languageBinding = new Binding()
                {
                    Source = this,
                    Mode   = BindingMode.TwoWay,
                    UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                    Path = new PropertyPath(BreadcrumbItem.LanguageProperty)
                };

                LocalizeItemSelector localizeItemSelector;
                foreach (var item in objlist)
                {
                    localizeItemSelector = new LocalizeItemSelector();
                    CommonMethods.AddLocalizeItem(localizeItemSelector, "ja", item.NameJa != null ? item.NameJa : PropertyValueNotSet);
                    CommonMethods.AddLocalizeItem(localizeItemSelector, "en", item.NameEn != null ? item.NameEn : PropertyValueNotSet);
                    CommonMethods.AddLocalizeItem(localizeItemSelector, "th", item.NameTh != null ? item.NameTh : PropertyValueNotSet);
                    CommonMethods.AddLocalizeItem(localizeItemSelector, "zh", item.NameTh != null ? item.NameTh : PropertyValueNotSet);

                    if (item.PId == 0)
                    {
                        withChildBreadcrumbItem         = new BreadcrumbItem();
                        withChildBreadcrumbItem.Header  = localizeItemSelector.setLocalizeValue(withChildBreadcrumbItem, BreadcrumbItem.HeaderProperty);
                        withChildBreadcrumbItem.PageUri = item.PageUri;
                        withChildBreadcrumbItem.SetBinding(BreadcrumbItem.LanguageProperty, languageBinding);
                        this.Items.Add(withChildBreadcrumbItem);

                        var Parents1 = ItemSource.OrderBy(p => p.DisplayIndex).Where(p => p.PId == item.Id);
                        if (Parents1.Any())
                        {
                            GenerateBar(Parents1);
                        }
                    }
                    else
                    {
                        withoutChildBreadcrumbItem         = new BreadcrumbItem();
                        withoutChildBreadcrumbItem.PageUri = item.PageUri;
                        withoutChildBreadcrumbItem.SetBinding(BreadcrumbItem.LanguageProperty, languageBinding);
                        withoutChildBreadcrumbItem.Header = localizeItemSelector.setLocalizeValue(withoutChildBreadcrumbItem, BreadcrumbItem.HeaderProperty);

                        if (!DicBreadCrumbItemAddressBar.ContainsKey(item.Id))
                        {
                            DicBreadCrumbItemAddressBar.Add(item.Id, withoutChildBreadcrumbItem);
                        }
                        if (DicBreadCrumbItemAddressBar.ContainsKey(item.PId))
                        {
                            DicBreadCrumbItemAddressBar[item.PId].Items.Add(withoutChildBreadcrumbItem);
                        }
                        else
                        {
                            withChildBreadcrumbItem.Items.Add(withoutChildBreadcrumbItem);
                        }
                        var Parents = ItemSource.OrderBy(p => p.DisplayIndex).Where(p => p.PId == item.Id);
                        if (Parents.Any())
                        {
                            GenerateBar(Parents);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }