protected override void Drop(LayoutDocumentFloatingWindow floatingWindow) { ILayoutDocumentPane model = this._targetPane.Model as ILayoutDocumentPane; switch (base.Type) { case DropTargetType.DocumentPaneDockLeft: { LayoutDocumentPane layoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument); LayoutDocumentPaneGroup parent = model.Parent as LayoutDocumentPaneGroup; if (parent == null) { ILayoutContainer layoutContainer = model.Parent; LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup() { Orientation = Orientation.Horizontal }; layoutContainer.ReplaceChild(model, layoutDocumentPaneGroup); layoutDocumentPaneGroup.Children.Add(model); layoutDocumentPaneGroup.Children.Insert(0, layoutDocumentPane); break; } else if (!parent.Root.Manager.AllowMixedOrientation || parent.Orientation == Orientation.Horizontal) { parent.Orientation = Orientation.Horizontal; int num = parent.IndexOfChild(model); parent.Children.Insert(num, layoutDocumentPane); break; } else { LayoutDocumentPaneGroup layoutDocumentPaneGroup1 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Horizontal }; parent.ReplaceChild(model, layoutDocumentPaneGroup1); layoutDocumentPaneGroup1.Children.Add(layoutDocumentPane); layoutDocumentPaneGroup1.Children.Add(model); break; } } case DropTargetType.DocumentPaneDockTop: { LayoutDocumentPane layoutDocumentPane1 = new LayoutDocumentPane(floatingWindow.RootDocument); LayoutDocumentPaneGroup parent1 = model.Parent as LayoutDocumentPaneGroup; if (parent1 == null) { ILayoutContainer layoutContainer1 = model.Parent; LayoutDocumentPaneGroup layoutDocumentPaneGroup2 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Vertical }; layoutContainer1.ReplaceChild(model, layoutDocumentPaneGroup2); layoutDocumentPaneGroup2.Children.Add(model as LayoutDocumentPane); layoutDocumentPaneGroup2.Children.Insert(0, layoutDocumentPane1); break; } else if (!parent1.Root.Manager.AllowMixedOrientation || parent1.Orientation == Orientation.Vertical) { parent1.Orientation = Orientation.Vertical; int num1 = parent1.IndexOfChild(model); parent1.Children.Insert(num1, layoutDocumentPane1); break; } else { LayoutDocumentPaneGroup layoutDocumentPaneGroup3 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Vertical }; parent1.ReplaceChild(model, layoutDocumentPaneGroup3); layoutDocumentPaneGroup3.Children.Add(layoutDocumentPane1); layoutDocumentPaneGroup3.Children.Add(model); break; } } case DropTargetType.DocumentPaneDockRight: { LayoutDocumentPane layoutDocumentPane2 = new LayoutDocumentPane(floatingWindow.RootDocument); LayoutDocumentPaneGroup parent2 = model.Parent as LayoutDocumentPaneGroup; if (parent2 == null) { ILayoutContainer layoutContainer2 = model.Parent; LayoutDocumentPaneGroup layoutDocumentPaneGroup4 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Horizontal }; layoutContainer2.ReplaceChild(model, layoutDocumentPaneGroup4); layoutDocumentPaneGroup4.Children.Add(model as LayoutDocumentPane); layoutDocumentPaneGroup4.Children.Add(layoutDocumentPane2); break; } else if (!parent2.Root.Manager.AllowMixedOrientation || parent2.Orientation == Orientation.Horizontal) { parent2.Orientation = Orientation.Horizontal; int num2 = parent2.IndexOfChild(model); parent2.Children.Insert(num2 + 1, layoutDocumentPane2); break; } else { LayoutDocumentPaneGroup layoutDocumentPaneGroup5 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Horizontal }; parent2.ReplaceChild(model, layoutDocumentPaneGroup5); layoutDocumentPaneGroup5.Children.Add(model); layoutDocumentPaneGroup5.Children.Add(layoutDocumentPane2); break; } } case DropTargetType.DocumentPaneDockBottom: { LayoutDocumentPane layoutDocumentPane3 = new LayoutDocumentPane(floatingWindow.RootDocument); LayoutDocumentPaneGroup parent3 = model.Parent as LayoutDocumentPaneGroup; if (parent3 == null) { ILayoutContainer layoutContainer3 = model.Parent; LayoutDocumentPaneGroup layoutDocumentPaneGroup6 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Vertical }; layoutContainer3.ReplaceChild(model, layoutDocumentPaneGroup6); layoutDocumentPaneGroup6.Children.Add(model as LayoutDocumentPane); layoutDocumentPaneGroup6.Children.Add(layoutDocumentPane3); break; } else if (!parent3.Root.Manager.AllowMixedOrientation || parent3.Orientation == Orientation.Vertical) { parent3.Orientation = Orientation.Vertical; int num3 = parent3.IndexOfChild(model); parent3.Children.Insert(num3 + 1, layoutDocumentPane3); break; } else { LayoutDocumentPaneGroup layoutDocumentPaneGroup7 = new LayoutDocumentPaneGroup() { Orientation = Orientation.Vertical }; parent3.ReplaceChild(model, layoutDocumentPaneGroup7); layoutDocumentPaneGroup7.Children.Add(model); layoutDocumentPaneGroup7.Children.Add(layoutDocumentPane3); break; } } case DropTargetType.DocumentPaneDockInside: { LayoutDocumentPane layoutDocumentPane4 = model as LayoutDocumentPane; LayoutDocument rootDocument = floatingWindow.RootDocument; int previousContainerIndex = 0; if (this._tabIndex != -1) { previousContainerIndex = this._tabIndex; } else if (((ILayoutPreviousContainer)rootDocument).PreviousContainer == model && rootDocument.PreviousContainerIndex != -1) { previousContainerIndex = rootDocument.PreviousContainerIndex; } rootDocument.IsActive = false; layoutDocumentPane4.Children.Insert(previousContainerIndex, rootDocument); rootDocument.IsActive = true; break; } } base.Drop(floatingWindow); }
public DocumentClosingEventArgs(LayoutDocument document) { Document = document; }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { return(false); }
protected virtual void FixupLayout(LayoutRoot layout) { //fix container panes foreach (var lcToAttach in layout.Descendents().OfType <ILayoutPreviousContainer>() .Where(lc => lc.PreviousContainerId is not null)) { var paneContainerToAttach = layout.Descendents().OfType <ILayoutPaneSerializable>() .FirstOrDefault(lps => lps.Id == lcToAttach.PreviousContainerId); if (paneContainerToAttach is null) { throw new ArgumentException(string.Format("Unable to find a pane with id ='{0}'", lcToAttach.PreviousContainerId)); } lcToAttach.PreviousContainer = paneContainerToAttach as ILayoutContainer; } //now fix the content of the layoutcontents foreach (var lcToFix in layout.Descendents().OfType <LayoutAnchorable>().Where(lc => lc.Content is null) .ToArray()) { LayoutAnchorable previousAchorable = null; if (lcToFix.ContentId is not null) { //try find the content in replaced layout previousAchorable = _previousAnchorables.FirstOrDefault(a => a.ContentId == lcToFix.ContentId); } if (LayoutSerializationCallback is not null) { var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousAchorable is not null ? previousAchorable.Content : null); LayoutSerializationCallback(this, args); if (args.Cancel) { lcToFix.Close(); } else if (args.Content is not null) { lcToFix.Content = args.Content; } else if (args.Model.Content is not null) { lcToFix.Hide(false); } } else if (previousAchorable is null) { lcToFix.Hide(false); } else { lcToFix.Content = previousAchorable.Content; lcToFix.IconSource = previousAchorable.IconSource; } } foreach (var lcToFix in layout.Descendents().OfType <LayoutDocument>().Where(lc => lc.Content is null) .ToArray()) { LayoutDocument previousDocument = null; if (lcToFix.ContentId is not null) { //try find the content in replaced layout previousDocument = _previousDocuments.FirstOrDefault(a => a.ContentId == lcToFix.ContentId); } if (LayoutSerializationCallback is not null) { var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousDocument is not null ? previousDocument.Content : null); LayoutSerializationCallback(this, args); if (args.Cancel) { lcToFix.Close(); } else if (args.Content is not null) { lcToFix.Content = args.Content; } else if (args.Model.Content is not null) { lcToFix.Close(); } } else if (previousDocument is null) { lcToFix.Close(); } else { lcToFix.Content = previousDocument.Content; lcToFix.IconSource = previousDocument.IconSource; } } layout.CollectGarbage(); }
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) { // throw new NotImplementedException(); }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { Debug.WriteLine($"BeforeInsertDocument: {anchorableToShow.Title}, {anchorableToShow.Content}, {anchorableToShow.ContentId}"); //return true; return(BeforeInsertContent(layout, anchorableToShow)); }
internal override void Attach(LayoutContent model) { _document = model as LayoutDocument; base.Attach(model); }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { // We only allow 1 document in the layout when using this layout strategy return(false); }
public TabPage(IExplorerTabPage exTabPage, LayoutDocument layoutDoc) { ExTabPage = exTabPage; LayoutDoc = layoutDoc; }
public void AddTabModule(TabGenre tabG, bool singleInstance = true) { var tab = new LayoutDocument(); switch (tabG) { case TabGenre.StartPage: tab.Title = "Start Page"; tab.Content = new StartPage(); break; case TabGenre.Welcome: tab.Title = "Welcome"; tab.Content = new WelcomePage(); break; case TabGenre.Settings: tab.Title = "Settings"; tab.Content = new SettingsPage(); break; case TabGenre.PluginGenerator: tab.Title = "Plugin Generator"; tab.Content = new HaloPluginGenerator(); break; case TabGenre.PluginConverter: tab.Title = "Plugin Converter"; tab.Content = new HaloPluginConverter(); break; case TabGenre.ImgurHistory: tab.Title = "Imgur History"; tab.Content = new ImgurHistoryPage(); break; case TabGenre.MemoryManager: tab.Title = "Memory Manager"; tab.Content = new MemoryManager(); break; case TabGenre.VoxelConverter: tab.Title = "Voxel Converter"; tab.Content = new VoxelConverter(); break; case TabGenre.PostGenerator: tab.Title = "Post Generator"; tab.Content = new PostGenerator(); break; } if (singleInstance) { foreach (LayoutContent tabb in documentManager.Children.Where(tabb => tabb.Title == tab.Title)) { documentManager.SelectedContentIndex = documentManager.IndexOfChild(tabb); return; } } documentManager.Children.Add(tab); documentManager.SelectedContentIndex = documentManager.IndexOfChild(tab); }
/// <summary> /// Method is invoked to complete a drag & drop operation with a (new) docking position /// by docking of the LayoutDocument <paramref name="floatingWindow"/> into this drop target. /// </summary> /// <param name="floatingWindow"></param> protected override void Drop(LayoutDocumentFloatingWindow floatingWindow) { ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane; LayoutDocument documentActive = floatingWindow.Descendents().OfType <LayoutDocument>().FirstOrDefault(); switch (Type) { case DropTargetType.DocumentPaneDockBottom: #region DropTargetType.DocumentPaneDockBottom { var parentModel = targetModel.Parent as ILayoutGroup; var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup; int insertToIndex = parentModel.IndexOfChild(targetModel); if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical && parentModel.ChildrenCount == 1) { parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical; } if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical) { var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup; if (layoutDocumentPaneGroup != null && (layoutDocumentPaneGroup.Children.Count == 1 || layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical)) { var documentsToMove = layoutDocumentPaneGroup.Children.ToArray(); for (int i = 0; i < documentsToMove.Length; i++) { parentModel.InsertChildAt(insertToIndex + 1 + i, documentsToMove[i]); } } else { parentModel.InsertChildAt(insertToIndex + 1, floatingWindow.RootPanel); } } else { var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement; var newOrientedPanel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical, DockWidth = targetModelAsPositionableElement.DockWidth, DockHeight = targetModelAsPositionableElement.DockHeight, }; parentModel.InsertChildAt(insertToIndex, newOrientedPanel); newOrientedPanel.Children.Add(targetModel); newOrientedPanel.Children.Add(floatingWindow.RootPanel); } } break; #endregion DropTargetType.DocumentPaneDockBottom case DropTargetType.DocumentPaneDockTop: #region DropTargetType.DocumentPaneDockTop { var parentModel = targetModel.Parent as ILayoutGroup; var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup; int insertToIndex = parentModel.IndexOfChild(targetModel); if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical && parentModel.ChildrenCount == 1) { parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical; } if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical) { var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup; if (layoutDocumentPaneGroup != null && (layoutDocumentPaneGroup.Children.Count == 1 || layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical)) { var documentsToMove = layoutDocumentPaneGroup.Children.ToArray(); for (int i = 0; i < documentsToMove.Length; i++) { parentModel.InsertChildAt(insertToIndex + i, documentsToMove[i]); } } else { parentModel.InsertChildAt(insertToIndex, floatingWindow.RootPanel); } } else { var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement; var newOrientedPanel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical, DockWidth = targetModelAsPositionableElement.DockWidth, DockHeight = targetModelAsPositionableElement.DockHeight, }; parentModel.InsertChildAt(insertToIndex, newOrientedPanel); //the floating window must be added after the target modal as it could be raise a CollectGarbage call newOrientedPanel.Children.Add(targetModel); newOrientedPanel.Children.Insert(0, floatingWindow.RootPanel); } } break; #endregion DropTargetType.DocumentPaneDockTop case DropTargetType.DocumentPaneDockLeft: #region DropTargetType.DocumentPaneDockLeft { var parentModel = targetModel.Parent as ILayoutGroup; var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup; int insertToIndex = parentModel.IndexOfChild(targetModel); if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal && parentModel.ChildrenCount == 1) { parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal; } if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal) { var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup; if (layoutDocumentPaneGroup != null && (layoutDocumentPaneGroup.Children.Count == 1 || layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal)) { var documentsToMove = layoutDocumentPaneGroup.Children.ToArray(); for (int i = 0; i < documentsToMove.Length; i++) { parentModel.InsertChildAt(insertToIndex + i, documentsToMove[i]); } } else { parentModel.InsertChildAt(insertToIndex, floatingWindow.RootPanel); } } else { var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement; var newOrientedPanel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal, DockWidth = targetModelAsPositionableElement.DockWidth, DockHeight = targetModelAsPositionableElement.DockHeight, }; parentModel.InsertChildAt(insertToIndex, newOrientedPanel); //the floating window must be added after the target modal as it could be raise a CollectGarbage call newOrientedPanel.Children.Add(targetModel); newOrientedPanel.Children.Insert(0, floatingWindow.RootPanel); } } break; #endregion DropTargetType.DocumentPaneDockLeft case DropTargetType.DocumentPaneDockRight: #region DropTargetType.DocumentPaneDockRight { var parentModel = targetModel.Parent as ILayoutGroup; var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup; int insertToIndex = parentModel.IndexOfChild(targetModel); if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal && parentModel.ChildrenCount == 1) { parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal; } if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal) { var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup; if (layoutDocumentPaneGroup != null && (layoutDocumentPaneGroup.Children.Count == 1 || layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal)) { var documentToMove = layoutDocumentPaneGroup.Children.ToArray(); for (int i = 0; i < documentToMove.Length; i++) { parentModel.InsertChildAt(insertToIndex + 1 + i, documentToMove[i]); } } else { parentModel.InsertChildAt(insertToIndex + 1, floatingWindow.RootPanel); } } else { var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement; var newOrientedPanel = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Horizontal, DockWidth = targetModelAsPositionableElement.DockWidth, DockHeight = targetModelAsPositionableElement.DockHeight, }; parentModel.InsertChildAt(insertToIndex, newOrientedPanel); newOrientedPanel.Children.Add(targetModel); newOrientedPanel.Children.Add(floatingWindow.RootPanel); } } break; #endregion DropTargetType.DocumentPaneDockRight case DropTargetType.DocumentPaneDockInside: #region DropTargetType.DocumentPaneDockInside { var paneModel = targetModel as LayoutDocumentPane; var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup; // A LayoutFloatingDocumentWindow can contain multiple instances of both Anchorables or Documents // and we should drop these back into the DocumentPane if they are available var allowedDropTypes = new[] { typeof(LayoutDocument), typeof(LayoutAnchorable) }; int i = _tabIndex == -1 ? 0 : _tabIndex; foreach (var anchorableToImport in layoutDocumentPaneGroup.Descendents().OfType <LayoutContent>() .Where(item => allowedDropTypes.Contains(item.GetType())).ToArray()) { paneModel.Children.Insert(i, anchorableToImport); i++; } } break; #endregion DropTargetType.DocumentPaneDockInside } if (documentActive != null) { documentActive.IsActive = true; } base.Drop(floatingWindow); }
private void OnSaveImp() { if (_sfd == null) { _sfd = new SaveFileDialog(); _sfd.Filter = "Person (*.7astro)|*.7astro"; _sfd.FileName = "Anonymous"; _sfd.Title = "Save"; _sfd.InitialDirectory = Global.PersonsDir; } if (this.Documents.Children.Count > 0) { LayoutDocument doc = null; foreach (var child in this.Documents.Children) { var buffer = child as LayoutDocument; if (buffer != null) { if (buffer.IsSelected) { doc = buffer; break; } } } if (doc != null) { if (doc.IsSelected) { var frame = doc.Content as Frame; Views.EventView eventView = null; if (frame != null) { eventView = frame.Content as Views.EventView; if (eventView != null) { _sfd.FileName = System.IO.Path.Combine( Global.PersonsDir, (string.IsNullOrWhiteSpace(eventView.Event.BirthData.Name) || eventView.Event.BirthData.Name == "-" ? "Anonymous" : eventView.Event.BirthData.Name)) + ".7astro"; if (System.IO.File.Exists(_sfd.FileName)) { using (var writer = new System.IO.StreamWriter(_sfd.FileName, false, Encoding.UTF8)) { writer.Write(eventView.Event.BirthData.JSONSerialize()); } Saved(eventView); return; } var showed = _sfd.ShowDialog(); if (showed == true) { using (var writer = new System.IO.StreamWriter(_sfd.FileName, false, Encoding.UTF8)) { writer.Write(eventView.Event.BirthData.JSONSerialize()); } Saved(eventView); } } } } } } }
/// <summary> /// Finds the zones declared in the theme template. /// </summary> protected void FindZones() { _zones = LayoutDocument.GetElementsByTagName("rock:zone") .Cast <RockZoneElement>() .ToDictionary(z => z.Name.Replace(" ", string.Empty), z => z); }
protected void GenerateAdminFooter(bool canAdministrateBlockOnPage = false) { bool canAdministratePage = PageCache.IsAuthorized(Rock.Security.Authorization.ADMINISTRATE, CurrentPerson); bool canEditPage = PageCache.IsAuthorized(Rock.Security.Authorization.EDIT, CurrentPerson); if (PageCache.IncludeAdminFooter && (canAdministratePage || canAdministrateBlockOnPage || canEditPage)) { // Add the page admin script AddScriptLink(ResolveRockUrl("~/Scripts/Bundles/RockAdmin.js"), false); var adminFooter = LayoutDocument.CreateElement("div"); adminFooter.SetAttribute("id", "cms-admin-footer"); LayoutDocument.Body.AppendChild(adminFooter); //phLoadStats = new PlaceHolder(); //adminFooter.Controls.Add( phLoadStats ); //// If the current user is Impersonated by another user, show a link on the admin bar to login back in as the original user //var impersonatedByUser = Session["ImpersonatedByUser"] as UserLogin; //var currentUserIsImpersonated = ( HttpContext.Current?.User?.Identity?.Name ?? string.Empty ).StartsWith( "rckipid=" ); //if ( canAdministratePage && currentUserIsImpersonated && impersonatedByUser != null ) //{ // HtmlGenericControl impersonatedByUserDiv = new HtmlGenericControl( "span" ); // impersonatedByUserDiv.AddCssClass( "label label-default margin-l-md" ); // _btnRestoreImpersonatedByUser = new LinkButton(); // _btnRestoreImpersonatedByUser.ID = "_btnRestoreImpersonatedByUser"; // //_btnRestoreImpersonatedByUser.CssClass = "btn"; // _btnRestoreImpersonatedByUser.Visible = impersonatedByUser != null; // _btnRestoreImpersonatedByUser.Click += _btnRestoreImpersonatedByUser_Click; // _btnRestoreImpersonatedByUser.Text = $"<i class='fa-fw fa fa-unlock'></i> " + $"Restore { impersonatedByUser?.Person?.ToString()}"; // impersonatedByUserDiv.Controls.Add( _btnRestoreImpersonatedByUser ); // adminFooter.Controls.Add( impersonatedByUserDiv ); //} var buttonBar = LayoutDocument.CreateElement("div"); adminFooter.AppendChild(buttonBar); buttonBar.SetAttribute("class", "button-bar"); // RockBlock Config if (canAdministratePage || canAdministrateBlockOnPage) { var aBlockConfig = JavascriptIconLinkElement("Block Configuration", "btn block-config", "fa fa-th-large", "Rock.admin.pageAdmin.showBlockConfig()"); buttonBar.AppendChild(aBlockConfig); } if (canEditPage || canAdministratePage) { // RockPage Properties var aPageProperties = ModalIconLinkElement("Page Properties", "btn properties", "fa fa-cog", ResolveRockUrl($"~/PageProperties/{PageId}?t=Page Properties")); aPageProperties.SetAttribute("id", "aPageProperties"); buttonBar.AppendChild(aPageProperties); } if (canAdministratePage) { // Child Pages var aChildPages = ModalIconLinkElement("Child Pages", "btn page-child-pages", "fa fa-sitemap", ResolveRockUrl($"~/pages/{PageId}?t=Child Pages&pb=&sb=Done")); aChildPages.SetAttribute("id", "aChildPages"); buttonBar.AppendChild(aChildPages); // RockPage Zones var aPageZones = JavascriptIconLinkElement("Page Zones", "btn page-zones", "fa fa-columns", "Rock.admin.pageAdmin.showPageZones()"); buttonBar.AppendChild(aPageZones); // RockPage Security //var pageEntityTypeId = EntityTypeCache.Get( typeof( Rock.Model.Page ) ).Id; var pageEntityTypeId = 42; var aPageSecurity = ModalIconLinkElement("Page Security", "btn page-security", "fa fa-lock", ResolveRockUrl($"~/Secure/{pageEntityTypeId}/{PageId}?t=Page Security&pb=&sb=Done")); buttonBar.AppendChild(aPageSecurity); // ShorLink Properties var aShortLink = ModalIconLinkElement("Add Short Link", "btn properties", "fa fa-link", ResolveRockUrl($"~/ShortLink/{PageId}?t=Shortened Link&url={Context.RawUrl}")); aShortLink.SetAttribute("id", "aShortLink"); buttonBar.AppendChild(aShortLink); // System Info var aSystemInfo = ModalIconLinkElement("Rock Information", "btn system-info", "fa fa-info-circle", ResolveRockUrl("~/SystemInfo?t=System Information&pb=&sb=Done")); buttonBar.AppendChild(aSystemInfo); } } }
/// <summary> /// 页面导航跳转,生成新页面 /// </summary> /// <param name="viewInfo">页面信息</param> private void navigate(ViewInfo viewInfo) { Application.Current.MainWindow.Cursor = Cursors.Wait; UserControlBase view = null; if (Equals(viewInfo, null)) { Application.Current.Resources["UiMessage"] = "未找到页面信息,请确认MenuFunctionViewInfoMap.json配置正确!"; LogHelper.Info(Application.Current.Resources["UiMessage"].ToString()); Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } //已经打开则激活 if (layoutDocumentPane.Children.Any(a => a.Title == viewInfo.DisplayName.ToString())) { var tmp = layoutDocumentPane.Children.FirstOrDefault(a => a.Title == viewInfo.DisplayName.ToString()); tmp.IsActive = true; Application.Current.Resources["UiMessage"] = $"{viewInfo.DisplayName} 页面已经打开,设置激活成功!"; Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } try { view = System.Reflection.Assembly.Load(viewInfo.ViewAssemblyName) .CreateInstance(viewInfo.ViewName) as UserControlBase; } catch (Exception ex) { Application.Current.Resources["UiMessage"] = "未找到页面:" + viewInfo.ViewName + ex.Message; LogHelper.Error(Application.Current.Resources["UiMessage"] + viewInfo.ToString(), ex); Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } if (Equals(view, null)) { Application.Current.Resources["UiMessage"] = "未找到页面:" + viewInfo.ViewName; LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString()); Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } VmBase viewModel = null; try { viewModel = System.Reflection.Assembly.Load(viewInfo.ViewModelAssemblyName) .CreateInstance(viewInfo.ViewModelName) as VmBase; } catch (Exception ex) { Application.Current.Resources["UiMessage"] = "未找到ViewModel:" + viewInfo.ViewModelName; LogHelper.Error(Application.Current.Resources["UiMessage"] + viewInfo.ToString(), ex); Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } if (Equals(viewModel, null)) { Application.Current.Resources["UiMessage"] = "未找到ViewModel:" + viewInfo.ViewModelName; LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString()); Application.Current.MainWindow.Cursor = Cursors.Arrow; return; } //Application.Current.Resources["UiMessage"] = viewInfo.DisplayName; //LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString()); //view.Parameter = viewInfo.Parameter; //viewModel.Parameter = view.Parameter; viewModel.Parameter = viewInfo.Parameter; viewModel.MenuModule = viewInfo.MenuModule; view.DataContext = viewModel; //根据页面类型生成页面 switch (viewInfo.ViewType) { case ViewType.PopupNoTitle: //没有标题栏的页面 MahApps.Metro.Controls.MetroWindow popupNoTitleWindows = new MahApps.Metro.Controls.MetroWindow(); popupNoTitleWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner; popupNoTitleWindows.Style = Utility.Windows.ResourceHelper.FindResource(@"CleanWindowStyleKey") as Style; popupNoTitleWindows.GlowBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush; popupNoTitleWindows.Owner = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow; popupNoTitleWindows.ResizeMode = ResizeMode.NoResize; popupNoTitleWindows.IsCloseButtonEnabled = false; popupNoTitleWindows.ShowInTaskbar = popupNoTitleWindows.Owner == null ? true : false; popupNoTitleWindows.MouseDown += PopupWindows_MouseDown; popupNoTitleWindows.ShowCloseButton = false; popupNoTitleWindows.WindowStartupLocation = WindowStartupLocation.CenterScreen; popupNoTitleWindows.Width = view.Width; popupNoTitleWindows.Height = view.Height; popupNoTitleWindows.TitlebarHeight = 0; //有限实用配置的图标,没有则使用默认的图标,没有则使用主窗体的 popupNoTitleWindows.Icon = Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon) ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://*****:*****@"CleanWindowStyleKey") as Style; popupWindows.GlowBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush; popupWindows.Owner = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow; popupWindows.ResizeMode = ResizeMode.NoResize; popupWindows.IsCloseButtonEnabled = false; popupWindows.ShowCloseButton = false; popupWindows.Width = view.Width; popupWindows.Height = view.Height; popupWindows.Title = viewInfo.DisplayName; //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标 popupWindows.Icon = Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon) ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://*****:*****@"pack://application:,,,/Solution.Desktop.Resource;component/Images/logo_16x16.ico") ?? Application.Current.MainWindow.Icon; layoutDocument.Content = view; layoutDocumentPane.Children.Add(layoutDocument); layoutDocument.IsActive = true; layoutDocument.Closed += LayoutDocument_Closed; Application.Current.MainWindow.Cursor = Cursors.Arrow; break; case ViewType.SingleWindow: //单个视图。主要为了显示帮助窗口 MahApps.Metro.Controls.MetroWindow singleWindows = new MahApps.Metro.Controls.MetroWindow(); singleWindows.TitlebarHeight = 23; singleWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner; singleWindows.Style = Utility.Windows.ResourceHelper.FindResource(@"CleanWindowStyleKey") as Style; singleWindows.GlowBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush; singleWindows.Content = view; singleWindows.Width = view.Width; singleWindows.Height = view.Height; singleWindows.Title = viewInfo.DisplayName; //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标 singleWindows.Icon = Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon) ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://application:,,,/Solution.Desktop.Resource;component/Images/logo_16x16.ico") ?? Application.Current.MainWindow.Icon; singleWindows.Closed += Window_Closed; singleWindows.Show(); singleWindows.Focus(); Application.Current.MainWindow.Cursor = Cursors.Arrow; break; } }
public MainWindow() { try { InitializeComponent(); _application = new ExplorerApplication(this); _application.DockWindowAdded += new DockWindowAddedEvent(_application_DockWindowAdded); _application.OnShowDockableWindow += new OnShowDockableWindowEvent(_application_OnShowDockableWindow); #region Windows Forms Control Disign _toolStripAddress = new System.Windows.Forms.ToolStrip(); _toolStripAddress.Stretch = true; _toolStripAddress.GripMargin = new System.Windows.Forms.Padding(1); _toolStripAddress.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; _toolStripAddress.BackColor = System.Drawing.Color.White; winFormsHostStripAddress.Child = _toolStripAddress; #endregion _tree = new gView.Framework.UI.Dialogs.FormCatalogTree(_application, false); _tree.NodeSelected += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeClickedEvent(tree_NodeSelected); _tree.NodeRenamed += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeRenamedEvent(tree_NodeRenamed); _tree.NodeDeleted += new gView.Framework.UI.Dialogs.FormCatalogTree.NodeDeletedEvent(tree_NodeDeleted); //winFormsHostExplorerTree.Child = _tree; PlugInManager compMan = new PlugInManager(); foreach (var tabType in compMan.GetPlugins(gView.Framework.system.Plugins.Type.IExplorerTabPage)) { IExplorerTabPage page = compMan.CreateInstance <IExplorerTabPage>(tabType); if (page == null || page.Control == null) { continue; } page.OnCreate(_application); LayoutDocument layoutDoc = new LayoutDocument(); layoutDoc.Title = layoutDoc.ContentId = page.Title; layoutDoc.CanClose = false; layoutDoc.CanFloat = false; layoutDoc.Content = new WindowsFormsHost(); ((WindowsFormsHost)layoutDoc.Content).Child = page.Control; _tabPages.Add(new TabPage(page, layoutDoc)); if (page is gView.Framework.UI.Controls.ContentsList) { ((gView.Framework.UI.Controls.ContentsList)page).ItemSelected += new gView.Framework.UI.Controls.ContentsList.ItemClickedEvent(ContentsList_ItemSelected); _content = (gView.Framework.UI.Controls.ContentsList)page; } } explorerDocPane.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(explorerDocPane_PropertyChanged); anchorPaneRight.Children[0].Hide(); _application.AddDockableWindow(_tree, DockWindowState.left); try { XmlDocument doc = new XmlDocument(); doc.Load("menu.explorer.xml"); MakeMainMenuBar(doc.SelectSingleNode("//Menubar")); } catch { } MakeRibbon(); ValidateButtons(); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message + "\n" + ex.StackTrace); } }
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) { Debug.WriteLine("AfterInsertDocument"); }
public bool TryLoadSourceFile(string filePath, bool UseBlendoverEffect = true, bool TryOpenIncludes = true, bool SelectMe = false) { var fileInfo = new FileInfo(filePath); if (fileInfo.Exists) { var extension = fileInfo.Extension.ToLowerInvariant().Trim('.', ' '); if (extension == "sp" || extension == "inc" || extension == "txt" || extension == "cfg" || extension == "ini") { var finalPath = fileInfo.FullName; try { File.GetAccessControl(finalPath); } catch (UnauthorizedAccessException) { return(false); } var editors = GetAllEditorElements(); if (editors != null) { foreach (var editor in editors) { if (editor.FullFilePath == finalPath) { if (SelectMe) { editor.Parent.IsSelected = true; } return(true); } } } AddEditorElement(finalPath, fileInfo.Name, SelectMe); if (TryOpenIncludes && Program.OptionsObject.Program_OpenCustomIncludes) { using var textReader = fileInfo.OpenText(); var source = Regex.Replace(textReader.ReadToEnd(), @"/\*.*?\*/", string.Empty, RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Singleline); var regex = new Regex(@"^\s*\#include\s+((\<|"")(?<name>.+?)(\>|""))", RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline); var mc = regex.Matches(source); for (var i = 0; i < mc.Count; ++i) { try { var fileName = mc[i].Groups["name"].Value; if (!(fileName.EndsWith(".inc", StringComparison.InvariantCultureIgnoreCase) || fileName.EndsWith(".sp", StringComparison.InvariantCultureIgnoreCase))) { fileName += ".inc"; } fileName = Path.Combine( fileInfo.DirectoryName ?? throw new NullReferenceException(), fileName); TryLoadSourceFile(fileName, false, Program.OptionsObject.Program_OpenIncludesRecursively); } catch (Exception) { // ignored } } } } else if (extension == "smx") { var layoutDocument = new LayoutDocument { Title = "DASM: " + fileInfo.Name }; var dasmElement = new DASMElement(fileInfo); layoutDocument.Content = dasmElement; DockingPane.Children.Add(layoutDocument); DockingPane.SelectedContentIndex = DockingPane.ChildrenCount - 1; } if (UseBlendoverEffect) { BlendOverEffect.Begin(); } return(true); } return(false); }
/// <summary> /// Activates the document in the docking manager, which makes it the active document. /// </summary> /// <param name="document">The document.</param> /// <exception cref="ArgumentNullException">The <paramref name="document"/> is <c>null</c>.</exception> public static void ActivateDocument(LayoutDocument document) { Argument.IsNotNull("document", document); LayoutDocumentPane.SelectedContentIndex = LayoutDocumentPane.IndexOfChild(document); }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument layoutDocumentToShow, ILayoutContainer destinationContainer) => false;
internal override void Detach() { _document = null; base.Detach(); }
/// <summary> /// Handles the NotifyCollectionChangedEventArgs event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event.</param> /// <param name="region">The region.</param> /// <param name="regionTarget">The region target.</param> void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DockingManager regionTarget) { if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (var eOldItem in e.OldItems) { var disposables = new[] { eOldItem as IDisposable, (eOldItem as FrameworkElement)?.DataContext as IDisposable, (eOldItem as ContentControl)?.Content as IDisposable, ((eOldItem as ContentControl)?.Content as FrameworkElement)?.DataContext as IDisposable }; foreach (var disposable in disposables) { if (disposable != null) { disposable.Dispose(); } } } } if (e.Action == NotifyCollectionChangedAction.Add) { foreach (FrameworkElement item in e.NewItems) { UIElement view = item as UIElement; if (view != null) { //Create a new layout document to be included in the LayoutDocuemntPane (defined in xaml) LayoutDocument newLayoutDocument = new LayoutDocument(); //Set the content of the LayoutDocument newLayoutDocument.Content = item; newLayoutDocument.Title = (item.DataContext as ITitledItem)?.Title; ServerMonitorModel viewModel = item.DataContext as ServerMonitorModel; if (viewModel != null) { //All my viewmodels have properties DisplayName and IconKey newLayoutDocument.Title = viewModel.CurrentServer.Name; viewModel.OpenServer(); newLayoutDocument.Closed += (s, a) => { Task.Factory.StartNew(() => { viewModel.CloseServer(); viewModel.Cleanup(); }); }; } //Store all LayoutDocuments already pertaining to the LayoutDocumentPane (defined in xaml) List <LayoutDocument> oldLayoutDocuments = new List <LayoutDocument>(); //Get the current ILayoutDocumentPane ... Depending on the arrangement of the views this can be either //a simple LayoutDocumentPane or a LayoutDocumentPaneGroup ILayoutDocumentPane currentILayoutDocumentPane = (ILayoutDocumentPane)regionTarget.Layout.RootPanel.Children[0]; if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup)) { //If the current ILayoutDocumentPane turns out to be a group //Get the children (LayoutDocuments) of the first pane LayoutDocumentPane oldLayoutDocumentPane = (LayoutDocumentPane)currentILayoutDocumentPane.Children.ToList()[0]; foreach (LayoutDocument child in oldLayoutDocumentPane.Children) { oldLayoutDocuments.Insert(0, child); } } else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane)) { //If the current ILayoutDocumentPane turns out to be a simple pane //Get the children (LayoutDocuments) of the single existing pane. foreach (LayoutDocument child in currentILayoutDocumentPane.Children) { oldLayoutDocuments.Insert(0, child); } } //Create a new LayoutDocumentPane and inserts your new LayoutDocument LayoutDocumentPane newLayoutDocumentPane = new LayoutDocumentPane(); newLayoutDocumentPane.InsertChildAt(0, newLayoutDocument); //Append to the new LayoutDocumentPane the old LayoutDocuments foreach (LayoutDocument doc in oldLayoutDocuments) { newLayoutDocumentPane.InsertChildAt(0, doc); } //Traverse the visual tree of the xaml and replace the LayoutDocumentPane (or LayoutDocumentPaneGroup) in xaml //with your new LayoutDocumentPane (or LayoutDocumentPaneGroup) if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane)) { regionTarget.Layout.RootPanel.ReplaceChildAt(0, newLayoutDocumentPane); } else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup)) { currentILayoutDocumentPane.ReplaceChild(currentILayoutDocumentPane.Children.ToList()[0], newLayoutDocumentPane); regionTarget.Layout.RootPanel.ReplaceChildAt(0, currentILayoutDocumentPane); } newLayoutDocument.IsActive = true; } } } }
private object ShowPluginWindow(IXbimXplorerPluginWindow pluginWindow, bool setCurrent = false) { var aswindow = pluginWindow as Window; if (aswindow != null) { var cmode = pluginWindow.GetUiContainerMode(); if (cmode == PluginWindowUiContainerEnum.Dialog) { pluginWindow.BindUi(MainWindow); aswindow.ShowDialog(); var closeAction = pluginWindow.GetUiAttribute().CloseAction; if (closeAction == PluginWindowCloseAction.Hide) { return(aswindow); } } else { Logger.LogError("Plugin type {pluginType} has unsuitable containermode {containerMode}.", aswindow.GetType().Name, cmode); } return(null); } var asControl = pluginWindow as UserControl; if (asControl != null) { if (!_pluginWindows.Contains(pluginWindow)) { _pluginWindows.Add(pluginWindow); } // preparing user control asControl.HorizontalAlignment = HorizontalAlignment.Stretch; asControl.VerticalAlignment = VerticalAlignment.Stretch; //set data binding pluginWindow.BindUi(MainWindow); switch (pluginWindow.GetUiContainerMode()) { case PluginWindowUiContainerEnum.LayoutAnchorable: { // inner var inner = new LayoutAnchorable() { Title = pluginWindow.WindowTitle, Content = asControl }; var pane = GetRightPane(); pane.Children.Add(inner); inner.Closed += PluginWindowClosed; if (setCurrent) { inner.IsActive = true; } return(inner); } case PluginWindowUiContainerEnum.LayoutDoc: { var ld = new LayoutDocument { Title = pluginWindow.WindowTitle, Content = asControl }; MainDocPane.Children.Add(ld); ld.Closed += PluginWindowClosed; if (setCurrent) { ld.IsActive = true; } return(ld); } default: Logger.LogError("Plugin type {pluginType} has unsuitable containermode.", asControl.GetType().Name); break; } } Logger.LogError("{pluginWindow} does not inherit from UserControl as expected", pluginWindow.GetType()); return(null); }
private object ShowPluginWindow(IXbimXplorerPluginWindow pluginWindow, bool setCurrent = false) { // ReSharper disable once SuspiciousTypeConversion.Global // this is because the type is loaded at runtime if (pluginWindow is Window) { // ReSharper disable once SuspiciousTypeConversion.Global // this is because the type is loaded at runtime var aswindow = (Window)pluginWindow; var cmode = pluginWindow.GetUiContainerMode(); switch (cmode) { case PluginWindowUiContainerEnum.Dialog: pluginWindow.BindUi(MainWindow); // aswindow.Closed += PluginWindowClosed; // no need to add the closed control... as the code is not progressing until closed aswindow.ShowDialog(); var closeAction = pluginWindow.GetUiAttribute().CloseAction; if (closeAction == PluginWindowCloseAction.Hide) { return(aswindow); } break; default: Log.ErrorFormat("Plugin type {0} has unsuitable containermode ({1}).", pluginWindow.GetType().Name, cmode); break; } return(null); } if (pluginWindow is UserControl) { if (!_pluginWindows.Contains(pluginWindow)) { _pluginWindows.Add(pluginWindow); } // preparing user control var uc = pluginWindow as UserControl; uc.HorizontalAlignment = HorizontalAlignment.Stretch; uc.VerticalAlignment = VerticalAlignment.Stretch; //set data binding pluginWindow.BindUi(MainWindow); switch (pluginWindow.GetUiContainerMode()) { case PluginWindowUiContainerEnum.LayoutAnchorable: { // inner var inner = new LayoutAnchorable() { Title = pluginWindow.WindowTitle, Content = uc }; GetRightPane().Children.Add(inner); if (setCurrent) { inner.IsActive = true; } return(inner); } case PluginWindowUiContainerEnum.LayoutDoc: { var ld = new LayoutDocument { Title = pluginWindow.WindowTitle, Content = uc }; MainDocPane.Children.Add(ld); ld.Closed += PluginWindowClosed; if (setCurrent) { ld.IsActive = true; } return(ld); } default: Log.ErrorFormat("Plugin type {0} has unsuitable containermode.", pluginWindow.GetType().Name); break; } } Log.ErrorFormat("{0} does not inherit from UserControl as expected", pluginWindow.GetType()); return(null); }
protected virtual void FixupLayout(LayoutRoot layout) { int i; foreach (ILayoutPreviousContainer layoutPreviousContainer in from lc in layout.Descendents().OfType <ILayoutPreviousContainer>() where lc.PreviousContainerId != null select lc) { ILayoutPaneSerializable layoutPaneSerializable = layout.Descendents().OfType <ILayoutPaneSerializable>().FirstOrDefault <ILayoutPaneSerializable>((ILayoutPaneSerializable lps) => lps.Id == layoutPreviousContainer.PreviousContainerId); if (layoutPaneSerializable == null) { throw new ArgumentException(string.Format("Unable to find a pane with id ='{0}'", layoutPreviousContainer.PreviousContainerId)); } layoutPreviousContainer.PreviousContainer = layoutPaneSerializable as ILayoutContainer; } LayoutAnchorable[] array = ( from lc in layout.Descendents().OfType <LayoutAnchorable>() where lc.Content == null select lc).ToArray <LayoutAnchorable>(); for (i = 0; i < (int)array.Length; i++) { LayoutAnchorable content = array[i]; LayoutAnchorable layoutAnchorable = null; if (content.ContentId != null) { layoutAnchorable = this._previousAnchorables.FirstOrDefault <LayoutAnchorable>((LayoutAnchorable a) => a.ContentId == content.ContentId); } if (this.LayoutSerializationCallback != null) { LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg = new LayoutSerializationCallbackEventArgs(content, (layoutAnchorable != null ? layoutAnchorable.Content : null)); this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg); if (layoutSerializationCallbackEventArg.Cancel) { content.Close(); } else if (layoutSerializationCallbackEventArg.Content != null) { content.Content = layoutSerializationCallbackEventArg.Content; } else if (layoutSerializationCallbackEventArg.Model.Content != null) { content.Hide(false); } } else if (layoutAnchorable != null) { content.Content = layoutAnchorable.Content; content.IconSource = layoutAnchorable.IconSource; } else { content.Hide(false); } } LayoutDocument[] layoutDocumentArray = ( from lc in layout.Descendents().OfType <LayoutDocument>() where lc.Content == null select lc).ToArray <LayoutDocument>(); for (i = 0; i < (int)layoutDocumentArray.Length; i++) { LayoutDocument layoutDocument = layoutDocumentArray[i]; LayoutDocument layoutDocument1 = null; if (layoutDocument.ContentId != null) { layoutDocument1 = this._previousDocuments.FirstOrDefault <LayoutDocument>((LayoutDocument a) => a.ContentId == layoutDocument.ContentId); } if (this.LayoutSerializationCallback != null) { LayoutSerializationCallbackEventArgs layoutSerializationCallbackEventArg1 = new LayoutSerializationCallbackEventArgs(layoutDocument, (layoutDocument1 != null ? layoutDocument1.Content : null)); this.LayoutSerializationCallback(this, layoutSerializationCallbackEventArg1); if (layoutSerializationCallbackEventArg1.Cancel) { layoutDocument.Close(); } else if (layoutSerializationCallbackEventArg1.Content != null) { layoutDocument.Content = layoutSerializationCallbackEventArg1.Content; } else if (layoutSerializationCallbackEventArg1.Model.Content != null) { layoutDocument.Close(); } } else if (layoutDocument1 != null) { layoutDocument.Content = layoutDocument1.Content; } else { layoutDocument.Close(); } } layout.CollectGarbage(); }
/// <summary> /// Handles the NotifyCollectionChangedEventArgs event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event.</param> /// <param name="region">The region.</param> /// <param name="regionTarget">The region target.</param> void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DockingManager regionTarget) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (FrameworkElement item in e.NewItems) { UIElement view = item as UIElement; if (view != null) { //Create a new layout document to be included in the LayoutDocuemntPane (defined in xaml) LayoutDocument newLayoutDocument = new LayoutDocument(); //Set the content of the LayoutDocument newLayoutDocument.Content = item; /*IDecompileViewModel viewModel = item.DataContext as IDecompileViewModel; * * if (viewModel != null) * { * Binding binding = new Binding("Title") { Source = viewModel,Mode=BindingMode.OneWay }; * BindingOperations.SetBinding(newLayoutDocument, LayoutDocument.TitleProperty, binding); * }*/ //Store all LayoutDocuments already pertaining to the LayoutDocumentPane (defined in xaml) List <LayoutDocument> oldLayoutDocuments = new List <LayoutDocument>(); //Get the current ILayoutDocumentPane ... Depending on the arrangement of the views this can be either //a simple LayoutDocumentPane or a LayoutDocumentPaneGroup ILayoutDocumentPane currentILayoutDocumentPane = (ILayoutDocumentPane)regionTarget.Layout.RootPanel.Children[0]; if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup)) { //If the current ILayoutDocumentPane turns out to be a group //Get the children (LayoutDocuments) of the first pane LayoutDocumentPane oldLayoutDocumentPane = (LayoutDocumentPane)currentILayoutDocumentPane.Children.ToList()[0]; foreach (LayoutDocument child in oldLayoutDocumentPane.Children) { oldLayoutDocuments.Insert(0, child); } } else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane)) { //If the current ILayoutDocumentPane turns out to be a simple pane //Get the children (LayoutDocuments) of the single existing pane. foreach (LayoutDocument child in currentILayoutDocumentPane.Children) { oldLayoutDocuments.Insert(0, child); } } //Create a new LayoutDocumentPane and inserts your new LayoutDocument LayoutDocumentPane newLayoutDocumentPane = new LayoutDocumentPane(); newLayoutDocumentPane.InsertChildAt(0, newLayoutDocument); //Append to the new LayoutDocumentPane the old LayoutDocuments foreach (LayoutDocument doc in oldLayoutDocuments) { newLayoutDocumentPane.InsertChildAt(0, doc); } //Traverse the visual tree of the xaml and replace the LayoutDocumentPane (or LayoutDocumentPaneGroup) in xaml //with your new LayoutDocumentPane (or LayoutDocumentPaneGroup) if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane)) { regionTarget.Layout.RootPanel.ReplaceChildAt(0, newLayoutDocumentPane); } else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup)) { currentILayoutDocumentPane.ReplaceChild(currentILayoutDocumentPane.Children.ToList()[0], newLayoutDocumentPane); regionTarget.Layout.RootPanel.ReplaceChildAt(0, currentILayoutDocumentPane); } newLayoutDocument.IsActive = true; } } } }
protected virtual void FixupLayout(LayoutRoot layout) { //fix container panes foreach (var lcToAttach in layout.Descendents().OfType <ILayoutPreviousContainer>().Where(lc => lc.PreviousContainerId != null)) { var paneContainerToAttach = layout.Descendents().OfType <ILayoutPaneSerializable>().FirstOrDefault(lps => lps.Id == lcToAttach.PreviousContainerId); if (paneContainerToAttach == null) { throw new ArgumentException($"Unable to find a pane with id ='{lcToAttach.PreviousContainerId}'"); } lcToAttach.PreviousContainer = paneContainerToAttach as ILayoutContainer; } //now fix the content of the layout anchorable contents foreach (var lcToFix in layout.Descendents().OfType <LayoutAnchorable>().Where(lc => lc.Content == null).ToArray()) { LayoutAnchorable previousAchorable = null; //try find the content in replaced layout if (lcToFix.ContentId != null) { previousAchorable = _previousAnchorables.FirstOrDefault(a => a.ContentId == lcToFix.ContentId); } if (previousAchorable != null && previousAchorable.Title != null) { lcToFix.Title = previousAchorable.Title; } if (LayoutSerializationCallback != null) { // Ask client application via callback if item should be deserialized var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousAchorable?.Content); LayoutSerializationCallback(this, args); if (args.Cancel) { lcToFix.Close(); } else if (args.Content != null) { lcToFix.Content = args.Content; } else if (args.Model.Content != null) { lcToFix.Hide(false); // hide layoutanchorable if client app supplied no content } } else if (previousAchorable == null) // No Callback and no provious document -> skip this { lcToFix.Hide(false); } else { // No Callback but previous anchoreable available -> load content from previous document lcToFix.Content = previousAchorable.Content; lcToFix.IconSource = previousAchorable.IconSource; } } //now fix the content of the layout document contents foreach (var lcToFix in layout.Descendents().OfType <LayoutDocument>().Where(lc => lc.Content == null).ToArray()) { LayoutDocument previousDocument = null; //try find the content in replaced layout if (lcToFix.ContentId != null) { previousDocument = _previousDocuments.FirstOrDefault(a => a.ContentId == lcToFix.ContentId); } if (LayoutSerializationCallback != null) { // Ask client application via callback if this realy should be deserialized var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousDocument?.Content); LayoutSerializationCallback(this, args); if (args.Cancel) { lcToFix.Close(); } else if (args.Content != null) { lcToFix.Content = args.Content; } else if (args.Model.Content != null) // Close document if client app supplied no content { lcToFix.Close(); } } else if (previousDocument == null) // No Callback and no provious document -> skip this { lcToFix.Close(); } else { // No Callback but previous document available -> load content from previous document lcToFix.Content = previousDocument.Content; lcToFix.IconSource = previousDocument.IconSource; } } layout.CollectGarbage(); }
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument layoutDocumentToShow) { }
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) { }
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) { //TODO - can I stop anchorables being docked? return(false); }