Beispiel #1
0
        public ActionResult GetMenu()
        {
            //TODO Eliminar cuando se descubra una mejor forma
            IApplicationContext appContext =
                new XmlApplicationContext(HttpContext.Server.MapPath(@"~/Config/service.xml"),
                    HttpContext.Server.MapPath(@"~/Config/repository.xml"));
            UsuarioService = (IUsuarioService)appContext.GetObject("UsuarioService");
            PerfilMenuService = (IPerfilMenuService)appContext.GetObject("PerfilMenuService");
            //

            List<Usuario> ListUsuario = UsuarioService.ReadUsuarioByUsername(User.Identity.Name).ToList();
            Usuario usuario = (Usuario)ListUsuario[0];
            IList<PerfilMenu> ListPM = PerfilMenuService.ReadPerfilMenuByPerfilId(usuario.PerfilId).ToList();
            IList<Menu> items = new List<Menu>();

            foreach (PerfilMenu pm in ListPM)
            {
                pm.Menu.Activo = pm.Activo;
                items.Add(pm.Menu);
            }

            MenuViewModel menuViewModel = new MenuViewModel(items, usuario);

            return PartialView("_Nav", menuViewModel);
        }
        public void ShowSessionsCommand_Executed_ClearsAndNavigatesToSessions()
        {
            var viewModel = new MenuViewModel(Messenger);

            viewModel.ShowSessionsCommand.Execute(null);

            Assert.AreEqual(1, Dispatcher.ShowViewModelRequests.Count);
            var request = Dispatcher.ShowViewModelRequests.First();
            Assert.AreEqual(request.ViewModelType, typeof(SessionsViewModel));
            Assert.That(request.PresentationValues.ContainsKey(PresentationBundleFlagKeys.ClearStack));
        }
 public object CreateViewModel()
 {
     //I am only interested in a Design time implementation.
     var optionsVm = new MenuViewModel();
     if(Designer.IsDesignMode)
     {
         optionsVm.ServiceLocator.RegisterService<IOptionsDataSource>(new DesignData.DesignTimeOptionsDataSource());
         return optionsVm;
     }
     return null;
 }
        public ActionResult Menu()
        {
            var viewModel = new MenuViewModel
                {
                    IsLoggedIn = this.identityTasks.IsSignedIn()
                };

            return this.View(
                string.Empty,
                string.Empty,
                viewModel);
        }
        public ActionResult Menu()
        {
            MenuViewModel viewModel;
            if (this.HttpContext.Cache["menu"] != null)
            {
                viewModel = (MenuViewModel)this.HttpContext.Cache["menu"];
            }
            else
            {
                var categories = this.homeService
                .GetCategories()
                .To<CategoryViewModel>()
                .ToList();

                var sports = this.homeService
                    .GetSports()
                    .To<SportViewModel>()
                    .ToList();

                var brands = this.homeService
                    .GetBrands()
                    .To<BrandViewModel>()
                    .ToList();

                viewModel = new MenuViewModel()
                {
                    Categories = categories,
                    Sports = sports,
                    Brands = brands
                };

                this.HttpContext.Cache["menu"] = viewModel;
            }

            return PartialView("_NavigationPartial", viewModel);
        }
Beispiel #6
0
 public MenuWindow()
 {
     InitializeComponent();
     DataContext = new MenuViewModel();
 }
Beispiel #7
0
 public static IList <ILabelVievModel> GetWaypointsWithin(Random r, int n, IAudioSelectionViewModel selection, MenuViewModel waypointsMenu)
 {
     return(Enumerable.Range(0, n).Select(i => (ILabelVievModel) new WaypointLabelViewModel(RandomWaypoint(r))
     {
         Position = (r.NextDouble() * selection.Duration + selection.Start),
         Menu = waypointsMenu
     }).ToList());
 }
