/// <summary>
        /// Opens a camera capture view controller.
        /// </summary>
        /// <param name="parent">The parent view controller that invoked the method.</param>
        /// <param name="callback">Action to call after photo is captured.</param>
        /// <param name="onCancel">Action to call if canceling from camera.</param>
        /// <param name="cameraToUse">Can set to default the front or rear camera.</param>
        public static void TakePicture <TViewModel>(BaseViewController <TViewModel> parent, Action <NSDictionary> callback, Action onCancel, UIImagePickerControllerCameraDevice cameraToUse = UIImagePickerControllerCameraDevice.Front)
            where TViewModel : BaseViewModel
        {
            var status = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);

            if (status == AVAuthorizationStatus.NotDetermined)
            {
                AVCaptureDevice.RequestAccessForMediaType(AVMediaType.Video, (accessGranted) =>
                {
                    if (accessGranted)
                    {
                        // Open the camera
                        parent.InvokeOnMainThread(delegate
                        {
                            InitializeCamera(parent, callback, onCancel, cameraToUse);
                        });
                    }
                    // If they have said no do nothing.
                });
            }
            else if (status == AVAuthorizationStatus.Authorized)
            {
                // Open the camera
                InitializeCamera(parent, callback, onCancel, cameraToUse);
            }
            else
            {
                // They said no in the past, so show them an alert to direct them to the app's settings.
                OpenSettingsAlert(parent, "Camera Access Required", "Authorization to access the camera is required to use this feature of the app.");
            }
        }
    private void OnOpenView(Views id, object viewModel = null)
    {
        RectTransform view;

        if (m_viewDict.ContainsKey(id))
        {
            view = m_viewDict[id];
        }
        else
        {
            view = (Object.Instantiate <RectTransform>(Resources.Load <RectTransform>("Views/" + id.ToString())));
            view.gameObject.SetActive(false);
            view.transform.SetParent(m_refs.m_viewContainer);
            view.localPosition        = Vector3.zero;
            view.transform.localScale = Vector3.one;
            view.offsetMin            = view.offsetMax = Vector2.zero;
            m_viewDict.Add(id, view);
        }

        view.SetAsLastSibling();
        BaseViewController baseController = GetController(id);

        baseController.Open(view.gameObject, viewModel);
        m_viewStack.Push(baseController);
    }
        /// <summary>
        /// Opens the photo library to allow the user to choose a picture.
        /// </summary>
        /// <param name="parent">The parent view controller that invoked the method.</param>
        /// <param name="callback">The function to call after a picture was chosen.</param>
        public static void SelectPicture <TViewModel>(BaseViewController <TViewModel> parent, Action <NSDictionary> callback, Action onCancel)
            where TViewModel : BaseViewModel
        {
            var status = PHPhotoLibrary.AuthorizationStatus;

            if (status == PHAuthorizationStatus.NotDetermined)
            {
                PHPhotoLibrary.RequestAuthorization((PHAuthorizationStatus authStatus) =>
                {
                    if (authStatus == PHAuthorizationStatus.Authorized)
                    {
                        // Show the media picker.
                        parent.InvokeOnMainThread(delegate
                        {
                            InitializePhotoPicker(parent, callback, onCancel);
                        });
                    }
                    // If they have said no do nothing.
                });
            }
            else if (status == PHAuthorizationStatus.Authorized)
            {
                // Show the media picker.
                InitializePhotoPicker(parent, callback, onCancel);
            }
            else
            {
                // They said no in the past, so show them an alert to direct them to the app's settings.
                OpenSettingsAlert(parent, "Photo Access Required", "Authorization to access photos is required to use this feature of the app.");
            }
        }
