private void MenuItem_Delete(object sender, RoutedEventArgs e) { int rs = SQliteDbContext.DeleteOnePin(SelectedpinEx.PinCode, SelectedpinEx.ProjectNO); if (rs > 0) { this.canvas.Children.Remove(tempEp); (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pins.Remove(SelectedpinEx); tempEp = null; SelectedpinEx = null; } }
private void Ellipse_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Ellipse ep = sender as Ellipse; mousedown = true; if (Operator != Operation.Create) { tempEp = ep; TempBruhes = ep.Fill; ep.Fill = Brushes.LawnGreen; ep.CaptureMouse(); } if (Operator == Operation.Delete) { ep.ReleaseMouseCapture(); canvas.Children.Remove(ep); if (ep.Name != null && ep.Name != "") { SQliteDbContext.DeleteOnePin(ep.Name.Substring(1, ep.Name.Length - 1), (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Project.ProjectNO); PinEx p = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pins.ToList().Find(x => x.PinCode == ep.Name.Substring(1, ep.Name.Length - 1)); (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pins.Remove(p); } } if (Operator == Operation.Modify) { if (tempEp != null) { int value = 0; int.TryParse(txtDia.Text, out value); if (cbDia.IsChecked.HasValue && cbDia.IsChecked.Value) { tempEp.Height = value; tempEp.Width = value; } if (cbDia.IsChecked.HasValue && cbColor.IsChecked.Value) { tempEp.Fill = clpk.SelectedBrush; } } if (tempEp.Name == "") { Pin p = new Pin(); p.PinEX = canvas.RenderSize.Width; p.PinEY = canvas.RenderSize.Height; p.PinSX = Canvas.GetLeft(tempEp); p.PinSY = Canvas.GetTop(tempEp); p.Radius = tempEp.ActualHeight; if (tempEp.Fill.ToString().Trim().Length > 0 && tempEp.Fill.ToString() != "0") { p.DrawColor = tempEp.Fill.ToString(); } else { p.DrawColor = "#FF0000"; } bool isrelay = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.CablePaper.IsSafeBox == 1; p.ProjectNO = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Project.ProjectNO; p.FixtureCode = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.CablePaper.FixtureCode; (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pin = p; CodeWindow codeWindow = new CodeWindow(isrelay); codeWindow.ShowDialog(); tempEp.Name = "P" + p.PinCode; //canvas.RegisterName(tempEp.Name, tempEp); tempEp.Fill = TempBruhes; } else { string projectno = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Project.ProjectNO; Pin p = SQliteDbContext.GetOnePin(tempEp.Name.Substring(1, tempEp.Name.Length - 1), projectno); if (p == null) { return; } p.PinEX = canvas.RenderSize.Width; p.PinEY = canvas.RenderSize.Height; p.PinSX = Canvas.GetLeft(tempEp); p.PinSY = Canvas.GetTop(tempEp); p.Radius = tempEp.ActualHeight; (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pin = p; bool isrelay = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.CablePaper.IsSafeBox == 1; CodeWindow codeWindow = new CodeWindow(isrelay); codeWindow.IsModify = true; codeWindow.ShowDialog(); // tempEp.Name ="P"+ p.PinCode; } } }