Esempio n. 1
0
        private View CreateSpacer()
        {
            var spacer = new View(context);

            spacer.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1);
            spacer.SetBackgroundColor(DroidUtils.GetColorFromResources(context, Resource.Color.LightGreyFillColor1));
            return(spacer);
        }
Esempio n. 2
0
        private SwitchCompat CreateSwitch(bool value)
        {
            var toggle = new SwitchCompat(context);

            toggle.LayoutParameters = CreateLinearLayoutParams(DroidUtils.DpToPixels(64), ViewGroup.LayoutParams.WrapContent, GravityFlags.Right | GravityFlags.CenterVertical);
            toggle.Checked          = value;
            toggle.CheckedChange   += Toggle_CheckedChange;

            return(toggle);
        }
Esempio n. 3
0
        private SeekBar CreateSeekBar(double value, double min, double max, double increment, int numDecimals, bool showLabel, string tooltip = null)
        {
            var seek    = new SeekBar(new ContextThemeWrapper(context, Resource.Style.LightGraySeekBar));
            var padding = DroidUtils.DpToPixels(20);

            seek.SetPadding(padding, padding, padding, padding);
            seek.Min              = (int)(min * 1000);
            seek.Max              = (int)(max * 1000);
            seek.Progress         = (int)(value * 1000);
            seek.ProgressChanged += Seek_ProgressChanged;

            return(seek);
        }
Esempio n. 4
0
        private LinearLayout CreateLinearLayout(bool vertical, bool matchParentWidth, bool matchParentHeight, int margin, bool radioGroup = false, float weight = 0.0f)
        {
            var layout = new LinearLayout.LayoutParams(
                matchParentWidth  ? ViewGroup.LayoutParams.MatchParent : ViewGroup.LayoutParams.WrapContent,
                matchParentHeight ? ViewGroup.LayoutParams.MatchParent : ViewGroup.LayoutParams.WrapContent, weight);

            margin = DroidUtils.DpToPixels(margin);
            layout.SetMargins(margin, margin, margin, margin);

            var lin = radioGroup ? new RadioGroup(context) : new LinearLayout(context);

            lin.LayoutParameters = layout;
            lin.Orientation      = vertical ? Orientation.Vertical : Orientation.Horizontal;
            return(lin);
        }
Esempio n. 5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (pageLayout != null)
            {
                return(pageLayout);
            }

            context = container.Context;

            var margin = DroidUtils.DpToPixels(2);
            var coordLayoutParameters = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            coordLayoutParameters.SetMargins(margin, margin, margin, margin);

            pageLayout = new LinearLayout(container.Context);
            pageLayout.LayoutParameters = coordLayoutParameters;
            pageLayout.Orientation      = Orientation.Vertical;
            pageLayout.SetBackgroundColor(DroidUtils.ToAndroidColor(Theme.DarkGreyFillColor1));

            var first = true;

            for (int i = 0; i < properties.Count; i++)
            {
                var prop = properties[i];

                if (prop.layout == null || prop.visible == false)
                {
                    continue;
                }

                if (!first)
                {
                    pageLayout.AddView(CreateSpacer());
                }
                if (i == firstAdvancedProperty)
                {
                    pageLayout.AddView(CreateAdvancedPropertiesBanner());
                }

                pageLayout.AddView(prop.layout);
                first = false;
            }

            return(pageLayout);
        }
Esempio n. 6
0
        public int AddSlider(string label, double value, double min, double max, double increment, int numDecimals, string format = "{0}", string tooltip = null)
        {
            // On older androids, the seekbar misbehave when using negative values.
            // Make everything relative to zero and remap.
            var prop    = new Property();
            var seekBar = CreateSeekBar(value - min, 0, max - min, 0, 0, false);

            prop.type    = PropertyType.Slider;
            prop.label   = CreateTextView(SanitizeLabel(label), Resource.Style.LightGrayTextMedium);
            prop.tooltip = !string.IsNullOrEmpty(tooltip) ? CreateTextView(tooltip, Resource.Style.LightGrayTextSmallTooltip) : null;
            if (format != null)
            {
                prop.value = CreateTextView(string.Format(format, value), Resource.Style.LightGrayTextSmall);
            }
            prop.layout = CreateLinearLayout(true, true, false, 10);
            prop.controls.Add(seekBar);
            prop.sliderFormat = format;
            prop.sliderMin    = min;

            var inner = CreateLinearLayout(false, true, false, 0);

            seekBar.LayoutParameters = CreateLinearLayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent, GravityFlags.CenterVertical, 1.0f);
            inner.AddView(seekBar);

            if (prop.value != null)
            {
                prop.value.LayoutParameters = CreateLinearLayoutParams(DroidUtils.DpToPixels(72), ViewGroup.LayoutParams.WrapContent, GravityFlags.CenterVertical);
                inner.AddView(prop.value);
            }

            prop.layout.AddView(prop.label);
            if (prop.tooltip != null)
            {
                prop.layout.AddView(prop.tooltip);
            }
            prop.layout.AddView(inner);

            properties.Add(prop);

            return(properties.Count - 1);
        }
