void IEvaluableMarkupExtension.Initialize(IParserContext context)
 {
   if (Id == null)
     throw new XamlBindingException("GetModelMarkupExtension: Property Id has to be given");
   IModelLoader loader = context.GetContextVariable(typeof(IModelLoader)) as IModelLoader;
   if (loader == null)
     throw new XamlBindingException("GetModelMarkupExtension: No model loader instance present in parser context");
   _model = loader.GetOrLoadModel(new Guid(Id));
 }
Exemplo n.º 2
0
 void IEvaluableMarkupExtension.Initialize(IParserContext context)
 {
   if (Id == null)
     throw new XamlBindingException("GetModelMarkupExtension: Property Id has to be given");
   IModelLoader loader = context.GetContextVariable(typeof(IModelLoader)) as IModelLoader;
   if (loader == null)
     throw new XamlBindingException("GetModelMarkupExtension: No model loader instance present in parser context");
   _model = loader.GetOrLoadModel(new Guid(Id));
 }
Exemplo n.º 3
0
        public override void FinishInitialization(IParserContext context)
        {
            base.FinishInitialization(context);
            ISkinResourceBundle resourceBundle = (ISkinResourceBundle)context.GetContextVariable(typeof(ISkinResourceBundle));

            // This resourceBundle is the resource bundle where the screen itself is located. It is necessary to use the resource bundle
            // of the skin where the screen file which contains the <Screen> element is located and NOT the resource bundle of the
            // screen which is being loaded by the ScreenManager, because the skin file with the <Screen> element might be included
            // into that screen which is being loaded by the ScreenManager.
            // We need the correct resource bundle to get the native size of the skin which defines the <Screen> element.
            _skinWidth  = resourceBundle.SkinWidth;
            _skinHeight = resourceBundle.SkinHeight;
        }
 public override void FinishInitialization(IParserContext context)
 {
     base.FinishInitialization(context);
     if (!string.IsNullOrEmpty(_source))
     {
         ISkinResourceBundle resourceBundle;
         string sourceFilePath = SkinContext.SkinResources.GetResourceFilePath(_source, true, out resourceBundle);
         if (sourceFilePath == null)
         {
             throw new XamlLoadException("Could not open ResourceDictionary source file '{0}' (evaluated path is '{1}')", _source, sourceFilePath);
         }
         object             obj       = XamlLoader.Load(sourceFilePath, resourceBundle, (IModelLoader)context.GetContextVariable(typeof(IModelLoader)));
         ResourceDictionary mergeDict = obj as ResourceDictionary;
         if (mergeDict == null)
         {
             if (obj != null)
             {
                 TryDispose(ref obj);
             }
             throw new Exception(String.Format("Resource '{0}' doesn't contain a resource dictionary", _source));
         }
         TakeOver(mergeDict, false, true);
     }
     if (_mergedDictionaries != null && _mergedDictionaries.Count > 0)
     {
         foreach (ResourceDictionary dictionary in _mergedDictionaries)
         {
             TakeOver(dictionary, false, true);
         }
         _mergedDictionaries.Clear();
     }
     FireChanged();
 }
Exemplo n.º 5
0
        public void FinishInitialization(IParserContext context)
        {
            ISkinResourceBundle resourceBundle;
            string includeFilePath = SkinContext.SkinResources.GetResourceFilePath(_includeName, true, out resourceBundle);

            if (includeFilePath == null)
            {
                throw new XamlLoadException("Include: Could not open include file '{0}' (evaluated path is '{1}')", _includeName, includeFilePath);
            }
            _content = XamlLoader.Load(includeFilePath, resourceBundle, (IModelLoader)context.GetContextVariable(typeof(IModelLoader)));
            if (_content is UIElement)
            {
                UIElement target = (UIElement)_content;
                // Merge resources with those from the included content
                target.Resources.TakeOver(_resources, true, true);
                _resources = null;
            }
            else if (_content is ResourceDictionary)
            {
                ((ResourceDictionary)_content).TakeOver(_resources, true, true);
                _resources = null;
            }
        }
Exemplo n.º 6
0
 public void FinishInitialization(IParserContext context)
 {
   ISkinResourceBundle resourceBundle;
   string includeFilePath = SkinContext.SkinResources.GetResourceFilePath(_includeName, true, out resourceBundle);
   if (includeFilePath == null)
     throw new XamlLoadException("Include: Could not open include file '{0}' (evaluated path is '{1}')", _includeName, includeFilePath);
   _content = XamlLoader.Load(includeFilePath, resourceBundle, (IModelLoader) context.GetContextVariable(typeof(IModelLoader)));
   if (_content is UIElement)
   {
     UIElement target = (UIElement) _content;
     // Merge resources with those from the included content
     target.Resources.TakeOver(_resources, true, true);
     _resources = null;
   }
   else if (_content is ResourceDictionary)
   {
     ((ResourceDictionary) _content).TakeOver(_resources, true, true);
     _resources = null;
   }
 }