private void CreateString() { if (Creating) { // There is no ElementNode selected in the tree if (inputElements == null) { StringCount++; } // We've got an ElementNode selected in the tree, now figure out what to do with it. else { int inputStringCount = 0; int inputPixelCount = 0; PreviewTools.CountPixelsAndStrings(inputElements, out inputPixelCount, out inputStringCount); int stringNum = _strings.Count(); // is this a single node with no children? if (inputPixelCount == 0 && inputStringCount == 0) { PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, inputElements, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we're here, we've got a group selected else { // Do we have multiple child strings in this group and no individual pixels selected? if (stringNum <= inputStringCount - 1 && inputPixelCount == 0) { StringType = StringTypes.Pixel; ElementNode child = null; if (inputStringCount > 0) { child = inputElements.Children.ToList()[stringNum]; } else { child = inputElements; } int pixelCount = child.Count(); PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), child.Count(), child, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we're here, we have multiple pixels in a single string and no strings in our parent node else if (inputPixelCount > 2 && inputStringCount == 0 && stringNum == 0) { StringType = StringTypes.Pixel; PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), inputElements.Count(), inputElements, ZoomLevel); line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } // If we get here, there is nothing valid selected so add a string and move on else { PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, null, ZoomLevel); line.StringType = StringType; line.Parent = this; _strings.Add(line); _stringCount = _strings.Count(); } } } } }