Exemple #1
0
        public static T add_UIElement <T>(this DesignerCanvas designerCanvas, T uiElement, string newControlContent, int top, int left, int width, int height)
            where T : UIElement
        {
            try
            {
                if (uiElement.notNull())
                {
                    var newDesignerItem = new DiagramDesigner.DesignerItem();
                    uiElement.IsHitTestVisible = false;

                    newDesignerItem.width_Wpf(width);
                    newDesignerItem.height_Wpf(height);
                    newDesignerItem.top_Wpf(top);
                    newDesignerItem.left_Wpf(left);

                    //newControl.width_Wpf(height-5);
                    //newControl.width_Wpf(height-5);

                    /*if (newControl is FrameworkElement)
                     * {
                     *      (newControl as FrameworkElement).width_Wpf(width -5);
                     *      (newControl as FrameworkElement).height_Wpf(height -5 );
                     *      //(newControl as FrameworkElement).top_Wpf(top - 5);
                     *      //(newControl as FrameworkElement).left_Wpf(left + 5);
                     * }*/

                    if (newControlContent.valid() && uiElement is ContentControl)
                    {
                        (uiElement as ContentControl).Content = newControlContent;
                    }

                    newDesignerItem.Content = uiElement;

                    designerCanvas.Children.Add(newDesignerItem);
                    return((T)uiElement);
                }
            }
            catch (Exception ex)
            {
                ex.log("in DesignerCanvas add_DesignerItem");
            }
            return(default(T));
        }