예제 #1
0
        public TwoColumnCell(CGRect tableViewBounds, bool isHeader = false)
        {
            if (isHeader)
            {
                Id = "HeaderCell";
            }

            var w = tableViewBounds.Width;

            var left  = w * 70 / 100 + 5;
            var right = w * 30 / 100;

            const float cellHeight = 60;

            const float y = 0;

            var cell = new UITableViewCell(UITableViewCellStyle.Default, Id)
            {
                Frame          = new CGRect(0, 0, w, cellHeight),
                SelectionStyle = UITableViewCellSelectionStyle.Gray,
                //if you want the selected row effect :S
                UserInteractionEnabled = false
            };

            // I couldn't set the padding, so, x = 15, and so on
            LeftValue = new UILabel(new CGRect(15, y, left, cellHeight))
            {
                LineBreakMode = UILineBreakMode.TailTruncation
            };

            RightValue = new UILabel(new CGRect(left + 5, y, right - 5, cellHeight))
            {
                LineBreakMode = UILineBreakMode.TailTruncation
            };

            if (isHeader)
            {
                cell.AddSubviews(LeftValue, RightValue);
            }
            else
            {
                cell.AddSubviews(LeftValue, GetVerticalSep(left, cellHeight - 19), RightValue);
            }

            Add(cell);
        }
예제 #2
0
        public MultiColumnCell(CGRect tableViewBounds, Tuple <string, int>[] labelsWidth, bool isHeader = false)
        {
            if (isHeader)
            {
                Id = "HeaderCell";
            }

            var w = tableViewBounds.Width;

            var previous = 0.0;

            var sepxpos = 0.0;

            var limit = labelsWidth.Length - 1;

            var separators = new UIView[limit];

            var views = new UIView[labelsWidth.Length];

            for (int i = 0; i < labelsWidth.Length; i++)
            {
                var lw = labelsWidth[i];

                var cw = w * lw.Item2 / 100;

                var x = previous < 1 ? 15 : previous + 3;

                previous += cw;

                var label = new UILabel(new CGRect(x, Y, cw, CellHeight))
                {
                    LineBreakMode = UILineBreakMode.TailTruncation,
                    Text          = lw.Item1
                };

                views[i] = label;

                if (!isHeader && i < limit)
                {
                    sepxpos      += cw;
                    separators[i] = GetVerticalSep(sepxpos, CellHeight - 16);
                }
            }


            var cell = new UITableViewCell(UITableViewCellStyle.Default, Id)
            {
                Frame                  = new CGRect(0, 0, w, CellHeight),
                SelectionStyle         = UITableViewCellSelectionStyle.Gray,
                UserInteractionEnabled = false
            };

            if (!isHeader)
            {
                cell.AddSubviews(separators);
            }

            cell.AddSubviews(views);

            Add(cell);
        }
            public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                if (indexPath.Section == 0) {
                    var infocell = new UITableViewCell ();
                    if (controller._controllerMode == 2) {
                        var inform = AppApi.GetSheets ().DataStudent.First (x => x.Id == editModel.SheetId);
                        //Customizing the progress bar
                        float sumWordAnswers = inform.Bad + inform.Good + inform.Nearly + inform.No;
                        var customProgressBar = UICustomProgressBar.Create ();
                        customProgressBar.Frame = new System.Drawing.RectangleF (10, 40, UIScreen.MainScreen.Bounds.Width-20, 4);
                        var width = customProgressBar.Frame.Width;
                        var height = customProgressBar.Frame.Height;

                        if (sumWordAnswers != 0) {

                            var badWidth = (inform.Bad / sumWordAnswers) * width;
                            var goodWidth = (inform.Good / sumWordAnswers) * width;
                            var noWidth = (inform.No / sumWordAnswers) * width;
                            var nearlyWidth = (inform.Nearly / sumWordAnswers) * width;

                            customProgressBar.ProgressBarRed = new System.Drawing.RectangleF (0, 2, badWidth, height);
                            customProgressBar.ProgressBarYellow = new System.Drawing.RectangleF (badWidth, 2, nearlyWidth, height);
                            customProgressBar.ProgressBarGreen = new System.Drawing.RectangleF (badWidth + nearlyWidth, 2, goodWidth, height);
                            customProgressBar.ProgressBarSilver = new System.Drawing.RectangleF (badWidth + nearlyWidth + goodWidth, 2, noWidth, height);

                        } else {
                            customProgressBar.ProgressBarRed = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarYellow = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarGreen = new System.Drawing.RectangleF (0, 0, 0, 0);
                            customProgressBar.ProgressBarSilver = new System.Drawing.RectangleF (0, 0, width, height);
                        }
                        infocell.AddSubview (customProgressBar);
                    } else {
                        UITextField title = new UITextField (new System.Drawing.RectangleF (15, 35, UIScreen.MainScreen.Bounds.Width - 130, 20));
                        title.Placeholder = "Введите название";
                        title.BorderStyle = UITextBorderStyle.RoundedRect;
                        if (editModel != null)
                            title.Text = editModel.Name;

                        UIButton save = new UIButton (new System.Drawing.RectangleF (title.Frame.Right + 5, 35, 100, 20));
                        save.SetTitle ("Сохранить", UIControlState.Normal);
                        save.BackgroundColor = UIColor.FromRGB (15, 83, 250);

                        save.TouchUpInside += (object sender, EventArgs e) => {

                        };

                        infocell.AddSubviews (new UIView[]{ title, save });
                    }

                    return infocell;
                }

                var cell = UIWordEdit.Create (); //tableView.DequeueReusableCell (UIWordEdit.Key, indexPath) as UIWordEdit;
                // if there are no cells to reuse, create a new one
                //if (cell == null)
                //	cell = new UIListWordCell (UITableViewCellStyle.Default, cellIdentifier);

                var oneItem = model.Data [indexPath.Row];
                cell.Id = oneItem.Id;
                cell.Russian = oneItem.Russian;
                cell.Transcr = oneItem.Transcription;
                cell.Example = oneItem.Description;
                cell.English = oneItem.English;
                cell.EditBtmEvent = (object sender, EventArgs e) => {
                    controller.Edit (model.Data [indexPath.Row]);
                };
                cell.DelBtmEvent = (object sender, EventArgs e) => {
                    if (!AppApi.DeleteWord (model.Data [indexPath.Row].Id))
                        return;
                    model.Data.RemoveAt (indexPath.Row);
                    tableView.DeleteRows (new NSIndexPath[]{ indexPath }, UITableViewRowAnimation.Fade);
                };

                if (controller._controllerMode == 2)
                    cell.DisableControls = true;

                return cell;
            }