Esempio n. 7
0
        public HorizontalNumberPicker(Context context, int val, int min, int max) : base(context)
        {
            var lp = new LinearLayout.LayoutParams(DroidUtils.DpToPixels(64), DroidUtils.DpToPixels(48));

            lp.Weight  = 1;
            lp.Gravity = GravityFlags.CenterHorizontal | GravityFlags.CenterVertical;

            buttonLess      = new MaterialButton(context);
            buttonLess.Text = "-";
            buttonLess.SetTextColor(Android.Graphics.Color.Black);
            buttonLess.BackgroundTintList = ColorStateList.ValueOf(DroidUtils.GetColorFromResources(context, Resource.Color.LightGreyFillColor1));
            buttonLess.LayoutParameters   = lp;

            buttonMore      = new MaterialButton(context);
            buttonMore.Text = "+";
            buttonMore.SetTextColor(Android.Graphics.Color.Black);
            buttonMore.BackgroundTintList = ColorStateList.ValueOf(DroidUtils.GetColorFromResources(context, Resource.Color.LightGreyFillColor1));
            buttonMore.LayoutParameters   = lp;

            textView                  = new TextView(new ContextThemeWrapper(context, Resource.Style.LightGrayTextMedium));
            textView.Text             = "";
            textView.LayoutParameters = lp;
            textView.Gravity          = GravityFlags.Center;

            AddView(buttonLess);
            AddView(textView);
            AddView(buttonMore);

            buttonLess.Touch += ButtonLess_Touch;
            buttonMore.Touch += ButtonMore_Touch;

            minimum = min;
            maximum = max;
            value   = val;

            UpdateValue(false);
        }
Esempio n. 8
0
        private EditText CreateEditText(string txt, int maxLength)
        {
            var editText = new EditText(new ContextThemeWrapper(context, Resource.Style.LightGrayTextMedium));

            editText.InputType = InputTypes.ClassText;
            editText.Text      = txt;
            editText.SetTextColor(Application.Context.GetColorStateList(Resource.Color.light_grey));
            editText.Background.SetColorFilter(BlendModeColorFilterCompat.CreateBlendModeColorFilterCompat(DroidUtils.GetColorFromResources(context, Resource.Color.LightGreyFillColor1), BlendModeCompat.SrcAtop));
            editText.SetMaxLines(1);
            editText.SetOnEditorActionListener(this);
            editText.AfterTextChanged += EditText_AfterTextChanged;

            if (maxLength > 0)
            {
                editText.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(maxLength) });
            }

            return(editText);
        }
Esempio n. 9
0
        private Spinner CreateSpinner(string[] values, string value, string tooltip = null)
        {
            var spinner = new Spinner(new ContextThemeWrapper(context, Resource.Style.LightGrayTextMedium));
            var adapter = new CustomFontArrayAdapter(spinner, context, Android.Resource.Layout.SimpleSpinnerItem, values);

            spinner.Adapter = adapter;
            spinner.Background.SetColorFilter(BlendModeColorFilterCompat.CreateBlendModeColorFilterCompat(DroidUtils.GetColorFromResources(context, Resource.Color.LightGreyFillColor1), BlendModeCompat.SrcAtop));
            spinner.SetSelection(adapter.GetPosition(value));
            spinner.ItemSelected += Spinner_ItemSelected;
            return(spinner);
        }
Esempio n. 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var info = FamiStudioForm.Instance != null ? FamiStudioForm.Instance.ActiveDialog as TutorialDialogActivityInfo : null;

            if (savedInstanceState != null || info == null)
            {
                Finish();
                return;
            }

            var appBarLayoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, DroidUtils.GetSizeAttributeInPixel(this, Android.Resource.Attribute.ActionBarSize));

            appBarLayoutParams.ScrollFlags = 0;

            toolbar = new AndroidX.AppCompat.Widget.Toolbar(new ContextThemeWrapper(this, Resource.Style.ToolbarTheme));
            toolbar.LayoutParameters = appBarLayoutParams;
            toolbar.SetTitleTextAppearance(this, Resource.Style.LightGrayTextMediumBold);
            SetSupportActionBar(toolbar);

            ActionBar actionBar = SupportActionBar;

            if (actionBar != null)
            {
                actionBar.Title = "Welcome to FamiStudio!";
            }

            appBarLayout = new AppBarLayout(this);
            appBarLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            appBarLayout.AddView(toolbar);

            var margin = DroidUtils.DpToPixels(10);

            var linearLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            linearLayoutParams.Gravity = GravityFlags.Center;
            linearLayoutParams.SetMargins(margin, margin, margin, margin);

            textView                  = new TextView(new ContextThemeWrapper(this, Resource.Style.LightGrayTextMedium));
            textView.Text             = TutorialMessages[0];
            textView.LayoutParameters = linearLayoutParams;

            webView = new MaxHeightWebView(this);
            webView.LayoutParameters = linearLayoutParams;

            var coordLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);;

            coordLayoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(this, null);

            var linearLayout = new LinearLayout(new ContextThemeWrapper(this, Resource.Style.DarkBackgroundStyle));

            linearLayout.LayoutParameters = coordLayoutParams;
            linearLayout.Orientation      = Android.Widget.Orientation.Vertical;
            linearLayout.AddView(textView);
            linearLayout.AddView(webView);

            coordLayout = new CoordinatorLayout(this);
            coordLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            coordLayout.AddView(appBarLayout);
            coordLayout.AddView(linearLayout);

            RefreshPage();

            SetContentView(coordLayout);
        }
