Пример #1
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Index"></param>
        private void AddList(MainListModel model, int Index = -1)
        {
            if (Index != -1)
            {
                Lists.Insert(Index, model);
            }
            else
            {
                Lists.Add(model);
            }

            AddSelectedItem(model, Index);
        }
Пример #2
0
        /// <summary>
        /// 添加已选对象
        /// </summary>
        /// <param name="item"></param>
        private void AddSelectedItem(MainListModel item, int Index = -1)
        {
            Xamarin.Forms.TemplatedView view = new Xamarin.Forms.TemplatedView();
            view.ControlTemplate = _ctControlTemplate;
            view.BindingContext  = item;

            if (Index != -1)
            {
                view.IsVisible = true;
            }
            else
            {
                _spList.Children.Add(view);
            }
        }
Пример #3
0
        /// <summary>
        /// 删除已选
        /// </summary>
        /// <param name="item"></param>
        private void RemoveSelected(MainListModel item)
        {
            Lists.Remove(item);

            Xamarin.Forms.TemplatedView _view = null;
            foreach (Xamarin.Forms.TemplatedView items in this._spList.Children)
            {
                if (items.BindingContext == item)
                {
                    _view = items;
                    break;
                }
            }

            if (null != _view)
            {
                _view.IsVisible = false;
            }
        }
Пример #4
0
        public MainListViewModel(Page _element, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate)
        {
            this._element = _element;

            this._spList            = spList;
            this._ctControlTemplate = ctControlTemplate;

            // 菜单列表填充一下



            _addInnerBill = new MainListModel()
            {
                Name = "InnerBill", GoCommand = this.GoCommand
            };
            AddList(_addInnerBill);
            _addOuterBill = new MainListModel()
            {
                Name = "OuterBill", GoCommand = this.GoCommand
            };
            AddList(_addOuterBill);
            _importManager = new MainListModel()
            {
                Name = "ExpenditureManager", GoCommand = this.GoCommand
            };
            AddList(_importManager);
            _financeLog = new MainListModel()
            {
                Name = "FinanceLog", GoCommand = this.GoCommand
            };
            AddList(_financeLog);
            _openCashDrawer = new MainListModel()
            {
                Name = "OpenCashDrawer", GoCommand = this.GoCommand
            };
            AddList(_openCashDrawer);
            _balanceManager = new MainListModel()
            {
                Name = "BalanceManager", GoCommand = this.GoCommand
            };
            AddList(_balanceManager);
            _statistic = new MainListModel()
            {
                Name = "Statistic", GoCommand = this.GoCommand
            };
            AddList(_statistic);
            //AddList(new MainListModel() { Name = "ChangeLanguage", GoCommand = this.GoCommand });
            AddList(new MainListModel()
            {
                Name = "ChangePassword", GoCommand = this.GoCommand
            });
            AddList(new MainListModel()
            {
                Name = "About", GoCommand = this.GoCommand
            });
            AddList(new MainListModel()
            {
                Name = "Exit", GoCommand = this.GoCommand
            });


            Notification.Instance.NotificationLanguage += (obj, value, args) => { Device.BeginInvokeOnMainThread(() => { LoginRefresh(); }); };
            Notification.Instance.NotificationLogin    += (obj, value, args) => { Device.BeginInvokeOnMainThread(() => { LoginRefresh(); }); };

            // 设置语言
            LoginRefresh();



            foreach (var item in Res.Instance.AllLangList.OrderBy(x => x.Value.LangOrder))
            {
                Dict dict = new Dict()
                {
                    Name = Res.Instance.GetString("LangName", item.Value.Culture), Value = item.Value.LangIndex
                };
                AllLang.Add(dict);
            }
        }