Beispiel #8
0
 public MenuPage()
 {
     InitializeComponent();
     BindingContext = new MenuViewModel();
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            historyViewModel = ServiceContainer.Resolve <HistoryViewModel> ();
            menuViewModel    = ServiceContainer.Resolve <MenuViewModel> ();

            var view = inflater.Inflate(Resource.Layout.HistoryFragmentLayout, null, true);

            searchText              = view.FindViewById <EditText> (Resource.Id.historySearchText);
            searchText.TextChanged += (sender, e) => {
                if (historySearchAdapter != null)
                {
                    historySearchAdapter.FilterItems(searchText.Text);
                    historySearchAdapter.NotifyDataSetChanged();
                }
            };
            var clearSearch = view.FindViewById <ImageButton> (Resource.Id.historyClearSearch);

            clearSearch.Click += (sender, e) => searchText.Text = string.Empty;

            tabHost         = view.FindViewById <TabHost> (Resource.Id.historyTabHost);
            historyListView = view.FindViewById <ListView> (Resource.Id.historyListView);

            localManger = new LocalActivityManager(Activity, true);
            localManger.DispatchCreate(savedInstanceState);
            tabHost.Setup(localManger);

            var dateIndicator = CreateTab("DATE");

            TabHost.TabSpec dateTab = tabHost.NewTabSpec("Date");
            dateTab.SetIndicator(dateIndicator);
            dateTab.SetContent(new TabContent(new TextView(tabHost.Context)));

            var callsIndicator = CreateTab("CALLS");

            TabHost.TabSpec callsTab = tabHost.NewTabSpec("Calls");
            callsTab.SetIndicator(callsIndicator);
            callsTab.SetContent(new TabContent(new TextView(tabHost.Context)));

            var assignmentIndicator = CreateTab("ASSIGNMENTS");

            TabHost.TabSpec assignments = tabHost.NewTabSpec("Assignments");
            assignments.SetIndicator(assignmentIndicator);
            assignments.SetContent(new TabContent(new TextView(tabHost.Context)));

            tabHost.AddTab(dateTab);
            tabHost.AddTab(callsTab);
            tabHost.AddTab(assignments);

            tabHost.TabChanged += (sender, e) => {
                if (History != null)
                {
                    switch (tabHost.CurrentTab)
                    {
                    case 0:
                        historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.OrderBy(h => h.Date).ToList());
                        break;

                    case 1:
                        historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.Where(h => h.Type == AssignmentHistoryType.PhoneCall).ToList());
                        break;

                    default:
                        historySearchAdapter = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.Where(h => h.Type == AssignmentHistoryType.Assignment).ToList());
                        break;
                    }
                    historySearchAdapter.Assignment = Assignment;
                    historyListView.Adapter         = historySearchAdapter;
                }
            };
            if (History != null)
            {
                historySearchAdapter            = new HistoryListAdapter(Activity, Resource.Layout.HistoryItemLayout, History.OrderBy(a => a.Date).ToList());
                historySearchAdapter.Assignment = Assignment;
                historyListView.Adapter         = historySearchAdapter;
            }

            historyListView.ItemClick += (sender, e) => {
                var intent = new Intent(Activity, typeof(SummaryHistoryActivity));
                historyViewModel.SelectedAssignmentHistory = History.ElementAtOrDefault(e.Position);
                menuViewModel.MenuIndex = 0;
                StartActivity(intent);
            };

            return(view);
        }
        public ActionResult Menu(ShoppingCart cart, BrowseHistory bh, int id = 0, int reorderid = 0)
        {
            if (cart == null)
            {
                ControllerContext cc = new ControllerContext();
                cart = new ShoppingCart();
                cc.HttpContext.Session["ShoppingCart"] = cart;
                return(Redirect("/Home"));
            }
            if (bh == null)
            {
                ControllerContext cc = new ControllerContext();
                bh            = new BrowseHistory();
                bh.IsDelivery = true;
                cc.HttpContext.Session["BorseHistory"] = bh;
                return(Redirect("~/Home"));
            }
            if (string.IsNullOrEmpty(cart.CartKey) == false && string.IsNullOrEmpty(cart.BossName) == false)
            {
                return(Redirect("~/Group"));
            }

            if (id == 0)
            {
                return(Redirect("~/Home"));
            }
            if (cart.BizId != id)
            {
                cart.Clear();
                cart.IsDelivery = bh.IsDelivery;
                cart.BizId      = id;
            }
            if (reorderid > 0)
            {
                cart.Clear();
                SetupReorder(reorderid, cart, bh);
            }
            MenuViewModel mvm = new MenuViewModel();

            mvm.BizInfo = BizInfoRepository.GetBizInfoById(id);
            BizInfo bi = mvm.BizInfo;

            cart.BizName = bi.BizTitle;
            StringBuilder sb = new StringBuilder();

            sb.Append("[");
            sb.Append("[");
            sb.Append("'" + bi.BizTitle + "',");
            sb.Append("'" + bi.Address.AddressLine + "',");
            sb.Append("'" + bi.Address.City + "',");
            sb.Append("'" + bi.Address.State + "',");
            sb.Append("'" + bi.Address.ZipCode + "',");
            sb.Append("'" + bi.Latitude + "',");
            sb.Append("'" + bi.Longitude + "',");
            sb.Append("'" + bi.BizInfoId + "',");
            sb.Append("'" + bi.ImageUrl + "'],");
            sb.Remove(sb.Length - 1, 1);
            sb.Append("]");
            mvm.MapMarkers        = sb.ToString();
            mvm.Maplink           = GoogleMapLink(bi);
            cart.IsBizDelivery    = mvm.BizInfo.Delivery;
            cart.TaxRate          = mvm.BizInfo.TaxPercentageRate;
            cart.OrderMinimum     = mvm.BizInfo.DeliveryMinimum;
            cart.DeliveryFee      = mvm.BizInfo.DeliveryFee;
            mvm.Cart              = cart;
            mvm.Cart.IsDelivery   = bh.IsDelivery;
            mvm.Cart.BizId        = id;
            mvm.Cart.DeliveryFee  = mvm.BizInfo.DeliveryFee;
            mvm.Cart.OrderMinimum = mvm.BizInfo.DeliveryMinimum;
            mvm.Cart.BizName      = mvm.BizInfo.BizTitle;
            mvm.History           = bh;
            string rul = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.UrlReferrer.PathAndQuery;

            mvm.ReturnUrl    = rul;
            mvm.MenuList     = BizInfoRepository.GetBizCuisinesByBizInfoId(id, true).ToList();
            mvm.FirstSubmenu = mvm.MenuList.FirstOrDefault();
            List <DiscountCoupon> ldc = new List <DiscountCoupon>();
            List <FreeItemCoupon> lfc = new List <FreeItemCoupon>();

            if (mvm.BizInfo.HasDiscountCoupons)
            {
                ldc = DiscountCouponRepository.GetBizDiscountCouponsByMinimum(id, cart.SubTotal(), true);
            }
            mvm.DiscountCouponList = ldc;
            if (mvm.BizInfo.HasFreeItemCoupons)
            {
                lfc = FreeItemCouponRepository.GetBizFreeItemCouponsByMinimum(id, cart.SubTotal(), true);
            }
            mvm.FreeItemCouponList = lfc;
            ViewBag.rurl           = HttpContext.Request.UrlReferrer == null ? "~/Home" : HttpContext.Request.Url.PathAndQuery;
            mvm.ProductsWithImage  = ProductRepository.GetAllProductsByBizInfoId(bi.BizInfoId, true).Where(e => string.IsNullOrEmpty(e.SmallImage) == false && e.SmallImage.StartsWith("imageSoon", true, null) == false).ToList();
            mvm.BizImages          = bi.BizImages.Where(e => string.IsNullOrEmpty(e.SmallImageName) == false && e.SmallImageName.StartsWith("imageSoon", true, null) == false && e.Active == true).ToList();

            ViewBag.bagitems = GetCartItems(cart);
            return(View(mvm));
        }
