예제 #1
0
        protected override void OnInitializeOriginalView()
        {
            base.OnInitializeOriginalView();

            OriginalView.SetSingleLine(true);
            if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean)
            {
                OriginalView.SetBackgroundDrawable(gradientDrawable);
            }
            else
            {
                OriginalView.SetBackground(gradientDrawable);
            }
            OriginalView.SetPadding((int)SupportView.PaddingInside, 0, (int)SupportView.PaddingInside, 0);
            OriginalView.TextSize = (float)SupportView.FontSize;
            OriginalView.SetTextColor(SupportView.TextColor.ToAndroid());
            OriginalView.TextAlignment = Android.Views.TextAlignment.Center;
            OriginalView.Typeface      = SpecAndroid.CreateTypeface(Context, SupportView.FontFamily.Split('#')[0]);
            OriginalView.Hint          = SupportView.Placeholder;

            OriginalView.Focusable            = true;
            OriginalView.FocusableInTouchMode = true;
            OriginalView.RequestFocusFromTouch();

            OriginalView.FocusChange += OriginalView_FocusChange;
            OriginalView.TextChanged += OriginalView_TextChanged;
            OriginalView.InitlizeReturnKey(SupportView.ReturnType);
            OriginalView.EditorAction += (sender, ev) =>
            {
                SupportView.SendOnReturnKeyClicked();
            };
        }
        /*
         * EXPORT SETTINGS
         */
        public void OnSettingsBaseDataSet <TEntry>(IBaseDataSetXF <TEntry> baseDataSetXF, MikePhil.Charting.Data.BaseDataSet originalBaseDataSet) where TEntry : Widget.Charts.Models.BaseEntry
        {
            /*
             * Properties could not set
             * IF_GetGradientColor
             */


            if (baseDataSetXF.IF_GetColors() != null && baseDataSetXF.IF_GetColors().Count > 0)
            {
                originalBaseDataSet.SetColors(baseDataSetXF.IF_GetColors().Select(obj => obj.ToAndroid().ToArgb()).ToArray());
            }
            if (baseDataSetXF.IF_GetValueColors() != null && baseDataSetXF.IF_GetValueColors().Count > 0)
            {
                originalBaseDataSet.SetValueTextColors(baseDataSetXF.IF_GetValueColors().Select(obj => new Java.Lang.Integer(obj.ToAndroid().ToArgb())).ToList());
            }
            if (baseDataSetXF.IF_GetHighlightEnabled().HasValue)
            {
                originalBaseDataSet.HighlightEnabled = baseDataSetXF.IF_GetHighlightEnabled().Value;
            }
            if (baseDataSetXF.IF_GetVisible().HasValue)
            {
                originalBaseDataSet.Visible = baseDataSetXF.IF_GetVisible().Value;
            }
            if (baseDataSetXF.IF_GetDrawIcons().HasValue)
            {
                originalBaseDataSet.SetDrawIcons(baseDataSetXF.IF_GetDrawIcons().Value);
            }
            if (baseDataSetXF.IF_GetDrawValues().HasValue)
            {
                originalBaseDataSet.SetDrawValues(baseDataSetXF.IF_GetDrawValues().Value);
            }
            if (baseDataSetXF.IF_GetValueFormatter() != null)
            {
                originalBaseDataSet.ValueFormatter = new DataSetValueFormatterExport(baseDataSetXF.IF_GetValueFormatter());
            }
            if (baseDataSetXF.IF_GetValueTextSize().HasValue)
            {
                originalBaseDataSet.ValueTextSize = (baseDataSetXF.IF_GetValueTextSize().Value);
            }
            try
            {
                if (!string.IsNullOrEmpty(baseDataSetXF.IF_GetValueFontFamily()))
                {
                    originalBaseDataSet.ValueTypeface = SpecAndroid.CreateTypeface(UltimateXFSettup.Context, baseDataSetXF.IF_GetValueFontFamily());
                }
            }
            catch (Exception ex)
            {
            }
        }
        public static void SetupConfigBase(this ComponentBase OriginalAxis, ConfigBase SupportXAxis)
        {
            /*
             * Properties could not set
             * Typeface
             */
            if (SupportXAxis.Enabled.HasValue)
            {
                OriginalAxis.Enabled = SupportXAxis.Enabled.Value;
            }

            if (SupportXAxis.XOffset.HasValue)
            {
                OriginalAxis.XOffset = SupportXAxis.XOffset.Value;
            }

            if (SupportXAxis.YOffset.HasValue)
            {
                OriginalAxis.YOffset = SupportXAxis.YOffset.Value;
            }

            if (SupportXAxis.TextSize.HasValue)
            {
                OriginalAxis.TextSize = SupportXAxis.TextSize.Value;
            }

            if (SupportXAxis.TextColor.HasValue)
            {
                OriginalAxis.TextColor = SupportXAxis.TextColor.Value.ToAndroid();
            }

            if (!string.IsNullOrEmpty(SupportXAxis.FontFamily))
            {
                OriginalAxis.Typeface = SpecAndroid.CreateTypeface(UltimateXFSettup.Context, SupportXAxis.FontFamily);
            }
        }
