Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UIActionStatusMessage"/> class.
 /// </summary>
 /// <param name="sourceTypeFullName">Full name of the source type.</param>
 /// <param name="senderView">The sender view.</param>
 /// <param name="uIAction">The u i action.</param>
 /// <param name="uIActionStatus">The u i action status.</param>
 public UIActionStatusMessage(
     System.String sourceTypeFullName,
     System.String senderView,
     UIAction uIAction,
     UIActionStatus uIActionStatus)
     : this(sourceTypeFullName, senderView, uIAction, uIActionStatus, null)
 {
 }
Exemplo n.º 2
0
        public override TreeActionEventArgs ConstructEventArgs(UIAction uIAction)
        {
            if (uIAction == UIAction.Selected)
            {
                return new TreeActionEventArgs()
                {
                    Action = TreeAction.ChangeSelect,
                    ChangeNum = SummaryItem.FirstChangeNumber,
                    FirstChangeNum = SummaryItem.FirstChangeNumber,
                    LastChangeNum = SummaryItem.LastChangeNumber
                };
            }

            return null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UIActionStatusMessage"/> class.
        /// </summary>
        /// <param name="sourceTypeFullName">Full name of the source type.</param>
        /// <param name="senderView">The sender view.</param>
        /// <param name="uIAction">The u i action.</param>
        /// <param name="uIActionStatus">The u i action status.</param>
        /// <param name="errorMessage">The error message.</param>
        public UIActionStatusMessage(
            System.String sourceTypeFullName,
            System.String senderView,
            UIAction uIAction,
            UIActionStatus uIActionStatus,
            string errorMessage
            )

        {
            this.ErrorMessage = errorMessage;
            this.SourceTypeFullName = sourceTypeFullName;
            this.SenderView = senderView;
            this.UIAction = uIAction;
            this.UIActionStatus = uIActionStatus;
        }
Exemplo n.º 4
0
        public CalendarSettingsViewModel(
            IUserPreferences userPreferences,
            IInteractorFactory interactorFactory,
            INavigationService navigationService,
            IRxActionFactory rxActionFactory,
            IPermissionsService permissionsService)
            : base(userPreferences, interactorFactory, navigationService, rxActionFactory)
        {
            Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService));

            this.permissionsService = permissionsService;

            RequestAccess            = rxActionFactory.FromAction(requestAccess);
            TogglCalendarIntegration = rxActionFactory.FromAsync(togglCalendarIntegration);

            SelectCalendar
            .Elements
            .Subscribe(onCalendarSelected);

            CalendarListVisible = calendarListVisibleSubject.AsObservable().DistinctUntilChanged();
        }
Exemplo n.º 5
0
    public void AddAction(UIAction a, Action <string[]> func, params string [] t)
    {
        switch (a)
        {
        case UIAction.MouseOut:
            TypeActions_MouseOut.Add(new UIAction_Method(func, t));
            break;

        case UIAction.MouseOver:
            TypeActions_MouseOver.Add(new UIAction_Method(func, t));
            break;

        case UIAction.MouseUp:
            TypeActions_MouseUp.Add(new UIAction_Method(func, t));
            break;

        case UIAction.MouseDown:
            TypeActions_MouseDown.Add(new UIAction_Method(func, t));
            break;
        }
    }
Exemplo n.º 6
0
        public static IDisposable BindAction(this IReactive <View> reactive, UIAction action, ButtonEventType eventType = ButtonEventType.Tap)
        {
            IObservable <Unit> eventObservable = Observable.Empty <Unit>();

            switch (eventType)
            {
            case ButtonEventType.Tap:
                eventObservable = reactive.Base.Rx().Tap();
                break;

            case ButtonEventType.LongPress:
                eventObservable = reactive.Base.Rx().LongPress();
                break;
            }

            return(Observable.Using(
                       () => action.Enabled.Subscribe(e => { reactive.Base.Enabled = e; }),
                       _ => eventObservable
                       )
                   .Subscribe(action.Inputs));
        }
Exemplo n.º 7
0
        private void InPhieuKham(string tenkhoa, Button button, string sokham, int isUuTien)
        {
            try
            {
                string val = "BỆNH NHÂN THƯỜNG";
                if (ma_KhoaKcb == "KKB")
                {
                    val = (isUuTien == 0) ? "BỆNH NHÂN THƯỜNG" : "BỆNH NHÂN ƯU TIÊN";
                }

                UIAction._EnableControl(button, false, "");
                DataTable dataTable = new DataTable();
                Utility.AddColumToDataTable(ref dataTable, "So_Kham", typeof(string));
                DataRow row = dataTable.NewRow();
                row["So_Kham"] = Utility.sDbnull(sokham);
                dataTable.Rows.Add(row);
                CRPT_SOKHAM crpt_sokham = new CRPT_SOKHAM();
                crpt_sokham.SetDataSource(dataTable);
                crpt_sokham.SetParameterValue("TEN_BENH_VIEN", _QMSProperties.TenBenhVien);
                string str2 = NgayIn(DateTime.Now);
                crpt_sokham.SetParameterValue("PrintDate", str2);
                crpt_sokham.SetParameterValue("TenKhoa", Utility.sDbnull(tenkhoa));
                crpt_sokham.SetParameterValue("LoaiDoiTuong", val);
                if (!string.IsNullOrEmpty(_QMSProperties.PrinterName))
                {
                    crpt_sokham.PrintOptions.PrinterName = Utility.sDbnull(_QMSProperties.PrinterName);
                }
                crpt_sokham.PrintToPrinter(1, false, 0, 0);
                UIAction._EnableControl(button, true, "");
                button.Focus();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg("Lỗi khi in số khám\n" + ex.Message);
            }
            finally
            {
                UIAction._EnableControl(button, true, "");
            }
        }
