示例#1
0
        private static void ImportDescriptionLineUser(ref Canvas myCanvas, XmlNodeList listDescriptionLine, ControlTemplate template)
        {
            DescriptionLineUser ucmlObject;

            foreach (XmlNode xn in listDescriptionLine)
            {
                ucmlObject = new DescriptionLineUser().ImportToXml(xn);
                list[1]++;
                ucmlObject.Template = template;

                // Calling ApplyTemplate enables us to navigate the visual tree right now (important!)
                ucmlObject.ApplyTemplate();

                var d = (TextBlock)ucmlObject.Template.FindName("Description", ucmlObject);
                d.Text = ucmlObject.Description.ToString();

                var p = (TextBlock)ucmlObject.Template.FindName("Percentage", ucmlObject);
                p.Text       = ucmlObject.Percentage.ToString() + "%";
                p.Foreground = ucmlObject.myColor;

                Border b = (Border)ucmlObject.Template.FindName("circle", ucmlObject);
                b.BorderBrush = ucmlObject.myColor;

                Polyline  pl = (Polyline)ucmlObject.Template.FindName("Line", ucmlObject);
                TextBlock tb = (TextBlock)ucmlObject.Template.FindName("Description", ucmlObject);
                pl.Stroke     = ucmlObject.myColor;
                tb.Foreground = ucmlObject.myColor;

                // Add new object as child of canvas to allow get ucmlObjsct's size from it's template
                myCanvas.Children.Add(ucmlObject);
                // Update the layout of the ucml object
                ucmlObject.UpdateLayout();

                // Set position top and left of ucml object on the canvas
                Canvas.SetLeft(ucmlObject, ucmlObject.PosTopX);
                Canvas.SetTop(ucmlObject, ucmlObject.PosTopY);
                // Move our thumb to the front to be over the lines
                Canvas.SetZIndex(ucmlObject, 1);
                // Update the layout of the ucml object
                ucmlObject.UpdateLayout();

                listUsers.Add(ucmlObject);
            }
        }
        public DescriptionLineUser Clone(UcmlObject obj)
        {
            var newObj = new DescriptionLineUser();
            var aux    = (DescriptionLineUser)obj;

            newObj.Id                  = aux.Id;
            newObj.UcmlName            = aux.UcmlName;
            newObj.Color               = aux.Color;
            newObj.PosTopX             = aux.PosTopX;
            newObj.PosTopY             = aux.PosTopY;
            newObj.Description         = aux.Description;
            newObj.TemplateName        = aux.TemplateName;
            newObj.listNewProp         = aux.listNewProp;
            newObj.UcmlWidth           = aux.UcmlWidth;
            newObj.UcmlHeight          = aux.UcmlHeight;
            newObj.myColor             = aux.myColor;
            newObj.Percentage          = aux.Percentage;
            newObj.StartLine           = aux.StartLine;
            newObj.IdObjectStarLine    = aux.IdObjectStarLine;
            newObj.IdObjectEndLine     = aux.IdObjectEndLine;
            newObj.isAbleUserSelection = aux.isAbleUserSelection;

            return(newObj);
        }