Beispiel #11
0
 public MenuPage(ClientViewModel frame, LoggedClient loggedClient)
 {
     InitializeComponent();
     DataContext = new MenuViewModel(frame, loggedClient);
 }
Beispiel #12
0
        private static void createRightHistogramMenu(HistogramOperationViewModel histogramOperationViewModel)
        {
            var attachmentViewModel = histogramOperationViewModel.AttachementViewModels.First(avm => avm.AttachmentOrientation == AttachmentOrientation.Right);
            var menuViewModel       = new MenuViewModel
            {
                AttachmentOrientation = attachmentViewModel.AttachmentOrientation,
                NrColumns             = 2,
                NrRows = 2
            };

            histogramOperationViewModel.HistogramOperationModel.PropertyChanged += (sender, args) =>
            {
                var model = histogramOperationViewModel.HistogramOperationModel;
                if (args.PropertyName == model.GetPropertyName(() => model.StatisticalComparisonOperationModel))
                {
                    if (model.StatisticalComparisonOperationModel == null)
                    {
                        foreach (var mvm in menuViewModel.MenuItemViewModels.ToArray())
                        {
                            menuViewModel.MenuItemViewModels.Remove(mvm);
                        }
                    }
                    else
                    {
                        var menuItem = new MenuItemViewModel
                        {
                            MenuViewModel     = menuViewModel,
                            Row               = 0,
                            ColumnSpan        = 1,
                            RowSpan           = 2,
                            Column            = 0,
                            Size              = new Vec(54, 54),
                            Position          = histogramOperationViewModel.Position,
                            TargetSize        = new Vec(54, 54),
                            IsAlwaysDisplayed = true
                        };
                        var attr1 = new StatisticalComparisonMenuItemViewModel
                        {
                            StatisticalComparisonOperationModel = model.StatisticalComparisonOperationModel
                        };

                        menuItem.MenuItemComponentViewModel = attr1;
                        menuViewModel.MenuItemViewModels.Add(menuItem);

                        var        toggles = new List <ToggleMenuItemComponentViewModel>();
                        var        items   = new List <MenuItemViewModel>();
                        TestType[] types   = new TestType[] { TestType.chi2, TestType.ttest };
                        int        count   = 0;
                        foreach (var type in types)
                        {
                            var toggleMenuItem = new MenuItemViewModel
                            {
                                MenuViewModel     = menuViewModel,
                                Row               = count,
                                RowSpan           = 0,
                                Position          = histogramOperationViewModel.Position,
                                Column            = 1,
                                Size              = new Vec(54, 25),
                                TargetSize        = new Vec(54, 25),
                                IsAlwaysDisplayed = true
                            };
                            //toggleMenuItem.Position = attachmentItemViewModel.Position;
                            var toggle = new ToggleMenuItemComponentViewModel
                            {
                                Label     = type.ToString(),
                                IsChecked = model.StatisticalComparisonOperationModel.TestType == type
                            };
                            toggles.Add(toggle);
                            toggleMenuItem.MenuItemComponentViewModel = toggle;
                            toggleMenuItem.MenuItemComponentViewModel.PropertyChanged += (sender2, args2) =>
                            {
                                var toogleModel = sender2 as ToggleMenuItemComponentViewModel;
                                if (args2.PropertyName == model.GetPropertyName(() => toogleModel.IsChecked))
                                {
                                    if (toogleModel.IsChecked)
                                    {
                                        model.StatisticalComparisonOperationModel.TestType = type;
                                        model.StatisticalComparisonOperationModel.FireOperationModelUpdated(new OperationModelUpdatedEventArgs());
                                        foreach (var tg in toogleModel.OtherToggles)
                                        {
                                            tg.IsChecked = false;
                                        }
                                    }
                                }
                            };
                            menuViewModel.MenuItemViewModels.Add(toggleMenuItem);
                            items.Add(toggleMenuItem);
                            count++;
                        }
                        foreach (var mi in items)
                        {
                            (mi.MenuItemComponentViewModel as ToggleMenuItemComponentViewModel).OtherToggles.AddRange(toggles.Where(ti => ti != mi.MenuItemComponentViewModel));
                        }
                    }
                }
            };

            attachmentViewModel.MenuViewModel = menuViewModel;
        }
 public ModPanelViewModel(MenuViewModel menuViewModel)
 {
     Menu = menuViewModel;
 }