Exemplo n.º 8
0
        public TokenResetViewModel(
            IUserAccessManager userAccessManager,
            ITogglDataSource dataSource,
            INavigationService navigationService,
            IUserPreferences userPreferences,
            IAnalyticsService analyticsService,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory,
            IInteractorFactory interactorFactory)
            : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));

            this.dataSource        = dataSource;
            this.userAccessManager = userAccessManager;
            this.interactorFactory = interactorFactory;

            Done    = rxActionFactory.FromObservable(done);
            SignOut = rxActionFactory.FromAsync(signout);

            Error = Done.Errors
                    .Select(transformException);

            HasError = Error
                       .Select(error => !string.IsNullOrEmpty(error))
                       .DistinctUntilChanged()
                       .AsDriver(schedulerProvider);

            NextIsEnabled = Password
                            .Select(Shared.Password.From)
                            .CombineLatest(Done.Executing, (password, isExecuting) => password.IsValid && !isExecuting)
                            .DistinctUntilChanged()
                            .AsDriver(schedulerProvider);
        }
Exemplo n.º 9
0
 IEnumerator CoroutineUseCard()
 {
     while (true)
     {
         UIAction action = Game.BattleManager.GetTopUIAction();
         if (action != null)
         {
             if (action.BindActionList != null)
             {
                 for (int i = 0; i < action.BindActionList.Count; i++)
                 {
                     StartCoroutine(action.BindActionList[i].Excute());
                 }
             }
             yield return(action.Excute());
         }
         else
         {
             yield return(null);
         }
     }
 }
Exemplo n.º 10
0
        /// <summary> Resets this instance to the default values </summary>
        /// <param name="behaviorType"> Behavior type </param>
        public void Reset(UIButtonBehaviorType behaviorType)
        {
            m_behaviorType  = behaviorType;
            Enabled         = DEFAULT_ENABLED;
            Ready           = DEFAULT_READY;
            DisableInterval = GetDefaultDisableInterval(behaviorType);
            SelectButton    = DEFAULT_SELECT_BUTTON;
            DeselectButton  = DEFAULT_DESELECT_BUTTON;

            ButtonAnimationType         = DEFAULT_BUTTON_ANIMATION_TYPE;
            LoadSelectedPresetAtRuntime = DEFAULT_LOAD_SELECTED_PRESET_AT_RUNTIME;

            PresetCategory = DefaultPresetCategory;
            PresetName     = DefaultPresetName;

            PunchAnimation = new UIAnimation(AnimationType.Punch);
            StateAnimation = new UIAnimation(AnimationType.State);
            Animators      = new List <AnimatorEvent>();

            TriggerEventsAfterAnimation = DEFAULT_TRIGGER_EVENTS_AFTER_ANIMATION;
            OnTrigger = new UIAction();
        }
Exemplo n.º 11
0
        public override TreeActionEventArgs ConstructEventArgs(UIAction uIAction)
        {
            if (uIAction == UIAction.Selected)
            {
                int nextChangeIndex = CSUtils.FindFirstIndexGreaterThanOrEqualTo(_changePositions.Keys, _charPos);
                int prevChangeIndex = CSUtils.FindLastIndexLessThanOrEqualTo(_changePositions.Keys, _charPos);

                int iIndex = -1;
                if (nextChangeIndex == -1)
                {
                    iIndex = prevChangeIndex;
                }
                else if (prevChangeIndex == -1)
                {
                    iIndex = nextChangeIndex;
                }
                else
                {
                    int nextOffset = Math.Abs(_charPos - _changePositions.Keys[nextChangeIndex]);
                    int prevOffset = Math.Abs(_charPos - _changePositions.Keys[prevChangeIndex]);
                    iIndex = nextOffset < prevOffset ? nextChangeIndex : prevChangeIndex;
                }

                int changeNum = _changePositions.Values[iIndex];
                int offset = _charPos - _changePositions.Keys[iIndex];

                return new TreeActionEventArgs()
                {
                    Action = TreeAction.SearchSelect,
                    HighlightedTextRedlinePos = _charPos,
                    HighlightedText = _highlightedText,
                    ChangeNum = changeNum,
                    HighlightedTextOffsetFromChange = offset
                };

            }

            return null;
        }
Exemplo n.º 12
0
    public void AddAction(UIAction a, Action func)
    {
        switch (a)
        {
        case UIAction.MouseOut:
            Actions_MouseOut.Add(func);
            break;

        case UIAction.MouseOver:
            Actions_MouseOver.Add(func);
            break;

        case UIAction.MouseUp:
            Actions_MouseUp.Add(func);

            break;

        case UIAction.MouseDown:
            Actions_MouseDown.Add(func);
            break;
        }
    }
Exemplo n.º 13
0
    public void SetSpell(Spell _spell)
    {
        playerAction.spell = _spell;
        ItemSelectionBox.DisableButtons();
        ItemSelectionBox.gameObject.SetActive(false);

        List <GameObject> targets = new List <GameObject>();

        if (_spell.targetsAllies)
        {
            targets.AddRange(BSM.Heroes);
            targets.Remove(activePlayer.gameObject);
        }
        else
        {
            targets.AddRange(BSM.Enemies);
        }
        SelectionBox.SetSelectionBox(true);
        SelectionBox.SetButtons(targets, this);
        HeroRows.SetActive(true);
        previousUIAction = currentUIAction;
        currentUIAction  = UIAction.MAGICTARGET;
    }
