Exemplo n.º 1
0
        public Control VisitWithResult(XmlNode node, ParseContext context)
        {
            var typeName = string.Format("{0}.{1}", node.NamespaceURI, node.LocalName);

            var childType = context.GetCustomControlType(typeName);

            if (childType != null)
            {
                var control = Activator.CreateInstance(childType) as Control;

                XamlProcessor.LoadAttributes(control, node, context);

                // The top-most panel/controls are going to get their DataContexts set to the passed in view model
                if (control.DataContext == null)
                {
                    control.DataContext = context.ViewModel;
                }

                if (control is Panel)
                {
                    XamlProcessor.LoadPanel(control as Panel, node, context);
                }

                return(control);
            }

            Debug.LogError("Could not locate panel class for type: " + typeName);

            return(null);
        }
Exemplo n.º 2
0
        internal Control GenerateItem(object item)
        {
            var control = XamlProcessor.LoadDataTemplate(xmlTemplate, context, item);

            control.DataContext = item;

            return(control);
        }
Exemplo n.º 3
0
 private void SaveXamlElementDefaults(string[] xaml)
 {
     try
     {
         foreach (var item in xaml)
         {
             XamlProcessor.LoadElementDefaults(item);
         }
     }
     catch (Exception e)
     {
         Log.Error(e.ToString());
     }
 }
Exemplo n.º 4
0
        internal void OnConnectedToDesigner()
        {
            Bus.Listen <VisualTreeNodeSelected>(OnVisualTreeNodeSelected);
            Bus.Listen <ForceVisualTreeRefresh>(_ => Designer.GetVisualTree());
            Bus.Listen <XamlElementDefaultsReceived>(e => SaveXamlElementDefaults(e.Xaml));
            Bus.Listen <OpenXamlResponseReceived>(e => OnOpenXaml(e.Xaml, e.FileName));

            Editors.Initialize();
            XamlProcessor.Reset();
            RegisterPropertyEditors();
            SendSupportedTypesMessage();
            Designer.GetVisualTree();
            Designer.GetDesignSurfaceXaml();
        }
Exemplo n.º 5
0
        public void LoadPage(string view, object viewModel)
        {
            Clear();

            this.viewModel = viewModel;

            // Get the controls in one fell swoop so we're not in the process of parsing while updates are going on
            var parsedControls = XamlProcessor.ParseXaml(view, viewModel);

            foreach (var c in parsedControls)
            {
                controls.Add(c);
            }
        }
Exemplo n.º 6
0
        public void Visit(XmlNode node, ParseContext context)
        {
            foreach (var rn in node.ChildNodes.OfType <XmlNode>())
            {
                var itemKey = rn.Attributes.GetNamedItem("Key");

                // Not going to support keyless styles and templates for now
                if (itemKey == null)
                {
                    Debug.LogWarning("Version 1.0 does not support keyless resources.");
                    continue;
                }

                var visitor = XamlProcessor.CreateVisitor(rn);
                visitor.Visit(rn, context);
            }
        }
Exemplo n.º 7
0
        public Control VisitWithResult(XmlNode node, ParseContext context)
        {
            var controlType = context.GetControlType(node.LocalName);

            if (controlType != null)
            {
                var control = Activator.CreateInstance(controlType) as Control;

                XamlProcessor.LoadAttributes(control, node, context);

                if (control is Panel)
                {
                    XamlProcessor.LoadPanel(control as Panel, node, context);
                }

                return(control);
            }

            Debug.LogError("Could not locate panel class for type: " + node.LocalName);

            return(null);
        }
Exemplo n.º 8
0
 private static void Main(string[] args)
 {
     XamlProcessor.Process();
 }
Exemplo n.º 9
0
 private void OnOpenXaml(string[] xaml, string fileName)
 {
     XamlProcessor.Reset();
     SaveXamlElementDefaults(xaml);
     Project.State.OpenFile = fileName;
 }