private void DisplayContainers(List <MRUItemsContainer> containers) { int scrollPosition = panelItems.VerticalScroll.Value; panelItems.VerticalScroll.Value = 0; currentTopPosition = 0; foreach (MRUItemsContainer container in containers) { Label groupCaption = new Label { Text = container.ContainerCaption, Left = 1, Top = currentTopPosition, AutoSize = true }; panelItems.Controls.Add(groupCaption); currentTopPosition += TextRenderer.MeasureText(groupCaption.Text, groupCaption.Font).Height + 3; foreach (MRUItem item in container.Items) { MRUItemControl mruControl = new MRUItemControl(); panelItems.Controls.Add(mruControl); mruControl.Initialize(item, localization.ItemLocalization, imageForItem); mruControl.Top = currentTopPosition; mruControl.Left = 1; ItemViews.Add(mruControl); currentTopPosition += mruControl.Height; } } CorrectWidthForItems(); panelItems.VerticalScroll.Value = scrollPosition; }
public Infrastructure Create(string function) { if (function == "login") { LogIn _view = new LogIn(); ModelEntities _entity = new ModelEntities(); LoginCommand loginCommand = new LoginCommand(_view); RegisterCommand registerCommand = new RegisterCommand(_view); ViewModel _viewModel = new ViewModel(_entity, loginCommand.Command, registerCommand.Command); loginCommand.ViewModel = _viewModel; registerCommand.ViewModel = _viewModel; return(new Infrastructure(_view, _viewModel, _entity)); } if (function == "item") { ItemViews _view = new ItemViews(); ModelEntities _entity = new ModelEntities(); LoginCommand loginCommand = new LoginCommand(_view); RegisterCommand registerCommand = new RegisterCommand(_view); ViewModel _viewModel = new ViewModel(_entity, loginCommand.Command, registerCommand.Command); loginCommand.ViewModel = _viewModel; registerCommand.ViewModel = _viewModel; return(new Infrastructure(_view, _viewModel, _entity)); } else { return(null); } }
/// <summary> /// Display MRU item containers /// </summary> /// <param name="containers">MRU containers to display</param> public override void ShowMRUItems(List <MRUItemsContainer> containers) { if (ItemViews != null) { ItemViews.Clear(); } ItemViews = new List <IMRUItemView>(); menuContents = new List <ToolStripItem>(); containers.ForEach(container => { MRUContainerToolStripSeparator separator = new MRUContainerToolStripSeparator(); separator.Text = container.ContainerCaption; separator.SetTextPresentation(this.Font, new SolidBrush(Color.Gray)); menuContents.Add(separator); container.Items.ToList().ForEach(item => { var mruItemMenu = new MRUItemMenu(); mruItemMenu.Initialize(item, localization.ItemLocalization); ItemViews.Add(mruItemMenu); menuContents.Add(mruItemMenu); }); }); if (containers.Count() > 0) { menuContents.Add(new ToolStripSeparator()); menuContents.Add(CreateClearAllMenu()); } AttachMenuItems(); }
internal void Add(object view, ViewModel viewModel) { ItemViews _view = (ItemViews)view; string userName = _view.AddAssign.SelectedValue.ToString(); int userID = viewModel.Model.Users.Where(s => s.UserName == userName).Select(t => t.UserID).First(); string category = _view.AddCategory.SelectedValue.ToString(); int categoryID = viewModel.Model.Categories.Where(s => s.CategoryDesc == category).Select(t => t.CategoryID).First(); viewModel.Model.Items.Add(new Models.Item() { CategoryID = categoryID, ItemDesc = _view.AddItem.Text, AssignedTo = userID, DueDate = Convert.ToDateTime(_view.AddDueDate.Text) }); viewModel.Model.SaveChanges(); int itemid = viewModel.Model.Items.Select(t => t.ItemID).OrderByDescending(u => u).First(); viewModel.Model.SubItems.Add(new Models.SubItem() { ItemID = itemid, SubItemDesc = _view.AddSubItem1.Text }); viewModel.Model.SaveChanges(); viewModel.Model.SubItems.Add(new Models.SubItem() { ItemID = itemid, SubItemDesc = _view.AddSubItem2.Text }); viewModel.Model.SaveChanges(); viewModel.GetItems(); }
public override async Task OnInitializing() { await base.OnInitializing(); emptyTemplate?.Ignored(dataSource.Any()); if (ItemViews.None()) { await UpdateSource(DataSource); } }
/// <summary> /// Display MRU item containers /// </summary> /// <param name="containers">MRU containers to display</param> public override void ShowMRUItems(List <MRUItemsContainer> containers) { if (ItemViews != null) { ItemViews.Clear(); } ItemViews = new List <IMRUItemView>(); containers.ForEach(container => { container.Items.ToList().ForEach(item => { var mruItemMenu = new MRUItemMenu(); mruItemMenu.Initialize(item, localization.ItemLocalization); ItemViews.Add(mruItemMenu); }); }); AttachMenuItems(); }
private void CorrectWidthForItems() { if (ItemViews == null || ItemViews.Count == 0) { return; } int width = panelItems.Width - 2; if (currentTopPosition > this.panelItems.Height) { width = panelItems.Width - 18; } ItemViews.ForEach((IMRUItemView item) => { Control itemControl = item as Control; itemControl.Width = width; // itemControl.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right); }); }
public Infrastructure Create(ModelEntities entity, string function) { if (function == "item") { ItemViews _view = new ItemViews(); SelectionCommand selectionCommand = new SelectionCommand(_view); UpdateItemCommand updateItemCommand = new UpdateItemCommand(_view); AddItemCommand addItemCommand = new AddItemCommand(_view); ViewModel _viewModel = new ViewModel(entity, selectionCommand.Command, updateItemCommand.Command, addItemCommand.Command); selectionCommand.ViewModel = _viewModel; updateItemCommand.ViewModel = _viewModel; addItemCommand.ViewModel = _viewModel; return(new Infrastructure(_view, _viewModel, entity)); } else { return(null); } }
internal Expression <Func <Item, bool> > GetCriteria(object view) { ItemViews _view = (ItemViews)view; string category = _view.Category.SelectedValue == null ? null : _view.Category.SelectedValue.ToString(); string userGroup = _view.UserGroup.SelectedValue == null ? null : _view.UserGroup.SelectedValue.ToString(); string status = _view.Status.SelectedItem == null ? null: ((ComboBoxItem)(_view.Status.SelectedItem)).Content.ToString(); string dueDate = _view.DueIn.SelectedItem == null? null:((ComboBoxItem)(_view.DueIn.SelectedItem)).Content.ToString(); double diff = dueDate != null?Convert.ToDouble(dueDate.Substring(0, 2).Trim()) : 0.0000; DateTime endDate = (dueDate != null)?DateTime.Now.AddDays(diff):DateTime.Now.AddDays(1000); // Func<Item, bool> func = return(s => ((category != null ? s.Category.CategoryDesc == category : true) && (userGroup != null ? s.User.UserGroup == userGroup : true) && (bool)(status != null ? (status == "IsStarted" ? s.IsStarted : (status == "IsDone" ? s.IsDone : s.IsClosed)) : true) && (dueDate != null ? s.DueDate <= endDate : true) )); //return new System.Linq.Expressions.Expression(); }
private void AttachMenuItems() { if (menuItem == null) { return; } menuItem.DropDownItems.Clear(); if (ItemViews != null && ItemViews.Count() > 0) { menuItem.Enabled = true; ItemViews.ForEach(itemView => { (itemView as MRUItemMenu).Appearance = menuItemAppearance; menuItem.DropDownItems.Add(itemView as ToolStripMenuItem); }); menuItem.DropDownItems.Add(new ToolStripSeparator()); menuItem.DropDownItems.Add(CreateClearAllMenu()); } else { menuItem.Enabled = false; } }