private NavigationLink BuildNavigationLink(DeclaredNode parent, Item child, Item contextItem)
        {
            if (!child.IsDerivedFrom(NavigationTemplateIDs.NavigationLinkID))
            {
                LogIncompatibleItemWarning(child);
                return(null);
            }

            NavigationLink link = null;

            if (child.IsDerivedFrom(NavigationTemplateIDs.ImageNavigationLinkID))
            {
                link = ModelMapper.MapItemToNew <ImageNavigationLink>(child);
            }
            else
            {
                link = ModelMapper.MapItemToNew <NavigationLink>(child);
            }

            link.Parent = parent;

            if (contextItem == null)
            {
                return(link);
            }

            if (LinkTargetIsAncestorOfContext(child, contextItem))
            {
                link.IsActive = true;
            }

            return(link);
        }
示例#2
0
        public ActionResult Update(int id, string webPageId, FormCollection form)
        {
            DBDataContext  db = Utils.DB.GetContext();
            NavigationLink l  = db.NavigationLinks.SingleOrDefault(x => x.ID == id);

            if (l != null)
            {
                if (ModelState.IsValid)
                {
                    TryUpdateModel(l);
                    l.WebPageID = Convert.ToInt32(webPageId);

                    try
                    {
                        db.SubmitChanges();
                        return(RedirectToAction("Index", "Link", new { controller = "Link", tab = l.Section.TabID.ToString(), section = l.SectionID.ToString() }));
                    }
                    catch (Exception ex)
                    {
                        ErrorHandler.Report.Exception(ex, "Link/Update");
                        ModelState.AddModelError("", "An unknown error occurred. Please try again in few minutes.");
                    }
                }

                ViewData["Title"]     = "Edit Link";
                ViewData["Action"]    = "Update";
                ViewData["TabID"]     = l.Section.TabID.ToString();
                ViewData["SectionID"] = l.SectionID.ToString();
                return(View("Manage", l));
            }

            return(RedirectToAction("Index", "Link", new { controller = "Link", tab = l.Section.TabID.ToString(), section = l.SectionID.ToString() }));
        }
示例#3
0
        /// <summary>
        /// Delete Link
        /// </summary>
        /// <param name="id">Link ID</param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            DBDataContext  db = Utils.DB.GetContext();
            NavigationLink l  = db.NavigationLinks.SingleOrDefault(x => x.ID == id);

            if (l != null)
            {
                //delete link
                db.NavigationLinks.DeleteOnSubmit(l);

                try
                {
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    ErrorHandler.Report.Exception(ex, "Link/Delete");
                    ModelState.AddModelError("", "An unknown error occurred. Please try again in few minutes.");
                }
            }
            else
            {
                ModelState.AddModelError("", "Section does not exist in the database");
            }

            return(RedirectToAction("Index", "Link", new { controller = "Link", tab = l.Section.TabID.ToString(), section = l.SectionID.ToString() }));
        }
示例#4
0
        private INavigationLink CreateNavigationLink(TemplatedBasePageType page)
        {
            string name      = page.Name;
            bool   isOverlay = false;

            IHasPageTitle pageWithTitle = page as IHasPageTitle;

            if (pageWithTitle != null)
            {
                name = pageWithTitle.PageTitle;
            }

            //overlay setting
            IHasOverlaySetting pageWithOverlay = page as IHasOverlaySetting;

            if (pageWithOverlay != null)
            {
                isOverlay = pageWithOverlay.IsOverlayInNavigation;
            }

            NavigationLink link = new NavigationLink()
            {
                Name        = name,
                Url         = new Url(this._urlResolver.GetUrl(page.PageLink)).Uri,
                NewWindow   = false,
                IsOverlayOn = isOverlay
            };

            return(link);
        }
示例#5
0
        /// <summary>
        /// Load View (ADD/EDIT)
        /// </summary>
        /// <param name="tab">Tab ID</param>
        /// <param name="section">Section ID</param>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Manage(string tab, string section, int id = 0)
        {
            ViewData["TabID"]     = tab;
            ViewData["SectionID"] = section;

            if (id > 0)
            {
                //edit
                DBDataContext  db = Utils.DB.GetContext();
                NavigationLink l  = db.NavigationLinks.SingleOrDefault(x => x.ID == id);
                if (l != null)
                {
                    ViewData["Title"]      = "Edit Link";
                    ViewData["Action"]     = "Update";
                    l.SectionID            = Convert.ToInt32(section);
                    ViewData["TemplateID"] = l.WebPage.TemplateID.ToString();
                    return(View("Manage", l));
                }
                else
                {
                    //cannot find model in database
                    return(RedirectToAction("Index", "Link", new{ controller = "Link", tab = tab, section = section }));
                }
            }
            else
            {
                //add
                ViewData["Title"]      = "Add Link";
                ViewData["Action"]     = "Add";
                ViewData["TemplateID"] = null;
                return(View("Manage"));
            }
        }