예제 #4
0
        protected virtual void OnInitializeOriginalChartSettings()
        {
            if (SupportChartView != null && OriginalChartView != null)
            {
                /*
                 * Properties could not set
                 */
                if (SupportChartView.LogEnabled.HasValue)
                {
                    OriginalChartView.LogEnabled = SupportChartView.LogEnabled.Value;
                }

                if (SupportChartView.HighLightPerTapEnabled.HasValue)
                {
                    OriginalChartView.HighlightPerTapEnabled = SupportChartView.HighLightPerTapEnabled.Value;
                }

                if (SupportChartView.DragDecelerationEnabled.HasValue)
                {
                    OriginalChartView.DragDecelerationEnabled = SupportChartView.DragDecelerationEnabled.Value;
                }

                if (SupportChartView.DragDecelerationFrictionCoef.HasValue)
                {
                    OriginalChartView.DragDecelerationFrictionCoef = SupportChartView.DragDecelerationFrictionCoef.Value;
                }

                if (SupportChartView.ExtraTopOffset.HasValue)
                {
                    OriginalChartView.ExtraTopOffset = SupportChartView.ExtraTopOffset.Value;
                }

                if (SupportChartView.ExtraLeftOffset.HasValue)
                {
                    OriginalChartView.ExtraLeftOffset = SupportChartView.ExtraLeftOffset.Value;
                }

                if (SupportChartView.ExtraRightOffset.HasValue)
                {
                    OriginalChartView.ExtraRightOffset = SupportChartView.ExtraRightOffset.Value;
                }

                if (SupportChartView.ExtraBottomOffset.HasValue)
                {
                    OriginalChartView.ExtraBottomOffset = SupportChartView.ExtraBottomOffset.Value;
                }

                if (SupportChartView.MaxHighlightDistance.HasValue)
                {
                    OriginalChartView.MaxHighlightDistance = SupportChartView.MaxHighlightDistance.Value;
                }

                if (SupportChartView.DescriptionChart != null)
                {
                    OriginalChartView.Description.Text = SupportChartView.DescriptionChart.Text;
                }

                if (SupportChartView.AnimationX != null)
                {
                    var animator = SupportChartView.AnimationX;
                    if (animator.Duration.HasValue)
                    {
                        if (animator.EasingType.HasValue)
                        {
                            OriginalChartView.AnimateX(animator.Duration.Value, ConvertAnimationType(animator.EasingType.Value));
                        }
                        else
                        {
                            OriginalChartView.AnimateX(animator.Duration.Value);
                        }
                    }
                }

                if (SupportChartView.AnimationY != null)
                {
                    var animator = SupportChartView.AnimationY;
                    if (animator.Duration.HasValue)
                    {
                        if (animator.EasingType.HasValue)
                        {
                            OriginalChartView.AnimateY(animator.Duration.Value, ConvertAnimationType(animator.EasingType.Value));
                        }
                        else
                        {
                            OriginalChartView.AnimateY(animator.Duration.Value);
                        }
                    }
                }

                if (SupportChartView.XAxis != null && OriginalChartView.XAxis != null)
                {
                    var SupportXAxis = SupportChartView.XAxis;
                    var OriginalAxis = OriginalChartView.XAxis;

                    OriginalAxis.SetupConfigBase(SupportXAxis);
                    OriginalAxis.SetupAxisConfigBase(SupportXAxis);
                    OriginalAxis.SetupXAxisConfig(SupportXAxis);

                    if (SupportChartView.XAxis.AxisValueFormatter == null)
                    {
                        //OriginalChartView.XAxis.ValueFormatter = new FullTitleFormatter();
                    }
                    else
                    {
                        OriginalChartView.XAxis.ValueFormatter = new AxisValueFormatterExport(SupportChartView.XAxis.AxisValueFormatter);
                    }
                }

                if (SupportChartView.Legend != null)
                {
                    var SupportLegend  = SupportChartView.Legend;
                    var OriginalLegend = OriginalChartView.Legend;

                    if (SupportLegend.Enabled.HasValue)
                    {
                        OriginalLegend.Enabled = SupportLegend.Enabled.Value;
                    }

                    if (SupportLegend.XOffset.HasValue)
                    {
                        OriginalLegend.XOffset = SupportLegend.XOffset.Value;
                    }

                    if (SupportLegend.YOffset.HasValue)
                    {
                        OriginalLegend.YOffset = SupportLegend.YOffset.Value;
                    }

                    if (SupportLegend.TextSize.HasValue)
                    {
                        OriginalLegend.TextSize = SupportLegend.TextSize.Value;
                    }

                    if (!string.IsNullOrEmpty(SupportLegend.FontFamily))
                    {
                        OriginalLegend.Typeface = SpecAndroid.CreateTypeface(UltimateXFSettup.Context, SupportLegend.FontFamily);
                    }

                    if (SupportLegend.TextColor.HasValue)
                    {
                        OriginalLegend.TextColor = SupportLegend.TextColor.Value.ToAndroid();
                    }

                    if (SupportLegend.LegendHorizontalAlignment.HasValue)
                    {
                        switch (SupportLegend.LegendHorizontalAlignment.Value)
                        {
                        case Widget.Charts.Models.Legend.LegendHorizontalAlignment.LEFT:
                            OriginalLegend.HorizontalAlignment = MikePhil.Charting.Components.Legend.LegendHorizontalAlignment.Left;
                            break;

                        case Widget.Charts.Models.Legend.LegendHorizontalAlignment.CENTER:
                            OriginalLegend.HorizontalAlignment = MikePhil.Charting.Components.Legend.LegendHorizontalAlignment.Center;
                            break;

                        case Widget.Charts.Models.Legend.LegendHorizontalAlignment.RIGHT:
                            OriginalLegend.HorizontalAlignment = MikePhil.Charting.Components.Legend.LegendHorizontalAlignment.Right;
                            break;

                        default:
                            break;
                        }
                    }

                    if (SupportLegend.LegendVerticalAlignment.HasValue)
                    {
                        switch (SupportLegend.LegendVerticalAlignment.Value)
                        {
                        case Widget.Charts.Models.Legend.LegendVerticalAlignment.TOP:
                            OriginalLegend.VerticalAlignment = MikePhil.Charting.Components.Legend.LegendVerticalAlignment.Top;
                            break;

                        case Widget.Charts.Models.Legend.LegendVerticalAlignment.CENTER:
                            OriginalLegend.VerticalAlignment = MikePhil.Charting.Components.Legend.LegendVerticalAlignment.Center;
                            break;

                        case Widget.Charts.Models.Legend.LegendVerticalAlignment.BOTTOM:
                            OriginalLegend.VerticalAlignment = MikePhil.Charting.Components.Legend.LegendVerticalAlignment.Bottom;
                            break;

                        default:
                            break;
                        }
                    }

                    if (SupportLegend.LegendOrientation.HasValue)
                    {
                        switch (SupportLegend.LegendOrientation.Value)
                        {
                        case Widget.Charts.Models.Legend.LegendOrientation.HORIZONTAL:
                            OriginalLegend.Orientation = MikePhil.Charting.Components.Legend.LegendOrientation.Horizontal;
                            break;

                        case Widget.Charts.Models.Legend.LegendOrientation.VERTICAL:
                            OriginalLegend.Orientation = MikePhil.Charting.Components.Legend.LegendOrientation.Vertical;
                            break;

                        default:
                            break;
                        }
                    }

                    if (SupportLegend.LegendDirection.HasValue)
                    {
                        switch (SupportLegend.LegendDirection.Value)
                        {
                        case Widget.Charts.Models.Legend.LegendDirection.LEFT_TO_RIGHT:
                            OriginalLegend.Direction = MikePhil.Charting.Components.Legend.LegendDirection.LeftToRight;
                            break;

                        case Widget.Charts.Models.Legend.LegendDirection.RIGHT_TO_LEFT:
                            OriginalLegend.Direction = MikePhil.Charting.Components.Legend.LegendDirection.RightToLeft;
                            break;

                        default:
                            break;
                        }
                    }

                    if (SupportLegend.LegendForm.HasValue)
                    {
                        switch (SupportLegend.LegendForm.Value)
                        {
                        case Widget.Charts.Models.Legend.LegendForm.NONE:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.None;
                            break;

                        case Widget.Charts.Models.Legend.LegendForm.EMPTY:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.Empty;
                            break;

                        case Widget.Charts.Models.Legend.LegendForm.DEFAULT:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.Default;
                            break;

                        case Widget.Charts.Models.Legend.LegendForm.SQUARE:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.Square;
                            break;

                        case Widget.Charts.Models.Legend.LegendForm.CIRCLE:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.Circle;
                            break;

                        case Widget.Charts.Models.Legend.LegendForm.LINE:
                            OriginalLegend.Form = MikePhil.Charting.Components.Legend.LegendForm.Line;
                            break;

                        default:
                            break;
                        }
                    }

                    if (SupportLegend.DrawInsideEnabled.HasValue)
                    {
                        OriginalLegend.SetDrawInside(SupportLegend.DrawInsideEnabled.Value);
                    }

                    if (SupportLegend.FormSize.HasValue)
                    {
                        OriginalLegend.FormSize = (SupportLegend.FormSize.Value);
                    }

                    if (SupportLegend.FormLineWidth.HasValue)
                    {
                        OriginalLegend.FormLineWidth = (SupportLegend.FormLineWidth.Value);
                    }

                    if (SupportLegend.XEntrySpace.HasValue)
                    {
                        OriginalLegend.XEntrySpace = (SupportLegend.XEntrySpace.Value);
                    }

                    if (SupportLegend.YEntrySpace.HasValue)
                    {
                        OriginalLegend.YEntrySpace = (SupportLegend.YEntrySpace.Value);
                    }

                    if (SupportLegend.FormToTextSpace.HasValue)
                    {
                        OriginalLegend.FormToTextSpace = (SupportLegend.FormToTextSpace.Value);
                    }

                    if (SupportLegend.StackSpace.HasValue)
                    {
                        OriginalLegend.StackSpace = (SupportLegend.StackSpace.Value);
                    }

                    if (SupportLegend.WordWrapEnabled.HasValue)
                    {
                        OriginalLegend.WordWrapEnabled = (SupportLegend.WordWrapEnabled.Value);
                    }

                    if (SupportLegend.MaxSizePercent.HasValue)
                    {
                        OriginalLegend.MaxSizePercent = (SupportLegend.MaxSizePercent.Value);
                    }

                    if (SupportLegend.NeededWidth.HasValue)
                    {
                        OriginalLegend.MNeededWidth = (SupportLegend.NeededWidth.Value);
                    }

                    if (SupportLegend.NeededHeight.HasValue)
                    {
                        OriginalLegend.MNeededHeight = (SupportLegend.NeededHeight.Value);
                    }

                    if (SupportLegend.TextHeightMax.HasValue)
                    {
                        OriginalLegend.MTextHeightMax = (SupportLegend.TextHeightMax.Value);
                    }

                    if (SupportLegend.TextWidthMax.HasValue)
                    {
                        OriginalLegend.MTextWidthMax = (SupportLegend.TextWidthMax.Value);
                    }
                }
            }
        }