Esempio n. 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var info = FamiStudioForm.Instance != null ? FamiStudioForm.Instance.ActiveDialog as PropertyDialogActivityInfo : null;

            if (savedInstanceState != null || info == null)
            {
                Finish();
                return;
            }

            dlg = info.Dialog;
            dlg.CloseRequested += Dlg_CloseRequested;

            var appBarLayoutParams = new AppBarLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, DroidUtils.GetSizeAttributeInPixel(this, Android.Resource.Attribute.ActionBarSize));

            appBarLayoutParams.ScrollFlags = 0;

            toolbar = new AndroidX.AppCompat.Widget.Toolbar(new ContextThemeWrapper(this, Resource.Style.ToolbarTheme));
            toolbar.LayoutParameters = appBarLayoutParams;
            toolbar.SetTitleTextAppearance(this, Resource.Style.LightGrayTextMediumBold);
            SetSupportActionBar(toolbar);

            ActionBar actionBar = SupportActionBar;

            if (actionBar != null)
            {
                actionBar.SetDisplayHomeAsUpEnabled(true);
                actionBar.SetHomeButtonEnabled(true);
                actionBar.SetHomeAsUpIndicator(Android.Resource.Drawable.IcMenuCloseClearCancel);
                actionBar.Title = dlg.Title;
            }

            appBarLayout = new AppBarLayout(this);
            appBarLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            appBarLayout.AddView(toolbar);

            fragmentView = new FragmentContainerView(this);
            fragmentView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            fragmentView.Id = FragmentViewId;

            var scrollViewLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            scrollViewLayoutParams.Behavior = new AppBarLayout.ScrollingViewBehavior(this, null);

            scrollView = new NestedScrollView(new ContextThemeWrapper(this, Resource.Style.DarkBackgroundStyle));
            scrollView.LayoutParameters = scrollViewLayoutParams;
            scrollView.AddView(fragmentView);

            coordLayout = new CoordinatorLayout(this);
            coordLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            coordLayout.AddView(appBarLayout);
            coordLayout.AddView(scrollView);

            SetContentView(coordLayout);

            SupportFragmentManager.BeginTransaction().SetReorderingAllowed(true).Add(fragmentView.Id, dlg.Properties, "PropertyDialog").Commit();
        }
Esempio n. 12
0
            public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                var acticity = container.Context as MultiPropertyDialogActivity;

                var dp2  = DroidUtils.DpToPixels(2);
                var dp10 = DroidUtils.DpToPixels(10);
                var dp36 = DroidUtils.DpToPixels(36);

                var linearLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

                linearLayoutParams.SetMargins(dp2, dp2, dp2, dp2);

                var linearLayout = new LinearLayout(container.Context);

                linearLayout.Orientation      = Orientation.Vertical;
                linearLayout.LayoutParameters = linearLayoutParams;
                linearLayout.SetBackgroundColor(DroidUtils.GetColorFromResources(container.Context, Resource.Color.DarkGreyFillColor1));

                var first = true;

                for (int i = 0; i < dialog.PageCount; i++)
                {
                    var tab = dialog.GetPropertyPageTab(i);

                    if (!tab.visible)
                    {
                        continue;
                    }

                    if (!first)
                    {
                        var spacer = new View(container.Context);
                        spacer.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1);
                        spacer.SetBackgroundColor(DroidUtils.GetColorFromResources(container.Context, Resource.Color.LightGreyFillColor1));
                        linearLayout.AddView(spacer);
                    }

                    first = false;

                    var imageView = new ImageView(container.Context);
                    imageView.LayoutParameters = new LinearLayout.LayoutParams(dp36, dp36);
                    imageView.SetImageBitmap(PlatformUtils.LoadBitmapFromResource($"FamiStudio.Resources.{tab.image}@2x.png", true));

                    var textViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                    textViewLayoutParams.Gravity = GravityFlags.Left | GravityFlags.CenterVertical;

                    var textView = new TextView(new ContextThemeWrapper(container.Context, Resource.Style.LightGrayTextMedium));
                    textView.Text             = tab.text;
                    textView.LayoutParameters = textViewLayoutParams;
                    textView.SetPadding(dp10, 0, 0, 0);

                    var buttonLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                    buttonLayoutParams.SetMargins(dp10, dp10, dp10, dp10);

                    var buttonLayout = new LinearLayout(container.Context);
                    buttonLayout.LayoutParameters = buttonLayoutParams;
                    buttonLayout.AddView(imageView);
                    buttonLayout.AddView(textView);
                    buttonLayout.SetOnClickListener(acticity);

                    linearLayout.AddView(buttonLayout);

                    tab.button = buttonLayout;
                }

                return(linearLayout);
            }