private void btnLaunchCustomUI_Click(object sender, System.EventArgs e)
        {
            try
            {
                var dataClassInstance = (ICustomUIDrivenClass)_args.InitialValue;

                var uiInstance = Activator.CreateInstance(_uiType);

                ICustomUI instanceAsCustomUI = (ICustomUI)uiInstance;
                instanceAsCustomUI.CatalogueRepository = _args.CatalogueRepository;

                instanceAsCustomUI.SetGenericUnderlyingObjectTo(dataClassInstance);
                var dr = ((Form)instanceAsCustomUI).ShowDialog();

                if (dr != DialogResult.Cancel)
                {
                    var result = instanceAsCustomUI.GetFinalStateOfUnderlyingObject();
                    _args.Setter(result);
                    _args.InitialValue = result;
                }
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
        }
Beispiel #2
0
        void Initialize()
        {
            AutoresizingMask       = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            DirectionalLockEnabled = true;

            var helpText = "";

            var vs = SourceType.GetCustomAttributes(typeof(CustomUIAttribute), true);

            IsCustomUI = vs.Length > 0;

            if (IsCustomUI)
            {
                CustomUIType = ((CustomUIAttribute)vs[0]).UIType;
                CustomUI     = Activator.CreateInstance(CustomUIType) as ICustomUI;
                CustomUI.SetModel(Source);
                CustomUI.OnOK += delegate {
                    try {
                        if (OnOK != null)
                        {
                            OnOK();
                        }
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };
                AddSubview(CustomUI as UIView);
                this.ExclusiveTouch          = false;
                this.CanCancelContentTouches = false;
                this.DelaysContentTouches    = false;
            }
            else
            {
                AlwaysBounceVertical   = true;
                AlwaysBounceHorizontal = false;
                helpText = InitializePropsUI();
            }

            ConfirmButton = new LcarsComp {
                Shape = LcarsShape.Button
            };
            ConfirmButton.Def.Caption        = "ADD";
            ConfirmButton.Def.NeedsDoubleTap = false;
            ConfirmButton.Def.IsCommandable  = false;
            ConfirmButton.Def.Command        = delegate {
                HideKeyBoard(this);
                if (OnOK != null)
                {
                    OnOK();
                }
            };

            CancelButton = new LcarsComp {
                Shape = LcarsShape.Button, Hidden = true
            };
            CancelButton.Def.Caption        = "CANCEL";
            CancelButton.Def.NeedsDoubleTap = false;
            CancelButton.Def.IsCommandable  = true;
            CancelButton.Def.Command        = delegate {
                HideKeyBoard(this);
                if (OnCancel != null)
                {
                    OnCancel();
                }
            };

            if (IsCustomUI)
            {
                ConfirmButton.Hidden = true;
                CancelButton.Hidden  = true;
            }

            GeneralHelp = new UITextView();
            GeneralHelp.BackgroundColor = UIColor.Black;
            GeneralHelp.TextColor       = Theme.TitleColor;
            GeneralHelp.Font            = Theme.TextFont;
            GeneralHelp.Editable        = false;
            GeneralHelp.Text            = helpText;

            AddSubview(CancelButton);
            AddSubview(ConfirmButton);
            AddSubview(GeneralHelp);
        }
 protected override void OnBinding(GameObject target)
 {
     base.OnBinding(target);
     component = target.GetComponent <ICustomUI>();
 }
Beispiel #4
0
        void Initialize()
        {
            AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            DirectionalLockEnabled = true;

            var helpText = "";

            var vs = SourceType.GetCustomAttributes (typeof(CustomUIAttribute), true);
            IsCustomUI = vs.Length > 0;

            if (IsCustomUI) {
                CustomUIType = ((CustomUIAttribute)vs[0]).UIType;
                CustomUI = Activator.CreateInstance (CustomUIType) as ICustomUI;
                CustomUI.SetModel (Source);
                CustomUI.OnOK += delegate {
                    try {
                        if (OnOK != null) {
                            OnOK ();
                        }
                    } catch (Exception error) {
                        Log.Error (error);
                    }
                };
                AddSubview (CustomUI as UIView);
                this.ExclusiveTouch = false;
                this.CanCancelContentTouches = false;
                this.DelaysContentTouches = false;

            } else {
                AlwaysBounceVertical = true;
                AlwaysBounceHorizontal = false;
                helpText = InitializePropsUI ();
            }

            ConfirmButton = new LcarsComp { Shape = LcarsShape.Button };
            ConfirmButton.Def.Caption = "ADD";
            ConfirmButton.Def.NeedsDoubleTap = false;
            ConfirmButton.Def.IsCommandable = false;
            ConfirmButton.Def.Command = delegate {
                HideKeyBoard (this);
                if (OnOK != null) {
                    OnOK ();
                }
            };

            CancelButton = new LcarsComp { Shape = LcarsShape.Button, Hidden = true };
            CancelButton.Def.Caption = "CANCEL";
            CancelButton.Def.NeedsDoubleTap = false;
            CancelButton.Def.IsCommandable = true;
            CancelButton.Def.Command = delegate {
                HideKeyBoard (this);
                if (OnCancel != null) {
                    OnCancel ();
                }
            };

            if (IsCustomUI) {
                ConfirmButton.Hidden = true;
                CancelButton.Hidden = true;
            }

            GeneralHelp = new UITextView ();
            GeneralHelp.BackgroundColor = UIColor.Black;
            GeneralHelp.TextColor = Theme.TitleColor;
            GeneralHelp.Font = Theme.TextFont;
            GeneralHelp.Editable = false;
            GeneralHelp.Text = helpText;

            AddSubview (CancelButton);
            AddSubview (ConfirmButton);
            AddSubview (GeneralHelp);
        }