Esempio n. 1
0
        protected TreeIter AddSection(TreeIter parentIter, OptionsDialogSection section, object dataObject)
        {
            TreeIter it;

            if (parentIter.Equals(TreeIter.Zero))
            {
                string sectionLabel = "<b>" + GLib.Markup.EscapeText(section.Label) + "</b>";
                it = store.AppendValues(section, null, sectionLabel, false, null);
            }
            else
            {
                string icon = section.Icon.IsNull ? "md-empty-category" : section.Icon.ToString();
                it = store.AppendValues(parentIter, section, icon, section.Label, true, null);
            }

            if (!section.CustomNode)
            {
                AddChildSections(it, section, dataObject);
            }

            // Remove the section if it doesn't have children nor panels
            SectionPage page = CreatePage(it, section, dataObject);
            TreeIter    cit;

            if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren(out cit, it))
            {
                store.Remove(ref it);
            }
            return(it);
        }
Esempio n. 2
0
        internal TreeIter AddSection(TreeIter parentIter, OptionsDialogSection section, object dataObject)
        {
            TreeIter it;

            if (parentIter.Equals(TreeIter.Zero))
            {
                it = store.AppendValues(section);
            }
            else
            {
                it = store.AppendValues(parentIter, section);
            }

            if (!section.CustomNode)
            {
                AddChildSections(it, section, dataObject);
            }

            // Remove the section if it doesn't have children nor panels
            SectionPage page = CreatePage(it, section, dataObject);
            TreeIter    cit;

            if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren(out cit, it))
            {
                store.Remove(ref it);
                pages.Remove(section);
                return(TreeIter.Zero);
            }
            return(it);
        }
Esempio n. 3
0
        public IActionResult SiteMap()
        {
            var model      = new HtmlSiteMapModel();
            var allPages   = this.sitePageRepository.GetLivePage(1, int.MaxValue, out int total);
            var sectionIds = allPages.Select(x => x.SitePageSectionId).Distinct();

            foreach (var sectionId in sectionIds)
            {
                var section           = this.sitePageSectionRepository.Get(sectionId);
                var allPagesInSection = allPages.Where(x => x.SitePageSectionId == sectionId).ToList();
                var indexPage         = allPagesInSection.FirstOrDefault(x => x.IsSectionHomePage == true);

                if (indexPage == null)
                {
                    continue;
                }

                var sectionUrl = this.GetSectionUrl(section, indexPage);

                var siteSectionPage =
                    new SectionPage()
                {
                    AnchorText   = indexPage.BreadcrumbName,
                    CanonicalUrl = sectionUrl
                };

                foreach (var page in allPagesInSection)
                {
                    if (!page.IsLive || page.IsSectionHomePage)
                    {
                        continue;
                    }

                    var pagePath = UrlBuilder.BlogUrlPath(page.SitePageSection.Key, page.Key);
                    var pageUrl  = new Uri(UrlBuilder.GetCurrentDomain(this.HttpContext) + pagePath).ToString().TrimEnd('/');

                    siteSectionPage.ChildPages.Add(
                        new SectionPage()
                    {
                        CanonicalUrl = pageUrl,
                        AnchorText   = page.BreadcrumbName
                    });
                }

                siteSectionPage.ChildPages = siteSectionPage.ChildPages.OrderBy(x => x.AnchorText).ToList();

                model.SectionPages.Add(siteSectionPage);
            }

            model.SectionPages = model.SectionPages.OrderBy(x => x.AnchorText).ToList();

            return(this.View("Index", model));
        }