Exemplo n.º 14
0
        private void OnLayerChange(Layer layer, UIAction action)
        {
            // get LayerEntry by layer
            LayerEntry layerEntry = LayerManager.Instance.GetLayerEntry(layer);

            if (layerEntry.View == null)
            {
                if (InitManager.Instance.Debug)
                {
                    Debug.LogWarning("View" + layer.ToString() + " not found :'(");
                }
                return;
            }

            if (action == UIAction.Show)
            {
                layerEntry.View.onShow();
            }
            else
            {
                layerEntry.View.onHide();
            }
        }
Exemplo n.º 15
0
        public ForgotPasswordViewModel(
            ITimeService timeService,
            IUserAccessManager userAccessManager,
            IAnalyticsService analyticsService,
            INavigationService navigationService,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(userAccessManager, nameof(userAccessManager));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.timeService       = timeService;
            this.userAccessManager = userAccessManager;
            this.analyticsService  = analyticsService;
            this.navigationService = navigationService;
            this.rxActionFactory   = rxActionFactory;

            Reset = rxActionFactory.FromObservable(reset, Email.Select(email => email.IsValid));
            Close = rxActionFactory.FromAction(returnEmail, Reset.Executing.Invert());

            var resetActionStartedObservable = Reset
                                               .Executing
                                               .Where(executing => executing)
                                               .Select(_ => (Exception)null);

            ErrorMessage = Reset.Errors
                           .Merge(resetActionStartedObservable)
                           .Select(toErrorString)
                           .StartWith("")
                           .DistinctUntilChanged();

            PasswordResetSuccessful = Reset.Elements
                                      .Select(_ => true)
                                      .StartWith(false);
        }
Exemplo n.º 16
0
        public static Guid GetIdentifier(UIAction uiAction)
        {
            var retGuid = Guid.Empty;

            switch (uiAction)
            {
            case UIAction.AryaReadOnly:
                retGuid = AryaReadOnly; break;

            case UIAction.AttributeView:
                retGuid = AttributeView; break;

            case UIAction.QueryView:
                retGuid = QueryView; break;

            case UIAction.SchemaView:
                retGuid = SchemaView; break;

            case UIAction.SkuView:
                retGuid = SkuView; break;

            case UIAction.PermissionsManager:
                retGuid = PermissionsManager;
                break;

            case UIAction.RoleManager:
                retGuid = RoleManager;
                break;
            }

            if (retGuid != Guid.Empty)
            {
                return(retGuid);
            }
            throw new ArgumentOutOfRangeException("uiAction", uiAction, @"Invalid or crazy enum");
        }
Exemplo n.º 17
0
        // Timer End event in Update Loop of next frame
        private void TimerEndLayer()
        {
            int count = _hideLayerList.Count;

            for (var i = 0; i < count; i++)
            {
                Layer    layer  = _hideLayerList[i];
                UIAction action = LayerManager.Instance.GetToggledStatus(layer);
                if (action == UIAction.Hide)
                {
                    // important: do trigger action/event first, then hide it
                    LayerManager.Instance.SetAction(layer, action);
                    this.Hide(layer);
                }
                else
                {
                    DoAnimation(layer, -1);
                }
            }

            // reset
            _hideLayerList.Clear();
            _timerStarted = false;
        }
        public SiriShortcutsCustomTimeEntryViewModel(
            ITogglDataSource dataSource,
            IInteractorFactory interactorFactory,
            IRxActionFactory rxActionFactory,
            IOnboardingStorage onboardingStorage,
            ISchedulerProvider schedulerProvider,
            INavigationService navigationService) : base(navigationService)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));

            this.navigationService = navigationService;
            this.interactorFactory = interactorFactory;
            this.onboardingStorage = onboardingStorage;

            SelectTags      = rxActionFactory.FromAsync(selectTags);
            SelectProject   = rxActionFactory.FromAsync(selectProject);
            SelectClipboard = rxActionFactory.FromAsync(selectClipboard);

            IsBillableAvailable = Workspace
                                  .Where(ws => ws?.Id != null)
                                  .SelectMany(ws => interactorFactory.IsBillableAvailableForWorkspace(ws.Id).Execute())
                                  .DistinctUntilChanged()
                                  .AsDriver(false, schedulerProvider);

            HasTags  = Tags.Select(tags => tags.Any()).AsDriver(false, schedulerProvider);
            TagNames = Tags
                       .Select(tags => tags.Select(t => t.Name))
                       .AsDriver(Enumerable.Empty <string>(), schedulerProvider);
            ProjectClientTask =
                projectClientTaskInfo.AsDriver(EditTimeEntryViewModel.ProjectClientTaskInfo.Empty, schedulerProvider);
        }
