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; }
private void SetLabel(Gates.AbstractGate ag) { string value = ag.Name; TextBlock lblName = chartLabels[ag]; // I want to make sure the label fits within the area alloted. // If not, shorten it until it does, add ... FormattedText ft; string txtForLbl = value; ft = new FormattedText(txtForLbl, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(lblName.FontFamily, lblName.FontStyle, lblName.FontWeight, lblName.FontStretch), lblName.FontSize, lblName.Foreground); bool modified = false; while (ft.Width > 70) { modified = true; txtForLbl = txtForLbl.Substring(0, txtForLbl.Length - 1); ft = new FormattedText(txtForLbl + "...", CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(lblName.FontFamily, lblName.FontStyle, lblName.FontWeight, lblName.FontStretch), lblName.FontSize, lblName.Foreground); } if (modified) { txtForLbl += "..."; } lblName.Text = txtForLbl; chartLines[ag].ToolTip = value; }
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 } }
public ConnectedWire(Gates.AbstractGate originGate, Gate.TerminalID origin, Gates.AbstractGate destGate, Gate.TerminalID dest) :base() { if (origin.isInput || !dest.isInput) { throw new ArgumentException("Can only connect output (origin) to input (dest)"); } Value = false; this.originGate = originGate; this.destGate = destGate; this.origin = origin; this.dest = dest; //originGate.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(originGate_PropertyChanged); originGate.PropertyChanged += EventDispatcher.CreateBatchDispatchedHandler(originGate, originGate_PropertyChanged); Connect(); }
private void ag_PropertyChanged(object sender, PropertyChangedEventArgs e) { Gates.AbstractGate ag = sender as Gates.AbstractGate; DateTime dt = DateTime.Now; Dispatcher.BeginInvoke(new Action(() => { if (e.PropertyName == "Name") { SetLabel(ag); } else { if (chartLines[ag].Stroke != Brushes.Gray) { chartLines[ag].DataArrives(GetValue(ag), dt); } } })); }
public ChangeNumInputs(Gates.Circuit c, Gates.AbstractGate original, Gates.AbstractGate replacement) { this.c = c; this.orig_gate = original; this.new_gate = replacement; }
public GTerm(Gates.AbstractGate gate, double offset, Gate.Position pos) { this.pos = pos; this.offset = offset; this.gate = gate; }