Beispiel #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var MenuDataGroups = MenuDataSource.GetGroups((String)navigationParameter);

            this.DefaultViewModel["Groups"] = MenuDataGroups;
        }
        private void RaiseLeafMenuClicked(object sender, MenuDataSource param)
        {
            LeafMenuClickedEventArgs newEventArgs = new LeafMenuClickedEventArgs(param);

            newEventArgs.RoutedEvent = LeafMenuClickedEvent;
            RaiseEvent(newEventArgs);
        }
        private void ApplyItemColor(TreeViewItem item)
        {
            if (item == null)
            {
                return;
            }
            MenuDataSource dataSource = (MenuDataSource)item.DataContext;

            item.Background           = new SolidColorBrush(dataSource.BackgroundColor);
            item.Padding              = new Thickness(dataSource.PaddingLeft, 0, 0, 0);
            item.Foreground           = new SolidColorBrush(dataSource.ForegroundColor);
            item.Expanded            += new RoutedEventHandler(TreeViewItem_Expanded);
            item.MouseLeftButtonDown += new MouseButtonEventHandler(TreeViewItem_MouseLeftButtonDown);
            if (!item.HasItems)
            {
                item.BorderThickness = new Thickness(0, 0, 0, 1);
                item.BorderBrush     = new SolidColorBrush(Color.FromArgb(255, 226, 226, 226));
            }
            else
            {
                item.ExpandSubtree();
                for (int i = 0; i < item.Items.Count; i++)
                {
                    TreeViewItem child = (TreeViewItem)(item
                                                        .ItemContainerGenerator
                                                        .ContainerFromIndex(i));
                    ApplyItemColor(child);
                }
                item.IsExpanded = false;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var item = MenuDataSource.GetItem((String)navigationParameter);

            this.DefaultViewModel["Group"] = item.Group;
            this.DefaultViewModel["Items"] = item.Group.Items;
            this.flipView.SelectedItem     = item;
        }
        private void BindTree()
        {
            Loading            = true;
            tvMain.ItemsSource = MenuDataSource.GetSampleList();
            for (int i = 0; i < tvMain.Items.Count; i++)
            {
                TreeViewItem child = (TreeViewItem)(tvMain
                                                    .ItemContainerGenerator
                                                    .ContainerFromIndex(i));
                ApplyItemColor(child);
            }
            Loading = false;
            TreeViewItem first = (TreeViewItem)(tvMain
                                                .ItemContainerGenerator
                                                .ContainerFromIndex(0));

            if (first != null)
            {
                DeepExpand(first);
            }
        }
        public AjaxResult Save(MenuDataSource old, MenuDataSource model)
        {
            bool addFlag = model.ID < 1;
            var  user    = logRep.User;

            model.ENABLED    = true;
            model.CREATEBY   = user.ACCOUNT;
            model.CREATEDATE = DateTime.Now;
            model.UPDATEBY   = model.CREATEBY;
            model.UPDATEDATE = model.CREATEDATE;

            if (addFlag)
            {
                int        dsId = dsRep.Add <int>(model);
                bool       flag = dsId > 0;
                ActionType type = ActionType.SYS_ADD;
                string     msg  = WebConst.GetActionMsg(type, flag);
                return(new AjaxResult(flag, msg));
            }
            else
            {
                bool flag = dsRep.Update(model, m => new
                {
                    m.DATA,
                    m.DEFAULTTEXT,
                    m.DEFAULTVALUE,
                    m.OPTOINDATA,
                    m.PARAMETERDATA,
                    m.TYPE,
                    m.UPDATEBY,
                    m.UPDATEDATE
                }, m => m.ID == model.ID);
                ActionType type = ActionType.SYS_UPDATE;
                string     msg  = WebConst.GetActionMsg(type, flag);
                return(new AjaxResult(flag, msg));
            }
        }
Beispiel #7
0
        public ActionResult SaveDataSource(MenuDataSource old, MenuDataSource model)
        {
            var result = dataSource.Save(old, model);

            return(Json(result));
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     MenuDataSource md = new MenuDataSource();
 }
Beispiel #9
0
 internal LeafMenuClickedEventArgs(MenuDataSource param)
 {
     Param = param;
 }