/* * Updates any 'special' text elements */ public virtual void UpdateText() { foreach (var textObject in Children.OfType <TextBlock>()) { if (textObject.Name == "_Model") { textObject.Text = ComponentModel; } else if (textObject.Name == "_Value") { textObject.Text = ComponentValue.ToString(); } } }
//Populate a TreeViewItem with items following a preferred value series that represent a given component; between the magnitudes specified by magBegin and magEnd private void PopulateMenu(TreeViewItem root, double[] series, int magBegin, int magEnd, string suffix, string componentType) { for (int mag = magBegin; mag <= magEnd; mag++) { foreach (double seriesValue in series) { double val = seriesValue * Math.Pow(10, mag); Quantity q = new Quantity(); q.Val = val; TreeViewItem newItem = new TreeViewItem(); newItem.Header = new ComponentData(componentType, val, q.ToString() + suffix); root.Items.Add(newItem); } } }
public void UpdateGrid() { GeometryGroup gridLines = new GeometryGroup(); double lineX = 0; Quantity currentTime = new Quantity(); currentTime.Val = 0; HLabels.Children.Clear(); while (lineX >= -GraphArea.ActualWidth) { gridLines.Children.Add(new LineGeometry(new Point(GraphArea.ActualWidth + lineX, 0), new Point(GraphArea.ActualWidth + lineX, GraphArea.ActualHeight))); TextBlock label = new TextBlock(); label.HorizontalAlignment = HorizontalAlignment.Left; label.TextAlignment = TextAlignment.Center; label.Text = currentTime.ToString(); label.RenderTransformOrigin = new Point(0.5, 0.5); label.RenderTransform = new TranslateTransform(lineX + GraphArea.ActualWidth + 50, 0); HLabels.Children.Add(label); lineX -= VerticalGridSpacing; currentTime.Val -= SecPerDiv.Val; } double lineY = GraphArea.ActualHeight / 2; Quantity currentVoltsA = new Quantity(); currentVoltsA.Val = -VoltsOffset; Quantity currentVoltsB = new Quantity(); currentVoltsB.Val = -VoltsOffset; VLabels.Children.Clear(); while (lineY > 0) { gridLines.Children.Add(new LineGeometry(new Point(0, lineY), new Point(GraphArea.ActualWidth, lineY))); TextBlock label1 = new TextBlock(); label1.HorizontalAlignment = HorizontalAlignment.Right; label1.Text = currentVoltsA.ToString(); label1.RenderTransformOrigin = new Point(1, 0.5); label1.RenderTransform = new TranslateTransform(-5, lineY - 10); VLabels.Children.Add(label1); /* if (lineY != (GraphArea.ActualHeight - lineY)) * {*/ gridLines.Children.Add(new LineGeometry(new Point(0, GraphArea.ActualHeight - lineY), new Point(GraphArea.ActualWidth, GraphArea.ActualHeight - lineY))); TextBlock label2 = new TextBlock(); label2.HorizontalAlignment = HorizontalAlignment.Right; label2.Text = currentVoltsB.ToString(); label2.RenderTransformOrigin = new Point(1, 0.5); label2.RenderTransform = new TranslateTransform(-5, GraphArea.ActualHeight - lineY - 10); VLabels.Children.Add(label2); //} lineY -= HorizontalGridSpacing; currentVoltsA.Val += VoltsPerDiv.Val; currentVoltsB.Val -= VoltsPerDiv.Val; } GraphGrid.Data = gridLines; }