Пример #4
0
        public IntroduceView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
        {
            Text = TargetGo.transform.Find("Content/Text").GetComponent <Text>();

            CloseBtn = TargetGo.transform.Find("CloseBtn").GetComponent <Button>();
            CloseBtn.onClick.AddListener(OnClickCloseBtn);
        }
        public void UpdateCell(Post post)
        {
            _currentPost = post;

            _scheduledWorkAvatar?.Cancel();
            if (!string.IsNullOrEmpty(_currentPost.Avatar))
            {
                _scheduledWorkAvatar = ImageService.Instance.LoadUrl(_currentPost.Avatar, TimeSpan.FromDays(30))
                                       .LoadingPlaceholder("ic_noavatar.png")
                                       .ErrorPlaceholder("ic_noavatar.png")
                                       .FadeAnimation(false, false, 0)
                                       .DownSample(200)
                                       .Into(avatar);
            }
            else
            {
                avatar.Image = UIImage.FromBundle("ic_noavatar");
            }

            commentText.Text = _currentPost.Body;
            loginLabel.Text  = _currentPost.Author;
            likeLabel.Text   = _currentPost.NetVotes.ToString();
            costLabel.Text   = BaseViewController.ToFormatedCurrencyString(_currentPost.TotalPayoutReward);
            //costLabel.Hidden = true; //!BasePresenter.User.IsNeedRewards;
            likeButton.Selected = _currentPost.Vote;
            likeButton.Enabled  = true;
            timestamp.Text      = _currentPost.Created.ToPostTime();

            likeLabel.Text = $"{_currentPost.NetLikes} {(_currentPost.NetLikes == 1 ? Localization.Messages.Like : Localization.Messages.Likes)}";
            LayoutIfNeeded();
        }
 private void OnCloseView()
 {
     if (m_viewStack.Count != 0)
     {
         BaseViewController baseController = m_viewStack.Pop();
         baseController.Close();
     }
 }
Пример #7
0
 public static void OnCoinBalancedViewDidDisappear <TViewModel>(this BaseViewController <TViewModel> controller)
     where TViewModel : BaseViewModel
 {
     if (controller != null && controller.Context != null)
     {
         controller.Context.OnDeactivated();
     }
 }
Пример #8
0
 public static void OnCoinBalancedViewDidLoad <TViewModel>(this BaseViewController <TViewModel> controller)
     where TViewModel : BaseViewModel
 {
     if (controller != null && controller.Context != null)
     {
         OnViewDidLoad(controller.Context, controller.View, controller.GetType().Name);
     }
 }
Пример #9
0
 /// <summary>
 /// Initializes the photo picker view controller.
 /// </summary>
 /// <param name="parent">Parent view controller</param>
 /// <param name="callback">Callback once photo is selected.</param>
 /// <param name="onCancel">On cancel action.</param>
 private static void InitializePhotoPicker(BaseViewController parent, Action <NSDictionary> callback, Action onCancel)
 {
     _callback = callback;
     _onCancel = onCancel;
     Init();
     picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
     parent.PresentViewController(picker, true, null);
 }
Пример #10
0
 public CommonActionBarView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
     ResourceMgr.Instance.LoadResource("Prefab/Shield03", ((resource, b) =>
     {
         o = resource.UnityObj as GameObject;
         o = GameObject.Instantiate(o);
         o.SetActive(false);
     }));
 }
Пример #11
0
        public CrtMenu(string selector = null, bool addDefaultItems = false, bool immediateMode = true, string quitMenu = "..")
            : base(selector, addDefaultItems, immediateMode)
        {
            Add(new MI_Quit(this, quitMenu));

            OnRun += (m) =>
            {
                BaseViewController.BeginOutput();
                BaseViewController.PrintHeader($"{this.Selector} menu");
            };
        }
Пример #12
0
 private void VotedAction(Post post, OperationResult <VoteResponse> operationResult)
 {
     if (string.Equals(post.Url, _currentPost.Url, StringComparison.OrdinalIgnoreCase) && operationResult.IsSuccess)
     {
         likeButton.Selected = operationResult.Result.IsSuccess;
         flagButton.Selected = _currentPost.Flag;
         rewards.Text        = BaseViewController.ToFormatedCurrencyString(operationResult.Result.NewTotalPayoutReward);
         netVotes.Text       = $"{_currentPost.NetVotes.ToString()} {Localization.Messages.Likes}";
     }
     likeButton.Enabled = true;
 }
Пример #13
0
 /// <summary>
 /// Sends the view message.
 /// </summary>
 /// <returns><c>true</c>, if view message was sent, <c>false</c> otherwise.</returns>
 /// <param name="view">View.</param>
 /// <param name="msg">Message.</param>
 public bool SendViewMessage(BaseViewController view, object msg)
 {
     foreach (BaseViewController mview in viewList)
     {
         if (mview.Equals(view))
         {
             mview.OnReceiveMessage(msg);
             return(true);
         }
     }
     return(false);
 }