示例#6
0
        public void IsRequestForSamePage_WithRequestForDirectoryWithMatchingDefaultAspxNavigateUrl_ReturnsTrue()
        {
            // arrange
            var navigationLink = new NavigationLink();

            // act
            bool isSamePage = navigationLink.IsRequestForSamePage("/Foo/Bar/Default.aspx", "/Foo/Bar/");

            // assert
            Assert.IsTrue(isSamePage);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HamburgerMenuNavigationListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            NavigationLink navLink = HamburgerMenuNavigationListView.SelectedItem as NavigationLink;

            HamburgerMenuSplitView.Content = navLink.Control;

            if (HamburgerMenuSplitView.DisplayMode == SplitViewDisplayMode.Overlay || HamburgerMenuSplitView.DisplayMode == SplitViewDisplayMode.CompactOverlay)
            {
                HamburgerMenuToggleButton.IsChecked = false;
            }
        }
示例#8
0
        public void IsRequestForSamePage_WithRequestForRootAndNavigateUrlAsSlash_ReturnsTrue()
        {
            // arrange
            var navigationLink = new NavigationLink();

            // act
            bool isSamePage = navigationLink.IsRequestForSamePage("/", "/");

            // assert
            Assert.IsTrue(isSamePage);
        }
        private void navigatorLinksGrid_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            NavigationLink link = navigationRoot.Items[e.Item.DataSetIndex];

            link.Name = ((TextBox)e.Item.FindControl("textname")).Text;
            link.Url  = ((TextBox)e.Item.FindControl("texturl")).Text;

            SaveList(Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName));
            Session["newtelligence.DasBlog.Web.EditNavigatorLinksBox.NavigationRoot"] = null;

            Response.Redirect(Page.Request.Url.AbsoluteUri, true);
        }
        public void SetBreadCrumb(string text, NavigationLink route, bool addNavBack)
        {
            if (addCurrentNavBack)
            {
                history.Push(currentRoute);
            }

            addCurrentNavBack = addNavBack;
            currentRoute      = route;

            OnBreadCrumbChange?.Invoke(text);
        }
示例#11
0
 private void KeepOrientationClick(NavigationLink link)
 {
     if (DisplayInformation.AutoRotationPreferences == DisplayOrientations.None)
     {
         link.Label = Quran.Core.Properties.Resources.auto_orientation;
         DisplayInformation.AutoRotationPreferences = DisplayInformation.GetForCurrentView().CurrentOrientation;
     }
     else
     {
         link.Label = Quran.Core.Properties.Resources.keep_orientation;
         DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;
     }
 }
示例#12
0
        public void IsRequestForSamePage_WithRequestForDefaultAspxRootAndNavigateUrlAsSlash_ReturnsTrue()
        {
            // arrange
            var navigationLink = new NavigationLink {
                NavigateUrl = "~/"
            };

            // act
            bool isSamePage = navigationLink.IsRequestForSamePage("/", "/Default.aspx");

            // assert
            Assert.IsTrue(isSamePage);
        }
示例#13
0
 private void TurnOnButton(NavigationLink link)
 {
     ChangeImage(link.ContentOfImage, link.ActiveImageSource);
     link.MainStackLayout.IsEnabled = false;
     if (link.Label != null)
     {
         link.Label.TextColor = Color.FromHex("#365989");
     }
     if (_currentLink != null)
     {
         MakeButtonInactive();
     }
     _currentLink = link;
 }
        private void ProcessLinkChildren(Item parent, NavigationLink parentLink, Item contextItem)
        {
            var children = parent.GetChildren();

            foreach (Item child in children)
            {
                var link = BuildNavigationLink(parentLink, child, contextItem);
                if (link == null)
                {
                    continue;
                }
                parentLink.ChildLinks.Add(link);
                ProcessLinkChildren(child, link, contextItem);
            }
        }
示例#15
0
        private static void ProcessLinkChildren(Item parent, NavigationLink parentLink)
        {
            var children = parent.GetChildren();

            foreach (Item child in children)
            {
                var link = GetLinkChild(child);
                if (link == null)
                {
                    continue;
                }
                parentLink.ChildLinks.Add(link);
                ProcessLinkChildren(child, link);
            }
        }
