示例#1
0
        private void SetColor(Gates.AbstractGate ag)
        {
            ChartLine cl = chartLines[ag];

            if (ag.NumberOfInputs > 0)
            {
                cl.Stroke = Brushes.Blue;
            }
            else
            {
                cl.Stroke = Brushes.Red;
            }

            if (ag is Gates.IOGates.Clock)
            {
                cl.Stroke = Brushes.Green;
            }

            if (ag is Gates.IOGates.AbstractNumeric)
            {
                if (ag.NumberOfInputs > 0)
                {
                    cl.Stroke = Brushes.DarkBlue;
                }
                else
                {
                    cl.Stroke = Brushes.DarkRed;
                }
            }

            chartLabels[ag].Foreground = cl.Stroke;
        }
示例#2
0
        private void AddGate(Gates.AbstractGate ag)
        {
            if (chartLines.ContainsKey(ag))
            {
                // re-activate previously deleted gate
                chartLines[ag].JumpToOffset(((btnPause.IsChecked.Value ? beginPause : DateTime.Now) - begin - paused).TotalSeconds);
                chartLines[ag].IsPaused = btnPause.IsChecked.Value;
                SetColor(ag);
            }
            else if (ag is Gates.IOGates.UserIO ||
                     ag is Gates.IOGates.Clock ||
                     ag is Gates.IOGates.AbstractNumeric)
            {
                double max = 1;
                if (ag is Gates.IOGates.AbstractNumeric)
                {
                    max = ((Gates.IOGates.AbstractNumeric)ag).MaxValue;
                }

                // if the view is paused, base the offset on the start of pause
                // rather than current time
                // adjust by when the view began and how long total pause time
                // which doesn't include current pause
                ChartLine cl = new ChartLine(0, max,
                                             ((btnPause.IsChecked.Value ? beginPause : DateTime.Now) - begin - paused).TotalSeconds);
                cl.Height = 45;



                cl.IsPaused = btnPause.IsChecked.Value;
                lbLines.Items.Add(cl);
                cl.MajorLine   = tickRuler.MajorLine;
                chartLines[ag] = cl;
                TextBlock tb = new TextBlock();
                tb.Height = 15;
                tb.Margin = new Thickness(5, 15, 0, 15);

                lbLineLabels.Items.Add(tb);
                chartLabels[ag] = tb;

                SetColor(ag);
                SetLabel(ag);

                ag.PropertyChanged += ag_PropertyChanged;

                slZoom_ValueChanged(null, null);     // reset the log value for the new line
            }
        }