private Label DrawToothNumber(CompositeElement element) { Label labelToothNumber = new Label(); var groupNameLength = element.GroupName.Length; labelToothNumber.Content = element.GroupName.Substring(groupNameLength - 2); element.RelativeToothNumber = labelToothNumber; labelToothNumber.IsHitTestVisible = false; //labelToothNumber.Foreground = Brushes.AliceBlue; labelToothNumber.FontSize = 14; labelToothNumber.FontWeight = FontWeights.UltraBold; labelToothNumber.Effect = new DropShadowEffect() { ShadowDepth=0, Color=Colors.Yellow, Opacity=0.8, BlurRadius=3 }; CanvasMain.Children.Add(labelToothNumber); Canvas.SetLeft(labelToothNumber, Canvas.GetLeft(element)); Canvas.SetTop(labelToothNumber, Canvas.GetTop(element)); // Номер зуба Canvas.SetZIndex(element.RelativeToothNumber, 99); return labelToothNumber; }
public void Replace(CompositeElement newElement, Vector oldShift) { Canvas canvas = Parent as Canvas; if (canvas == null) return; CompositeElement oldElement = this; CompositeElement oldRelElement = oldElement.RelativeElement; CompositeElement newRelElement = newElement.RelativeElement; newElement.Position = oldElement.Position; var dx = newElement.Width - oldElement.Width; var dy = newElement.Height - oldElement.Height; if (oldElement.CompositeLocation == Elements.CompositeLocation.Bot && newElement.Source != oldElement.Source) { // 0 newElement.Position -= new Vector(oldElement.HorizontalShift, 0); newElement.Position += oldShift; } if (oldElement.CompositeLocation == Elements.CompositeLocation.Top && newElement.Source != oldElement.Source) { // 0 newElement.Position -= new Vector(dx / 2, dy); newElement.Position += oldShift; } if (oldElement.CompositeLocation == Elements.CompositeLocation.Bot) { newElement.Position -= new Vector(dx, 0); } //Image/lunky_plastyka/48.png 21 14 //if (newElement.Source.ToString().Substring(newElement.Source.ToString().Length - 21, 14) == "lunky_plastyka" // || newElement.Source.ToString().Substring(newElement.Source.ToString().Length - 20, 14) == "lunky_plastyka") if (newElement.Source.ToString().Contains("lunky_plastyka")) { if (newElement is CompositeElement) { if (oldElement.CompositeLocation == CompositeLocation.Top && (oldElement.GroupName.Substring(5, 1) == "1" || oldElement.GroupName.Substring(5, 1) == "2")) { if (oldElement.RelativeElement != null) canvas.Children.Remove(oldElement.RelativeElement); } else if (oldElement.CompositeLocation == CompositeLocation.Bot && (oldElement.GroupName.Substring(5, 1) == "3" || oldElement.GroupName.Substring(5, 1) == "4")) { if (oldElement.RelativeElement != null) canvas.Children.Remove(oldElement.RelativeElement); } } } //newElement.Position -= new Vector(dx / 2, dy); //if (newRelElement == null && newElement.Source != oldElement.Source) // //newElement.Position = new Point(100, 100); // newElement.Position = oldElement.Position - oldShift; if (oldRelElement != null) { newElement.RelativeElement = oldRelElement; oldRelElement.RelativeElement = newElement; newElement.IsMerged = oldRelElement.IsMerged; } canvas.Children.Remove(oldElement); }
private void DeleteToothNumber(Label labelToothNumber, CompositeElement element) { element.RelativeToothNumber = null; CanvasMain.Children.Remove(labelToothNumber); }
public Element CloneIntoCanvas(Canvas canvas, Point point) { Element element = null; if (this is UnlimitedElement) { element = new UnlimitedElement(); } if (this is GroupElement && !(this is CompositeElement)) { element = new GroupElement((this as GroupElement).GroupName); } if (this is CompositeElement) { element = new CompositeElement(); //if (this.Name == "element_bot") //{ // var elementShell = (this.Parent as Grid).Parent as CompositeElementShell; // //point += new Vector(elementShell.HorizontalShift, 0); //} (element as CompositeElement).GroupName = (this as CompositeElement).GroupName; } element.IsClone = true; element.Source = this.Source; element.Width = this.ActualWidth; element.Height = this.ActualHeight; if (this.Size != 0) { element.Size = this.Size; element.Width *= this.Size; element.Height *= this.Size; } else element.Size = 1; canvas.Children.Add(element); element.Position = point; if (element is CompositeElement && this.Name == "element_bot") { var elementShell = (this.Parent as Grid).Parent as CompositeElementShell; element.Position += new Vector(elementShell.HorizontalShift, 0); } //if (element is CompositeElement) //{ // var composite = element as CompositeElement; // if (!composite.IsMerged && composite.GroupName != null) // { // if (((composite.GroupName.Substring(5, 1) == "1" || composite.GroupName.Substring(5, 1) == "1") && composite.CompositeLocation == CompositeLocation.Bot) || // ((composite.GroupName.Substring(5, 1) == "3" || composite.GroupName.Substring(5, 1) == "4") && composite.CompositeLocation == CompositeLocation.Top)) // { // var toothNumb = composite.GroupName.Substring(5, 2); // Canvas.SetLeft(composite, Values.CrownPosition[toothNumb][0]); // Canvas.SetTop(composite, Values.CrownPosition[toothNumb][1]); // } // } //} return element; }