Esempio n. 4
0
        protected void InitializeTemplate(WebTemplatePage content)
        {
            dynamic namedSections = new Json();

            content.Sections = namedSections;

            foreach (WebSection section in content.Data.Sections)
            {
                SectionPage sectionJson = new SectionPage();
                namedSections[section.Name] = sectionJson;
                sectionJson.Name            = section.Name;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Collects the children pages of a section page and map them to a list of MenuContentViewModel objects.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <returns>A list of MenuContentViewModel objects</returns>
        private List <MenuContentViewModel> GetChildrenViewModels(SectionPage parent)
        {
            var childrenViewModels  = new List <MenuContentViewModel>();
            var maxNumberOfChildren = parent.MaxNumberOfMenuEntries >= 0 ? parent.MaxNumberOfMenuEntries : 500;
            var children            = _contentLoader.Service.GetChildren <ContentPage>(parent.ContentLink, LanguageSelector.AutoDetect(), 0, 500).
                                      Where(sp => _filterService.Service.IsVisible(sp)).ToList();

            foreach (var child in children)
            {
                childrenViewModels.Add(
                    new MenuContentViewModel
                {
                    Title            = child.MenuTitle,
                    Description      = child.MenuDescription,
                    URL              = _urlResolver.Service.GetUrl(child),
                    RenderAsLinkOnly = children.IndexOf(child) + 1 > maxNumberOfChildren
                });
            }

            return(childrenViewModels);
        }
Esempio n. 6
0
        void CreatePageWidget(SectionPage page)
        {
            List <PanelInstance> boxPanels = new List <PanelInstance> ();
            List <PanelInstance> tabPanels = new List <PanelInstance> ();

            foreach (PanelInstance pi in page.Panels)
            {
                if (pi.Widget == null)
                {
                    pi.Widget = pi.Panel.CreatePanelWidget();
                    if (pi.Widget == null)
                    {
                        continue;
                    }

                    //HACK: work around bug 469427 - broken themes match on widget names
                    if (pi.Widget.Name.IndexOf("Panel") > 0)
                    {
                        pi.Widget.Name = pi.Widget.Name.Replace("Panel", "_");
                    }
                }
                else if (pi.Widget.Parent != null)
                {
                    ((Gtk.Container)pi.Widget.Parent).Remove(pi.Widget);
                }

                if (pi.Node.Grouping == PanelGrouping.Tab)
                {
                    tabPanels.Add(pi);
                }
                else
                {
                    boxPanels.Add(pi);
                }
            }

            // Try to fit panels with grouping=box or auto in the main page.
            // If they don't fit. Move auto panels to its own tab page.

            int  mainPageSize;
            bool fits;

            do
            {
                PanelInstance lastAuto = null;
                mainPageSize = 0;
                foreach (PanelInstance pi in boxPanels)
                {
                    if (pi.Node.Grouping == PanelGrouping.Auto)
                    {
                        lastAuto = pi;
                    }
                    // HACK: This we are parenting/unparenting the widget here as a workaround
                    // for a layout issue. To properly calculate the size of the widget, the widget
                    // needs to have the style that it will have when added to the window.
                    pi.Widget.Parent = this;
                    mainPageSize    += pi.Widget.SizeRequest().Height + 6;
                    pi.Widget.Unparent();
                }
                fits = mainPageSize <= pageFrame.Allocation.Height;
                if (!fits)
                {
                    if (lastAuto != null && boxPanels.Count > 1)
                    {
                        boxPanels.Remove(lastAuto);
                        tabPanels.Insert(0, lastAuto);
                    }
                    else
                    {
                        fits = true;
                    }
                }
            } while (!fits);

            Gtk.VBox box = new VBox(false, 12);
            box.Show();
            for (int n = 0; n < boxPanels.Count; n++)
            {
                if (n != 0)
                {
                    HSeparator sep = new HSeparator();
                    sep.Show();
                    box.PackStart(sep, false, false, 0);
                }
                PanelInstance pi = boxPanels [n];
                box.PackStart(pi.Widget, pi.Node.Fill, pi.Node.Fill, 0);
                pi.Widget.Show();
            }

            box.BorderWidth = 12;

            if (tabPanels.Count > 0)
            {
                /*				SquaredNotebook nb = new SquaredNotebook ();
                 * nb.Show ();
                 * nb.AddTab (box, GettextCatalog.GetString ("General"));
                 * foreach (PanelInstance pi in tabPanels) {
                 *      Gtk.Alignment a = new Alignment (0, 0, 1, 1);
                 *      a.BorderWidth = 9;
                 *      a.Show ();
                 *      a.Add (pi.Widget);
                 *      nb.AddTab (a, GettextCatalog.GetString (pi.Node.Label));
                 *      pi.Widget.Show ();
                 * }*/
                Gtk.Notebook nb = new Notebook();
                nb.Show();
                if (box.Children.Length > 0)
                {
                    Gtk.Label blab = new Gtk.Label(GettextCatalog.GetString("General"));
                    blab.Show();
                    box.BorderWidth = 9;
                    nb.InsertPage(box, blab, -1);
                }
                foreach (PanelInstance pi in tabPanels)
                {
                    Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString(pi.Node.Label));
                    lab.Show();
                    Gtk.Alignment a = new Alignment(0, 0, 1, 1);
                    a.BorderWidth = 9;
                    a.Show();
                    a.Add(pi.Widget);
                    nb.InsertPage(a, lab, -1);
                    pi.Widget.Show();
                }
                page.Widget    = nb;
                nb.BorderWidth = 12;
            }
            else
            {
                page.Widget = box;
            }
        }
Esempio n. 7
0
        SectionPage CreatePage(TreeIter it, OptionsDialogSection section, object dataObject)
        {
            SectionPage page;

            if (pages.TryGetValue(section, out page))
            {
                return(page);
            }

            page            = new SectionPage();
            page.Iter       = it;
            page.Panels     = new List <PanelInstance> ();
            pages [section] = page;

            List <OptionsPanelNode> nodes = new List <OptionsPanelNode> ();

            if (!string.IsNullOrEmpty(section.TypeName) || section.CustomNode)
            {
                nodes.Add(section);
            }

            if (!section.CustomNode)
            {
                foreach (ExtensionNode nod in section.ChildNodes)
                {
                    OptionsPanelNode node = nod as OptionsPanelNode;
                    if (node != null && !(node is OptionsDialogSection))
                    {
                        nodes.Add(node);
                    }
                }
            }

            foreach (OptionsPanelNode node in nodes.ToArray())
            {
                if (!string.IsNullOrEmpty(node.Replaces))
                {
                    var replaced = nodes.FindIndex(n => n.Id == node.Replaces);
                    if (replaced != -1)
                    {
                        nodes.Remove(node);
                        nodes [replaced] = node;
                    }
                }
            }

            foreach (OptionsPanelNode node in nodes)
            {
                PanelInstance pi = null;
                if (panels.TryGetValue(node, out pi))
                {
                    if (pi.DataObject == dataObject)
                    {
                        // The panel can be reused
                        if (!pi.Panel.IsVisible())
                        {
                            continue;
                        }
                    }
                    else
                    {
                        // If the data object has changed, this panel instance can't be
                        // reused anymore. Destroy it.
                        panels.Remove(node);
                        if (pi.Widget != null)
                        {
                            pi.Widget.Destroy();
                        }
                        IDisposable d = pi.Panel as IDisposable;
                        if (d != null)
                        {
                            d.Dispose();
                        }
                        pi = null;
                    }
                }
                if (pi == null)
                {
                    IOptionsPanel panel = node.CreatePanel();
                    pi            = new PanelInstance();
                    pi.Panel      = panel;
                    pi.Node       = node;
                    pi.DataObject = dataObject;
                    page.Panels.Add(pi);
                    panel.Initialize(this, dataObject);
                    if (!panel.IsVisible())
                    {
                        page.Panels.Remove(pi);
                        continue;
                    }
                    panels [node] = pi;
                }
                else
                {
                    page.Panels.Add(pi);
                }
            }
            return(page);
        }
Esempio n. 8
0
		void CreatePageWidget (SectionPage page)
		{
			List<PanelInstance> boxPanels = new List<PanelInstance> ();
			List<PanelInstance> tabPanels = new List<PanelInstance> ();
			
			foreach (PanelInstance pi in page.Panels) {
				if (pi.Widget == null) {
					pi.Widget = pi.Panel.CreatePanelWidget ();
					//HACK: work around bug 469427 - broken themes match on widget names
					if (pi.Widget.Name.IndexOf ("Panel") > 0)
						pi.Widget.Name = pi.Widget.Name.Replace ("Panel", "_");
				}
				else if (pi.Widget.Parent != null)
					((Gtk.Container) pi.Widget.Parent).Remove (pi.Widget);
					
				if (pi.Node.Grouping == PanelGrouping.Tab)
					tabPanels.Add (pi);
				else
					boxPanels.Add (pi);
			}
			
			// Try to fit panels with grouping=box or auto in the main page.
			// If they don't fit. Move auto panels to its own tab page.
			
			int mainPageSize;
			bool fits;
			do {
				PanelInstance lastAuto = null;
				mainPageSize = 0;
				foreach (PanelInstance pi in boxPanels) {
					if (pi.Node.Grouping == PanelGrouping.Auto)
						lastAuto = pi;
					// HACK: This we are parenting/unparenting the widget here as a workaround
					// for a layout issue. To properly calculate the size of the widget, the widget
					// needs to have the style that it will have when added to the window.
					pi.Widget.Parent = this;
					mainPageSize += pi.Widget.SizeRequest ().Height + 6;
					pi.Widget.Unparent ();
				}
				fits = mainPageSize <= pageFrame.Allocation.Height;
				if (!fits) {
					if (lastAuto != null && boxPanels.Count > 1) {
						boxPanels.Remove (lastAuto);
						tabPanels.Insert (0, lastAuto);
					} else {
						fits = true;
					}
				}
			} while (!fits);
			
			Gtk.VBox box = new VBox (false, 12);
			box.Show ();
			for (int n=0; n<boxPanels.Count; n++) {
				if (n != 0) {
					HSeparator sep = new HSeparator ();
					sep.Show ();
					box.PackStart (sep, false, false, 0);
				}
				PanelInstance pi = boxPanels [n];
				box.PackStart (pi.Widget, pi.Node.Fill, pi.Node.Fill, 0);
				pi.Widget.Show ();
			}
			
			box.BorderWidth = 12;

			if (tabPanels.Count > 0) {
				/*				SquaredNotebook nb = new SquaredNotebook ();
				nb.Show ();
				nb.AddTab (box, GettextCatalog.GetString ("General"));
				foreach (PanelInstance pi in tabPanels) {
					Gtk.Alignment a = new Alignment (0, 0, 1, 1);
					a.BorderWidth = 9;
					a.Show ();
					a.Add (pi.Widget);
					nb.AddTab (a, GettextCatalog.GetString (pi.Node.Label));
					pi.Widget.Show ();
				}*/
				Gtk.Notebook nb = new Notebook ();
				nb.Show ();
				Gtk.Label blab = new Gtk.Label (GettextCatalog.GetString ("General"));
				blab.Show ();
				box.BorderWidth = 9;
				nb.InsertPage (box, blab, -1);
				foreach (PanelInstance pi in tabPanels) {
					Gtk.Label lab = new Gtk.Label (GettextCatalog.GetString (pi.Node.Label));
					lab.Show ();
					Gtk.Alignment a = new Alignment (0, 0, 1, 1);
					a.BorderWidth = 9;
					a.Show ();
					a.Add (pi.Widget);
					nb.InsertPage (a, lab, -1);
					pi.Widget.Show ();
				}
				page.Widget = nb;
				nb.BorderWidth = 12;
			} else {
				page.Widget = box;
			}
		}
Esempio n. 9
0
		SectionPage CreatePage (TreeIter it, OptionsDialogSection section, object dataObject)
		{
			SectionPage page;
			if (pages.TryGetValue (section, out page))
				return page;
			
			page = new SectionPage ();
			page.Iter = it;
			page.Panels = new List<PanelInstance> ();
			pages [section] = page;
			
			List<OptionsPanelNode> nodes = new List<OptionsPanelNode> ();
			if (!string.IsNullOrEmpty (section.TypeName) || section.CustomNode)
				nodes.Add (section);
			
			if (!section.CustomNode) {
				foreach (ExtensionNode nod in section.ChildNodes) {
					OptionsPanelNode node = nod as OptionsPanelNode;
					if (node != null && !(node is OptionsDialogSection))
						nodes.Add (node);
				}
			}
			
			foreach (OptionsPanelNode node in nodes)
			{
				PanelInstance pi = null;
				if (panels.TryGetValue (node, out pi)) {
					if (pi.DataObject == dataObject) {
						// The panel can be reused
						if (!pi.Panel.IsVisible ())
							continue;
					} else {
						// If the data object has changed, this panel instance can't be
						// reused anymore. Destroy it.
						panels.Remove (node);
						if (pi.Widget != null)
							pi.Widget.Destroy ();
						IDisposable d = pi.Panel as IDisposable;
						if (d != null)
							d.Dispose ();
						pi = null;
					}
				}
				if (pi == null) {
					IOptionsPanel panel = node.CreatePanel ();
					pi = new PanelInstance ();
					pi.Panel = panel;
					pi.Node = node;
					pi.DataObject = dataObject;
					page.Panels.Add (pi);
					panel.Initialize (this, dataObject);
					if (!panel.IsVisible ()) {
						page.Panels.Remove (pi);
						continue;
					}
					panels [node] = pi;
				} else
					page.Panels.Add (pi);
			}
			return page;
		}
Esempio n. 10
0
        // Function to populate a provided AbsoluteLayout with note images from this section, and with some sort of position indicator
        public BoxView PopulateSongLayout(SectionPage page, SectionLayout layout, bool IsEditable)
        {
            // Make sure that the layout has been measured
            if (!layout.SizeIsValid)
            {
                return(null);
            }

            // Remember the page calling this so that it can be notified
            DisplayPage = page;

            // Clear the layout
            layout.Children.Clear();

            // Figure out what to show
            int numberOfNotes = NoteSequence.Count;

            // Find measurements
            layoutWidth  = layout.LayoutWidth;
            layoutHeight = layout.LayoutHeight;
            int extraSpaces = IsEditable ? 2 : 1;

            NoteWidth         = 0.25 * layoutHeight;
            BlockWidthPerNote = layoutWidth / (numberOfNotes + extraSpaces);
            FirstNoteXOffset  = 0.5 * (BlockWidthPerNote - NoteWidth);

            // Calculate section metadata if need be
            if (MetadataIsDirty)
            {
                CalculateNoteMetadata();
            }

            // Display the time signature beat count
            double AnchorX;

            AnchorX = FirstNoteXOffset;
            Label sigCount = new Label();

            sigCount.FontSize = 20;
            sigCount.Text     = BeatsPerMeasure.ToString();
            sigCount.HorizontalTextAlignment = TextAlignment.Center;
            sigCount.VerticalTextAlignment   = TextAlignment.Center;
            AbsoluteLayout.SetLayoutFlags(sigCount, AbsoluteLayoutFlags.None);
            AbsoluteLayout.SetLayoutBounds(sigCount, new Rectangle(AnchorX, 0.1 * layoutHeight, NoteWidth, 0.4 * layoutHeight));
            layout.Children.Add(sigCount);

            // Display the time signature beat count
            Label sigValue = new Label();

            sigValue.FontSize = 20;
            sigValue.Text     = BeatValue.ToString();
            sigValue.HorizontalTextAlignment = TextAlignment.Center;
            sigValue.VerticalTextAlignment   = TextAlignment.Center;
            AbsoluteLayout.SetLayoutFlags(sigValue, AbsoluteLayoutFlags.None);
            AbsoluteLayout.SetLayoutBounds(sigValue, new Rectangle(AnchorX, 0.5 * layoutHeight, NoteWidth, 0.4 * layoutHeight));
            layout.Children.Add(sigValue);

            // Place an image of each note, and a box that is coloured according to the accent
            for (int i = 0; i < numberOfNotes; i++)
            {
                Note note = NoteSequence[i];
                // The note image
                Image img = new Image();
                img.Aspect = Aspect.AspectFit;
                if ((note.Metadata.NoOfBeams > 0) && (note.Metadata.JoinableToPrevious || note.Metadata.JoinableToNext))
                {
                    if (note.IsDotted)
                    {
                        img.Source = ImageSource.FromFile(FILE_NAMES[8]);
                    }
                    else
                    {
                        img.Source = ImageSource.FromFile(FILE_NAMES[2]);
                    }
                }
                else
                {
                    img.Source = ImageSource.FromFile(FILE_NAMES[note.ImageIndex]);
                }
                if (DisplayPage != null)
                {
                    img.GestureRecognizers.Add(new TapGestureRecognizer {
                        Command              = new Command(index => TapImage((int)index)),
                        CommandParameter     = i,
                        NumberOfTapsRequired = 1
                    });
                }
                AnchorX = FirstNoteXOffset + BlockWidthPerNote * (i + 1);
                AbsoluteLayout.SetLayoutFlags(img, AbsoluteLayoutFlags.None);
                AbsoluteLayout.SetLayoutBounds(img, new Rectangle(AnchorX, 0.25 * layoutHeight, NoteWidth, 1.5 * NoteWidth));
                layout.Children.Add(img);
                // The accent box
                if (IsEditable)
                {
                    BoxView accentBox = new BoxView();
                    Color   color;
                    switch (note.Accent)
                    {
                    case 0: color = Color.FromRgb(0.0, 1.0, 0.0); break;

                    case 1: color = Color.FromRgb(1.0, 1.0, 0.0); break;

                    case 2: color = Color.FromRgb(1.0, 0.5, 0.0); break;

                    case 3: color = Color.FromRgb(1.0, 0.0, 0.0); break;

                    default: color = Color.FromRgb(0.0, 0.0, 0.0); break;
                    }
                    accentBox.BackgroundColor = color;
                    accentBox.Opacity         = 0.4;
                    if (DisplayPage != null)
                    {
                        accentBox.GestureRecognizers.Add(new TapGestureRecognizer
                        {
                            Command              = new Command(index => ChangeAccent((int)index)),
                            CommandParameter     = i,
                            NumberOfTapsRequired = 1
                        });
                    }
                    AnchorX = BlockWidthPerNote * (i + 1);
                    AbsoluteLayout.SetLayoutFlags(accentBox, AbsoluteLayoutFlags.None);
                    AbsoluteLayout.SetLayoutBounds(accentBox, new Rectangle(AnchorX, 0.8 * layoutHeight, BlockWidthPerNote, 0.2 * layoutHeight));
                    layout.Children.Add(accentBox);
                }
            }

            // For editable displays, add an extra image at the end where a note can be added at the end of the sequence
            if (IsEditable)
            {
                Image img = new Image();
                img.Aspect = Aspect.Fill;
                img.Source = ImageSource.FromFile(FILE_NAMES[24]);
                if (DisplayPage != null)
                {
                    img.GestureRecognizers.Add(new TapGestureRecognizer
                    {
                        Command              = new Command(index => TapImage((int)index)),
                        CommandParameter     = numberOfNotes,
                        NumberOfTapsRequired = 1
                    });
                }
                AnchorX = BlockWidthPerNote * (numberOfNotes + 1);
                AbsoluteLayout.SetLayoutFlags(img, AbsoluteLayoutFlags.None);
                AbsoluteLayout.SetLayoutBounds(img, new Rectangle(AnchorX, 0.0, BlockWidthPerNote, 0.9 * layoutHeight));
                layout.Children.Add(img);
            }

            // Add ties
            int    tieCount;
            double tieWidth;

            for (int i = 0; i < numberOfNotes; i++)
            {
                tieCount = NoteSequence[i].TieString;
                if (tieCount == 0)
                {
                    continue;
                }
                Image img = new Image();
                img.Aspect = Aspect.Fill;
                img.Source = ImageSource.FromFile(FILE_NAMES[25]);
                tieWidth   = tieCount - 1;
                AnchorX    = FirstNoteXOffset + BlockWidthPerNote * (i + 1);
                AbsoluteLayout.SetLayoutFlags(img, AbsoluteLayoutFlags.None);
                AbsoluteLayout.SetLayoutBounds(img, new Rectangle(AnchorX, 0.65 * layoutHeight, BlockWidthPerNote * tieWidth, 0.1 * layoutHeight));
                layout.Children.Add(img);
                i += tieCount - 1;
            }

            // Add beams
            double beamWidth;

            for (int beamLevel = 1; beamLevel <= 4; beamLevel++)
            {
                for (int i = 0; i < numberOfNotes; i++)
                {
                    // Figure out if note is beamable at this level
                    if (NoteSequence[i].Metadata.NoOfBeams < beamLevel)
                    {
                        continue;
                    }

                    // Check that this note will be connected to surrounding notes at all
                    if ((NoteSequence[i].Metadata.JoinableToPrevious | NoteSequence[i].Metadata.JoinableToNext) == false)
                    {
                        continue;
                    }

                    // Check how many notes to beam
                    int noToBeam = 1;
                    while (i + noToBeam < numberOfNotes)
                    {
                        if (NoteSequence[i + noToBeam].Metadata.FallsOnBeat)
                        {
                            break;
                        }
                        if (NoteSequence[i + noToBeam].Metadata.NoOfBeams < beamLevel)
                        {
                            break;
                        }
                        noToBeam++;
                    }

                    // Draw the beam
                    BoxView boxy = new BoxView();
                    boxy.BackgroundColor = Color.Black;
                    AnchorX   = BlockWidthPerNote * (i + 0.5 + 1);
                    beamWidth = noToBeam == 1 ? NoteWidth * 0.5 : (noToBeam - 1) * BlockWidthPerNote;
                    if (noToBeam == 1)
                    {
                        if (i + 1 == numberOfNotes)
                        {
                            AnchorX -= NoteWidth * 0.5;
                        }
                        else if (NoteSequence[i].Metadata.JoinableToNext == false)
                        {
                            AnchorX -= NoteWidth * 0.5;
                        }
                    }
                    AbsoluteLayout.SetLayoutFlags(boxy, AbsoluteLayoutFlags.None);
                    AbsoluteLayout.SetLayoutBounds(boxy, new Rectangle(AnchorX, (0.2 + 0.05 * beamLevel) * layoutHeight, beamWidth, 0.025 * layoutHeight));
                    layout.Children.Add(boxy);
                    i += noToBeam - 1;
                }
            }

            // Add tuplets
            int    tupletCount, tupletDisplayNumber;
            double tupletWidth;

            for (int i = 0; i < numberOfNotes; i++)
            {
                tupletCount = NoteSequence[i].Tuplet;
                if (tupletCount == 0)
                {
                    continue;
                }
                switch (tupletCount)
                {
                case 1: tupletDisplayNumber = 3; break;

                case 2: tupletDisplayNumber = 5; break;

                case 3: tupletDisplayNumber = 6; break;

                case 4: tupletDisplayNumber = 7; break;

                case 5: tupletDisplayNumber = 7; break;

                case 6: tupletDisplayNumber = 9; break;

                default: continue;
                }
                tupletCount = AttemptTupletSequence(i, tupletCount);
                if (tupletCount < 2)
                {
                    // Faulty tuplet set - throw an error
                    NoteSequence[-1].Tuplet = 0;
                }
                Image img = new Image();
                img.Aspect  = Aspect.Fill;
                img.Source  = ImageSource.FromFile(FILE_NAMES[26]);
                tupletWidth = BlockWidthPerNote * (tupletCount - 1) + NoteWidth;
                AnchorX     = FirstNoteXOffset + BlockWidthPerNote * (i + 1);
                AbsoluteLayout.SetLayoutFlags(img, AbsoluteLayoutFlags.None);
                AbsoluteLayout.SetLayoutBounds(img, new Rectangle(AnchorX, 0.1 * layoutHeight, tupletWidth, 0.2 * layoutHeight));
                layout.Children.Add(img);
                Label label = new Label();
                label.Text = tupletDisplayNumber.ToString();
                label.HorizontalTextAlignment = TextAlignment.Center;
                AbsoluteLayout.SetLayoutFlags(label, AbsoluteLayoutFlags.None);
                AbsoluteLayout.SetLayoutBounds(label, new Rectangle(AnchorX, 0.05 * layoutHeight, tupletWidth, 0.2 * layoutHeight));
                layout.Children.Add(label);
                i += tupletCount - 1;
            }

            // Add the section progress indicator thingy, or the cursor selector thingy
            BoxView box = new BoxView();

            box.BackgroundColor = Color.CornflowerBlue;
            AbsoluteLayout.SetLayoutFlags(box, AbsoluteLayoutFlags.None);
            if (IsEditable)
            {
                box.Opacity = 0.4;
                AbsoluteLayout.SetLayoutBounds(box, new Rectangle(0.0, 0.0, BlockWidthPerNote, 0.8 * layoutHeight));
            }
            else
            {
                AbsoluteLayout.SetLayoutBounds(box, new Rectangle(0.0, 0.9 * layoutHeight, BlockWidthPerNote, 0.1 * layoutHeight));
            }
            layout.Children.Add(box);

            // Return a reference to the BoxView progress indication thingy
            return(box);
        }
Esempio n. 11
0
        public IActionResult Section
        (
            string categoryUrl         = "",
            string subcategoryUrl      = "",
            string groupUrl            = "",
            CatalogCountItems count    = CatalogCountItems.Small,
            CatalogSortingType sorting = CatalogSortingType.AscendingTitle,
            int page            = 1,
            string filters      = "",
            int minPrice        = 0,
            int maxPrice        = int.MaxValue,
            string manufacturer = "",
            ProductType type    = ProductType.Normal
        )
        {
            if (string.IsNullOrEmpty(categoryUrl))
            {
                return(NotFound());
            }

            Navigation navigation = commonRepository.GetNavigation();
            SeoData    seo        = commonRepository.GetSeo("catalog");

            ProductCategory    category    = catalogRepository.GetCategory(categoryUrl);
            ProductSubcategory subcategory = catalogRepository.GetSubcategory(subcategoryUrl);
            ProductGroup       group       = catalogRepository.GetGroup(groupUrl);

            if (category == null)
            {
                return(NotFound());
            }

            int countItems = productsFilterService.GetPageCountByItems(count);

            List <Product> products = productsFilterService.Filter
                                      (
                categoryUrl, subcategoryUrl, groupUrl,
                count, sorting, page,
                filters,
                minPrice, maxPrice,
                manufacturer, type
                                      );

            List <Breadcrumb> breadcrumbs = GetBreadcrumbs(category, subcategory, group);

            var catalogFilters = new CatalogFilters()
            {
                MinPrice      = (int)products.Min(x => x.Price),
                MaxPrice      = (int)products.Max(x => x.Price),
                Manufacturers = products.Any() ?
                                products.Select(x => x.Manufacturer).Distinct(new ManufacturerEqualityComparer()).ToList() :
                                new List <Manufacturer>(),
                CategoryFilters = new List <CategoryFilter>()
                {
                    new CategoryFilter("Категория 1", new List <CategoryFilterItem>()
                    {
                        new CategoryFilterItem(1, "Увлажняющие", "cat-1-uvlaj"),
                        new CategoryFilterItem(2, "Питательные", "cat-1-pitatel"),
                        new CategoryFilterItem(3, "Натуральные", "cat-1-natural"),
                        new CategoryFilterItem(4, "Дневные", "cat-1-den"),
                        new CategoryFilterItem(5, "Ночные", "cat-1-noch")
                    }),
                    new CategoryFilter("Категория 2", new List <CategoryFilterItem>()
                    {
                        new CategoryFilterItem(6, "Антивозрастные", "cat-2-antivozrast"),
                        new CategoryFilterItem(7, "Жирные", "cat-2-jirnie"),
                        new CategoryFilterItem(8, "Сухие", "cat-2-suhie"),
                        new CategoryFilterItem(9, "Невероятные", "cat-2-neveroyat"),
                        new CategoryFilterItem(10, "Чудесные", "cat-2-chudo")
                    })
                }
            };

            int pageCount   = products.Count() / countItems != 0 ? products.Count() / countItems : 1;
            var pagination  = new Pagination(page, pageCount);
            var sectionPage = new SectionPage(seo, navigation, breadcrumbs, products, products.Count, catalogFilters, pagination);

            return(View(sectionPage));
        }
Esempio n. 12
0
 public void ThenISeeTheFourthTeaserPanelWithText(string text)
 {
     var sectionPage = new SectionPage();
     Assert.IsTrue(FindElement(sectionPage.FourthTeaserLocator).Text.ToLower().Contains(text.ToLower()));
 }
        void CreatePageWidget(SectionPage page)
        {
            List <PanelInstance> boxPanels = new List <PanelInstance> ();
            List <PanelInstance> tabPanels = new List <PanelInstance> ();

            foreach (PanelInstance pi in page.Panels)
            {
                if (pi.Widget == null)
                {
                    pi.Widget = pi.Panel.CreatePanelWidget();
                    //HACK: work around bug 469427 - broken themes match on widget names
                    if (pi.Widget.Name.IndexOf("Panel") > 0)
                    {
                        pi.Widget.Name = pi.Widget.Name.Replace("Panel", "_");
                    }
                }
                else if (pi.Widget.Parent != null)
                {
                    ((Gtk.Container)pi.Widget.Parent).Remove(pi.Widget);
                }

                if (pi.Node.Grouping == PanelGrouping.Tab)
                {
                    tabPanels.Add(pi);
                }
                else
                {
                    boxPanels.Add(pi);
                }
            }

            // Try to fit panels with grouping=box or auto in the main page.
            // If they don't fit. Move auto panels to its own tab page.

            int  mainPageSize;
            bool fits;

            do
            {
                PanelInstance lastAuto = null;
                mainPageSize = 0;
                foreach (PanelInstance pi in boxPanels)
                {
                    if (pi.Node.Grouping == PanelGrouping.Auto)
                    {
                        lastAuto = pi;
                    }
                    mainPageSize += pi.Widget.SizeRequest().Height + 6;
                }
                fits = mainPageSize <= pageFrame.Allocation.Height;
                if (!fits)
                {
                    if (lastAuto != null && boxPanels.Count > 1)
                    {
                        boxPanels.Remove(lastAuto);
                        tabPanels.Insert(0, lastAuto);
                    }
                    else
                    {
                        fits = true;
                    }
                }
            }while (!fits);

            Gtk.VBox box = new VBox(false, 12);
            box.Show();
            for (int n = 0; n < boxPanels.Count; n++)
            {
                if (n != 0)
                {
                    HSeparator sep = new HSeparator();
                    sep.Show();
                    box.PackStart(sep, false, false, 0);
                }
                PanelInstance pi = boxPanels [n];
                box.PackStart(pi.Widget, pi.Node.Fill, pi.Node.Fill, 0);
                pi.Widget.Show();
            }

            if (tabPanels.Count > 0)
            {
                Gtk.Notebook nb = new Notebook();
                nb.Show();
                Gtk.Label blab = new Gtk.Label(GettextCatalog.GetString("General"));
                blab.Show();
                box.BorderWidth = 9;
                nb.InsertPage(box, blab, -1);
                foreach (PanelInstance pi in tabPanels)
                {
                    Gtk.Label lab = new Gtk.Label(GettextCatalog.GetString(pi.Node.Label));
                    lab.Show();
                    Gtk.Alignment a = new Alignment(0, 0, 1, 1);
                    a.BorderWidth = 9;
                    a.Show();
                    a.Add(pi.Widget);
                    nb.InsertPage(a, lab, -1);
                    pi.Widget.Show();
                }
                page.Widget = nb;
            }
            else
            {
                page.Widget = box;
            }
        }