Example #1
0
        public bool AddAppointment(string subject, string startStr, string endStr, string colorStr,
                                   string dateFormat)
        {
            if (m_calendar == null)
            {
                return(false);
            }
            SFAppointment appointment = new SFAppointment();

            appointment.Subject = (NSString)subject;
            DateTime dt = DateTime.ParseExact(startStr, dateFormat, null);

            appointment.StartTime = (NSDate)DateTime.SpecifyKind(dt, DateTimeKind.Local);
            dt = DateTime.ParseExact(endStr, dateFormat, null);
            appointment.EndTime = (NSDate)DateTime.SpecifyKind(dt, DateTimeKind.Local);
            appointment.AppointmentBackground = UtilsiOS.String2Color(colorStr);

            var appointments = m_calendar.Appointments;

            if (appointments == null)
            {
                appointments = new NSMutableArray();
            }
            appointments.Add(appointment);
            m_calendar.Appointments = appointments;

            return(true);
        }
Example #2
0
        public virtual void AddText(string text, string colorStr, double alpha = 1.0)
        {
            if (!(m_viewX is UITextView))
            {
                return;
            }
            var textView = m_viewX as UITextView;
            NSMutableAttributedString attrText = new NSMutableAttributedString(textView.AttributedText);

            var atts = new UIStringAttributes();

            atts.ForegroundColor = UtilsiOS.String2Color(colorStr, alpha);
            var attrTextAdd = new NSAttributedString(text, atts);

            //attributedString.BeginEditing();
            //attributedString.AddAttribute(UIStringAttributeKey.ForegroundColor, atts.ForegroundColor, new NSRange(0, 10));
            //attributedString.AddAttribute(UIStringAttributeKey.Font, UIFont.GetPreferredFontForTextStyle(UIFontTextStyle.Headline), new NSRange(0, 10));
            //attributedString.EndEditing();

            if (attrText.Length > 0)
            {
                attrText.Append(new NSAttributedString("\n"));
            }
            attrText.Append(attrTextAdd);
            textView.AttributedText = attrText;
        }
