コード例 #1
0
        private void Paperdata_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            PinEx pin = e.Row.Item as PinEx;

            if ((App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pins.Count(x => x.PhysicalChannel == pin.PhysicalChannel) > 1)
            {
                MessageBox.Show("物理地址不能重复!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            e.Cancel = true;
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tempEp != null)
            {
                tempEp.Fill = TempBruhes;
            }
            SelectedpinEx = (this.paperdata.SelectedItem as PinEx);
            if (SelectedpinEx == null)
            {
                return;
            }
            string name = "P" + SelectedpinEx.PinCode;

            // tempEp = canvas.FindName(name) as Ellipse;
            tempEp = GetChildObject <Ellipse>(canvas, name);
            if (tempEp != null)
            {
                TempBruhes  = tempEp.Fill;
                tempEp.Fill = Brushes.LawnGreen;
            }
        }
コード例 #4
0
        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;
                }
            }
        }