Beispiel #1
0
        /// <summary>
        /// レイアウトのシリアライズ処理を呼び出します。
        /// </summary>
        /// <param name="sender">送信元のオブジェクトです。</param>
        /// <param name="e">イベント引数です。</param>
        public static void CallLayoutSerialization(object sender, LayoutSerializationCallbackEventArgs e)
        {
            var anchorable = e.Model as LayoutAnchorable;
            if (anchorable != null)
            {
                var panelPresenter = GlobalPresenter.GetPanelPresenter();
                var factory = GlobalPresenter.GetToolFactory(e.Model.ContentId);
                if (factory != null)
                {
                    var tool = GlobalPresenter.AddTool(factory, panelPresenter);
                    e.Content = tool;
                    tool.IsVisible = anchorable.IsVisible;
                    if (anchorable.IsActive)
                    {
                        tool.IsActive = true;
                    }

                    tool.IsSelected = anchorable.IsSelected;
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
        void Serializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            if (e.Model.ContentId == "EnemyFleet")
                e.Model.ContentId = "CompassData";

            var rPane = new PaneViewModel() { Content = ViewFactory.GetContentFromID(e.Model.ContentId), ContentID = e.Model.ContentId, Title = e.Model.Title };
            e.Content = rPane;
            App.Root.Panes.Add(rPane);
        }
Beispiel #3
0
 void LayoutSerializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
 {            
     if (Profile != null && e.Model is LayoutDocument)
     {
         HeliosObject profileObject = HeliosSerializer.ResolveReferenceName(Profile, e.Model.ContentId);
         HeliosEditorDocument editor =  CreateDocumentEditor(profileObject);
         profileObject.PropertyChanged += DocumentObject_PropertyChanged;
         e.Content = CreateDocumentContent(editor);
         e.Model.Closed += Document_Closed;
         AddDocumentMeta(profileObject, (LayoutDocument)e.Model, editor);
     }
 }
        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(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 == null).ToArray())
            {
                LayoutAnchorable previousAchorable = null;
                if (lcToFix.ContentId != null)
                { 
                    //try find the content in replaced layout
                    previousAchorable = _previousAnchorables.FirstOrDefault(a => a.ContentId == lcToFix.ContentId);
                }

                if (LayoutSerializationCallback != null)
                {
                    var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousAchorable != null ? previousAchorable.Content : null);
                    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);
                }
                else if (previousAchorable == 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 == null).ToArray())
            {
                LayoutDocument previousDocument = null;
                if (lcToFix.ContentId != null)
                {
                    //try find the content in replaced layout
                    previousDocument = _previousDocuments.FirstOrDefault(a => a.ContentId == lcToFix.ContentId);
                }

                if (LayoutSerializationCallback != null)
                {
                    var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousDocument != null ? previousDocument.Content : null);
                    LayoutSerializationCallback(this, args);

                    if (args.Cancel)
                        lcToFix.Close();
                    else if (args.Content != null)
                        lcToFix.Content = args.Content;
                    else if (args.Model.Content != null)
                        lcToFix.Close();
                }
                else if (previousDocument == null)
                    lcToFix.Close();
                else
                    lcToFix.Content = previousDocument.Content;
            }


            layout.CollectGarbage();
        }
		void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(e.Model.ContentId))
				e.Content = LayoutParts.FirstOrDefault(item => item.UID == Guid.Parse(e.Model.ContentId));
		}
        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(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 == null).ToArray())
            {
                LayoutAnchorable previousAchorable = null;
                if (lcToFix.ContentId != null)
                {
                    //try find the content in replaced layout
                    previousAchorable = _previousAnchorables.FirstOrDefault(a => a.ContentId == lcToFix.ContentId);
                }

                if (LayoutSerializationCallback != null)
                {
                    var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousAchorable != null ? previousAchorable.Content : null);
                    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);
                    }
                }
                else if (previousAchorable == 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 == null).ToArray())
            {
                LayoutDocument previousDocument = null;
                if (lcToFix.ContentId != null)
                {
                    //try find the content in replaced layout
                    previousDocument = _previousDocuments.FirstOrDefault(a => a.ContentId == lcToFix.ContentId);
                }

                if (LayoutSerializationCallback != null)
                {
                    var args = new LayoutSerializationCallbackEventArgs(lcToFix, previousDocument != null ? previousDocument.Content : null);
                    LayoutSerializationCallback(this, args);

                    if (args.Cancel)
                    {
                        lcToFix.Close();
                    }
                    else if (args.Content != null)
                    {
                        lcToFix.Content = args.Content;
                    }
                    else if (args.Model.Content != null)
                    {
                        lcToFix.Close();
                    }
                }
                else if (previousDocument == null)
                {
                    lcToFix.Close();
                }
                else
                {
                    lcToFix.Content    = previousDocument.Content;
                    lcToFix.IconSource = previousDocument.IconSource;
                }
            }

            layout.CollectGarbage();
        }
Beispiel #7
0
		private void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(e.Model.ContentId))
			{
				var layoutPart = LayoutParts.FirstOrDefault(item => item.UID == Guid.Parse(e.Model.ContentId));
				if (layoutPart != null)
				{
					layoutPart.Margin = e.Model.Margin;
					layoutPart.BorderColor = e.Model.BorderColor;
					layoutPart.BorderThickness = e.Model.BorderThickness;
					layoutPart.BackgroundColor = e.Model.BackgroundColor;
				}
				e.Content = layoutPart;
			}
		}
 void ser_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
 {
     e.Content = new UserControl();
 }
Beispiel #9
0
        private void OnLayoutDeserialized(object sender, LayoutSerializationCallbackEventArgs e)
        {
            foreach (UiMenuItem item in _mainMenuView.Items)
            {
                if (e.Model.Title != (string)item.Header)
                    continue;

                e.Model.Content = item.CommandParameter;
                e.Cancel = true;
                return;
            }
        }
Beispiel #10
0
        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();
        }