Exemple #1
0
        private void MenuItem_Update(object sender, RoutedEventArgs e)
        {
            int count = SQliteDbContext.CheckAddressSingle(SelectedpinEx);
            int ct    = SQliteDbContext.GetOnePin(SelectedpinEx.PinCode, SelectedpinEx.ProjectNO).physicalChannel;

            if (count >= 1 && ct != SelectedpinEx.physicalChannel)
            {
                MessageBox.Show("物理地址已经被占用!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return;
            }
            int rs = SQliteDbContext.UpdatOnePin(SelectedpinEx);
        }
Exemple #2
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;
                }
            }
        }
        private bool CheckPin()
        {
            this.pin = (App.Current.Resources["Locator"] as ViewModelLocator).Paper.Pin;
            if (pin.PinCode.Trim().Length == 0)
            {
                MessageBox.Show("引脚编号不能为空!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            if (pin.physicalChannel <= 0)
            {
                MessageBox.Show("物理地址必须为大于零的整数!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            if (pin.IsSafeBox && pin.SafeBoxName.Trim().Length == 0)
            {
                MessageBox.Show("元件名称不能为空!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }
            else if (pin.IsSafeBox && !(pin.SafeBoxName.Trim().Contains("F") || pin.SafeBoxName.Trim().Contains("K")))
            {
                MessageBox.Show("请输入正确的元件名称(继电器—K 保险芯—F)!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }
            else if (pin.IsSafeBox)
            {
                if (!IsModify && SQliteDbContext.CheckSafeBoxNameSingle(pin) > 0)
                {
                    MessageBox.Show("元器件名称不能重复", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(false);
                }
                else if (IsModify)
                {
                    if (SQliteDbContext.GetOnePin(pin.PinCode, pin.ProjectNO).safeBoxName != pin.safeBoxName && SQliteDbContext.CheckSafeBoxNameSingle(pin) > 0)
                    {
                        MessageBox.Show("元器件名称不能重复", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return(false);
                    }
                }
            }

            if (SQliteDbContext.CheckCodeSingle(pin) && !IsModify)
            {
                MessageBox.Show("引脚编号不重复!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            if (SQliteDbContext.CheckAddressSingle(pin) >= 1)
            {
                MessageBox.Show("物理地址已经被占用!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            if (SQliteDbContext.CheckAddressSingle(pin) > 1 && SQliteDbContext.GetOnePin(pin.PinCode, pin.ProjectNO).physicalChannel != pin.physicalChannel && IsModify)
            {
                MessageBox.Show("物理地址已经被占用!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);

                return(false);
            }
            return(true);
        }