Exemplo n.º 19
0
 void LoadSTTKham()
 {
     if (dtSTTKham == null)
     {
         UIAction.SetText(lblQMSNumber, "00");
     }
     else
     {
         DataRow[] arrDr = dtSTTKham.Select(KcbQm.Columns.LoaiQms + "=" + (chkSoUutien.IsChecked ? "1" : "0"));
         if (arrDr.Length > 0)
         {
             string str = Utility.sDbnull(arrDr[0]["STT_KHAM"], "0");
             if (Utility.Int32Dbnull(arrDr[0]["STT_KHAM"], 0) < 10)
             {
                 str = Utility.FormatNumberToString(Utility.Int32Dbnull(arrDr[0]["STT_KHAM"], 0), "00");
             }
             UIAction.SetText(lblQMSNumber, str);
         }
         else
         {
             UIAction.SetText(lblQMSNumber, "00");
         }
     }
 }
        public NotificationSettingsViewModel(
            INavigationService navigationService,
            IBackgroundService backgroundService,
            IPermissionsService permissionsService,
            IUserPreferences userPreferences,
            ISchedulerProvider schedulerProvider,
            IRxActionFactory rxActionFactory)
        {
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(backgroundService, nameof(backgroundService));
            Ensure.Argument.IsNotNull(permissionsService, nameof(permissionsService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));

            this.navigationService  = navigationService;
            this.permissionsService = permissionsService;
            this.userPreferences    = userPreferences;
            this.schedulerProvider  = schedulerProvider;
            this.rxActionFactory    = rxActionFactory;

            PermissionGranted = backgroundService.AppResumedFromBackground
                                .SelectUnit()
                                .StartWith(Unit.Default)
                                .SelectMany(_ => permissionsService.NotificationPermissionGranted)
                                .DistinctUntilChanged()
                                .AsDriver(schedulerProvider);

            UpcomingEvents = userPreferences.CalendarNotificationsSettings()
                             .Select(s => s.Title())
                             .DistinctUntilChanged()
                             .AsDriver(schedulerProvider);

            RequestAccess      = rxActionFactory.FromAction(requestAccess);
            OpenUpcomingEvents = rxActionFactory.FromAsync(openUpcomingEvents);
        }
        public UpcomingEventsNotificationSettingsViewModel(
            IMvxNavigationService navigationService,
            IUserPreferences userPreferences)
        {
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(userPreferences, nameof(userPreferences));

            this.navigationService = navigationService;
            this.userPreferences   = userPreferences;

            this.AvailableOptions = new List <CalendarNotificationsOption>
            {
                CalendarNotificationsOption.Disabled,
                CalendarNotificationsOption.WhenEventStarts,
                CalendarNotificationsOption.FiveMinutes,
                CalendarNotificationsOption.TenMinutes,
                CalendarNotificationsOption.FifteenMinutes,
                CalendarNotificationsOption.ThirtyMinutes,
                CalendarNotificationsOption.OneHour
            };

            SelectOption = new InputAction <CalendarNotificationsOption>(onSelectOption);
            Close        = new UIAction(onClose);
        }
Exemplo n.º 22
0
 public UIAction FromAsync(Func <Task> asyncAction, IObservable <bool> enabledIf = null)
 {
     return(UIAction.FromAsync(asyncAction, schedulerProvider.MainScheduler, enabledIf));
 }
