void IExpandCollapseProvider.Collapse()
        {
            // Make sure that the control is enabled
            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
            {
                throw new ElementNotEnabledException();
            }

            // check if item can be collapsed
            switch (GetItemState(_hwnd))
            {
            case ExpandCollapseState.LeafNode:
            {
                throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
            }

            case ExpandCollapseState.Expanded:
            {
                DateTimeButton btn = new DateTimeButton(_hwnd, this, (int)DateTimeItem.Button);
                ((IInvokeProvider)btn).Invoke();
                return;
            }

            case ExpandCollapseState.Collapsed:
            {
                return;
            }
            }

            throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
        }
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            if (_IsDropDownType)
            {
                NativeMethods.Win32Rect rc = DateTimeButton.BoundingRect(_hwnd);
                if (Misc.PtInRect(ref rc, x, y))
                {
                    return(new DateTimeButton(_hwnd, this, (int)DateTimeItem.Button));
                }
            }

            return(null);
        }
        void ReleaseDesignerOutlets()
        {
            if (AddProjectOnboardingBubble != null)
            {
                AddProjectOnboardingBubble.Dispose();
                AddProjectOnboardingBubble = null;
            }

            if (DescriptionRemainingLengthLabel != null)
            {
                DescriptionRemainingLengthLabel.Dispose();
                DescriptionRemainingLengthLabel = null;
            }

            if (Placeholder != null)
            {
                Placeholder.Dispose();
                Placeholder = null;
            }

            if (StartDateButton != null)
            {
                StartDateButton.Dispose();
                StartDateButton = null;
            }

            if (TimeInput != null)
            {
                TimeInput.Dispose();
                TimeInput = null;
            }

            if (TimeInputTrailingConstraint != null)
            {
                TimeInputTrailingConstraint.Dispose();
                TimeInputTrailingConstraint = null;
            }

            if (TimeLabel != null)
            {
                TimeLabel.Dispose();
                TimeLabel = null;
            }

            if (TimeLabelTrailingConstraint != null)
            {
                TimeLabelTrailingConstraint.Dispose();
                TimeLabelTrailingConstraint = null;
            }

            if (BillableButton != null)
            {
                BillableButton.Dispose();
                BillableButton = null;
            }

            if (BillableButtonWidthConstraint != null)
            {
                BillableButtonWidthConstraint.Dispose();
                BillableButtonWidthConstraint = null;
            }

            if (BottomDistanceConstraint != null)
            {
                BottomDistanceConstraint.Dispose();
                BottomDistanceConstraint = null;
            }

            if (BottomOptionsSheet != null)
            {
                BottomOptionsSheet.Dispose();
                BottomOptionsSheet = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (DateTimeButton != null)
            {
                DateTimeButton.Dispose();
                DateTimeButton = null;
            }

            if (DescriptionTextView != null)
            {
                DescriptionTextView.Dispose();
                DescriptionTextView = null;
            }

            if (DoneButton != null)
            {
                DoneButton.Dispose();
                DoneButton = null;
            }

            if (ProjectsButton != null)
            {
                ProjectsButton.Dispose();
                ProjectsButton = null;
            }

            if (SuggestionsTableView != null)
            {
                SuggestionsTableView.Dispose();
                SuggestionsTableView = null;
            }

            if (TagsButton != null)
            {
                TagsButton.Dispose();
                TagsButton = null;
            }

            if (AddProjectBubbleLabel != null)
            {
                AddProjectBubbleLabel.Dispose();
                AddProjectBubbleLabel = null;
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddProjectBubbleLabel.Text = Resources.AddProjectBubbleText;

            prepareViews();
            prepareOnboarding();

            var source = new StartTimeEntryTableViewSource(SuggestionsTableView);

            SuggestionsTableView.Source = source;

            source.Rx().ModelSelected()
            .Subscribe(ViewModel.SelectSuggestion.Inputs)
            .DisposedBy(DisposeBag);

            ViewModel.Suggestions
            .Subscribe(SuggestionsTableView.Rx().ReloadSections(source))
            .DisposedBy(DisposeBag);

            source.ToggleTasks
            .Subscribe(ViewModel.ToggleTasks.Inputs)
            .DisposedBy(DisposeBag);

            TimeInput.Rx().Duration()
            .Subscribe(ViewModel.SetRunningTime.Inputs)
            .DisposedBy(DisposeBag);

            //Text

            ViewModel.DisplayedTime
            .Subscribe(TimeLabel.Rx().Text())
            .DisposedBy(DisposeBag);

            Placeholder.Text = ViewModel.PlaceholderText;

            // Buttons
            UIColor booleanToColor(bool b) => b
                ? Colors.StartTimeEntry.ActiveButton.ToNativeColor()
                : Colors.StartTimeEntry.InactiveButton.ToNativeColor();

            ViewModel.IsBillable
            .Select(booleanToColor)
            .Subscribe(BillableButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            ViewModel.IsSuggestingTags
            .Select(booleanToColor)
            .Subscribe(TagsButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            ViewModel.IsSuggestingProjects
            .Select(booleanToColor)
            .Subscribe(ProjectsButton.Rx().TintColor())
            .DisposedBy(DisposeBag);

            //Visibility
            ViewModel.IsBillableAvailable
            .Select(b => b ? (nfloat)42 : 0)
            .Subscribe(BillableButtonWidthConstraint.Rx().Constant())
            .DisposedBy(DisposeBag);

            // Actions
            CloseButton.Rx().Tap()
            .Subscribe(ViewModel.CloseWithDefaultResult)
            .DisposedBy(DisposeBag);

            DoneButton.Rx()
            .BindAction(ViewModel.Done)
            .DisposedBy(DisposeBag);

            ViewModel.Done.Elements
            .Subscribe(IosDependencyContainer.Instance.IntentDonationService.DonateStartTimeEntry)
            .DisposedBy(DisposeBag);

            BillableButton.Rx()
            .BindAction(ViewModel.ToggleBillable)
            .DisposedBy(DisposeBag);

            StartDateButton.Rx()
            .BindAction(ViewModel.SetStartDate)
            .DisposedBy(DisposeBag);

            DateTimeButton.Rx()
            .BindAction(ViewModel.ChangeTime)
            .DisposedBy(DisposeBag);

            TagsButton.Rx()
            .BindAction(ViewModel.ToggleTagSuggestions)
            .DisposedBy(DisposeBag);

            ProjectsButton.Rx()
            .BindAction(ViewModel.ToggleProjectSuggestions)
            .DisposedBy(DisposeBag);

            // Reactive
            ViewModel.TextFieldInfo
            .DistinctUntilChanged()
            .Subscribe(onTextFieldInfo)
            .DisposedBy(DisposeBag);

            DescriptionTextView.Rx().AttributedText()
            .Select(attributedString => attributedString.Length == 0)
            .Subscribe(isDescriptionEmptySubject)
            .DisposedBy(DisposeBag);

            Observable.CombineLatest(
                DescriptionTextView.Rx().AttributedText().SelectUnit(),
                DescriptionTextView.Rx().CursorPosition().SelectUnit()
                )
            .Select(_ => DescriptionTextView.AttributedText)     // Programatically changing the text doesn't send an event, that's why we do this, to get the last version of the text
            .Do(updatePlaceholder)
            .Select(text => text.AsSpans((int)DescriptionTextView.SelectedRange.Location).ToIImmutableList())
            .Subscribe(ViewModel.SetTextSpans.Inputs)
            .DisposedBy(DisposeBag);
        }
Example #5
0
        void ReleaseDesignerOutlets()
        {
            if (BillableButton != null)
            {
                BillableButton.Dispose();
                BillableButton = null;
            }

            if (BottomDistanceConstraint != null)
            {
                BottomDistanceConstraint.Dispose();
                BottomDistanceConstraint = null;
            }

            if (BottomOptionsSheet != null)
            {
                BottomOptionsSheet.Dispose();
                BottomOptionsSheet = null;
            }

            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (DateTimeButton != null)
            {
                DateTimeButton.Dispose();
                DateTimeButton = null;
            }

            if (DescriptionTextField != null)
            {
                DescriptionTextField.Dispose();
                DescriptionTextField = null;
            }

            if (DoneButton != null)
            {
                DoneButton.Dispose();
                DoneButton = null;
            }

            if (ProjectsButton != null)
            {
                ProjectsButton.Dispose();
                ProjectsButton = null;
            }

            if (SuggestionsTableView != null)
            {
                SuggestionsTableView.Dispose();
                SuggestionsTableView = null;
            }

            if (TagsButton != null)
            {
                TagsButton.Dispose();
                TagsButton = null;
            }

            if (TimeLabel != null)
            {
                TimeLabel.Dispose();
                TimeLabel = null;
            }
        }