Beispiel #14
0
 public ShellViewModel()
 {
     MenuViewModel = new MenuViewModel();
        ContentViewModel = new ContentViewModel();
 }
Beispiel #15
0
 public MenuView(ApplicationContext context)
 {
     InitializeComponent();
     viewModel        = new MenuViewModel(context);
     this.DataContext = viewModel;
 }
        public ActionResult FindAppsPath(string searchText = null)
        {
            MenuViewModel items = dbLMenu.GetMenuInfo(searchText);

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
        public ActionResult GetMenuInfo(string id)
        {
            MenuViewModel items = dbLMenu.GetMenuInfo(id);

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
        public void Add(MenuViewModel functionVm)
        {
            var function = _mapper.Map <Function>(functionVm);

            _functionRepository.Add(function);
        }
 public void Update(MenuViewModel functionVm)
 {
     var functionDb = _functionRepository.FindById(functionVm.Id);
     var function   = _mapper.Map <Function>(functionVm);
 }
 public MenuView()
 {
     InitializeComponent();
     menuVM = new MenuViewModel();
     this.BindingContext = menuVM;
 }
Beispiel #21
0
 public Menu()
 {
     InitializeComponent();
     viewModel      = new MenuViewModel(this);
     BindingContext = viewModel;
 }
        public MenuViewModel GetMainMenu()
        {
            if (_viewModel != null)
            {
                return(_viewModel);
            }

            var itemsByDepth = _menuItems.GroupBy(i => i.Metadata.Path.Count).OrderBy(i => i.Key);
            var rootSettings = _menuSettingsService.GetRootSettings(ExportContractNames.MainMenu);

            var builder = ImmutableList.CreateBuilder <MenuItemModel>();

            Dictionary <MenuPath, MenuItem> parentDepthMenuItems = new Dictionary <MenuPath, MenuItem>()
            {
                [new MenuPath(Array.Empty <string>())] = rootSettings
            };

            foreach (var depth in itemsByDepth)
            {
                if (depth.Key == 0)
                {
                    continue;
                }

                var currentDepthMenuItems = new Dictionary <MenuPath, MenuItem>();

                foreach (var item in depth)
                {
                    var path = item.Metadata.Path;

                    // if the parent item is not registered, it won't be included,
                    // even if it's referenced by other items
                    if (parentDepthMenuItems.TryGetValue(path.Parent, out var parentItem))
                    {
                        var itemName = path[path.Count - 1];

                        if (!parentItem.Items.TryGetValue(itemName, out var itemSettings))
                        {
                            itemSettings = new MenuItem()
                            {
                                Group = item.Metadata.DefaultGroup ?? "(default)",
                                Order = item.Metadata.DefaultOrder
                            };

                            parentItem.Items.Add(itemName, itemSettings);

                            if (!parentItem.Groups.ContainsKey(itemSettings.Group))
                            {
                                var group = _defaultGroups.SingleOrDefault(
                                    g => g.Metadata.Path.Parent == path.Parent &&
                                    g.Metadata.Path[g.Metadata.Path.Count - 1] == itemSettings.Group);

                                if (group == null)
                                {
                                    parentItem.Groups.Add(itemSettings.Group, new MenuGroup());
                                }
                                else
                                {
                                    parentItem.Groups.Add(itemSettings.Group, new MenuGroup()
                                    {
                                        Order = group.Metadata.DefaultOrder
                                    });
                                }
                            }
                        }

                        currentDepthMenuItems.Add(path, itemSettings);
                    }
                }

                parentDepthMenuItems = currentDepthMenuItems;
            }

            _menuSettingsService.SaveMenuSettings();

            foreach (var itemModel in GetChildren(new MenuPath(Array.Empty <string>()), rootSettings, 1))
            {
                builder.Add(itemModel);
            }

            return(_viewModel = new MenuViewModel(builder.ToImmutable()));

            IEnumerable <MenuItemModel> GetChildren(MenuPath parent, MenuItem itemSettings, int depth)
            {
                var depthItems = itemsByDepth.SingleOrDefault(d => d.Key == depth);

                var skipSeparator = true;

                foreach (var group in itemSettings.Items
                         .GroupBy(i => i.Value.Group)
                         .OrderBy(g => itemSettings.Groups[g.Key].Order))
                {
                    if (!skipSeparator)
                    {
                        yield return(new MenuItemSeparatorModel());
                    }

                    skipSeparator = true;

                    foreach (var item in group.OrderBy(i => i.Value.Order))
                    {
                        if (!item.Value.Enabled)
                        {
                            continue;
                        }

                        var menuItem = _menuItems.SingleOrDefault(
                            i => i.Metadata.Path.Parent == parent && i.Metadata.Path[i.Metadata.Path.Count - 1] == item.Key);

                        if (menuItem != null)
                        {
                            skipSeparator = false;

                            yield return(new MenuItemModel(
                                             menuItem, GetChildren(menuItem.Metadata.Path, item.Value, depth + 1)));
                        }
                    }
                }
            }
        }
Beispiel #23
0
 public ActionResult Create(MenuViewModel menuViewModel)
 {
     return(View(menuViewModel));
 }
Beispiel #24
0
        public override int Convert(Guid toDoGroupId, Type targetType, MenuView menuView, CultureInfo culture)
        {
            MenuViewModel viewModel = (MenuViewModel)menuView.BindingContext;

            return(viewModel.ToDoService.ToDoItems.Count(tdi => tdi.ToDoGroupId == toDoGroupId));
        }
        public MasterDetailPageMaster()
        {
            InitializeComponent();

            BindingContext = new MenuViewModel();
        }
Beispiel #26
0
 public MainWindow()
 {
     InitializeComponent();
     MenuViewModel.GetMenu(this);
 }
 private IViewComponentResult GetView(MenuViewModel model, bool isLeftMenuUsed)
 {
     return(View(isLeftMenuUsed ? "Default" : "Top", model));
 }
Beispiel #28
0
        public IEnumerable <Link> CreateLinks(Method method, MenuViewModel content = null)
        {
            var linkContainer = new LinkContainer();

            if (_urlHelper != null)
            {
                var getAll = new Link()
                {
                    Method = "GET", Rel = "get all menus", Href = _urlHelper.Link("GetAllMenus", new { })
                };
                var insert = new Link()
                {
                    Method = "POST", Rel = "insert menu", Href = _urlHelper.Link("InsertMenu", new { })
                };

                var getById = new Link();
                var update  = new Link();
                var delete  = new Link();

                if (content != null)
                {
                    getById = new Link()
                    {
                        Method = "GET", Rel = "get menu by id", Href = _urlHelper.Link("GetMenuByInstitution", new { })
                    };
                    update = new Link()
                    {
                        Method = "PUT", Rel = "update menu", Href = _urlHelper.Link("UpdateMenu", new { id = content.Id })
                    };
                    delete = new Link()
                    {
                        Method = "DELETE", Rel = "delete menu", Href = _urlHelper.Link("DeleteMenu", new { id = content.Id })
                    };
                }

                switch (method)
                {
                case Method.GetAll:
                    linkContainer.AddLink(getAll);
                    linkContainer.AddLink(insert);
                    break;

                case Method.Get:
                    linkContainer.AddLink(getById);
                    linkContainer.AddLink(update);
                    linkContainer.AddLink(delete);
                    break;

                case Method.Post:
                    linkContainer.AddLink(insert);
                    linkContainer.AddLink(getById);
                    linkContainer.AddLink(update);
                    linkContainer.AddLink(delete);
                    break;

                case Method.Put:
                    linkContainer.AddLink(update);
                    linkContainer.AddLink(getById);
                    linkContainer.AddLink(delete);
                    break;
                }
                linkContainer.Links[0].Rel = "self";
            }
            return(linkContainer.Links);
        }
Beispiel #29
0
 public AssignmentsActivity()
 {
     assignmentViewModel = ServiceContainer.Resolve <AssignmentViewModel>();
     assignmentViewModel.HoursChanged += HoursChanged;
     menuViewModel = ServiceContainer.Resolve <MenuViewModel> ();
 }
Beispiel #30
0
 public MenuView(MenuViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
        public ActionResult Menu()
        {
            MenuViewModel model = new MenuViewModel(context);

            return(PartialView(model));
        }
		public RootViewModel()
		{
			Home = new HomeViewModel();
			Menu = new MenuViewModel();
		}
Beispiel #33
0
 public WPFMenuViewModel(MenuViewModel model)
 {
     this.model = model;
 }
Beispiel #34
0
 public MenuView(MenuViewModel viewModel)
 {
     _viewModel = viewModel;
     InitializeComponent();
     DataContext = _viewModel;
 }
 public void AddMenu(MenuViewModel mvm)
 {
     Menus.Add(mvm);
 }
        public ActionResult Details(long? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            IMenu menu = _menuRepository.GetSingle((long)id);

            if (menu.id == 0)
            {
                return HttpNotFound();
            }

            IEnumerable<IMenuItem> menuItems = _menuItemRepository.GetByMenu((long)id);

            ViewBag.Title = "Details - " + menu.name;
            List<MenuItem> menu_items = _menuItemMapper.ToList(menuItems);

            MenuViewModel model = new MenuViewModel(menu, menuItems);
            return View(model);
        }
Beispiel #37
0
        private static void createAxisMenu(HistogramOperationViewModel histogramOperationViewModel, AttachmentOrientation attachmentOrientation,
                                           AttributeUsage axis, Vec size, double textAngle, bool isWidthBoundToParent, bool isHeightBoundToParent)
        {
            var attachmentViewModel =
                histogramOperationViewModel.AttachementViewModels.First(
                    avm => avm.AttachmentOrientation == attachmentOrientation);

            var menuViewModel = new MenuViewModel
            {
                AttachmentOrientation = attachmentViewModel.AttachmentOrientation,
                NrColumns             = attachmentOrientation == AttachmentOrientation.Bottom ? 5 : 2,
                NrRows = attachmentOrientation == AttachmentOrientation.Bottom ? 2 : 5
            };

            var menuItem = new MenuItemViewModel
            {
                MenuViewModel         = menuViewModel,
                Row                   = 0,
                ColumnSpan            = attachmentOrientation == AttachmentOrientation.Bottom ? 5 : 1,
                RowSpan               = attachmentOrientation == AttachmentOrientation.Bottom ? 1 : 5,
                Column                = attachmentOrientation == AttachmentOrientation.Bottom ? 0 : 1,
                Size                  = size,
                Position              = histogramOperationViewModel.Position,
                TargetSize            = size,
                IsAlwaysDisplayed     = true,
                IsWidthBoundToParent  = isWidthBoundToParent,
                IsHeightBoundToParent = isHeightBoundToParent
            };
            var attr1 = new AttributeTransformationMenuItemViewModel
            {
                TextAngle = textAngle,
                TextBrush = new SolidColorBrush(Helpers.GetColorFromString("#29aad5"))
            };

            histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).CollectionChanged += (sender, args) =>
            {
                var coll = sender as ObservableCollection <AttributeTransformationModel>;
                var attributeTransformationModel = coll.FirstOrDefault();
                attr1.Label = attributeTransformationModel == null ? "" : attributeTransformationModel.GetLabel();
                attr1.AttributeTransformationViewModel = new AttributeTransformationViewModel(histogramOperationViewModel, coll.FirstOrDefault());

                if (attributeTransformationModel != null)
                {
                    attributeTransformationModel.PropertyChanged += (sender2, args2) =>
                    {
                        attr1.Label = (sender2 as AttributeTransformationModel).GetLabel();
                    };
                }

                // remove old ones first
                foreach (var mvm in menuViewModel.MenuItemViewModels.Where(mvm => mvm.MenuItemComponentViewModel is ToggleMenuItemComponentViewModel).ToArray())
                {
                    menuViewModel.MenuItemViewModels.Remove(mvm);
                }

                var aom = attr1.AttributeTransformationViewModel.AttributeTransformationModel;
                var aggregateFunctions = new[] { AggregateFunction.None, AggregateFunction.Count }.ToList();
                if (aom != null)
                {
                    if (((AttributeFieldModel)aom.AttributeModel).InputDataType == InputDataTypeConstants.INT ||
                        (((AttributeFieldModel)aom.AttributeModel).InputDataType == InputDataTypeConstants.FLOAT))
                    {
                        aggregateFunctions.Add(AggregateFunction.Avg);
                        aggregateFunctions.Add(AggregateFunction.Sum);
                        if (MainViewController.Instance.MainModel.IsUnknownUnknownEnabled)
                        {
                            aggregateFunctions.Add(AggregateFunction.SumE);
                        }
                    }

                    var toggles = new List <ToggleMenuItemComponentViewModel>();
                    var items   = new List <MenuItemViewModel>();

                    var count = 0;
                    foreach (var aggregationFunction in aggregateFunctions)
                    {
                        var toggleMenuItem = new MenuItemViewModel
                        {
                            MenuViewModel = menuViewModel,
                            Row           = attachmentOrientation == AttachmentOrientation.Bottom ? 1 : count,
                            RowSpan       = 0,
                            Position      = histogramOperationViewModel.Position,
                            Column        = attachmentOrientation == AttachmentOrientation.Bottom ? count : 0,
                            Size          = new Vec(32, 32),
                            TargetSize    = new Vec(32, 32)
                        };
                        //toggleMenuItem.Position = attachmentItemViewModel.Position;
                        var toggle = new ToggleMenuItemComponentViewModel
                        {
                            Label     = aggregationFunction.ToString(),
                            IsChecked = aom.AggregateFunction == aggregationFunction
                        };
                        toggles.Add(toggle);
                        toggleMenuItem.MenuItemComponentViewModel = toggle;
                        toggleMenuItem.MenuItemComponentViewModel.PropertyChanged += (sender2, args2) =>
                        {
                            var model = sender2 as ToggleMenuItemComponentViewModel;
                            if (args2.PropertyName == model.GetPropertyName(() => model.IsChecked))
                            {
                                if (model.IsChecked)
                                {
                                    aom.AggregateFunction = aggregationFunction;
                                    foreach (var tg in model.OtherToggles)
                                    {
                                        tg.IsChecked = false;
                                    }
                                }
                            }
                        };
                        menuViewModel.MenuItemViewModels.Add(toggleMenuItem);
                        items.Add(toggleMenuItem);
                        count++;
                    }

                    foreach (var mi in items)
                    {
                        (mi.MenuItemComponentViewModel as ToggleMenuItemComponentViewModel).OtherToggles.AddRange(toggles.Where(ti => ti != mi.MenuItemComponentViewModel));
                    }
                }
            };
            attr1.TappedTriggered  = () => { attachmentViewModel.ActiveStopwatch.Restart(); };
            attr1.DroppedTriggered = attributeTransformationModel =>
            {
                var otherAxis     = axis == AttributeUsage.X ? AttributeUsage.Y : AttributeUsage.X;
                var existingModel = histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).Any() ?
                                    histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(axis).First() : null;
                var existingOtherModel = histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(otherAxis).Any() ?
                                         histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(otherAxis).First() : null;
                var swapAxes = existingModel != null && existingOtherModel.AttributeModel == attributeTransformationModel.AttributeModel &&
                               existingOtherModel.AggregateFunction == attributeTransformationModel.AggregateFunction;

                if (existingModel != null)
                {
                    histogramOperationViewModel.HistogramOperationModel.RemoveAttributeUsageTransformationModel(axis, existingModel);
                }
                if (!histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue).Any())
                {
                    var value = new AttributeTransformationModel(attributeTransformationModel.AttributeModel);
                    value.AggregateFunction = AggregateFunction.Count;
                    histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value);
                }
                histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(axis, attributeTransformationModel);
                attachmentViewModel.ActiveStopwatch.Restart();
                if (swapAxes)
                {
                    histogramOperationViewModel.HistogramOperationModel.RemoveAttributeUsageTransformationModel(otherAxis, existingOtherModel);
                    if (!histogramOperationViewModel.HistogramOperationModel.GetAttributeUsageTransformationModel(AttributeUsage.DefaultValue).Any())
                    {
                        var value = new AttributeTransformationModel(attributeTransformationModel.AttributeModel);
                        value.AggregateFunction = AggregateFunction.Count;
                        histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(AttributeUsage.DefaultValue, value);
                    }
                    histogramOperationViewModel.HistogramOperationModel.AddAttributeUsageTransformationModel(otherAxis, existingModel);
                }
            };

            menuItem.MenuItemComponentViewModel = attr1;
            menuViewModel.MenuItemViewModels.Add(menuItem);
            attachmentViewModel.MenuViewModel = menuViewModel;
        }
 public SideMenuPage()
 {
     InitializeComponent();
     viewModel      = new MenuViewModel();
     BindingContext = viewModel;
 }
