Example #1
0
 public bool LoadConfiguration(Stream config)
 {
     try
     {
         using (ViewElementFactory.Current.AllowConstruction())
             this.windowProfile = (WindowProfile)XamlReader.Load(config);
         this.windowProfile.Name = this.name;
         if (!new ExpressionWindowProfileValidator().Validate(this.windowProfile))
         {
             return(false);
         }
         if (this.content != null)
         {
             NakedView nakedView = (NakedView)this.windowProfile.Find((Predicate <ViewElement>)(v => v is NakedView));
             if (nakedView != null)
             {
                 nakedView.Content = this.content;
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Example #2
0
        public void CopyConfiguration(IWorkspace sourceWorkspace)
        {
            if (sourceWorkspace == null)
            {
                throw new ArgumentNullException("sourceWorkspace");
            }
            if (sourceWorkspace == this)
            {
                throw new ArgumentException("Cannot copy configuration from itself.", "sourceWorkspace");
            }
            Workspace workspace = sourceWorkspace as Workspace;

            if (workspace == null)
            {
                throw new ArgumentException("Source workspace must be of the type Workspace. Other types are not supported.", "sourceWorkspace");
            }
            WindowProfileSerializer profileSerializer = this.CreateWindowProfileSerializer();

            this.windowProfile = workspace.WindowProfile.Copy(this.name, profileSerializer);
            if (this.content == null)
            {
                return;
            }
            NakedView nakedView = (NakedView)this.windowProfile.Find((Predicate <ViewElement>)(v => v is NakedView));

            if (nakedView == null)
            {
                return;
            }
            nakedView.Content = this.content;
        }