private void CreateAndShowControl(Control newControl, string parameters, string title, bool addBookmark, bool isRedirected) { bool hasBookmarkBeenAdded = false; if (!(newControl == null)) { ISupportNavigation navigatable = newControl as ISupportNavigation; if (navigatable != null) { navigatable.SetParameters(parameters); if (addBookmark && !isRedirected) { title = navigatable.Title; } if (navigatable.CreateBookmarkAfterLoadCompleted) { hasBookmarkBeenAdded = true; navigatable.LoadCompleted += (o, e) => { title = navigatable.Title; SetTitle(title); if (addBookmark) { AddBookmark(title, ControlNameFactory.ControlToControlName(newControl), parameters); } }; } } if (!hasBookmarkBeenAdded) { SetTitle(title); if (addBookmark) { AddBookmark(title, ControlNameFactory.ControlToControlName(newControl), parameters); } } ContentPlaceholder.Content = newControl; } }
private bool ParseAndProcessBookmark(string bookmark) { bool success = false; if (bookmark.Length > 0 && bookmark.Contains(_bookmarkPartsSeparator)) { string[] bookmarkParts = bookmark.Split((new string[] { _bookmarkPartsSeparator }), StringSplitOptions.None); if (bookmarkParts.Length >= 3) { string controlName = bookmarkParts[0]; string title = bookmarkParts[1]; string parameters = bookmarkParts[2]; Control newControl = ControlNameFactory.ControlNameToControl(controlName); if (newControl != null) { NavigationEventArgs args = new NavigationEventArgs(newControl.GetType().AssemblyQualifiedName, parameters, true); OnBeforeNavigation(args); if (!args.Cancel) { CreateAndShowControl(newControl, args.Parameters, title, false, false); OnAfterBookmarkProcessing(true); success = true; } else { if (args.RedirectToOnCancel != null) { CreateAndShowControl((Control)Activator.CreateInstance(Csla.Reflection.MethodCaller.GetType(args.RedirectToOnCancel.ControlTypeName)), args.RedirectToOnCancel.Parameters, args.RedirectToOnCancel.Title, true, true); OnAfterBookmarkProcessing(true); success = true; } } } } } return(success); }