Exemple #1
0
        private static DrawingBrush GetIconFromUnInitializedDesigner(ActivityDesigner designer)
        {
            DrawingBrush icon = null;

            if (designer != null)
            {
                // force the designer to load
                designer.BeginInit();

                // An exception will be thrown, if BeginInit is called more than once on
                // the same activity designer prior to EndInit being called.  So we call
                // EndInit to avoid that, note this will cause an Initialized event.
                designer.EndInit();

                if (designer.Icon == null)
                {
                    // the loading of the default icon depends on Activity.Loaded event.
                    // however the designer might not be loaded unless it is added to the
                    // designer surface.  So we load the default icon manually here.
                    icon = designer.GetDefaultIcon();
                }
                else
                {
                    icon = designer.Icon;
                }
            }

            return(icon);
        }