Ejemplo n.º 1
0
        public void SelectSegment(ITSegment segment)
        {
            if (indexOfSelectedSegment != -1)
            {
                ITSegment previousSelectedSegment = segments[indexOfSelectedSegment];
                previousSelectedSegment.Selected = false;
            }

            indexOfSelectedSegment = segment.Index;
            segment.Selected       = true;
            SendActionForControlEvents(UIControlEvent.ValueChanged);
        }
Ejemplo n.º 2
0
        public void AddSegmentWithTitle(string title, UIImage selectedImage, UIImage normalImage)
        {
            ITSegment segment = new ITSegment(separatorWidth, verticalMargin, selectedColor, normalColor, selectedTextColor, normalTextColor, titleFont);

            segment.Index = segments.Count;
            segments.Add(segment);
            updateFrameForSegments();

            segment.Parent        = this;
            segment.Title         = title;
            segment.SelectedImage = selectedImage;
            segment.NormalImage   = normalImage;

            AddSubview(segment);
            numberOfSegments = segments.Count;
        }
Ejemplo n.º 3
0
        private void drawSeparatorWithContext(CGContext context)
        {
            context.SaveState();

            if (segments.Count > 1)
            {
                CGPath    path    = new CGPath();
                ITSegment segment = segments[0];

                if (organizeMode == ITSegmentOrganizeMode.ITSegmentOrganizeModeHorizontal)
                {
                    double originX = (double)Frame.Size.Width + separatorWidth / 2.0;
                    for (int index = 1; index < segments.Count; ++index)
                    {
                        segment = segments[index];

                        path.MoveToPoint((nfloat)originX, (nfloat)0.0);
                        path.AddLineToPoint((nfloat)originX, Frame.Size.Height);
                        originX += Frame.Size.Width + separatorWidth;
                    }
                }
                else
                {
                    double originY = Frame.Size.Height + separatorWidth / 2.0;
                    for (int index = 1; index < segments.Count; ++index)
                    {
                        segment = segments[index];
                        path.MoveToPoint((nfloat)0.0, (nfloat)originY);
                        path.AddLineToPoint(Frame.Size.Width, (nfloat)originY);
                        originY += Frame.Size.Height + separatorWidth;
                    }
                }

                context.AddPath(path);
                context.SetStrokeColor(separatorColor.CGColor);
                context.SetLineWidth((nfloat)separatorWidth);
                context.DrawPath(CGPathDrawingMode.Stroke);
            }

            context.RestoreState();
        }
Ejemplo n.º 4
0
        private void updateFrameForSegments()
        {
            if ((segments != null) && (segments.Count != 0))
            {
                int count = segments.Count;
                if (count > 1)
                {
                    if (organizeMode == ITSegmentOrganizeMode.ITSegmentOrganizeModeHorizontal)
                    {
                        double segmentWidth = (Frame.Size.Width - separatorWidth * (count - 1)) / count;
                        double originX      = 0.0;
                        foreach (ITSegment segment in segments)
                        {
                            segment.Frame = new CGRect(originX, 0.0, segmentWidth, Frame.Size.Height);
                            originX      += segmentWidth + separatorWidth;
                        }
                    }
                    else
                    {
                        double segmentHeight = (Frame.Size.Height - separatorWidth * (count - 1)) / count;
                        double originY       = 0.0;
                        foreach (ITSegment segment in segments)
                        {
                            segment.Frame = new CGRect(0.0, originY, Frame.Size.Width, segmentHeight);
                            originY      += segmentHeight + separatorWidth;
                        }
                    }
                }
                else
                {
                    ITSegment segment = segments[0];
                    segment.Frame = new CGRect(0.0, 0.0, Frame.Size.Width, Frame.Size.Height);
                }
            }

            SetNeedsDisplay();
        }