示例#16
0
        // Build a localized Menu
        private async Task BuildLocalizedMenu()
        {
            NavigationLinks.Add(new NavigationLink
            {
                Label  = Quran.Core.Properties.Resources.home,
                Symbol = Symbol.Home,
                Action = () => { Frame.Navigate(typeof(MainView)); }
            });
            NavigationLinks.Add(new NavigationLink
            {
                Label  = Quran.Core.Properties.Resources.translation,
                Symbol = Symbol.Globe,
                Action = TranslationClick
            });
            _bookmarkNavigationLink = new NavigationLink
            {
                Action = () =>
                {
                    ViewModel.TogglePageBookmark();
                }
            };
            SetBookmarkNavigationLink();
            NavigationLinks.Add(_bookmarkNavigationLink);
            NavigationLinks.Add(new NavigationLink
            {
                Label  = Quran.Core.Properties.Resources.recite,
                Symbol = Symbol.Volume,
                Action = () => { AudioPlay(this, null); }
            });
            var keepOrientationLink = new NavigationLink
            {
                Label  = Quran.Core.Properties.Resources.keep_orientation,
                Symbol = Symbol.Orientation,
            };

            keepOrientationLink.Action = () => { KeepOrientationClick(keepOrientationLink); };
            NavigationLinks.Add(keepOrientationLink);
            _pageFormatNavigationLink = new NavigationLink
            {
                Action = () =>
                {
                    ViewModel.TwoPageView = !ViewModel.TwoPageView;
                }
            };
            await SetPageFormatNavigationLink();

            NavigationLinks.Add(_pageFormatNavigationLink);
        }
示例#17
0
        private bool ShouldSelect()
        {
            var parent = this.GetParent <ITabView>();

            if (parent == null)
            {
                return(false);
            }

            int index = parent.TabItems.IndexOf(Pair ?? this);

            if (index < 0)
            {
                return(false);
            }

            previousIndex = parent.SelectedIndex;

            Link link = null;

            if (IsSelected && NavigationLink != null)
            {
                link = (Link)NavigationLink.Clone();
            }
            else
            {
                var newStack = PaneManager.Instance.FromNavContext(UI.Pane.Master, index);
                if (newStack != null && newStack.CurrentView != null)
                {
                    link = new Link(PaneManager.Instance.GetNavigatedURI(newStack.CurrentView), new Dictionary <string, string>());
                }
                else if (NavigationLink != null)
                {
                    link = (Link)NavigationLink.Clone();
                }
            }

            if (!PaneManager.Instance.ShouldNavigate(link, UI.Pane.Tabs, NavigationType.Tab))
            {
                return(false);
            }

            PaneManager.Instance.CurrentTab = index;
            return(true);
        }
示例#18
0
        private INavigationLink CreateNavigationLink(string name, PageData page)
        {
            Uri uri = new Url(page.PageLink.ToString()).Uri;

            NavigationLink link = new NavigationLink()
            {
                Name      = name,
                Url       = uri,
                NewWindow = false,
            };

            if (page is IHasOverlaySetting)
            {
                IHasOverlaySetting overlayPage = page as IHasOverlaySetting;

                link.IsOverlayOn = overlayPage.IsOverlayInNavigation;
            }

            return(link);
        }
示例#19
0
        public static int GetWebPageID(string tab, string section, string page)
        {
            int webPageId = 0;

            DBDataContext db = Utils.DB.GetContext();

            if (!string.IsNullOrEmpty(tab) && !string.IsNullOrEmpty(section) && !string.IsNullOrEmpty(page))
            {
                Tab t = db.Tabs.SingleOrDefault(x => x.URLTitle.Equals(tab));
                if (t != null)
                {
                    if (section.Equals("faq"))
                    {
                        webPageId = Convert.ToInt32(t.FAQPageID);
                    }
                    else
                    {
                        Section s = t.Sections.SingleOrDefault(x => x.URLTitle.Equals(section));
                        if (s != null)
                        {
                            NavigationLink l = s.NavigationLinks.SingleOrDefault(x => x.WebPage.URLTitle.Equals(page));
                            if (l != null)
                            {
                                webPageId = l.WebPageID;
                            }
                        }
                    }
                }
            }
            else
            {
                //home page
                WebPage p = db.WebPages.SingleOrDefault(x => x.IsHomePage == true);
                if (p != null)
                {
                    webPageId = p.ID;
                }
            }

            return(webPageId);
        }