Beispiel #39
0
		public MenuPage ()
		{
			InitializeComponent ();
			BindingContext = new MenuViewModel ();
		}
Beispiel #40
0
        private static void createBottomExampleMenu(ExampleOperationViewModel exampleOperationViewModel)
        {
            var attachmentViewModel =
                exampleOperationViewModel.AttachementViewModels.First(
                    avm => avm.AttachmentOrientation == AttachmentOrientation.Bottom);

            attachmentViewModel.ShowOnAttributeMove = true;

            var menuViewModel = new MenuViewModel
            {
                AttachmentOrientation = attachmentViewModel.AttachmentOrientation,
                NrColumns             = 3,
                NrRows = 1
            };

            var addMenuItem = new MenuItemViewModel
            {
                MenuViewModel         = menuViewModel,
                Row                   = 0,
                ColumnSpan            = 1,
                RowSpan               = 1,
                Column                = 0,
                Size                  = new Vec(25, 25),
                TargetSize            = new Vec(25, 25),
                IsAlwaysDisplayed     = false,
                IsWidthBoundToParent  = false,
                IsHeightBoundToParent = false,
                Position              = exampleOperationViewModel.Position
            };
            var attr1 = new AttributeTransformationMenuItemViewModel
            {
                Label     = "+",
                TextBrush = new SolidColorBrush(Helpers.GetColorFromString("#171717")),
                CanDrag   = false,
                CanDrop   = true
            };

            attr1.DroppedTriggered = attributeTransformationModel => { exampleOperationViewModel.ExampleOperationModel.AttributeUsageTransformationModels.Add(attributeTransformationModel); };

            addMenuItem.MenuItemComponentViewModel = attr1;
            menuViewModel.MenuItemViewModels.Add(addMenuItem);
            attachmentViewModel.MenuViewModel = menuViewModel;

            exampleOperationViewModel.ExampleOperationModel.AttributeUsageTransformationModels.CollectionChanged += (sender, args) =>
            {
                var coll = sender as ObservableCollection <AttributeTransformationModel>;

                // remove old ones first
                if (args.OldItems != null)
                {
                    foreach (var oldItem in args.OldItems)
                    {
                        var oldAttributeTransformationModel = oldItem as AttributeTransformationModel;
                        var found = menuViewModel.MenuItemViewModels.FirstOrDefault(mvm =>
                                                                                    (((AttributeTransformationMenuItemViewModel)mvm.MenuItemComponentViewModel).AttributeTransformationViewModel != null) &&
                                                                                    (((AttributeTransformationMenuItemViewModel)mvm.MenuItemComponentViewModel).AttributeTransformationViewModel.AttributeTransformationModel ==
                                                                                     oldAttributeTransformationModel));
                        if (found != null)
                        {
                            menuViewModel.MenuItemViewModels.Remove(found);
                        }
                    }
                }

                menuViewModel.NrRows = (int)Math.Ceiling(coll.Count / 3.0) + 1;
                addMenuItem.Row      = menuViewModel.NrRows - 1;

                // add new ones
                if (args.NewItems != null)
                {
                    foreach (var newItem in args.NewItems)
                    {
                        var newAttributeTransformationModel = newItem as AttributeTransformationModel;
                        var newMenuItem = new MenuItemViewModel
                        {
                            MenuViewModel = menuViewModel,
                            Size          = new Vec(50, 50),
                            TargetSize    = new Vec(50, 50),
                            Position      = addMenuItem.Position
                        };
                        var newAttr = new AttributeTransformationMenuItemViewModel
                        {
                            Label = newAttributeTransformationModel.GetLabel(),
                            AttributeTransformationViewModel = new AttributeTransformationViewModel(exampleOperationViewModel, newAttributeTransformationModel),
                            TextBrush = new SolidColorBrush(Helpers.GetColorFromString("#29aad5")),
                            CanDrag   = false,
                            CanDrop   = false
                        };
                        newMenuItem.Deleted += (sender1, args1) =>
                        {
                            var atm =
                                ((AttributeTransformationMenuItemViewModel)((MenuItemViewModel)sender1).MenuItemComponentViewModel).AttributeTransformationViewModel.AttributeTransformationModel;
                            exampleOperationViewModel.ExampleOperationModel.AttributeUsageTransformationModels.Remove(atm);
                        };
                        newMenuItem.MenuItemComponentViewModel = newAttr;
                        menuViewModel.MenuItemViewModels.Add(newMenuItem);
                    }
                }

                var count = 0;
                foreach (var menuItemViewModel in menuViewModel.MenuItemViewModels.Where(mvm => mvm != addMenuItem))
                {
                    menuItemViewModel.Column = count % 3;
                    menuItemViewModel.Row    = (int)Math.Floor(count / 3.0);
                    count++;
                }
                attachmentViewModel.ActiveStopwatch.Restart();
                menuViewModel.FireUpdate();
            };
        }