Пример #14
0
    /// <summary>
    /// Opens the view.
    /// </summary>
    /// <param name="viewControlerName">View controler name.</param>
    /// <param name="isFullScreen">If set to <c>true</c> is full screen.</param>
    /// <param name="customData">Custom data.</param>
    public void OpenView(string viewControlerName, bool isFullScreen, object customData)
    {
        TurnOffScreenClick(true);

        Type ViewType = Type.GetType("ViewController." + viewControlerName);

        if (ViewType == null)
        {
            Debug.LogError(string.Format("打开界面 {0} 失败.", viewControlerName));
            return;
        }
        BaseViewController view = Activator.CreateInstance(ViewType) as BaseViewController;

        view.name         = viewControlerName;
        view.isFullScreen = isFullScreen;

        //历史界面暂停,如果打开的界面是全屏,历史界面进入后台
        foreach (BaseViewController oldView in viewList)
        {
            if (!oldView.isPaused)
            {
                oldView.Pause();
                Debug.Log(oldView.name + " ______PAUSED.");
            }
            if (isFullScreen)
            {
                if (!oldView.isHided)
                {
                    oldView.Hide();
                    Debug.Log(oldView.name + " ______HIDED.");
                }
            }
        }

        if (isFullScreen)
        {
            view.ShowBlackBg(true);
        }
        else
        {
            view.ShowBlackBg(false);
        }

        view.OnOpen(customData);
        Tools.normalizedParent(view.view.transform, UIRoot.transform);

        Debug.Log(view.name + " ______OPENED.");

        TurnOnScreenClick();

        view.instanceId = viewList.Count + 1;
        viewList.Add(view);
    }
Пример #15
0
 public override void LoadView()
 {
     View = new UITextView()
     {
         Editable = false
     };
     menuButton = new UIBarButtonItem(Images.MenuImage, UIBarButtonItemStyle.Plain,
                                      (s, e) => { NotificationManager.Shared.ProcToggleMenu(); })
     {
         AccessibilityIdentifier = "menu"
     };
     NavigationItem.LeftBarButtonItem = BaseViewController.ShouldShowMenuButton(this) ? menuButton : null;
 }
Пример #16
0
        /// <summary>
        /// Initializes the camera.
        /// </summary>
        /// <param name="parent">Parent view controller.</param>
        /// <param name="callback">Callback once photo is taken</param>
        /// <param name="onCancel">On cancel action</param>
        /// <param name="cameraToUse">Camera to use.</param>
        private static void InitializeCamera(BaseViewController parent, Action <NSDictionary> callback, Action onCancel, UIImagePickerControllerCameraDevice cameraToUse)
        {
            _callback = callback;
            _onCancel = onCancel;
            Init();
            picker.SourceType = UIImagePickerControllerSourceType.Camera;
            var cameraAvailable = UIImagePickerController.IsCameraDeviceAvailable(cameraToUse);

            if (cameraAvailable)
            {
                picker.CameraDevice = cameraToUse;
                parent.PresentViewController(picker, true, null);
            }
            else
            {
                parent.ShowAlert("The camera is unavailable", "No Camera");
            }
        }
Пример #17
0
 /// <summary>
 /// Opens an alert with a button to dismiss or go to the app's settings.
 /// </summary>
 /// <param name="parent">Parent view controller</param>
 /// <param name="title">Title of the alert</param>
 /// <param name="message">Alert message</param>
 private static void OpenSettingsAlert(BaseViewController parent, string title, string message)
 {
     parent.InvokeOnMainThread(delegate
     {
         //Create Alert
         var alertController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);
         //Add Cancel Action
         alertController.AddAction(UIAlertAction.Create("Return to App", UIAlertActionStyle.Default, null));
         // Add Open Settings Action
         alertController.AddAction(UIAlertAction.Create("Open Settings", UIAlertActionStyle.Default, (UIAlertAction obj) => {
             var settingsString = UIKit.UIApplication.OpenSettingsUrlString;
             var url            = new NSUrl(settingsString);
             UIApplication.SharedApplication.OpenUrl(url);
         }));
         // Present Alert
         parent.PresentViewController(alertController, true, null);
     });
 }
