コード例 #1
0
    void Spawn()
    {
        string[] names = itemName.Split(',');

        int width = 0;

        for (int i = 0; i < names.Length; i++)
        {
            string name = names[i];


            RadioButtonHandler radio = RadioPrefab.Spawn();

            radio.OnShow(name, this);
            RadioButtons.Add(radio);

            RectTransform itemTransform = (RectTransform)radio.transform;

            //itemTransform = (RectTransform)radio.transform;
            itemTransform.SetParent(gridTransform);
            itemTransform.localScale = Vector3.one;


            width += (int)itemTransform.rect.width;

            //Debug.Log(string.Format("name : {2} || ItenWidth : {0}, sunWidth : {1}", (int)itemTransform.rect.width, width, name));
        }

        if (width < 1080)
        {
            width = 1080;
        }
        gridTransform.sizeDelta     = new Vector2(width, gridTransform.sizeDelta.y);
        gridTransform.localPosition = new Vector3(width * 0.5F, gridTransform.localPosition.y, gridTransform.localPosition.z);
    }
コード例 #2
0
        public static void MapContent(RadioButtonHandler handler, RadioButton radioButton)
        {
            if (radioButton.ResolveControlTemplate() == null)
            {
                radioButton.ControlTemplate = RadioButton.DefaultTemplate;
            }

            RadioButtonHandler.MapContent(handler, radioButton);
        }
コード例 #3
0
 public void UncheckOtherRadios(RadioButtonHandler radio)
 {
     foreach (var r in RadioButtons)
     {
         if (r != radio)
         {
             r.IsSelected = false;
             r.UpdateState();
         }
     }
 }
コード例 #4
0
ファイル: RadioButton.Windows.cs プロジェクト: Glepooek/maui
        public static void MapContent(RadioButtonHandler handler, RadioButton radioButton)
        {
            if (radioButton.ResolveControlTemplate() != null)
            {
                handler.PlatformView.Style =
                    UI.Xaml.Application.Current.Resources["RadioButtonControlStyle"] as UI.Xaml.Style;
            }
            else
            {
                handler.PlatformView.ClearValue(FrameworkElement.StyleProperty);
            }

            RadioButtonHandler.MapContent(handler, radioButton);
        }
コード例 #5
0
        public static void MapContent(RadioButtonHandler handler, RadioButton radioButton)
        {
            if (radioButton.ResolveControlTemplate() != null)
            {
                if (handler.PlatformView is ContentViewGroup vg && handler.MauiContext != null)
                {
                    // Cleanup the old view when reused
                    vg.RemoveAllViews();

                    if (handler.VirtualView.PresentedContent is IView view)
                    {
                        vg.AddView(view.ToPlatform(handler.MauiContext));
                    }
                }

                return;
            }

            RadioButtonHandler.MapContent(handler, radioButton);
        }
コード例 #6
0
 bool GetNativeIsChecked(RadioButtonHandler radioButtonHandler) =>
 GetNativeRadioButton(radioButtonHandler).IsChecked ?? false;
コード例 #7
0
 UI.Xaml.Controls.RadioButton GetNativeRadioButton(RadioButtonHandler radioButtonHandler) =>
 radioButtonHandler.PlatformView;
コード例 #8
0
 AppCompatRadioButton GetNativeRadioButton(RadioButtonHandler radioButtonHandler) =>
 (AppCompatRadioButton)radioButtonHandler.NativeView;
コード例 #9
0
 AppCompatRadioButton GetNativeRadioButton(RadioButtonHandler radioButtonHandler) =>
 (AppCompatRadioButton)radioButtonHandler.PlatformView;
コード例 #10
0
    void Spawn()
    {
        string[] names = itemName.Split(',');

        int width = 0;

        for (int i = 0; i < names.Length; i++)
        {
            string        name          = names[i];
            RectTransform itemTransform = null;

            if (name.Contains("Toggle"))
            {
                name = name.Split('_')[0];
                //Debug.Log("Toggle name : " + name);
                var toggle = TogglePrefab.Spawn();

                toggle.OnShow(name, this);
                toggleButtons.Add(toggle);
                itemTransform = (RectTransform)toggle.transform;
            }
            else if (name.Contains("Separator"))
            {
                var separator = SeparatorPrefab.Spawn();
                separator.gameObject.name = name;
                itemTransform             = (RectTransform)separator.transform;

                separators.Add(separator);
            }
            else if (name.Contains("Basic"))
            {
                name = name.Split('_')[0];
                //Debug.Log("Basic name : " + name);
                var but = ButtonPrefab.Spawn();
                but.OnShow(name, this);

                basicButtons.Add(but);

                itemTransform = (RectTransform)but.transform;
            }
            else
            {
                //Debug.Log("Radio name : " + name);
                RadioButtonHandler radio = RadioPrefab.Spawn();

                radio.OnShow(name, this);
                RadioButtons.Add(radio);

                itemTransform = (RectTransform)radio.transform;
            }

            itemTransform.SetParent(gridTransform);
            itemTransform.localScale = Vector3.one;


            width += (int)itemTransform.rect.width;

            //Debug.Log(string.Format("name : {2} || ItenWidth : {0}, sunWidth : {1}", (int)itemTransform.rect.width, width, name));
        }

        if (width < 1080)
        {
            width = 1080;
        }
        gridTransform.sizeDelta     = new Vector2(width, gridTransform.sizeDelta.y);
        gridTransform.localPosition = new Vector3(width * 0.5F, gridTransform.localPosition.y, gridTransform.localPosition.z);
    }