示例#20
0
        public static IHtmlString ParseNavLink(this HtmlHelper html, NavigationLink link)
        {
            if (link == null)
            {
                return("".ToHtmlString());
            }

            UrlHelper  url     = new UrlHelper(html.ViewContext.RequestContext);
            TagBuilder linktag = new TagBuilder("a");

            string breadCrumb = html.ViewContext.TempData[ViewDataKeys.BreadCrumb] as string ?? html.ViewContext.ViewData[ViewDataKeys.BreadCrumb] as string
                                ?? html.ViewContext.TempData[ViewDataKeys.TopBreadCrumb] as string ?? html.ViewContext.ViewData[ViewDataKeys.TopBreadCrumb] as string;

            RouteValueDictionary htmlAttributes = new RouteValueDictionary(link.HtmlAttributes);

            linktag.MergeAttributes(htmlAttributes);

            if (!string.IsNullOrWhiteSpace(breadCrumb))
            {
                if (link.Text == breadCrumb)
                {
                    linktag.AddCssClass("selected");
                }
            }

            if (link.RouteValue != null)
            {
                linktag.Attributes.Add("href", url.RouteUrl(link.RouteValue));
            }
            else
            {
                linktag.Attributes.Add("href", url.RouteUrl(link.RouteName));
            }

            linktag.InnerHtml += link.Text;
            return(linktag.ToString().ToHtmlString());
        }