Пример #18
0
    /// <summary>
    /// Closes the view.
    /// </summary>
    /// <param name="viewControlerName">View controler name.</param>
    public void CloseView(string viewControlerName)
    {
        for (int i = viewList.Count - 1; i >= 0; i--)
        {
            BaseViewController mView = viewList[i];
            if (mView.name.Equals(viewControlerName))
            {
                mView.Close();
                Debug.Log(mView.name + " ______CLOSED.");
                viewList.Remove(mView);
                break;
            }
        }

        //前一个界面继续
        for (int i = viewList.Count - 1; i >= 0; i--)
        {
            BaseViewController mView = viewList[i];
            if (mView.isPaused)
            {
                mView.Resume();
                Debug.Log(mView.name + " ______RESUMED.");
                break;
            }
        }

        //往前查第一个全屏界面之上的历史界面回到前台
        for (int i = viewList.Count - 1; i >= 0; i--)
        {
            BaseViewController mView = viewList[i];
            if (mView.isHided)
            {
                mView.Show();
                Debug.Log(mView.name + " ______SHOWDED.");
            }
            if (mView.isFullScreen)
            {
                break;
            }
        }
    }
Пример #19
0
        public override void LoadView()
        {
            View = view = new EqualizerView(this);
            var style = View.GetStyle();

            if (NavigationController == null)
            {
                return;
            }
            NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes
            {
                ForegroundColor = style.AccentColor
            };

            menuButton = new UIBarButtonItem(Images.MenuImage, UIBarButtonItemStyle.Plain,
                                             (s, e) => { NotificationManager.Shared.ProcToggleMenu(); })
            {
                AccessibilityIdentifier = "menu",
            };
            NavigationItem.LeftBarButtonItem = BaseViewController.ShouldShowMenuButton(this) ? menuButton : null;
        }
Пример #20
0
        static void Main(string[] args)
        {
            // Initialize with the test data
            AddDefaultShips();
            AddDefaultContainers();

            PrintHeader();

            // Build the navigation menu and assign actions
            var fleetMenu = new CrtMenu("fleet")
            {
                new CMenuItem("list", s => TransportViewController.ShowTransportMediaList()),
                new CMenuItem("add ship", s => TransportViewController.AddShip()),
                new CMenuItem("&add truck", s => TransportViewController.AddTruck()),
                new CMenuItem("show load", s => ContainerViewController.ShowContainerListByTransport()),
                new CMenuItem("rename", s => TransportViewController.Rename()),
                new CMenuItem("delete", s => TransportViewController.Delete()),
            };

            var containersMenu = new CrtMenu("cargo")
            {
                new CMenuItem("list", s => ContainerViewController.ShowContainerList()),
                new CMenuItem("add container", s => ContainerViewController.AddContainer()),
                new CMenuItem("load", s => ContainerViewController.Load()),
                new CMenuItem("unload", s => ContainerViewController.Unload()),
                new CMenuItem("rename", s => ContainerViewController.Rename()),
                new CMenuItem("delete", s => ContainerViewController.Delete()),
            };

            var m = new CrtMenu("Main", quitMenu: "exit")
            {
                new CMenuItem(fleetMenu.Selector, s => BaseViewController.ExecuteSubMenu(fleetMenu)),
                new CMenuItem(containersMenu.Selector, s => BaseViewController.ExecuteSubMenu(containersMenu))
            };

            m.ImmediateMenuMode = true;
            m.Run();
        }
Пример #21
0
 public SystemMsgView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #22
0
 public ShopView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #23
0
 public ChatPlayInfoView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #24
0
 public FactoryView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #25
0
 public void registerWindow(string windowName,GameObject window,BaseViewController controller)
 {
     this._windowMap.Add (windowName, window);
     this._controllerMap.Add (windowName, controller);
     window.SetActive (false);
 }
Пример #26
0
 public RegisterView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #27
0
        private int ID = 0;//当前售卖的物品的id

        public StoreSellView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
        {
        }
Пример #28
0
 public AddFriendSuccView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #29
0
 public CommonPlayerInfoView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }
Пример #30
0
 public override void DidRotate(UIInterfaceOrientation fromInterfaceOrientation)
 {
     base.DidRotate(fromInterfaceOrientation);
     NavigationItem.LeftBarButtonItem = BaseViewController.ShouldShowMenuButton(this) ? menuButton : null;
 }
Пример #31
0
 public RankingListView(GameObject targetGo, BaseViewController viewController) : base(targetGo, viewController)
 {
 }