/// <summary>
        /// Initializes a new WpfControlRenderer.
        /// </summary>
        /// <param name="writer">WpfXmlWriter to use for writing the output XAML.</param>
        /// <param name="sizer">Combo box sizer.</param>
        public WpfControlRenderer(WpfXmlWriter writer, WpfComboBoxSizer sizer)
        {
            _writer        = writer;
            _comboBoxSizer = sizer;

            _comboBoxSizer.Clear();
        }
示例#2
0
        public static void Render(Strategy_t strategy, XmlWriter writer, WpfComboBoxSizer sizer)
        {
            if (strategy.StrategyLayout == null)
            {
                throw ThrowHelper.New <RenderingException>(ExceptionContext, ErrorMessages.NoStrategyLayoutSupplied);
            }

            StrategyPanel_t rootPanel = strategy.StrategyLayout.StrategyPanel;

            if (rootPanel == null)
            {
                throw ThrowHelper.New <RenderingException>(ExceptionContext, ErrorMessages.NoStrategyPanelsInStrategy);
            }

            WpfXmlWriter wpfWriter = new WpfXmlWriter(writer);

            // TODO: Move this somewhere better
            WpfControlRenderer controlRenderer = new WpfControlRenderer(wpfWriter, sizer);

            // TODO: Move this elsewhere

            CompositionContainer defaultContainer = new CompositionContainer(new TypeCatalog(_defaultRenderers));

            if (!string.IsNullOrEmpty(CustomControlRenderer))
            {
                string applicationDirectory = (from assembly in System.AppDomain.CurrentDomain.GetAssemblies()
                                               where assembly.CodeBase.EndsWith(".exe")
                                               select System.IO.Path.GetDirectoryName(assembly.CodeBase.Replace("file:///", ""))).FirstOrDefault();

                string customControlRendererPath = Path.Combine(applicationDirectory, CustomControlRenderer);

                AssemblyCatalog overridesCatalog = new AssemblyCatalog(customControlRendererPath);

                CompositionContainer aggregateContainer = new CompositionContainer(overridesCatalog, defaultContainer);

                aggregateContainer.ComposeParts(controlRenderer);
            }
            else
            {
                defaultContainer.ComposeParts(controlRenderer);
            }

            int depth = 0;

            ProcessPanel(rootPanel, wpfWriter, controlRenderer, -1, ref depth);
        }