public void CommonInit() { // Create the text view and add it as a subview. We keep a weak reference // to that view afterwards for laying out the segment layers. text = new GraphTextView(new CGRect(0.0f, 0.0f, 32.0f, 112.0f)); AddSubview(text); // Create a mutable array to store segments, which is required by -addSegment segments = new List <GraphViewSegment> (); // Create a new current segment, which is required by -addX:y:z and other methods. // This is also a weak reference (we assume that the 'segments' array will keep the strong reference). current = AddSegment(); }
public void CommonInit () { // Create the text view and add it as a subview. We keep a weak reference // to that view afterwards for laying out the segment layers. text = new GraphTextView (new CGRect (0.0f, 0.0f, 32.0f, 112.0f)); AddSubview (text); // Create a mutable array to store segments, which is required by -addSegment segments = new List<GraphViewSegment> (); // Create a new current segment, which is required by -addX:y:z and other methods. // This is also a weak reference (we assume that the 'segments' array will keep the strong reference). current = AddSegment (); }
// The initial position of a segment that is meant to be displayed on the left side of the graph. // This positioning is meant so that a few entries must be added to the segment's history before it becomes // visible to the user. This value could be tweaked a little bit with varying results, but the X coordinate // should never be larger than 16 (the center of the text view) or the zero values in the segment's history // will be exposed to the user. GraphViewSegment AddSegment() { // Create a new segment and add it to the segments array. GraphViewSegment segment = new GraphViewSegment(); segments.Insert(0, segment); //Ensure that newly added segment layers are placed after the text view's layer so that the text view // always renders above the segment layer. Layer.InsertSublayerBelow(segment.Layer, text.Layer); // Console.WriteLine (this.Layer.InsertSublayerBelow (segment.layer, text.Layer)); // Position it properly //segment.layer.Position = kSegmentInitialPosition; segment.Layer.Position = kSegmentInitialPosition; return(segment); }
void RecycleSegment() { // We start with the last object in the segments array, as it should either be visible onscreen, // which indicates that we need more segments, or pushed offscreen which makes it eligable for recycling. int lastIndex = segments.Count - 1; GraphViewSegment lastObj = segments [lastIndex]; //Console.WriteLine(Layer.Bounds); if (lastObj.IsVisibleInRect(Layer.Bounds)) { current = AddSegment(); } else { lastObj.Reset(); lastObj.Layer.Position = kSegmentInitialPosition; segments.Insert(0, lastObj); segments.Remove(lastObj); //And make it our current segment current = lastObj; } }
public LayerDelegate(GraphViewSegment parent) { _parent = parent; }
public LayerDelegate (GraphViewSegment parent) { _parent = parent; }
void RecycleSegment () { // We start with the last object in the segments array, as it should either be visible onscreen, // which indicates that we need more segments, or pushed offscreen which makes it eligable for recycling. int lastIndex = segments.Count - 1; GraphViewSegment lastObj = segments [lastIndex]; //Console.WriteLine(Layer.Bounds); if (lastObj.IsVisibleInRect (Layer.Bounds)) { current = AddSegment (); } else { lastObj.Reset (); lastObj.Layer.Position = kSegmentInitialPosition; segments.Insert (0, lastObj); segments.Remove (lastObj); //And make it our current segment current = lastObj; } }
// The initial position of a segment that is meant to be displayed on the left side of the graph. // This positioning is meant so that a few entries must be added to the segment's history before it becomes // visible to the user. This value could be tweaked a little bit with varying results, but the X coordinate // should never be larger than 16 (the center of the text view) or the zero values in the segment's history // will be exposed to the user. GraphViewSegment AddSegment () { // Create a new segment and add it to the segments array. GraphViewSegment segment = new GraphViewSegment (); segments.Insert (0, segment); //Ensure that newly added segment layers are placed after the text view's layer so that the text view // always renders above the segment layer. Layer.InsertSublayerBelow (segment.Layer, text.Layer); // Console.WriteLine (this.Layer.InsertSublayerBelow (segment.layer, text.Layer)); // Position it properly //segment.layer.Position = kSegmentInitialPosition; segment.Layer.Position = kSegmentInitialPosition; return segment; }