Example #3
0
        public virtual bool SetFontColor(string colorStr)
        {
            if (ViewX == null)
            {
                return(false);
            }

            UIColor color = UtilsiOS.String2Color(colorStr);

            if (ViewX is UIButton)
            {
                UIButton button = (UIButton)ViewX;
                button.SetTitleColor(color, UIControlState.Normal);
            }
            else if (ViewX is UILabel)
            {
                ((UILabel)ViewX).TextColor = color;
            }
            else if (ViewX is UITextField)
            {
                ((UITextField)ViewX).TextColor = color;
            }
            else if (ViewX is UITextView)
            {
                ((UITextView)ViewX).TextColor = color;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Example #4
0
        public override bool SetFontColor(string colorStr)
        {
            UIColor color = UtilsiOS.String2Color(colorStr);

            m_fontColor = color;

            if (m_picker != null)
            {
                m_picker.HeaderTextColor         = color.ToColor();
                m_picker.ColumnHeaderTextColor   = color.ToColor();
                m_picker.UnSelectedItemTextColor = color.ToColor();
                m_picker.SelectedItemTextColor   = color.ToColor();
            }
            else if (m_chart != null && m_chart.Title != null)
            {
                m_chart.Title.TextColor = color;
            }
            else if (m_stepper != null)
            {
                m_stepper.TextColor         = color;
                m_stepper.BorderColor       = color;
                m_stepper.UpdownButtonColor = color;

                var settingsUp = m_stepper.IncrementButtonSettings;
                settingsUp.ButtonFontColor        = color;
                m_stepper.IncrementButtonSettings = settingsUp;
                var settingsDown = m_stepper.DecrementButtonSettings;
                settingsDown.ButtonFontColor      = color;
                m_stepper.DecrementButtonSettings = settingsDown;
            }
            else if (m_barcode != null)
            {
                m_barcode.TextColor = color;
            }
            else if (m_digitalGauge != null)
            {
                //m_digitalGauge.DimmedSegmentAlpha = 30;
                m_digitalGauge.DimmedSegmentColor = color;
                m_digitalGauge.CharacterColor     = color;
            }
            else if (m_circularGauge != null && m_circularGauge.Headers.Count > 0)
            {
                m_circularGauge.Headers[0].TextColor = color;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Example #5
0
        public override bool SetBackgroundColor(string colorStr, double alpha = 1.0)
        {
            var color = UtilsiOS.String2Color(colorStr, alpha);

            m_bgColor = color;

            if (m_picker != null)
            {
                m_picker.BackgroundColor = color.ToColor();
            }
            else if (m_chart != null)
            {
                m_chart.BackgroundColor = color;
            }
            else if (m_stepper != null)
            {
                m_stepper.BackgroundColor = color;
            }
            else if (m_grid != null)
            {
                m_grid.BackgroundColor = color;
            }
            else if (m_barcode != null)
            {
                m_barcode.BackgroundColor = color;
            }
            else if (m_digitalGauge != null)
            {
                m_digitalGauge.BackgroundColor = color;
            }
            else if (m_circularGauge != null)
            {
                m_circularGauge.BackgroundColor = color;
                m_circularScale.BackgroundColor = color;
                //m_needlePointer.BackgroundColor = color;
                //m_rangePointer1.BackgroundColor = color;
                //m_rangePointer2.BackgroundColor = color;
            }
            else if (m_busyIndicator != null)
            {
                m_busyIndicator.BackgroundColor = color;
            }
            else
            {
                ViewX.BackgroundColor = color;
            }

            return(true);
        }
Example #6
0
        public virtual bool SetBackgroundColor(string colorStr, double alpha = 1.0)
        {
            if (ViewX == null)
            {
                return(false);
            }
            if (colorStr.Equals("transparent", StringComparison.OrdinalIgnoreCase))
            {
                ViewX.Opaque = true;
                alpha        = 0.0;
            }
            else
            {
                ViewX.Opaque = false;
            }

            var color = UtilsiOS.String2Color(colorStr, alpha);

            ViewX.BackgroundColor = color;

            return(true);
        }
Example #7
0
        public static void SetBgColor(string colorStr, double alpha = 1.0)
        {
            var color = UtilsiOS.String2Color(colorStr, alpha);

            m_view.BackgroundColor = color;
        }
Example #8
0
        public void CreateCombobox(CGRect rect, string argument)
        {
            UIView parent = GetParentView();

            WidgetType = UIVariable.UIType.COMBOBOX;

            UIView mainView   = AppDelegate.GetCurrentView();
            int    mainHeight = (int)mainView.Frame.Size.Height;
            int    mainWidth  = (int)mainView.Frame.Size.Width;

            int pickerHeight = Math.Min(mainHeight / 3, 320);
            int pickerWidth  = Math.Min(mainWidth, 640);
            int pickerY      = mainHeight - pickerHeight + 20;

            m_picker  = new UIPickerView();
            m_button  = new UIButton();
            m_button2 = new UIButton();

            m_button.Frame = rect;

            m_picker.Frame  = new CGRect(0, pickerY, pickerWidth, pickerHeight);
            m_button2.Frame = new CGRect(0, pickerY - 20, pickerWidth, 40);

            string alignment = "", color1 = "", color2 = "", closeLabel = "";

            Utils.Extract(argument, ref alignment, ref color1, ref color2, ref closeLabel);
            m_alignment = alignment;
            Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                UtilsiOS.GetAlignment(alignment);

            m_viewY       = new UIView();
            m_viewY.Frame = new CGRect(0, 0, mainWidth, mainHeight);

            TypePickerViewModel model = new TypePickerViewModel(AppDelegate.GetCurrentController());

            /*model.RowSelected += (row) => {
             * string text = model.SelectedText;
             * SetText(text, alignment, true);
             * ActionDelegate?.Invoke(WidgetName, text);
             *
             * m_viewY.RemoveFromSuperview();
             * };*/
            m_picker.ShowSelectionIndicator = true;
            m_picker.Hidden = true;
            m_picker.Model  = model;

            if (!string.IsNullOrEmpty(color1))
            {
                m_viewY.BackgroundColor = UtilsiOS.String2Color(color1);
                if (string.IsNullOrEmpty(color2))
                {
                    color2 = color1;
                }
                m_picker.BackgroundColor = UtilsiOS.String2Color(color2);
            }

            //m_button.SetTitle(extraLabel, UIControlState.Normal);
            m_button.BackgroundColor = UIColor.Clear;
            m_button.SetTitleColor(UIColor.Black, UIControlState.Normal);
            m_button.Hidden             = false;
            m_button.Layer.BorderWidth  = 1;
            m_button.Layer.CornerRadius = 4;
            m_button.Layer.BorderColor  = UIColor.LightGray.CGColor;
            UIImage img = UtilsiOS.CreateComboboxImage(rect);

            m_button.SetBackgroundImage(img, UIControlState.Normal);
            m_button.ImageView.ClipsToBounds = true;
            m_button.ContentMode             = UIViewContentMode.Right;
            m_button.HorizontalAlignment     = al.Item1;
            m_button.TouchUpInside          += (sender, e) => {
                ResetCombos();
                m_button2.Hidden = false;
                m_picker.Hidden  = false;

                model = m_picker.Model as TypePickerViewModel;

                string text = GetText();
                int    row  = model.StringToRow(text);
                model.Selected(m_picker, (int)row, 0);
                mainView.BecomeFirstResponder();
                mainView.AddSubview(m_viewY);
            };

            if (string.IsNullOrEmpty(closeLabel))
            {
                closeLabel = "X";
            }
            m_button2.SetTitle(closeLabel + "\t", UIControlState.Normal);
            m_button2.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            m_button2.BackgroundColor     = UIColor.FromRGB(100, 100, 100);
            m_button2.SetTitleColor(UIColor.White, UIControlState.Normal);
            m_button2.Hidden         = true;
            m_button2.TouchUpInside += (sender, e) => {
                m_button2.Hidden = true;
                m_picker.Hidden  = true;
                string text = model.SelectedText;
                SetText(text, alignment, true /* triggered */);
                ActionDelegate?.Invoke(WidgetName, text);

                m_viewY.RemoveFromSuperview();
                mainView.BecomeFirstResponder();
            };

            mainView.AddSubview(m_button);

            m_viewY.AddSubview(m_picker);
            m_viewY.AddSubview(m_button2);

            m_viewX     = m_button;
            m_viewX.Tag = ++m_currentTag;
        }
Example #9
0
        public virtual bool SetValue(string arg1, string arg2 = "")
        {
            double val = Utils.ConvertToDouble(arg1);

            CurrVal = val;
            if (m_viewY is UIStepper)
            {
                UIStepper stepper = m_viewY as UIStepper;
                stepper.Value = val;
                UIView[] subviews = m_viewX.Subviews;
                foreach (UIView view in subviews)
                {
                    if (view is UILabel)
                    {
                        UILabel label = view as UILabel;
                        label.Text = CurrVal.ToString();
                    }
                }
            }
            else if (WidgetType == UIType.COMBOBOX)
            {
                switch (arg1)
                {
                case "alignment":
                    Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                        UtilsiOS.GetAlignment(arg2);
                    m_button.HorizontalAlignment = al.Item1;
                    break;

                case "backgroundcolorpicker":
                    m_picker.BackgroundColor = UtilsiOS.String2Color(arg2);
                    break;

                case "backgroundcolorbutton2":
                    m_button2.BackgroundColor = UtilsiOS.String2Color(arg2);
                    break;

                case "fontcolor2":
                    m_button2.SetTitleColor(UtilsiOS.String2Color(arg2), UIControlState.Normal);
                    break;

                case "text2":
                    m_button2.SetTitle(arg2 + "\t", UIControlState.Normal);
                    break;
                }
                if (string.IsNullOrEmpty(arg1) || arg1 == "value")
                {
                    SetComboboxText("", (int)val);
                }
            }
            else if (m_viewX is UISwitch)
            {
                ((UISwitch)m_viewX).On = (int)val == 1;
            }
            else if (m_viewX is UISlider)
            {
                ((UISlider)m_viewX).Value = (float)val;
            }
            else if (m_viewX is UIStepper)
            {
                ((UIStepper)m_viewX).Value = (float)val;
            }
            else if (m_viewX is UIPickerView)
            {
                UIPickerView picker = m_viewX as UIPickerView;
                picker.Select((int)val, 0, true);
                TypePickerViewModel model = picker.Model as TypePickerViewModel;
                model?.Selected(picker, (int)val, 0);
            }
            else if (m_viewX is UISegmentedControl)
            {
                ((UISegmentedControl)m_viewX).SelectedSegment = (nint)val;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Example #10
0
        public override bool SetValue(string arg1, string arg2 = "")
        {
            if (string.IsNullOrEmpty(arg2))
            {
                arg2 = arg1;
                arg1 = "value";
            }
            double valueNum = Utils.ConvertToDouble(arg2);

            if (m_circularGauge != null)
            {
                switch (arg1)
                {
                case "from":
                    m_circularScale.StartValue = (nfloat)valueNum;
                    break;

                case "to":
                    m_rangePointer2.Value    = (nfloat)valueNum;
                    m_circularScale.EndValue = (nfloat)valueNum;
                    break;

                case "step":
                    m_circularScale.Interval = (nfloat)valueNum;
                    break;

                case "value":
                    m_needlePointer.Value = (nfloat)valueNum;
                    break;

                case "start_range2":
                    m_rangePointer1.Value      = (nfloat)valueNum;
                    m_rangePointer2.RangeStart = (nfloat)valueNum;
                    break;

                case "start_angle":
                    m_circularScale.StartAngle = (nfloat)valueNum;
                    break;

                case "sweep_angle":
                    m_circularScale.SweepAngle = (nfloat)valueNum;
                    break;

                case "color_needle":
                    m_needlePointer.Color = UtilsiOS.String2Color(arg2);
                    break;

                case "radius_knob":
                    m_needlePointer.KnobRadius = (nfloat)valueNum;
                    break;

                case "color_knob":
                    m_needlePointer.KnobColor = UtilsiOS.String2Color(arg2);
                    break;

                case "color_labels":
                    m_circularScale.LabelColor           = UtilsiOS.String2Color(arg2);
                    m_circularGauge.Headers[0].TextColor = UtilsiOS.String2Color(arg2);
                    break;

                case "color_range1":
                    m_rangePointer1.Color = UtilsiOS.String2Color(arg2);
                    break;

                case "color_range2":
                    m_rangePointer2.Color = UtilsiOS.String2Color(arg2);
                    break;

                case "color_minorticks":
                    m_circularScale.MinorTickSettings.Color = UtilsiOS.String2Color(arg2);
                    break;

                case "color_majorticks":
                    m_circularScale.MajorTickSettings.Color = UtilsiOS.String2Color(arg2);
                    break;

                case "scale2_from":
                    CreateScale2IfNeeded();
                    m_circularScale2.StartValue = (nfloat)valueNum;
                    break;

                case "scale2_to":
                    CreateScale2IfNeeded();
                    m_circularScale2.EndValue = (nfloat)valueNum;
                    break;

                case "scale2_interval":
                    CreateScale2IfNeeded();
                    m_circularScale2.Interval = (nfloat)valueNum;
                    break;

                case "scale2_rimcolor":
                    CreateScale2IfNeeded();
                    m_circularScale2.RimColor = UtilsiOS.String2Color(arg2);
                    break;

                case "scale2_labelcolor":
                    CreateScale2IfNeeded();
                    m_circularScale2.LabelColor = UtilsiOS.String2Color(arg2);
                    break;
                }
            }
            else if (m_digitalGauge != null)
            {
                switch (arg1)
                {
                case "value":
                    m_digitalGauge.Value = (NSString)arg2;
                    break;
                }
            }
            else if (m_picker != null)
            {
                switch (arg1)
                {
                case "alignment":
                    Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                        UtilsiOS.GetAlignment(arg2);
                    m_alignment = al.Item2;
                    break;

                case "headerHeight":
                    m_picker.HeaderHeight = (nfloat)valueNum;
                    break;

                case "headerText":
                    m_picker.ShowHeader = true;
                    m_picker.HeaderText = (NSString)arg2;
                    break;

                case "colHeaderHeight":
                    m_picker.ColumnHeaderHeight = (nfloat)valueNum;
                    break;

                case "colHeaderText":
                    m_picker.ShowColumnHeader = true;
                    m_picker.ColumnHeaderText = (NSString)arg2;
                    break;

                case "index":
                    m_picker.SelectedIndex = (int)valueNum;
                    break;

                case "pickerMode":
                    m_picker.PickerMode = arg2.Equals("Default", StringComparison.OrdinalIgnoreCase) ?
                                          PickerMode.Default : PickerMode.Dialog;
                    break;
                }
            }
            else if (m_grid != null)
            {
                switch (arg1)
                {
                case "swipe_delete":
                    AddSwipeDelete();
                    break;

                case "swipe_edit":
                    AddSwipeEdit();
                    break;

                case "allow_drag":
                    m_grid.AllowDraggingRow = valueNum > 0;
                    break;

                case "allow_swipe":
                    m_grid.AllowSwiping = valueNum > 0;
                    break;

                case "allow_resize":
                    m_grid.AllowResizingColumn = valueNum > 0;
                    break;

                case "allow_sort":
                    m_grid.AllowSorting = valueNum > 0;
                    break;
                }
            }
            else if (m_barcode != null)
            {
                var settings39 = m_barcode.SymbologySettings as SFCode39Settings;
                if (settings39 != null)
                {
                    switch (arg1)
                    {
                    case "bar_height":
                        settings39.BarHeight = (nfloat)valueNum;
                        break;

                    case "bar_width":
                        settings39.NarrowBarWidth = (nfloat)valueNum;
                        break;
                    }
                }
            }
            else if (m_chart != null)
            {
                SFNumericalAxis numericalaxis = m_chart.SecondaryAxis as SFNumericalAxis;
                switch (arg1)
                {
                case "primary_axis":
                    m_chart.PrimaryAxis.Title.Text = (NSString)arg2;
                    break;

                case "secondary_axis":
                    m_chart.SecondaryAxis.Title.Text = (NSString)arg2;
                    break;

                case "x_min":
                    numericalaxis.Minimum = new NSNumber(valueNum);
                    break;

                case "x_max":
                    numericalaxis.Maximum = new NSNumber(valueNum);
                    break;

                case "x_interval":
                    numericalaxis.Interval = new NSNumber(valueNum);
                    break;
                }
            }
            else if (m_stepper != null)
            {
                switch (arg1)
                {
                case "min":
                    m_stepper.Minimum = (nfloat)valueNum;
                    break;

                case "max":
                    m_stepper.Maximum = (nfloat)valueNum;
                    break;

                case "step":
                    m_stepper.StepValue            = (nfloat)valueNum;
                    m_stepper.MaximumDecimalDigits = Utils.GetNumberOfDigits(arg2);
                    break;

                case "value":
                    m_stepper.Value = (nfloat)valueNum;
                    break;

                case "buttons":
                    switch (arg2)
                    {
                    case "left": m_stepper.SpinButtonAlignment = SFNumericUpDownSpinButtonAlignment.Left;
                        break;

                    case "right":
                        m_stepper.SpinButtonAlignment = SFNumericUpDownSpinButtonAlignment.Right;
                        break;

                    default: m_stepper.SpinButtonAlignment = SFNumericUpDownSpinButtonAlignment.Both;
                        break;
                    }
                    break;
                }
            }
            else if (m_busyIndicator != null)
            {
                if (arg1 == "bg_color")
                {
                    m_busyIndicator.BackgroundColor = UtilsiOS.String2Color(arg2);
                }
                else if (arg1 == "color")
                {
                    m_busyIndicator.Foreground = UtilsiOS.String2Color(arg2);
                }
                else if (arg1 == "secondary_color")
                {
                    m_busyIndicator.SecondaryColor = UtilsiOS.String2Color(arg2);
                }
                else if (arg1 == "duration")
                {
                    m_busyIndicator.Duration = (nfloat)valueNum;
                }
                else
                {
                    SetBusyIndicatorType(arg2);
                }
            }
            return(true);
        }
Example #11
0
        public override void AddData(List <string> data, string varName, string title, string extra)
        {
            if (m_grid != null)
            {
                if (title == "columns")
                {
                    m_model.AddColumns(data);
                }
                else if (title == "item")
                {
                    m_model.AddPoint(data);
                }
            }
            else if (m_chart != null)
            {
                var collection = new ObservableCollection <DataPoint>();
                for (int i = 0; i < data.Count - 1; i += 2)
                {
                    string coord = data[i];
                    double value = Utils.ConvertToDouble(data[i + 1]);
                    collection.Add(new DataPoint(coord, value));
                }
                if (SfType == SyncFusionType.DOUGHNUT_GRAPH)
                {
                    SFDoughnutSeries doughnutSeries = new SFDoughnutSeries();
                    doughnutSeries.ItemsSource     = collection;
                    doughnutSeries.XBindingPath    = "XValue";
                    doughnutSeries.YBindingPath    = "YValue";
                    doughnutSeries.EnableTooltip   = true;
                    doughnutSeries.EnableAnimation = true;
                    if (!string.IsNullOrEmpty(title))
                    {
                        //doughnutSeries.Label = title;
                        m_chart.Title.Text = (NSString)title;
                    }
                    doughnutSeries.DataMarker.ShowLabel    = true;
                    doughnutSeries.DataMarker.LabelContent = title == "values" ? SFChartLabelContent.YValue :
                                                             SFChartLabelContent.Percentage;
                    doughnutSeries.DataMarkerPosition = SFChartCircularSeriesLabelPosition.OutsideExtended;
                    doughnutSeries.LegendIcon         = SFChartLegendIcon.Circle;
                    if (!string.IsNullOrEmpty(extra))
                    {
                        var angles = extra.Split(new char[] { ',', ':' });
                        doughnutSeries.StartAngle = Utils.ConvertToDouble(angles[0]);
                        if (angles.Length > 1)
                        {
                            doughnutSeries.EndAngle = Utils.ConvertToDouble(angles[1]);
                        }
                    }
                    m_chart.Series.Add(doughnutSeries);
                }
                else if (SfType == SyncFusionType.SPLINE_GRAPH)
                {
                    SFSplineSeries splineSeries = new SFSplineSeries();
                    splineSeries.ItemsSource             = collection;
                    splineSeries.XBindingPath            = "XValue";
                    splineSeries.YBindingPath            = "YValue";
                    splineSeries.EnableTooltip           = true;
                    splineSeries.EnableAnimation         = true;
                    splineSeries.Label                   = title;
                    splineSeries.DataMarker.MarkerHeight = 5;
                    splineSeries.DataMarker.MarkerWidth  = 5;
                    splineSeries.DataMarker.ShowMarker   = true;
                    splineSeries.LegendIcon              = SFChartLegendIcon.Rectangle;
                    if (!string.IsNullOrEmpty(extra))
                    {
                        var colors = extra.Split(new char[] { ',', ':' });
                        splineSeries.Color = UtilsiOS.String2Color(colors[0]);
                        if (colors.Length > 1)
                        {
                            var color = UtilsiOS.String2Color(colors[1]);
                            splineSeries.DataMarker.MarkerColor = color;
                        }
                    }
                    m_chart.Series.Add(splineSeries);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    m_chart.Legend.Visible      = true;
                    m_chart.Legend.DockPosition = SFChartLegendPosition.Top;
                    //m_chart.Legend.
                    m_chart.Legend.ToggleSeriesVisibility = true;
                }
            }
            else if (m_picker != null)
            {
                m_strings            = data;
                m_picker.ItemsSource = data;
            }
        }