private void CalculateWidths() { if (PagesView == null) { return; } var visibleItems = PagesView.OfType <PageItemWrapper>().ToList(); if (this.Template == null) { return; } ItemsControl itemsControl = (ItemsControl)this.Template.FindName("items", this); if (itemsControl == null) { return; } foreach (var page in visibleItems) { page.Width = itemsControl.ActualWidth / visibleItems.Count; } }
private void MoveToPage(int pageIndex) { if (Pages.Count <= 0) { return; } if (Pages.Count == pageIndex) { ExtendedNextCommand.Execute(ExtendedNextCommandParams); return; } if (PageIndex >= 0) { Pages.ElementAt(PageIndex).IsSelected = false; } PageIndex = pageIndex; if (PageIndex >= 0) { Pages.ElementAt(PageIndex).IsSelected = true; } CommandManager.InvalidateRequerySuggested(); ItemsView.Refresh(); PagesView.Refresh(); CalculateWidths(); }
public ActionResult EditPage(PagesView model) { //checkk the state of the model if (!ModelState.IsValid) { return(View(model)); } using (DBLayer db = new DBLayer()) { //this part gets the id of the page that is being edited int id = model.Id; //this part is used to initials the slug of the page string slug = "home"; //this part is used to get the correct page that is being edited PageDTO pagedto = db.Pages.Find(id); //this part is for dto the title pagedto.Title = model.Title; //this part is to check if a slug has been entered and if not then set one automatically if (model.Slug != "home") { if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } } //this part is identify if the tile and slug are unique if (db.Pages.Where(x => x.Id != id).Any(x => x.Title == model.Title) || db.Pages.Where(x => x.Id != id).Any(x => x.Slug == slug)) { ModelState.AddModelError("", "Either the title or slug already exists please choose an alternative"); return(View(model)); } //dto the rest pagedto.Body = model.Body; pagedto.Slug = slug; pagedto.Sidebar = model.Sidebar; //this part saves the dto that occured db.SaveChanges(); } //this part is used to set temp data message TempData["SM"] = "You have successfully edited page!"; //redirect back to edit page area return(RedirectToAction("EditPage")); }
public ActionResult CreatePage(PagesView model) { //this part checks the model state of this page if (!ModelState.IsValid) { return(View(model)); } using (DBLayer db = new DBLayer()) { //this part is used to declare the slug for the page string slug; //this part intialises the PageDTO PageDTO dto = new PageDTO(); //the part dtos the title for the page dto.Title = model.Title; //check if the slug has been entered when creating a page if (string.IsNullOrWhiteSpace(model.Slug)) { slug = model.Title.Replace(" ", "-").ToLower(); } else { slug = model.Slug.Replace(" ", "-").ToLower(); } //this part is identify if the tile and slug are unique if (db.Pages.Any(x => x.Title == model.Title) || db.Pages.Any(x => x.Slug == slug)) { ModelState.AddModelError("", "Either the title or slug already exists please choose an alternative"); return(View(model)); } //data transfer object the rest of the objects dto.Body = model.Body; dto.Sorting = 100; dto.Slug = slug; dto.Sidebar = model.Sidebar; //this part saves all the data transfer objects that occured db.Pages.Add(dto); db.SaveChanges(); } //this part creates a tempdata message TempData["SM"] = "You have successfully created a new page!"; //redirect user return(RedirectToAction("CreatePage")); }
public void SetupPages() { //// init Pages presenter Pages = (PagesView)App.Resolve <IPagesView>(); Pages.Dock = DockStyle.Fill; Controls.Add(Pages); Pages.BringToFront(); // setup images App.Images.SetImagesTo(Pages.Pages); App.Images.SetImagesTo(Status); // load saved pages from config Pages.SetupContextMenu(); }
public PagesTest() { this.InitializeComponent(); #if DEBUG this.AttachDevTools(); #endif PreviousPage_btn = this.Find <Button>("P_pages"); NextPage_btn = this.Find <Button>("N_pages"); pagesvw = this.Find <PagesView>("PagesVW"); goto_box = this.Find <TextBox>("GotoPage"); goto_btn = this.Find <Button>("Goto_btn"); PreviousPage_btn.Click += PreviousPage_btn_Click; NextPage_btn.Click += NextPage_btn_Click; goto_btn.Click += Goto_btn_Click; }
// GET: Pages public ActionResult Index(string page = "") { //this part of the code gets and sets the slug for the page if (page == "") { page = "home"; } //this is used to decalere the model and the class PagesView model; PageDTO pagedto; //this checks if the pages being accessed exists using (DBLayer db = new DBLayer()) { if (!db.Pages.Any(x => x.Slug.Equals(page))) { return(RedirectToAction("Index", new { page = "" })); } } //this pulls all the data from the page class using (DBLayer db = new DBLayer()) { pagedto = db.Pages.Where(x => x.Slug == page).FirstOrDefault(); } // Set page title ViewBag.PageTitle = pagedto.Title; // Check for sidebar if (pagedto.Sidebar == true) { ViewBag.Sidebar = "Yes"; } else { ViewBag.Sidebar = "No"; } // Init model model = new PagesView(pagedto); // Return view with model return(View(model)); }
public ActionResult EditPage(int id) { PagesView model; using (DBLayer db = new DBLayer()) { //looks at the table and selects the correct page to edit PageDTO pagedto = db.Pages.Find(id); //checks if the page exists to change if (pagedto == null) { //displays error message to user return(Content("The page you are trying to edit does not exist")); } //this part intials the page view model = new PagesView(pagedto); } return(View(model)); }
public ActionResult PageDetails(int id) { //this part declares the pages view PagesView model; using (DBLayer db = new DBLayer()) { //this gets the correct page PageDTO pagedto = db.Pages.Find(id); //this part is used to confirm the page is the correct one if (pagedto == null) { return(Content("This page does not exist sorry")); } //this part is used to intialise the page model = new PagesView(pagedto); } //this retruns the model with view return(View(model)); }
void CreateViews() { PagesView.Scrolled += HandleScrolled; // PagesView.Frame = new RectangleF(0.0f, 64f, PagesView.Bounds.Width, PagesController.Frame.Top - this.NavigationController.NavigationBar.Frame.Height - 22); // PagesView.ContentSize = new SizeF(PagesView.Frame.Width, PagesView.Frame.Height); // PagesView.BackgroundColor = UIColor.Green; var width = PagesView.Bounds.Width; var height = PagesView.Bounds.Height; // Create pages // Poster page page1 = new UIScrollView(PagesView.Frame) { Frame = new RectangleF(0.0f, 0.0f, width, height), DirectionalLockEnabled = true, BackgroundColor = UIColor.Clear }; textHeader = new UILabel() { Text = "Header", Font = UIFont.BoldSystemFontOfSize(2.0f * UIFont.SystemFontSize), Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, ContentMode = UIViewContentMode.Top, BackgroundColor = UIColor.Clear, Frame = new RectangleF(Values.Frame, Values.Frame, width - 2 * Values.Frame, height) }; imagePoster = new UIImageView() { ContentMode = UIViewContentMode.Center | UIViewContentMode.ScaleAspectFit, BackgroundColor = UIColor.Clear }; textVersion = new UILabel() { Text = "Version", Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, ContentMode = UIViewContentMode.Top, BackgroundColor = UIColor.Clear, Frame = new RectangleF(Values.Frame, Values.Frame, width - 2 * Values.Frame, height) }; textAuthor = new UILabel() { Text = "Author", Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, ContentMode = UIViewContentMode.Top, BackgroundColor = UIColor.Clear, Frame = new RectangleF(Values.Frame, Values.Frame, width - 2 * Values.Frame, height) }; page1.AddSubview(textHeader); page1.AddSubview(imagePoster); page1.AddSubview(textVersion); page1.AddSubview(textAuthor); PagesView.AddSubview(page1); // Description page2 = new UIScrollView(PagesView.Frame) { Frame = new RectangleF(1.0f * width, 0.0f, width, PagesView.Frame.Height), DirectionalLockEnabled = true, ContentSize = new SizeF(width, height), BackgroundColor = UIColor.Clear }; textDescription = new UILabel() { Text = "Description", Lines = 0, LineBreakMode = UILineBreakMode.WordWrap, TextAlignment = UITextAlignment.Center, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight, ContentMode = UIViewContentMode.Top, BackgroundColor = UIColor.Clear, Frame = new RectangleF(Values.Frame, Values.Frame, width - 2 * Values.Frame, height) }; page2.AddSubview(textDescription); PagesView.AddSubview(page2); page3 = new UITableView(PagesView.Frame) { Frame = new RectangleF(2 * width, 0.0f, width, height), DirectionalLockEnabled = true, SeparatorStyle = UITableViewCellSeparatorStyle.None }; PagesView.AddSubview(page3); }
public PagesGridViewModel <SiteSettingPageViewModel> GetFilteredPagesList(PagesFilter request) { request.SetDefaultSortingOptions("Title"); PageProperties alias = null; PagesView viewAlias = null; SiteSettingPageViewModel modelAlias = null; var query = unitOfWork.Session .QueryOver(() => viewAlias) .Inner.JoinAlias(() => viewAlias.Page, () => alias) .Where(() => !alias.IsDeleted && alias.Status != PageStatus.Preview); var hasnotSeoDisjunction = Restrictions.Disjunction() .Add(Restrictions.Eq(Projections.Property(() => viewAlias.IsInSitemap), false)) .Add(RestrictionsExtensions.IsNullOrWhiteSpace(Projections.Property(() => alias.MetaTitle))) .Add(RestrictionsExtensions.IsNullOrWhiteSpace(Projections.Property(() => alias.MetaKeywords))) .Add(RestrictionsExtensions.IsNullOrWhiteSpace(Projections.Property(() => alias.MetaDescription))); var hasSeoProjection = Projections.Conditional(hasnotSeoDisjunction, Projections.Constant(false, NHibernateUtil.Boolean), Projections.Constant(true, NHibernateUtil.Boolean)); query = FilterQuery(query, request, hasnotSeoDisjunction); query = query .SelectList(select => select .Select(() => alias.Id).WithAlias(() => modelAlias.Id) .Select(() => alias.Version).WithAlias(() => modelAlias.Version) .Select(() => alias.Title).WithAlias(() => modelAlias.Title) .Select(() => alias.Status).WithAlias(() => modelAlias.PageStatus) .Select(hasSeoProjection).WithAlias(() => modelAlias.HasSEO) .Select(() => alias.CreatedOn).WithAlias(() => modelAlias.CreatedOn) .Select(() => alias.ModifiedOn).WithAlias(() => modelAlias.ModifiedOn) .Select(() => alias.PageUrl).WithAlias(() => modelAlias.Url) .Select(() => alias.Language.Id).WithAlias(() => modelAlias.LanguageId) .Select(() => alias.IsMasterPage).WithAlias(() => modelAlias.IsMasterPage)) .TransformUsing(Transformers.AliasToBean <SiteSettingPageViewModel>()); if (configuration.Security.AccessControlEnabled) { IEnumerable <Guid> deniedPages = accessControlService.GetDeniedObjects <PageProperties>(); foreach (var deniedPageId in deniedPages) { var id = deniedPageId; query = query.Where(f => f.Id != id); } } var count = query.ToRowCountFutureValue(); var categoriesFuture = categoryService.GetCategories(); IEnumerable <LookupKeyValue> languagesFuture = configuration.EnableMultilanguage ? languageService.GetLanguagesLookupValues() : null; var pages = query.AddSortingAndPaging(request).Future <SiteSettingPageViewModel>(); var layouts = layoutService .GetAvailableLayouts() .Select(l => new LookupKeyValue( string.Format("{0}-{1}", l.IsMasterPage ? "m" : "l", l.TemplateId), l.Title)) .ToList(); var model = CreateModel(pages, request, count, categoriesFuture, layouts); if (languagesFuture != null) { model.Languages = languagesFuture.ToList(); model.Languages.Insert(0, languageService.GetInvariantLanguageModel()); } return(model); }