Пример #1
0
        public UcDetailPage_Item(string title)
        {
            CName = title;

            this.datas = new ObservableCollection <HsLabelValue>();

            this.datas.CollectionChanged += new NotifyCollectionChangedEventHandler((sender, e) =>
            {
                this.onDataChanged();
            });

            this.lv.ItemsSource = datas;

            this.AllowEdit = true; //初始值为真

            #region 标题栏

            UcHeaderTitle headerTitle = new UcHeaderTitle(title);

            #endregion

            #region 控制栏

            StackLayout controlLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                BackgroundColor   = Color.White
            };

            controlLayout.Children.Add(
                new Button()
            {
                Text              = "添加明细",
                Command           = this,
                CommandParameter  = new HsCommandParams(SysActionKeys.新建),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Button)),
            });

            #endregion

            this.mainLayout.Children.Insert(0, headerTitle);

            this.mainLayout.Children.Insert(1, controlLayout);
        }
Пример #2
0
            public InnerContentPage(XElement xMenu)
            {
                //一级菜单名称
                string title = xMenu.Attribute("Mc").Value;

                List <ShortCutItem> items = new List <ShortCutItem>();

                foreach (XElement xSubMenu in xMenu.Elements("Menu"))
                {
                    items.Add(
                        new ShortCutItem()
                    {
                        Label = xSubMenu.Attribute("Mc").Value,
                        Value = xSubMenu.Attribute("Gnbh").Value,
                        Icon  = xSubMenu.Attribute("Icon2").Value,
                    });
                }


                this.BackgroundColor = Color.Transparent;

                //Header
                UcHeaderTitle headerTitle = new UcHeaderTitle(title);

                //StackLayout headLayout = new StackLayout()
                //{
                //    HorizontalOptions = LayoutOptions.FillAndExpand,
                //    VerticalOptions = LayoutOptions.Start,
                //    Padding = 5,
                //    BackgroundColor = Color.Black,// .White,
                //    Opacity = 0.7
                //};

                //Label header = new Label() { Text = title,TextColor = Color.White,FontSize = Device.GetNamedSize(NamedSize.Small,typeof(Label)) , HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center };

                //headLayout.Children.Add(header);

                //Main Grid
                Grid grid = new Grid()
                {
                    ColumnSpacing = 10, RowSpacing = 10
                };

                //图标设置3列
                int colCount = 3;

                int rowCount = (int)Math.Ceiling(items.Count / (double)colCount);

                for (int i = 0; i < colCount; i++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    });
                }


                for (int i = 0; i < rowCount; i++)
                {
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                }


                for (int i = 0; i < rowCount; i++)
                {
                    for (int j = 0; j < colCount; j++)
                    {
                        if (i * colCount + j < items.Count)
                        {
                            ShortCutItem item = items[i * colCount + j];

                            UcShortCut shortCut = new UcShortCut(item, item.Icon);

                            shortCut.Click += new EventHandler <HsEventArgs <IHsLabelValue> >((sender, e) =>
                            {
                                this.ItemClick?.Invoke(this, e);
                            });

                            grid.Children.Add(shortCut, j, i);
                        }
                    }
                }

                StackLayout layout = new StackLayout();

                layout.Children.Add(headerTitle);
                layout.Children.Add(
                    new ScrollView()
                {
                    Content = grid
                });


                Content = layout;
            }
Пример #3
0
        public UcDetailPage_Annex(string title)
        {
            this.AllowEdit  = true;
            this.AllowEmpty = true;

            #region 注册数据变化事件

            datas.CollectionChanged += new NotifyCollectionChangedEventHandler((sender, e) =>
            {
                if (!this.isRetrieveing) //获取初始数据时不触发更改事件。
                {
                    this.onDataChanged();
                }
            });

            #endregion

            #region 标题栏

            UcHeaderTitle headerTitle = new UcHeaderTitle(title);

            #endregion

            #region 控制栏

            StackLayout controlLayout = new StackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.Start,
                BackgroundColor   = Color.White
            };

            IEnumerable <HsActionKey> actionKeys = onCreateActionKeys();

            foreach (HsActionKey actionKey in actionKeys)
            {
                controlLayout.Children.Add(
                    new Button()
                {
                    Text              = actionKey.Label,
                    Command           = this,
                    CommandParameter  = new HsCommandParams(actionKey),
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize          = Device.GetNamedSize(NamedSize.Medium, typeof(Button)),
                });
            }

            #endregion

            #region 图像列表

            liveview = new ListView()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                //Opacity = 0.6,
                BackgroundColor = Color.Transparent,
                //RowHeight = 100
            };

            liveview.ItemTapped += new EventHandler <ItemTappedEventArgs>((sender, e) =>
            {
                ((ListView)sender).SelectedItem = null;
            });

            liveview.ItemSelected += new EventHandler <SelectedItemChangedEventArgs>((sender, e) =>
            {
                try
                {
                    if (e.SelectedItem != null)
                    {
                        this.itemClick(e.SelectedItem as T);
                    }
                }
                catch (Exception ex)
                {
                    this.ShowError(ex.Message);
                }
            });



            liveview.ItemTemplate = getDataTemplete();

            liveview.ItemsSource = datas;

            #endregion

            StackLayout rootLayout = new StackLayout()
            {
                Spacing = 0
            };

            rootLayout.Children.Add(headerTitle);
            rootLayout.Children.Add(controlLayout);
            rootLayout.Children.Add(liveview);

            this.Content = rootLayout;
        }