Exemple #1
0
        public DescriptionLineActivity Clone(UcmlObject obj)
        {
            var newObj = new DescriptionLineActivity();
            var aux    = (DescriptionLineActivity)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.EndLine             = aux.EndLine;
            newObj.IdObjectStarLine    = aux.IdObjectStarLine;
            newObj.IdObjectEndLine     = aux.IdObjectEndLine;
            newObj.isAbleUserSelection = aux.isAbleUserSelection;

            return(newObj);
        }
        private static void ImportDescriptionLineActivity(ref Canvas myCanvas, XmlNodeList listDescriptionLine, ControlTemplate template)
        {
            DescriptionLineActivity ucmlObject;

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

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

                TextBlock d = (TextBlock)ucmlObject.Template.FindName("Description", ucmlObject);
                d.Text  = ucmlObject.Description.ToString() + " (" + ucmlObject.Percentage + "%)";
                d.Width = Util.MeasureString(d.Text, d).Width;
                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();
                // Load my users
                LoadMyUsers(ucmlObject, myCanvas);
            }
        }