Esempio n. 1
0
 public static DocumentNode GetRootDesignDataNode(IProjectItem designDataFile, IProjectContext projectContext)
 {
     if (designDataFile == null)
     {
         return((DocumentNode)null);
     }
     return(DocumentContextHelper.GetParsedOrSniffedRootNode(designDataFile, projectContext));
 }
Esempio n. 2
0
        private static ViewUpdateManager.DocumentRelation GetDocumentRelation(SceneView sceneView, IProjectDocument projectDocument)
        {
            if (projectDocument == null)
            {
                return(ViewUpdateManager.DocumentRelation.Unrelated);
            }
            if (projectDocument.DocumentType == ProjectDocumentType.Application || projectDocument.DocumentType == ProjectDocumentType.ResourceDictionary || projectDocument.DocumentRoot != null && projectDocument.DocumentRoot.RootNode != null && PlatformTypes.UserControl.IsAssignableFrom((ITypeId)projectDocument.DocumentRoot.RootNode.Type))
            {
                return(ViewUpdateManager.DocumentRelation.Related);
            }
            string        withoutExtension = Path.GetFileNameWithoutExtension(projectDocument.Path);
            SampleDataSet sampleDataSet    = sceneView.SampleData.GetSampleDataSet(withoutExtension, true);

            if (sampleDataSet == null)
            {
                return(DocumentContextHelper.GetDesignDataMode(ProjectHelper.GetProject(sceneView.DesignerContext.ProjectManager, sceneView.Document.DocumentContext), projectDocument.Path) != DesignDataMode.None ? ViewUpdateManager.DocumentRelation.Related : ViewUpdateManager.DocumentRelation.Unrelated);
            }
            if (!sampleDataSet.XamlFilePath.Equals(projectDocument.Path, StringComparison.OrdinalIgnoreCase))
            {
                return(ViewUpdateManager.DocumentRelation.Unrelated);
            }
            return(!sampleDataSet.IsOnline ? ViewUpdateManager.DocumentRelation.OfflineSampleData : ViewUpdateManager.DocumentRelation.Related);
        }
Esempio n. 3
0
        public static IProjectItem GetDesignDataFile(DocumentNode documentNode)
        {
            IProject project = (IProject)((IServiceProvider)documentNode.TypeResolver).GetService(typeof(IProject));
            string   path    = (string)null;

            if (documentNode.Type.RuntimeType == typeof(DesignDataExtension))
            {
                path = DesignDataInstanceBuilder.GetSourceFilePath((DocumentCompositeNode)documentNode);
            }
            else if (documentNode.Parent == null)
            {
                path = documentNode.Context.DocumentUrl;
            }
            if (!string.IsNullOrEmpty(path))
            {
                IProjectItem projectItem = project.FindItem(DocumentReference.Create(path));
                if (projectItem != null && DocumentContextHelper.GetDesignDataMode(projectItem) != DesignDataMode.None)
                {
                    return(projectItem);
                }
            }
            return((IProjectItem)null);
        }
Esempio n. 4
0
 public static void PopulateDocumentSpecificPropertyCache(SceneViewModel viewModel)
 {
     PropertyCacheHelper.DispatchArguments arguments = new PropertyCacheHelper.DispatchArguments();
     arguments.ViewModel = viewModel;
     if (viewModel.Document == null || DocumentContextHelper.GetDesignDataMode((IProject)viewModel.ProjectContext.GetService(typeof(IProject)), viewModel.Document.Path) != DesignDataMode.None)
     {
         return;
     }
     if (!viewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
     {
         if (PropertyCacheHelper.InitializedSl)
         {
             return;
         }
         PropertyCacheHelper.InitializedSl = true;
         arguments.TypeList = new ITypeId[17]
         {
             PlatformTypes.Rectangle,
             PlatformTypes.Ellipse,
             PlatformTypes.Path,
             PlatformTypes.Grid,
             PlatformTypes.Canvas,
             PlatformTypes.StackPanel,
             PlatformTypes.ScrollViewer,
             PlatformTypes.Border,
             PlatformTypes.TextBox,
             PlatformTypes.TextBlock,
             PlatformTypes.PasswordBox,
             PlatformTypes.Button,
             PlatformTypes.CheckBox,
             PlatformTypes.ListBox,
             PlatformTypes.RadioButton,
             PlatformTypes.Slider,
             PlatformTypes.ScrollBar
         };
     }
     else
     {
         if (PropertyCacheHelper.InitializedWpf)
         {
             return;
         }
         PropertyCacheHelper.InitializedWpf = true;
         arguments.TypeList = new ITypeId[27]
         {
             PlatformTypes.Rectangle,
             PlatformTypes.Ellipse,
             PlatformTypes.Path,
             PlatformTypes.Grid,
             PlatformTypes.Canvas,
             PlatformTypes.StackPanel,
             ProjectNeutralTypes.WrapPanel,
             ProjectNeutralTypes.DockPanel,
             PlatformTypes.ScrollViewer,
             PlatformTypes.Border,
             ProjectNeutralTypes.Viewbox,
             PlatformTypes.TextBox,
             PlatformTypes.TextBlock,
             PlatformTypes.RichTextBox,
             PlatformTypes.PasswordBox,
             ProjectNeutralTypes.Label,
             PlatformTypes.FlowDocumentScrollViewer,
             PlatformTypes.Button,
             PlatformTypes.CheckBox,
             PlatformTypes.ComboBox,
             PlatformTypes.ListBox,
             PlatformTypes.RadioButton,
             PlatformTypes.Slider,
             ProjectNeutralTypes.TabControl,
             ProjectNeutralTypes.GridSplitter,
             PlatformTypes.ScrollBar,
             PlatformTypes.UniformGrid
         };
     }
     if (PropertyCacheHelper.Synchronous)
     {
         PropertyCacheHelper.WarmUpPropertyCacheByITypeId((object)arguments);
     }
     else
     {
         UIThreadDispatcher.Instance.BeginInvoke <object>(DispatcherPriority.ApplicationIdle, (Func <object>)(() => PropertyCacheHelper.WarmUpPropertyCacheByITypeId((object)arguments)));
     }
 }