示例#21
0
        public ActionResult Add(NavigationLink l, string webPageId, string tabId, string sectionId)
        {
            if (ModelState.IsValid)
            {
                DBDataContext db = Utils.DB.GetContext();

                l.Position = db.NavigationLinks.Where(x => x.SectionID == Convert.ToInt32(sectionId)).Count() + 1;
                Section s = db.Sections.SingleOrDefault(x => x.ID == Convert.ToInt32(sectionId));
                if (s != null)
                {
                    s.NavigationLinks.Add(l);
                    l.WebPageID = Convert.ToInt32(webPageId);


                    try
                    {
                        db.SubmitChanges();
                        return(RedirectToAction("Index", "Link", new { controller = "Link", tab = tabId, section = sectionId }));
                    }
                    catch (Exception ex)
                    {
                        ErrorHandler.Report.Exception(ex, "Links/Add");
                        ModelState.AddModelError("", "An unknown error occurred. Please try again in few minutes.");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Section does not exist in the database");
                }
            }

            ViewData["Title"]     = "Add Link";
            ViewData["Action"]    = "Add";
            ViewData["TabID"]     = tabId;
            ViewData["SectionID"] = sectionId;
            return(View("Manage"));
        }
示例#22
0
        private bool processAction(string action)
        {
            bool cancelNavigation = false;

            try
            {
                switch (action)
                {
                case ReportExecution.ActionExecuteReport:
                    cancelNavigation = true;
                    _reportDone      = false;
                    if (webBrowser.Document != null)
                    {
                        _report.InputRestrictions.Clear();
                        if (HeaderForm != null)
                        {
                            foreach (HtmlElement element in HeaderForm.All)
                            {
                                if (element.Id != null)
                                {
                                    _report.InputRestrictions.Add(element.Id, element.TagName.ToLower() == "option" ? element.GetAttribute("selected") : element.GetAttribute("value"));
                                    Debug.WriteLine("{0} {1} {2} {3}", element.Id, element.Name, element.GetAttribute("value"), element.GetAttribute("selected"));
                                }
                            }
                        }
                    }
                    _report.IsDrilling = false;
                    Execute();
                    break;

                case ReportExecution.ActionRefreshReport:
                    if (_report.IsExecuting)
                    {
                        cancelNavigation = true;
                        HtmlElement message = webBrowser.Document.All[ReportExecution.HtmlId_processing_message];
                        if (message != null)
                        {
                            message.SetAttribute("innerHTML", _report.ExecutionHeader);
                        }
                        HtmlElement messages = webBrowser.Document.All[ReportExecution.HtmlId_execution_messages];
                        if (messages != null)
                        {
                            messages.SetAttribute("innerHTML", Helper.ToHtml(_report.ExecutionMessages));
                        }
                    }
                    else if (!_reportDone)
                    {
                        //Set last drill path if any
                        if (_report.NavigationLinks.Count > 0)
                        {
                            _report.NavigationLinks.Last().Href = _report.ResultFilePath;
                        }

                        cancelNavigation   = true;
                        _reportDone        = true;
                        _report.IsDrilling = false;
                        _url = "file:///" + _report.HTMLDisplayFilePath;
                        webBrowser.Navigate(_url);
                    }
                    break;

                case ReportExecution.ActionCancelReport:
                    _execution.Report.LogMessage(_report.Translate("Cancelling report..."));
                    cancelNavigation = true;
                    _report.Cancel   = true;
                    break;

                case ReportExecution.ActionUpdateViewParameter:
                    cancelNavigation = true;
                    _report.UpdateViewParameter(GetFormValue(ReportExecution.HtmlId_parameter_view_id), GetFormValue(ReportExecution.HtmlId_parameter_view_name), GetFormValue(ReportExecution.HtmlId_parameter_view_value));
                    break;

                case ReportExecution.ActionViewHtmlResult:
                    string resultPath = _execution.GenerateHTMLResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewPrintResult:
                    resultPath = _execution.GeneratePrintResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewPDFResult:
                    resultPath = _execution.GeneratePDFResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionViewExcelResult:
                    resultPath = _execution.GenerateExcelResult();
                    if (File.Exists(resultPath))
                    {
                        Process.Start(resultPath);
                    }
                    cancelNavigation = true;
                    break;

                case ReportExecution.ActionDrillReport:
                    string nav = HeaderForm.GetAttribute(ReportExecution.HtmlId_navigation_attribute_name);
                    string src = HttpUtility.ParseQueryString(nav).Get("src");
                    string dst = HttpUtility.ParseQueryString(nav).Get("dst");
                    string val = HttpUtility.ParseQueryString(nav).Get("val");

                    string destLabel = "", srcRestriction = "";
                    bool   drillDone = false;
                    foreach (var model in _report.Models)
                    {
                        ReportElement element = model.Elements.FirstOrDefault(i => i.MetaColumnGUID == src);
                        if (element != null)
                        {
                            drillDone = true;
                            element.ChangeColumnGUID(dst);
                            destLabel = element.DisplayNameElTranslated;
                            if (val != null)
                            {
                                destLabel = "> " + destLabel;
                                //Add restriction
                                ReportRestriction restriction = ReportRestriction.CreateReportRestriction();
                                restriction.Source         = model.Source;
                                restriction.Model          = model;
                                restriction.MetaColumnGUID = src;
                                restriction.SetDefaults();
                                restriction.Operator = Operator.Equal;
                                if (restriction.IsEnum)
                                {
                                    restriction.EnumValues.Add(val);
                                }
                                else
                                {
                                    restriction.Value1 = val;
                                }
                                model.Restrictions.Add(restriction);
                                if (!string.IsNullOrEmpty(model.Restriction))
                                {
                                    model.Restriction = string.Format("({0}) AND ", model.Restriction);
                                }
                                model.Restriction += ReportRestriction.kStartRestrictionChar + restriction.GUID + ReportRestriction.kStopRestrictionChar;

                                srcRestriction = restriction.DisplayText;
                            }
                            else
                            {
                                destLabel = "< " + destLabel;
                                var restrictions = model.Restrictions.Where(i => i.MetaColumnGUID == dst).ToList();
                                foreach (var restr in restrictions)
                                {
                                    model.Restrictions.Remove(restr);
                                    model.Restriction = model.Restriction.Replace(ReportRestriction.kStartRestrictionChar + restr.GUID + ReportRestriction.kStopRestrictionChar, "1=1");
                                }
                            }
                        }
                    }

                    if (drillDone)
                    {
                        NavigationLink lastLink = null;
                        if (_report.NavigationLinks.Count == 0)
                        {
                            lastLink = new NavigationLink();
                            _report.NavigationLinks.Add(lastLink);
                        }
                        else
                        {
                            lastLink = _report.NavigationLinks.Last();
                        }

                        //create HTML result for navigation -> NavigationLinks must have one link to activate the button
                        _report.IsDrilling = true;
                        string htmlPath = _execution.GenerateHTMLResult();
                        lastLink.Href = htmlPath;
                        if (string.IsNullOrEmpty(lastLink.Text))
                        {
                            lastLink.Text = _report.ExecutionName;
                        }

                        string linkText = string.Format("{0} {1}", _report.ExecutionName, destLabel);
                        if (!string.IsNullOrEmpty(srcRestriction))
                        {
                            linkText += string.Format(" [{0}]", srcRestriction);
                        }
                        _report.NavigationLinks.Add(new NavigationLink()
                        {
                            Href = "#", Text = linkText
                        });
                    }

                    cancelNavigation = true;
                    _reportDone      = false;
                    Execute();
                    break;

                case ReportExecution.ActionGetNavigationLinks:
                    cancelNavigation = true;
                    HtmlElement navMenu = webBrowser.Document.All[ReportExecution.HtmlId_navigation_menu];
                    if (navMenu != null)
                    {
                        string links = "";
                        foreach (var link in _report.NavigationLinks)
                        {
                            links += string.Format("<li><a href='{0}'>{1}</a></li>", link.Href, HttpUtility.HtmlEncode(link.Text));
                        }
                        navMenu.SetAttribute("innerHTML", links);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                cancelNavigation = true;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(cancelNavigation);
        }
        private void navigatorLinksGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if ( e.CommandName == "AddItem" )
            {
                NavigationLink newLink = new NavigationLink();
                newLink.Name = "New Entry";
                navigationRoot.Items.Insert(0,newLink);
                navigatorLinksGrid.CurrentPageIndex = 0;
                navigatorLinksGrid.EditItemIndex = 0;
                BindGrid();
            }
			else if ( e.CommandName == "MoveUp" && e.Item != null )
			{
				int position = e.Item.DataSetIndex;

				if ( position > 0 )
				{
					NavigationLink link = new NavigationLink();
					link.Name = navigationRoot.Items[position].Name;
					link.Url = navigationRoot.Items[position].Url;
					navigationRoot.Items.RemoveAt( position );
					navigationRoot.Items.Insert( position-1, link );
					navigatorLinksGrid.CurrentPageIndex = (position-1) / navigatorLinksGrid.PageSize;
					if ( navigatorLinksGrid.EditItemIndex == position )
					{
						navigatorLinksGrid.EditItemIndex = position - 1;
					}
					else if ( navigatorLinksGrid.EditItemIndex == position - 1)
					{
						navigatorLinksGrid.EditItemIndex = position;
					}	
				}
				SaveList( Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(),baseFileName));
				Session["newtelligence.DasBlog.Web.EditNavigatorLinksBox.NavigationRoot"] = null;
            
				Response.Redirect( Page.Request.Url.AbsoluteUri, true );
			}
			else if ( e.CommandName == "MoveDown" && e.Item != null )
			{
				int position = e.Item.DataSetIndex;

				if ( position < navigationRoot.Items.Count-1 )
				{
					NavigationLink link = new NavigationLink();
					link.Name = navigationRoot.Items[position].Name;
					link.Url = navigationRoot.Items[position].Url;
					navigationRoot.Items.RemoveAt( position );
					navigationRoot.Items.Insert( position+1, link );
					navigatorLinksGrid.CurrentPageIndex = (position+1) / navigatorLinksGrid.PageSize;
					if ( navigatorLinksGrid.EditItemIndex == position )
					{
						navigatorLinksGrid.EditItemIndex = position + 1;
					}
					else if ( navigatorLinksGrid.EditItemIndex == position + 1)
					{
						navigatorLinksGrid.EditItemIndex = position;
					}
				}
				SaveList( Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(),baseFileName));
				Session["newtelligence.DasBlog.Web.EditNavigatorLinksBox.NavigationRoot"] = null;
            
				Response.Redirect( Page.Request.Url.AbsoluteUri, true );
			}
        }        
示例#24
0
 private void InitNavigationLinksObjects()
 {
     _phrLink = new NavigationLink
     {
         MainStackLayout     = PhrButton,
         ContentOfImage      = PhrContent,
         Image               = PhrSvgImage,
         Label               = PhrLabel,
         ActiveImageSource   = "oc.Source.Images.phractive.svg",
         InactiveImageSource = "oc.Source.Images.phr.svg",
         LinkStatus          = _homeDataResponse.ResponseData.MenuChoices.ViewPhr
     };
     _scoreLink = new NavigationLink
     {
         MainStackLayout     = ScoreButton,
         ContentOfImage      = ScoreContent,
         Image               = ScoreSvgImage,
         Label               = ScoreLabel,
         ActiveImageSource   = "oc.Source.Images.scoreactive.svg",
         InactiveImageSource = "oc.Source.Images.score.svg",
         LinkStatus          = _homeDataResponse.ResponseData.MenuChoices.ViewHealthScore
     };
     _eventsLink = new NavigationLink
     {
         MainStackLayout     = EventsButton,
         ContentOfImage      = EventsContent,
         Image               = EventsSvgImage,
         Label               = EventsLabel,
         ActiveImageSource   = "oc.Source.Images.eventsactive.svg",
         InactiveImageSource = "oc.Source.Images.events.svg",
         LinkStatus          = _homeDataResponse.ResponseData.MenuChoices.ViewEvents
     };
     _trackersLink = new NavigationLink
     {
         MainStackLayout     = TrackersButton,
         ContentOfImage      = TrackersContent,
         Image               = TrackersSvgImage,
         Label               = TrackersLabel,
         ActiveImageSource   = "oc.Source.Images.trackeractive.svg",
         InactiveImageSource = "oc.Source.Images.tracker.svg",
         LinkStatus          = _homeDataResponse.ResponseData.MenuChoices.ViewTrackers
     };
     _opportunitiesLink = new NavigationLink
     {
         MainStackLayout     = OpportunitiesButton,
         ContentOfImage      = OpportunitiesContent,
         Image               = OpportunitiesSvgImage,
         Label               = OpportunitiesLabel,
         ActiveImageSource   = "oc.Source.Images.opportunitiesactive.svg",
         InactiveImageSource = "oc.Source.Images.opportunities.svg",
         LinkStatus          = _homeDataResponse.ResponseData.MenuChoices.ViewOpportunities
     };
     _dashboardLink = new NavigationLink
     {
         MainStackLayout     = DashboardButton,
         ContentOfImage      = DashboardContent,
         Image               = DashboardSvgImage,
         ActiveImageSource   = "oc.Source.Images.dashboardactive.svg",
         InactiveImageSource = "oc.Source.Images.dashboard.svg"
     };
     _usericonLink = new NavigationLink
     {
         MainStackLayout     = UserButton,
         ContentOfImage      = UserContent,
         Image               = UserSvgImage,
         ActiveImageSource   = "oc.Source.Images.useractive.svg",
         InactiveImageSource = "oc.Source.Images.user.svg"
     };
 }
 public void Navigate(NavigationLink link)
 {
     OnNavigateToLink?.Invoke(link);
 }
        public SlideshowRuntime(Slideshow slideshow, ResourceProvider resourceProvider, GUIManager guiManager, int startIndex, TaskController additionalTasks)
        {
            this.guiManager = guiManager;

            Assembly assembly = Assembly.GetExecutingAssembly();

            using (Stream resourceStream = assembly.GetManifestResourceStream(SlideshowProps.BaseContextProperties.File))
            {
                mvcContext = SharedXmlSaver.Load <AnomalousMvcContext>(resourceStream);
            }
            navModel       = (NavigationModel)mvcContext.Models[SlideshowProps.BaseContextProperties.NavigationModel];
            displayManager = new SlideDisplayManager(slideshow.VectorMode);
            foreach (Slide slide in slideshow.Slides)
            {
                String slideName = slide.UniqueName;
                slide.setupContext(mvcContext, slideName, resourceProvider, displayManager);

                NavigationLink link = new NavigationLink(slideName, null, slideName + "/Show");
                navModel.addNavigationLink(link);
            }

            RunCommandsAction runCommands = (RunCommandsAction)mvcContext.Controllers["Common"].Actions["Start"];

            runCommands.addCommand(new NavigateToIndexCommand()
            {
                Index = startIndex
            });

            taskbar        = new ClosingTaskbar();
            taskbarLink    = new SingleChildChainLink(SlideTaskbarName, taskbar);
            taskbar.Close += close;
            previousTask   = new CallbackTask("Slideshow.Back", "Back", PreviousTaskName, "None", arg =>
            {
                back();
            });
            nextTask = new CallbackTask("Slideshow.Forward", "Forward", NextTaskName, "None", arg =>
            {
                next();
            });
            taskbar.addItem(new TaskTaskbarItem(previousTask));
            taskbar.addItem(new TaskTaskbarItem(nextTask));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.Reload", "Reload", ReloadTaskName, "None", arg =>
            {
                reload();
            })));
            //taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ToggleMode", "Toggle Display Mode", "SlideshowIcons/NormalVectorToggle", "None", arg =>
            //{
            //    displayManager.VectorMode = !displayManager.VectorMode;
            //    guiManager.layout();
            //})));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ZoomIn", "Zoom In", "SlideshowIcons/ZoomIn", "None", arg =>
            {
                zoomIn();
            })));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ResetZoom", "Reset Zoom", "SlideshowIcons/ResetZoom", "None", arg =>
            {
                if (displayManager.AdditionalZoomMultiple != 1.0f)
                {
                    displayManager.AdditionalZoomMultiple = 1.0f;
                    guiManager.layout();
                }
            })));
            taskbar.addItem(new TaskTaskbarItem(new CallbackTask("Slideshow.ZoomOut", "Zoom Out", "SlideshowIcons/ZoomOut", "None", arg =>
            {
                zoomOut();
            })));

            eventContext = new EventContext();
            ButtonEvent nextEvent = new ButtonEvent(EventLayers.Gui);

            nextEvent.addButton(KeyboardButtonCode.KC_RIGHT);
            nextEvent.FirstFrameUpEvent += eventManager =>
            {
                next();
            };
            eventContext.addEvent(nextEvent);

            ButtonEvent backEvent = new ButtonEvent(EventLayers.Gui);

            backEvent.addButton(KeyboardButtonCode.KC_LEFT);
            backEvent.FirstFrameUpEvent += eventManager =>
            {
                back();
            };
            eventContext.addEvent(backEvent);

            ButtonEvent zoomInEvent = new ButtonEvent(EventLayers.Gui);

            zoomInEvent.addButton(KeyboardButtonCode.KC_EQUALS);
            zoomInEvent.FirstFrameUpEvent += eventManager =>
            {
                zoomIn();
            };
            eventContext.addEvent(zoomInEvent);

            ButtonEvent zoomOutEvent = new ButtonEvent(EventLayers.Gui);

            zoomOutEvent.addButton(KeyboardButtonCode.KC_MINUS);
            zoomOutEvent.FirstFrameUpEvent += eventManager =>
            {
                zoomOut();
            };
            eventContext.addEvent(zoomOutEvent);

            ButtonEvent closeEvent = new ButtonEvent(EventLayers.Gui);

            closeEvent.addButton(KeyboardButtonCode.KC_ESCAPE);
            closeEvent.FirstFrameUpEvent += eventManager =>
            {
                ThreadManager.invoke(close); //Delay so we do not modify the input collection
            };
            eventContext.addEvent(closeEvent);

            foreach (Task task in additionalTasks.Tasks)
            {
                taskbar.addItem(new TaskTaskbarItem(task));
            }

            mvcContext.Blurred += (ctx) =>
            {
                guiManager.deactivateLink(SlideTaskbarName);
                guiManager.removeLinkFromChain(taskbarLink);
                GlobalContextEventHandler.disableEventContext(eventContext);
            };
            mvcContext.Focused += (ctx) =>
            {
                guiManager.addLinkToChain(taskbarLink);
                guiManager.pushRootContainer(SlideTaskbarName);
                setNavigationIcons();
                GlobalContextEventHandler.setEventContext(eventContext);
            };
            mvcContext.RemovedFromStack += (ctx) =>
            {
                taskbar.Dispose();
            };
        }
        private void navigatorLinksGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            if (e.CommandName == "AddItem")
            {
                NavigationLink newLink = new NavigationLink();
                newLink.Name = "New Entry";
                navigationRoot.Items.Insert(0, newLink);
                navigatorLinksGrid.CurrentPageIndex = 0;
                navigatorLinksGrid.EditItemIndex    = 0;
                BindGrid();
            }
            else if (e.CommandName == "MoveUp" && e.Item != null)
            {
                int position = e.Item.DataSetIndex;

                if (position > 0)
                {
                    NavigationLink link = new NavigationLink();
                    link.Name = navigationRoot.Items[position].Name;
                    link.Url  = navigationRoot.Items[position].Url;
                    navigationRoot.Items.RemoveAt(position);
                    navigationRoot.Items.Insert(position - 1, link);
                    navigatorLinksGrid.CurrentPageIndex = (position - 1) / navigatorLinksGrid.PageSize;
                    if (navigatorLinksGrid.EditItemIndex == position)
                    {
                        navigatorLinksGrid.EditItemIndex = position - 1;
                    }
                    else if (navigatorLinksGrid.EditItemIndex == position - 1)
                    {
                        navigatorLinksGrid.EditItemIndex = position;
                    }
                }
                SaveList(Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName));
                Session["newtelligence.DasBlog.Web.EditNavigatorLinksBox.NavigationRoot"] = null;

                Response.Redirect(Page.Request.Url.AbsoluteUri, true);
            }
            else if (e.CommandName == "MoveDown" && e.Item != null)
            {
                int position = e.Item.DataSetIndex;

                if (position < navigationRoot.Items.Count - 1)
                {
                    NavigationLink link = new NavigationLink();
                    link.Name = navigationRoot.Items[position].Name;
                    link.Url  = navigationRoot.Items[position].Url;
                    navigationRoot.Items.RemoveAt(position);
                    navigationRoot.Items.Insert(position + 1, link);
                    navigatorLinksGrid.CurrentPageIndex = (position + 1) / navigatorLinksGrid.PageSize;
                    if (navigatorLinksGrid.EditItemIndex == position)
                    {
                        navigatorLinksGrid.EditItemIndex = position + 1;
                    }
                    else if (navigatorLinksGrid.EditItemIndex == position + 1)
                    {
                        navigatorLinksGrid.EditItemIndex = position;
                    }
                }
                SaveList(Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), baseFileName));
                Session["newtelligence.DasBlog.Web.EditNavigatorLinksBox.NavigationRoot"] = null;

                Response.Redirect(Page.Request.Url.AbsoluteUri, true);
            }
        }