Exemplo n.º 23
0
        // Method called by UserInterface to display inventory list, update selected item, and return an action.
        public UIAction PrintProductSelectionMenu(Dictionary <ItemType, VendingMachineItem[]> items, UIAction actionToTake)
        {
            PrintBalance();
            int selectedRow    = 0;
            int selectedColumn = 0;
            int totalRows      = 19; // 20 rows, indexed at 0.
            int totalColumns   = 1;  // 2 columns, indexed at 0.
            int tablePadding   = 6;
            int currentRow     = 0;
            VendingMachineItem selectedItem = null;

            bool           isCurrentlyInMenu = true;
            ConsoleKeyInfo keyPress;

            while (isCurrentlyInMenu)
            {
                SetCursorPosition(tablePadding * 3, 0);
                switch (actionToTake)
                {
                case UIAction.CheckItem:
                    SetColor(DarkGray);
                    Write("This is where the things are! Check'em out!");
                    break;

                case UIAction.PurchaseItem:
                    SetColor(Gray);
                    Write("This is where the food lives! Come get you one!");
                    break;
                }
                SetColor(DarkGreen);
                SetCursorPosition(tablePadding + 4, 1);
                Write("A) Chips");
                SetCursorPosition(tablePadding + 4, 13);
                Write("C) Drinks");
                SetCursorPosition((WindowWidth - 2 * tablePadding) / 2 + 4, 1);
                Write("B) Candy");
                SetCursorPosition((WindowWidth - 2 * tablePadding) / 2 + 4, 13);
                Write("D) Gum");
                SetColor();

                foreach (KeyValuePair <ItemType, VendingMachineItem[]> itemList in items)
                {
                    bool activeColumn = false;
                    bool activeRow    = false;
                    switch (itemList.Key)
                    {
                    case ItemType.Candy:
                    case ItemType.Chip:
                        currentRow = -1;
                        CursorTop  = 1;
                        break;

                    case ItemType.Drink:
                    case ItemType.Gum:
                        currentRow = 9;
                        CursorTop  = 13;
                        break;
                    }

                    foreach (VendingMachineItem item in itemList.Value)
                    {
                        activeRow = ++currentRow == selectedRow;
                        switch (itemList.Key)
                        {
                        case ItemType.Chip:
                        case ItemType.Drink:
                            CursorLeft   = tablePadding;
                            activeColumn = selectedColumn == 0;
                            break;

                        case ItemType.Candy:
                        case ItemType.Gum:
                            CursorLeft   = (WindowWidth - 2 * tablePadding) / 2;
                            activeColumn = selectedColumn == 1;
                            break;
                        }

                        CursorTop++;

                        if (activeColumn && activeRow)
                        {
                            selectedItem = item;
                            CurrentType  = itemList.Key;
                            CurrentSlot  = currentRow;
                            if (CurrentSlot >= 10)
                            {
                                CurrentSlot -= 10;
                            }
                        }

                        if (item != null)
                        {
                            SetColor(activeColumn && activeRow);
                            if (item.Quantity > 0)
                            {
                                Write((item.Slot + 1) % 10 + ") " + item.Quantity + "x " + item.Name + "  " + item.Price.ToString("C"));
                            }
                            else
                            {
                                Write((item.Slot + 1) % 10 + ") ");
                                SetColor(DarkRed);
                                Write("SOLD OUT ");
                                SetColor(activeColumn && activeRow);
                                Write(item.Name + "  " + item.Price.ToString("C"));
                            }
                        }
                        else
                        {
                            if (activeColumn && activeRow)
                            {
                                SetColor(DarkGreen);
                            }
                            else
                            {
                                SetColor(DarkGray);
                            }
                            Write("  -- no item --");
                        }
                        SetColor();
                    }
                }
                keyPress = ReadKey(true);
                switch (keyPress.Key) // HACK: Refactor out keyPress? Only necessary if we need to refer back to modifier keys.
                {
                // Navigate menu using arrow keys
                case ConsoleKey.UpArrow:
                    if (--selectedRow < 0)
                    {
                        selectedRow = totalRows;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (++selectedRow > totalRows)
                    {
                        selectedRow = 0;
                    }
                    break;

                case ConsoleKey.LeftArrow:
                    if (--selectedColumn < 0)
                    {
                        selectedColumn = totalColumns;
                    }
                    break;

                case ConsoleKey.RightArrow:
                    if (++selectedColumn > totalColumns)
                    {
                        selectedColumn = 0;
                    }
                    break;

                // Navigate menu using item category letters: A, B, C, D
                case ConsoleKey.A:
                    selectedColumn = 0;
                    selectedRow    = 0;
                    break;

                case ConsoleKey.B:
                    selectedColumn = 1;
                    selectedRow    = 0;
                    break;

                case ConsoleKey.C:
                    selectedColumn = 0;
                    selectedRow    = 10;
                    break;

                case ConsoleKey.D:
                    selectedColumn = 1;
                    selectedRow    = 10;
                    break;

                // Navigate to specific row by number key or numpad.
                case ConsoleKey.NumPad1:
                case ConsoleKey.D1:
                    selectedRow = selectedRow < 10 ? 0 : 10;
                    break;

                case ConsoleKey.NumPad2:
                case ConsoleKey.D2:
                    selectedRow = selectedRow < 10 ? 1 : 11;
                    break;

                case ConsoleKey.NumPad3:
                case ConsoleKey.D3:
                    selectedRow = selectedRow < 10 ? 2 : 12;
                    break;

                case ConsoleKey.NumPad4:
                case ConsoleKey.D4:
                    selectedRow = selectedRow < 10 ? 3 : 13;
                    break;

                case ConsoleKey.NumPad5:
                case ConsoleKey.D5:
                    selectedRow = selectedRow < 10 ? 4 : 14;
                    break;

                case ConsoleKey.NumPad6:
                case ConsoleKey.D6:
                    selectedRow = selectedRow < 10 ? 5 : 15;
                    break;

                case ConsoleKey.NumPad7:
                case ConsoleKey.D7:
                    selectedRow = selectedRow < 10 ? 6 : 16;
                    break;

                case ConsoleKey.NumPad8:
                case ConsoleKey.D8:
                    selectedRow = selectedRow < 10 ? 7 : 17;
                    break;

                case ConsoleKey.NumPad9:
                case ConsoleKey.D9:
                    selectedRow = selectedRow < 10 ? 8 : 18;
                    break;

                case ConsoleKey.NumPad0:
                case ConsoleKey.D0:
                    selectedRow = selectedRow < 10 ? 9 : 19;
                    break;

                // Exit app via Q, cancel selection with escape, confirm selection with enter/spacebar
                case ConsoleKey.Q:
                    LastAction        = UIAction.Exit;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.Escape:
                    LastAction        = UIAction.DisplayMainMenu;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.Enter:
                case ConsoleKey.Spacebar:
                    LastAction        = actionToTake;
                    isCurrentlyInMenu = false;
                    break;
                }
            }

            return(LastAction);
        }
Exemplo n.º 24
0
        // HACK: Extension idea: Extract common input handling code into separate method or class.
        // Method called by UserInterface to display main menu and user's selected action.
        public UIAction PrintMainMenu()
        {
            PrintBalance();
            int            selectedOption    = 0;
            bool           isCurrentlyInMenu = true;
            ConsoleKeyInfo keyPress;

            while (isCurrentlyInMenu)
            {
                MainMenuOutput(selectedOption);
                keyPress = ReadKey(true);

                switch (keyPress.Key)
                {
                // Navigate menu using up/down arrow, select with enter/space
                case ConsoleKey.UpArrow:
                    if (--selectedOption < 0)
                    {
                        selectedOption = 2;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (++selectedOption > 2)
                    {
                        selectedOption = 0;
                    }
                    break;

                case ConsoleKey.Enter:
                case ConsoleKey.Spacebar:
                    isCurrentlyInMenu = false;
                    break;

                // Select specific menu choice with 1/2/3/escape
                case ConsoleKey.NumPad1:
                case ConsoleKey.D1:
                    selectedOption    = 0;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.NumPad2:
                case ConsoleKey.D2:
                    selectedOption    = 1;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.Escape:
                case ConsoleKey.Q:
                case ConsoleKey.NumPad3:
                case ConsoleKey.D3:
                    selectedOption    = 2;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.D4:
                    selectedOption    = 3;
                    isCurrentlyInMenu = false;
                    break;
                }
            }

            if (selectedOption == 0)
            {
                LastAction = UIAction.ReviewItems;
            }
            if (selectedOption == 1)
            {
                LastAction = UIAction.DisplayPurchasing;
            }
            if (selectedOption == 2)
            {
                LastAction = UIAction.Exit;
            }
            if (selectedOption == 3)
            {
                LastAction = UIAction.SalesReport;
            }
            return(LastAction);
        }
Exemplo n.º 25
0
        public EditTimeEntryViewModel(
            ITimeService timeService,
            ITogglDataSource dataSource,
            ISyncManager syncManager,
            IInteractorFactory interactorFactory,
            IMvxNavigationService navigationService,
            IOnboardingStorage onboardingStorage,
            IDialogService dialogService,
            IAnalyticsService analyticsService,
            IStopwatchProvider stopwatchProvider,
            IRxActionFactory actionFactory,
            ISchedulerProvider schedulerProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(syncManager, nameof(syncManager));
            Ensure.Argument.IsNotNull(timeService, nameof(timeService));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(onboardingStorage, nameof(onboardingStorage));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(analyticsService, nameof(analyticsService));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(actionFactory, nameof(actionFactory));

            this.dataSource        = dataSource;
            this.syncManager       = syncManager;
            this.timeService       = timeService;
            this.dialogService     = dialogService;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;
            this.analyticsService  = analyticsService;
            this.stopwatchProvider = stopwatchProvider;
            this.schedulerProvider = schedulerProvider;
            this.actionFactory     = actionFactory;
            OnboardingStorage      = onboardingStorage;

            workspaceIdSubject
            .Where(id => id.HasValue)
            .Subscribe(id => workspaceId = id.Value)
            .DisposedBy(disposeBag);

            isEditingDescriptionSubject = new BehaviorSubject <bool>(false);
            Description = new BehaviorRelay <string>(string.Empty, CommonFunctions.Trim);

            projectClientTaskSubject = new BehaviorSubject <ProjectClientTaskInfo>(ProjectClientTaskInfo.Empty);
            ProjectClientTask        = projectClientTaskSubject
                                       .AsDriver(ProjectClientTaskInfo.Empty, schedulerProvider);

            IsBillableAvailable = workspaceIdSubject
                                  .Where(id => id.HasValue)
                                  .SelectMany(workspaceId => interactorFactory.IsBillableAvailableForWorkspace(workspaceId.Value).Execute())
                                  .DistinctUntilChanged()
                                  .AsDriver(false, schedulerProvider);

            isBillableSubject = new BehaviorSubject <bool>(false);
            IsBillable        = isBillableSubject
                                .DistinctUntilChanged()
                                .AsDriver(false, schedulerProvider);

            startTimeSubject = new BehaviorSubject <DateTimeOffset>(DateTimeOffset.UtcNow);
            var startTimeObservable = startTimeSubject.DistinctUntilChanged();

            StartTime = startTimeObservable
                        .AsDriver(default(DateTimeOffset), schedulerProvider);

            var now = timeService.CurrentDateTimeObservable.StartWith(timeService.CurrentDateTime);

            durationSubject = new ReplaySubject <TimeSpan?>(bufferSize: 1);
            Duration        =
                durationSubject
                .Select(duration
                        => duration.HasValue
                            ? Observable.Return(duration.Value)
                            : now.CombineLatest(
                            startTimeObservable,
                            (currentTime, startTime) => currentTime - startTime))
                .Switch()
                .DistinctUntilChanged()
                .AsDriver(TimeSpan.Zero, schedulerProvider);

            var stopTimeObservable = Observable.CombineLatest(startTimeObservable, durationSubject, calculateStopTime)
                                     .DistinctUntilChanged();

            StopTime = stopTimeObservable
                       .AsDriver(null, schedulerProvider);

            var isTimeEntryRunningObservable = stopTimeObservable
                                               .Select(stopTime => !stopTime.HasValue)
                                               .Do(value => isRunning = value)
                                               .DistinctUntilChanged();

            IsTimeEntryRunning = isTimeEntryRunningObservable
                                 .AsDriver(false, schedulerProvider);

            tagsSubject = new BehaviorSubject <IEnumerable <IThreadSafeTag> >(Enumerable.Empty <IThreadSafeTag>());
            Tags        = tagsSubject
                          .Select(tags => tags.Select(ellipsize).ToImmutableList())
                          .AsDriver(ImmutableList <string> .Empty, schedulerProvider);

            isInaccessibleSubject = new BehaviorSubject <bool>(false);
            IsInaccessible        = isInaccessibleSubject
                                    .DistinctUntilChanged()
                                    .AsDriver(false, schedulerProvider);

            syncErrorMessageSubject = new BehaviorSubject <string>(string.Empty);
            SyncErrorMessage        = syncErrorMessageSubject
                                      .Select(error => error ?? string.Empty)
                                      .DistinctUntilChanged()
                                      .AsDriver(string.Empty, schedulerProvider);

            IsSyncErrorMessageVisible = syncErrorMessageSubject
                                        .Select(error => !string.IsNullOrEmpty(error))
                                        .DistinctUntilChanged()
                                        .AsDriver(false, schedulerProvider);

            Preferences = interactorFactory.GetPreferences().Execute()
                          .AsDriver(null, schedulerProvider);

            // Actions
            Close                   = actionFactory.FromAsync(closeWithConfirmation);
            SelectProject           = actionFactory.FromAsync(selectProject);
            SelectTags              = actionFactory.FromAsync(selectTags);
            ToggleBillable          = actionFactory.FromAction(toggleBillable);
            EditTimes               = actionFactory.FromAsync <EditViewTapSource>(editTimes);
            SelectStartDate         = actionFactory.FromAsync(selectStartDate);
            StopTimeEntry           = actionFactory.FromAction(stopTimeEntry, isTimeEntryRunningObservable);
            DismissSyncErrorMessage = actionFactory.FromAction(dismissSyncErrorMessage);
            Save   = actionFactory.FromAsync(save);
            Delete = actionFactory.FromAsync(delete);
        }
Exemplo n.º 26
0
 public UIAction FromObservable(Func <IObservable <Unit> > workFactory, IObservable <bool> enabledIf = null)
 {
     return(UIAction.FromObservable(workFactory, schedulerProvider.MainScheduler, enabledIf));
 }
Exemplo n.º 27
0
 public void Switch(LayerConfig layerConfig, UIAction action = UIAction.Show, float delay = -1)
 {
     Switch(LayerManager.Instance.GetLayerEntry(layerConfig).Layer, action, delay);
 }
Exemplo n.º 28
0
 public virtual TreeActionEventArgs ConstructEventArgs(UIAction uIAction)
 {
     return null;
 }
Exemplo n.º 29
0
        // Animation

        private void DoAnimation(Layer layer, float delay)
        {
            UIAction action = LayerManager.Instance.GetToggledStatus(layer);

            if (layer == Layer.None)
            {
                return;
            }

            // Fade In Animation
            if (action == UIAction.Show)
            {
                // enable triggers OpenAnimations via Animator
                this.Show(layer);

                // sound
                LayerEntry layerEntry = LayerManager.Instance.GetLayerEntry(layer);
                if (layerEntry == null)
                {
                    Debug.LogWarning("Layer named " + layer + " not found");
                    return;
                }
                LayerConfig UIConfig = layerEntry.LayerConfig;
                if (UIConfig != null)
                {
                    // play each animation
                    foreach (var anim in UIConfig.OpenAnimations)
                    {
                        anim.Object.Play(anim.State);
                    }

                    if (UIConfig.OpenSound != "")
                    {
                        SoundManager.Instance.Play(UIConfig.OpenSound, SoundManager.SoundType.Soundeffect, false, 0.5f);
                    }
                }

                LayerManager.Instance.SetAction(layer, action);
            }
            // Fade Out animation
            else
            {
                //bool isAnimation = false;
                // check if UIConfig Component exists
                LayerEntry layerEntry = LayerManager.Instance.GetLayerEntry(layer);
                if (layerEntry == null)
                {
                    Debug.LogWarning("Layer named " + layer + " not found");
                    return;
                }
                LayerConfig UIConfig = layerEntry.LayerConfig;
                if (UIConfig != null)
                {
                    // play each animation
                    foreach (var anim in UIConfig.CloseAnimations)
                    {
                        //isAnimation = true;
                        anim.Object.Play(anim.State);
                    }

                    // sound
                    if (UIConfig.CloseSound != "")
                    {
                        SoundManager.Instance.Play(UIConfig.CloseSound, SoundManager.SoundType.Soundeffect, false, 0.5f);
                    }
                }

                // save for delayed animation
                //if (isAnimation == false)
                if (delay == 0)
                {
                    this.Hide(layer);
                    LayerManager.Instance.SetAction(layer, action);
                }
                else
                {
                    AddHideLayerList(layer);
                }
            }
        }
Exemplo n.º 30
0
 /// <summary> Resets this instance to the default values </summary>
 public void Reset()
 {
     OnLoadScene   = new UIAction();
     OnSceneLoaded = new UIAction();
 }
Exemplo n.º 31
0
 public static IDisposable BindAction(this IReactive <UIButton> reactive, UIAction action,
                                      ButtonEventType eventType = ButtonEventType.Tap) =>
 reactive.BindAction(action, _ => Unit.Default, eventType);
Exemplo n.º 32
0
 /// <summary> Resets this instance to the default values </summary>
 /// <param name="behaviorType"> Behavior type </param>
 public void Reset(UIDrawerBehaviorType behaviorType)
 {
     DrawerBehaviorType = behaviorType;
     OnStart            = new UIAction();
     OnFinished         = new UIAction();
 }
Exemplo n.º 33
0
        // Method called by UserInterface to display purchasing menu and user's selected action.
        public UIAction PrintPurchasingMenu()
        {
            PrintBalance();
            int            selectedOption    = 0;
            bool           isCurrentlyInMenu = true;
            ConsoleKeyInfo keyPress;

            while (isCurrentlyInMenu)
            {
                PurchasingMenuOutput(selectedOption);
                keyPress = ReadKey(true);

                switch (keyPress.Key)
                {
                // Navigate menu using up/down arrow, select with enter/space
                case ConsoleKey.UpArrow:
                    if (--selectedOption < 0)
                    {
                        selectedOption = 2;
                    }
                    break;

                case ConsoleKey.DownArrow:
                    if (++selectedOption > 2)
                    {
                        selectedOption = 0;
                    }
                    break;

                case ConsoleKey.Enter:
                case ConsoleKey.Spacebar:
                    isCurrentlyInMenu = false;
                    break;

                // Select specific menu choice with 1/2/3
                case ConsoleKey.NumPad1:
                case ConsoleKey.D1:
                    selectedOption    = 0;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.NumPad2:
                case ConsoleKey.D2:
                    selectedOption    = 1;
                    isCurrentlyInMenu = false;
                    break;

                case ConsoleKey.NumPad3:
                case ConsoleKey.D3:
                    selectedOption    = 2;
                    isCurrentlyInMenu = false;
                    break;

                // Abort mission! Cancel out of purchasing menu.
                case ConsoleKey.Escape:
                    LastAction        = UIAction.DisplayMainMenu;
                    selectedOption    = -1;
                    isCurrentlyInMenu = false;
                    break;

                // Abort WHOLE PROGRAM! Bail out.
                case ConsoleKey.Q:
                    LastAction        = UIAction.Exit;
                    selectedOption    = -1;
                    isCurrentlyInMenu = false;
                    break;
                }
            }

            if (selectedOption == 0)
            {
                LastAction = UIAction.FeedMoney;
            }
            if (selectedOption == 1)
            {
                LastAction = UIAction.DisplayItems;
            }
            if (selectedOption == 2)
            {
                LastAction = UIAction.FinishTransaction;
            }
            return(LastAction);
        }
Exemplo n.º 34
0
        /// <summary>
        /// This is used in order to disable some menu items
        /// if none of the selected items can handle a given action.
        /// It serves a "be nicer to the user" purpose.
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        private bool CanAnySelectedItemDo(UIAction action)
        {
            switch (action)
            {
                case UIAction.Add:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (Gate.CanAdd(itm))
                            return true;
                    }
                    return false;

                case UIAction.Open:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (itm.Status == PathStatus.Directory || Gate.CanOpen(itm))
                            return true;
                    }
                    return false;

                case UIAction.Synchronize:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (Gate.CanSynchronize(itm))
                            return true;
                    }
                    return false;

                case UIAction.DeleteOrMove:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (Gate.CanDeleteOrMove(itm))
                            return true;
                    }
                    return false;

                case UIAction.SaveAs:
                    if (lvFileList.SelectedItems.Count != 1)
                        return false;

                    return Gate.CanSaveAs(lvFileList.SelectedItems[0] as KListViewItem);

                case UIAction.Revert:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (Gate.CanRevert(itm))
                            return true;

                    }
                    return false;

                case UIAction.Copy:
                    foreach (KListViewItem itm in lvFileList.SelectedItems)
                    {
                        if (Gate.CanCopy(itm))
                            return true;
                    }
                    return false;

                default:
                    Debug.Assert(false, "Wrong usage of CanAnySelectedItemDo.");
                    return false;
            }
        }
