public DialogLedProperty(EPatternDispMode mode, LedProperty led, int stringMax, int ledMax)
        {
            this.mode = mode;
            this.led  = led;

            InitializeComponent();
            Initialize(stringMax, ledMax);
        }
 private void CopyLedProperty(LedProperty from, LedProperty to)
 {
     to.RecNo       = from.RecNo;
     to.Type        = from.Type;
     to.X           = from.X;
     to.Y           = from.Y;
     to.StringIndex = from.StringIndex;
     to.LedIndex    = from.LedIndex;
     to.TurnOn      = from.TurnOn;
     to.Measuring   = from.Measuring;
 }
示例#3
0
        public PatternRow(int index, bool shortText = true)
        {
            Index = index;
            Leds  = new LedProperty[100];

            for (int i = 0; i < 100; i++)
            {
                Leds[i]   = new LedProperty(shortText);
                Leds[i].X = i;
                Leds[i].Y = index;
            }
        }
        private void patternGridView_DoubleClick(object sender, EventArgs e)
        {
            GridView         view = sender as GridView;
            DXMouseEventArgs ea   = e as DXMouseEventArgs;
            GridHitInfo      hit  = view.CalcHitInfo(ea.Location);

            if (hit == null)
            {
                return;
            }
            if (ReadOnly == true)
            {
                return;
            }

            if (hit.HitTest == GridHitTest.RowCell)
            {
                int         focusedRow = view.FocusedRowHandle;
                int         focusedCol = view.FocusedColumn.AbsoluteIndex - 1;
                LedProperty led        = PatternRows[focusedRow].Leds[focusedCol];

                switch (mode)
                {
                case EPatternDispMode.String:
                    ShowLedDialog(led);
                    break;

                case EPatternDispMode.StringAndLamp:
                    if (led.Type != ELedType.Disabled)
                    {
                        ShowLedDialog(led);
                    }
                    break;
                }

                RefreshGridData();
            }
        }
        private void ShowLedDialog(LedProperty led)
        {
            LedProperty newLed = new LedProperty();

            CopyLedProperty(led, newLed);

            DialogLedProperty dialog = new DialogLedProperty(mode, newLed, StringCount, LedCount);

            dialog.Text = $"LED - X:{led.X + 1}, Y:{led.Y + 1}";

            try
            {
                dialog.ShowDialog();
            }
            finally
            {
                if (dialog.DialogResult == DialogResult.OK)
                {
                    if ((mode == EPatternDispMode.String) && (newLed.Type == ELedType.Enabled))
                    {
                        if (IsExistStringLedNo(newLed.StringIndex, newLed.LedIndex) == true)
                        {
                            MessageBox.Show("StringNo and LedNo are already existed!",
                                            AppRes.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            CopyLedProperty(newLed, led);
                        }
                    }
                    else
                    {
                        CopyLedProperty(newLed, led);
                    }
                }
            }
        }
        private void patternGridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
        {
            int      smuIndex = 0;
            GridView view     = sender as GridView;

            if (e == null)
            {
                return;
            }
            if (e.Column == null)
            {
                return;
            }
            if (e.Column.FieldName == "No")
            {
                return;
            }

            LedProperty led = PatternRows[e.RowHandle].Leds[e.Column.AbsoluteIndex - 1];

            e.Appearance.Font = patternNoFont;
            e.Appearance.Options.UseTextOptions = true;
            e.Appearance.TextOptions.VAlignment = (mode == EPatternDispMode.String) ? VertAlignment.Center : VertAlignment.Top;

            switch (led.Type)
            {
            case ELedType.Disabled:
                e.Appearance.BackColor = Color.White;
                break;

            case ELedType.Enabled:
                if ((stringToSmus.Count > 0) && (stringToSmus.Count >= led.StringIndex))
                {
                    smuIndex = stringToSmus[led.StringIndex - 1];
                    if (smuIndex != -1)
                    {
                        e.Appearance.BackColor = Color.FromKnownColor(AppRes.Properties.SmuColors[smuIndex]);
                    }
                }
                break;

            case ELedType.Black:
                e.Appearance.BackColor = Color.Black;
                break;
            }

            e.Appearance.ForeColor = Color.Black;
            e.DefaultDraw();

            if (mode == EPatternDispMode.StringAndLamp)
            {
                switch (led.Type)
                {
                case ELedType.Enabled:
                    e.Cache.DrawRectangle(e.Bounds.X + (e.Bounds.Width / 2 - 9), e.Bounds.Y + 22, 8, 8, Color.Gray, 1);
                    e.Cache.FillRectangle((led.TurnOn == true) ? Color.Red : Color.DarkGray,
                                          new Rectangle((e.Bounds.X + e.Bounds.Width / 2 - 8), e.Bounds.Y + 23, 6, 6));

                    e.Cache.DrawRectangle(e.Bounds.X + (e.Bounds.Width / 2 + 2), e.Bounds.Y + 22, 8, 8, Color.Gray, 1);
                    e.Cache.FillRectangle((led.Measuring == true) ? Color.Lime : Color.DarkGray,
                                          new Rectangle(e.Bounds.X + (e.Bounds.Width / 2 + 3), e.Bounds.Y + 23, 6, 6));
                    break;

                case ELedType.Black:
                    e.Cache.DrawRectangle(e.Bounds.X + (e.Bounds.Width / 2 - 4),
                                          e.Bounds.Y + (e.Bounds.Height / 2 + 4), 8, 8, Color.Gray, 1);
                    e.Cache.FillRectangle((led.Measuring == true) ? Color.Lime : Color.DarkGray,
                                          new Rectangle(e.Bounds.X + (e.Bounds.Width / 2 - 3), e.Bounds.Y + (e.Bounds.Height / 2 + 5), 6, 6));
                    break;
                }
            }

            e.Handled = true;
        }