Beispiel #41
0
        private static void createLeftExampleMenu(ExampleOperationViewModel exampleOperationViewModel)
        {
            var attachmentViewModel =
                exampleOperationViewModel.AttachementViewModels.First(
                    avm => avm.AttachmentOrientation == AttachmentOrientation.Left);

            var menuViewModel = new MenuViewModel
            {
                AttachmentOrientation = attachmentViewModel.AttachmentOrientation,
                NrColumns             = 1,
                NrRows = 3
            };

            attachmentViewModel.MenuViewModel = menuViewModel;

            var toggles = new List <ToggleMenuItemComponentViewModel>();
            var items   = new List <MenuItemViewModel>();

            var count = 0;

            foreach (var exampleOperationType in new[] { ExampleOperationType.A, ExampleOperationType.B, ExampleOperationType.C })
            {
                var toggleMenuItem = new MenuItemViewModel
                {
                    MenuViewModel = menuViewModel,
                    Row           = count,
                    RowSpan       = 0,
                    Column        = 0,
                    Position      = exampleOperationViewModel.Position,
                    Size          = new Vec(50, 32),
                    TargetSize    = new Vec(50, 32)
                };

                var toggle = new ToggleMenuItemComponentViewModel
                {
                    Label     = exampleOperationType.ToString().ToLower(),
                    IsChecked = exampleOperationViewModel.ExampleOperationModel.ExampleOperationType == exampleOperationType
                };
                toggles.Add(toggle);
                toggleMenuItem.MenuItemComponentViewModel = toggle;
                toggleMenuItem.MenuItemComponentViewModel.PropertyChanged += (sender2, args2) =>
                {
                    var model = sender2 as ToggleMenuItemComponentViewModel;
                    if (args2.PropertyName == model.GetPropertyName(() => model.IsChecked))
                    {
                        if (model.IsChecked)
                        {
                            attachmentViewModel.ActiveStopwatch.Restart();
                            exampleOperationViewModel.ExampleOperationModel.ExampleOperationType = exampleOperationType;
                            foreach (var tg in model.OtherToggles)
                            {
                                tg.IsChecked = false;
                            }
                        }
                    }
                };
                menuViewModel.MenuItemViewModels.Add(toggleMenuItem);
                items.Add(toggleMenuItem);
                count++;
            }

            foreach (var mi in items)
            {
                (mi.MenuItemComponentViewModel as ToggleMenuItemComponentViewModel).OtherToggles.AddRange(toggles.Where(ti => ti != mi.MenuItemComponentViewModel));
            }
        }
Beispiel #42
0
 public MenuView(MenuViewModel menuViewModel)
 {
     _menuViewModel = menuViewModel;
       InitializeComponent();
 }