Exemplo n.º 35
0
 public override TreeActionEventArgs ConstructEventArgs(UIAction uIAction)
 {
     return null;
 }
Exemplo n.º 36
0
 public UIAction FromAction(Action action, IObservable <bool> enabledIf = null)
 {
     return(UIAction.FromAction(action, schedulerProvider.MainScheduler, enabledIf));
 }
Exemplo n.º 37
0
        protected override void Execute(CodeActivityContext context)
        {
            Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.MailItem    email = (Microsoft.Office.Interop.Outlook.MailItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            var    to       = To.Get(context);
            var    cc       = CC.Get(context);
            var    bcc      = BCC.Get(context);
            var    subject  = Subject.Get(context);
            var    account  = Account.Get(context);
            string body     = (Body != null ?Body.Get(context) : null);
            string htmlbody = (HTMLBody != null ? HTMLBody.Get(context) : null);

            if (!string.IsNullOrEmpty(htmlbody))
            {
                body = htmlbody;
            }
            var attachments = Attachments.Get(context);
            var uiaction    = UIAction.Get(context);

            Microsoft.Office.Interop.Outlook.Account oAccount = null;
            if (!string.IsNullOrEmpty(account))
            {
                for (int i = 1; i <= outlookApplication.Session.Accounts.Count; i++)
                {
                    if (outlookApplication.Session.Accounts[i].SmtpAddress == account)
                    {
                        oAccount = outlookApplication.Session.Accounts[i];
                    }
                }
            }

            email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatRichText;
            if (oAccount != null)
            {
                email.SendUsingAccount = oAccount;
            }
            email.To       = to;
            email.Subject  = subject;
            email.HTMLBody = body;
            email.CC       = cc;
            email.BCC      = bcc;

            if (attachments != null && attachments.Count() > 0)
            {
                foreach (var attachment in attachments)
                {
                    if (!string.IsNullOrEmpty(attachment))
                    {
                        email.Attachments.Add(attachment, Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 100000, Type.Missing);
                    }
                }
            }
            if (uiaction == "Show")
            {
                email.Display(true);
            }
            //else if(uiaction == "SendVisable")
            //{
            //    email.Display(true);
            //    email.Send();
            //}
            if (uiaction == "Draft")
            {
                email.Save();
            }
            else
            {
                email.Send();
            }
            if (EMail != null)
            {
                EMail.Set(context, new email(email));
            }
        }
Exemplo n.º 38
0
 public void SetUIAction(ActionButton _button)
 {
     m_CurrentUIAction = _button.Action;
 }