public SamplePage()
        {
            InitializeComponent();

            HideStatusBar();

            // Get selected sample and set that as the DataContext.
            DataContext = SampleManager.Current.SelectedSample;

            // Load and show the sample.
            SampleContainer.Content = SampleManager.Current.SampleToControl(SampleManager.Current.SelectedSample);

            // Default to the live sample view.
            LiveSample.IsChecked = true;

            string folderPath    = SampleManager.Current.SelectedSample.Path;
            string cssPath       = "ms-appx-web:///Resources\\github-markdown.css";
            string basePath      = $"ms-appx-web:///{folderPath.Substring(folderPath.LastIndexOf("Samples"))}";
            string readmePath    = System.IO.Path.Combine(folderPath, "Readme.md");
            string readmeContent = System.IO.File.ReadAllText(readmePath);

            readmeContent = _markdownRenderer.Parse(readmeContent);
            readmeContent = readmeContent.Replace("src='", "src=\"").Replace(".jpg'", ".jpg\"").Replace("src=\"", $"src=\"{basePath}\\");
            string htmlString = "<!doctype html><head><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>";

            DescriptionView.NavigateToString(htmlString);
            SourceCodeContainer.LoadSourceCode();
        }
Beispiel #2
0
        void InitializeWhatNewView()
        {
            if (BookInfo == null)
            {
                return;
            }
            WhatNewLabel.StringValue    = "What's New";
            CurrentDayLabel.StringValue = BookInfo.LastUpdatedDate.Value.ToString("dd MMM yyyy");
            nfloat height = HeightOfWhatNewInfoView();

            if (height > TEXTVIEW_SIXLINE_HEIGHT)
            {
                NSButton moreButton = CreateMoreButton();
                DescriptionView.WantsLayer = true;
                moreButton.Action          = new Selector("WhatNewViewShowAll:");
                moreButton.Target          = this;
                DescriptionView.AddSubview(moreButton);

                isDescripExpand = false;
            }
            else
            {
                nfloat orgHeight = DespTextField.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = DescriptionView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, descriptionViewHeight + offset);
                DescriptionView.SetFrameSize(newSize);
                //LayoutSubViews ();
            }
        }
        private void adjustHeight()
        {
            double height;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                height = nonScrollableContentHeight + ScrollViewContent.Bounds.Height;
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    height += UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom;
                }
            }
            else
            {
                var errorHeight = ErrorView.Hidden
                    ? 0
                    : ErrorView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var titleHeight      = DescriptionView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var isBillableHeight = BillableView.Hidden ? 0 : 56;
                var timeFieldsHeight = ViewModel.IsEditingGroup ? 0 : 167;
                height = preferredIpadHeight + errorHeight + titleHeight + timeFieldsHeight + isBillableHeight;
            }
            var newSize = new CGSize(0, height);

            if (newSize != PreferredContentSize)
            {
                PreferredContentSize = newSize;
                PresentationController.ContainerViewWillLayoutSubviews();
            }
            ScrollView.ScrollEnabled = ScrollViewContent.Bounds.Height > ScrollView.Bounds.Height;
        }
Beispiel #4
0
        void DescriptionShowAll(NSObject sender)
        {
            float  fontSize = 13.0f;
            nfloat height   = HeightWrappedToWidth(DespTextField, fontSize);

            if (!isDescripExpand)
            {
                nfloat orgHeight = DespTextField.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = DescriptionView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, descriptionViewHeight + offset);
                DescriptionView.SetFrameSize(newSize);

                var button = (NSButton)DescriptionView.Subviews [3];
                NSAttributedString title = Utility.AttributeTitle("...less", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isDescripExpand = true;
            }
            else
            {
                var oldSize = DescriptionView.Frame.Size;
                var newSize = new CGSize(oldSize.Width, descriptionViewHeight);
                DescriptionView.SetFrameSize(newSize);

                var button = (NSButton)DescriptionView.Subviews [3];
                NSAttributedString title = Utility.AttributeTitle("...more", Utility.ColorWithRGB(44, 117, 252, 1.0f), 12);
                button.Cell.AttributedTitle = title;

                isDescripExpand = false;
            }

            LayoutSubViews();
        }
        private void prepareViews()
        {
            DurationLabel.Font = DurationLabel.Font.GetMonospacedDigitFont();

            centerTextVertically(TagsTextView);
            TagsTextView.TextContainer.LineFragmentPadding = 0;

            if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Compact)
            {
                var bottomSafeAreaInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom;
                if (bottomSafeAreaInset >= ButtonsContainerBottomConstraint.Constant)
                {
                    ButtonsContainerBottomConstraint.Constant = 0;
                }
            }

            DescriptionTextView.TintColor       = Colors.StartTimeEntry.Cursor.ToNativeColor();
            DescriptionTextView.PlaceholderText = Resources.AddDescription;

            TimeEntryTimes.Hidden = ViewModel.IsEditingGroup;
            GroupDuration.Hidden  = !ViewModel.IsEditingGroup;
            DurationView.Hidden   = ViewModel.IsEditingGroup;
            StartDateView.Hidden  = ViewModel.IsEditingGroup;

            DescriptionView.InsertSeparator();
            SelectProject.InsertSeparator();
            TagsContainerView.InsertSeparator();
            TimeEntryTimes.InsertSeparator();
            DurationView.InsertSeparator();
            StartDateView.InsertSeparator();
            BillableView.InsertSeparator();
            StartTimeView.InsertSeparator(UIRectEdge.Right);
        }
        public override void SetByView(DescriptionView view)
        {
            var tabel = repo.Get();

            tabel.Alter            = view.Alter;
            tabel.Anrede           = view.Anrede;
            tabel.Augenfarbe       = view.Augenfarbe;
            tabel.FamilienstatusID = view.Familienstatus;
            tabel.Geburstag        = view.Geburstag;
            tabel.GeschlechtID     = view.Geschlecht;
            tabel.Gewicht          = view.Gewicht;
            tabel.Glaube           = view.Glaube;
            tabel.Groesse          = view.Groesse;
            tabel.Haarfarbe        = view.Haarfarbe;
            tabel.Hautfarbe        = view.Hautfarbe;
            tabel.Kultur           = view.Kultur;
            tabel.Name             = view.Name;
            tabel.Profession       = view.Profession;
            tabel.Rasse            = view.Rasse;
            repo.Update(tabel);
            repo.Submit();

            var current = charakterRepo.GetByID(this.charakterID);

            current.Name = tabel.Name;
        }
Beispiel #7
0
        public void SetSample(SampleInfo sample)
        {
            DataContext = sample;

            string folderPath    = sample.Path;
            string readmePath    = System.IO.Path.Combine(folderPath, "Readme.md");
            string readmeContent = System.IO.File.ReadAllText(readmePath);
            string cssPath       = folderPath.Substring(0, folderPath.LastIndexOf("Samples")) + "Resources\\github-markdown.css";

            readmeContent = _markdownRenderer.Parse(readmeContent);

            string htmlString = "<!doctype html><head><base href=\"" + readmePath + "\"><link rel=\"stylesheet\" href=\"" + cssPath + "\" /></head><body class=\"markdown-body\">" + readmeContent + "</body>";

            DescriptionView.NavigateToString(htmlString);
        }
Beispiel #8
0
        void InitializeDescriptionView()
        {
            if (BookInfo == null)
            {
                return;
            }

            float fontSize = 13.0f;

            string description = "3. Verify return to filter option page for Subscription " +
                                 "Given successful login with navigation to My Publications page, " +
                                 "When filtering books by 'Subscription' option \n" +
                                 "and selecting a Subscription title using TOC icon, " +
                                 "Then returning back to My Publications screen will maintain the list of filtered titles.338\n" +
                                 "When clicking the download icon on the subscribed download book, " +
                                 "showing the download progress and a cancel icon at end of progress bar\n" +
                                 "3. Cancel download progress this is";

            DespTextField.StringValue = description;
            if (BookInfo.Description != null)
            {
                DespTextField.StringValue = BookInfo.Description;
            }

            descriptionViewHeight = DescriptionView.Frame.Size.Height;

            var height = HeightWrappedToWidth(DespTextField, fontSize);

            if (height > TEXTVIEW_SIXLINE_HEIGHT)
            {
                NSButton moreButton = CreateMoreButton();
                DescriptionView.WantsLayer = true;
                moreButton.Action          = new Selector("DescriptionShowAll:");
                moreButton.Target          = this;
                DescriptionView.AddSubview(moreButton);

                isDescripExpand = false;
            }
            else
            {
                nfloat orgHeight = DespTextField.Frame.Size.Height;
                nfloat offset    = height - orgHeight;
                var    oldSize   = DescriptionView.Frame.Size;
                var    newSize   = new CGSize(oldSize.Width, descriptionViewHeight + offset);
                DescriptionView.SetFrameSize(newSize);
                //LayoutSubViews ();
            }
        }
Beispiel #9
0
        private void InitializeComponent()
        {
            this.storage = Services.StorageHandler.ReadStorageToFile("storage", "dat");
            this.zones   = new ZoneList(this.storage);
            Hotkey.Setup(this.storage);


            systemMenu = new ContextMenuStrip();
            mapStrip   = new ToolStripMenuItem("Map", null, new EventHandler(OnMapToggle));
            systemMenu.Items.Add(mapStrip);
            descStrip = new ToolStripMenuItem("Description", null, new EventHandler(OnDescriptionToggle));
            systemMenu.Items.Add(descStrip);
            systemMenu.Items.Add(new ToolStripSeparator());
            lockStrip = new ToolStripMenuItem("Lock", null, new EventHandler(OnToggleLockForms));
            systemMenu.Items.Add(lockStrip);
            systemMenu.Items.Add(new ToolStripSeparator());
            systemMenu.Items.Add(new ToolStripMenuItem("Settings", null, new EventHandler(OnSettings)));
            systemMenu.Items.Add(new ToolStripMenuItem("Exit", null, new EventHandler(OnExit)));

            Icon i = Icon.FromHandle(Properties.Resources.icon.GetHicon());

            trayIcon = new NotifyIcon
            {
                BalloonTipTitle  = "Ikaros",
                Icon             = i,
                ContextMenuStrip = systemMenu,
                Visible          = true
            };

            // Forms
            map         = new MapView(this.storage);
            description = new DescriptionView(this.storage);
            settings    = new SettingsView(this.storage, this.zones, this);

            if (storage.mapShown)
            {
                OnMapToggle(mapStrip, null);
            }
            if (storage.descriptionShown)
            {
                OnDescriptionToggle(descStrip, null);
            }


            m_GlobalHook          = Hook.GlobalEvents();
            m_GlobalHook.KeyDown += GlobalHookKeyPress;
        }
        private void adjustHeight()
        {
            double height;
            nfloat coveredByKeyboard = 0;

            if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Compact)
            {
                height  = nonScrollableContentHeight + ScrollViewContent.Bounds.Height;
                height += UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom;
            }
            else
            {
                var errorHeight = ErrorView.Hidden
                    ? 0
                    : ErrorView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var titleHeight      = DescriptionView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var isBillableHeight = BillableView.Hidden ? 0 : 56;
                var timeFieldsHeight = ViewModel.IsEditingGroup ? 0 : 167;
                height = preferredIpadHeight + errorHeight + titleHeight + timeFieldsHeight + isBillableHeight;
            }

            var newSize = new CGSize(0, height);

            if (newSize != PreferredContentSize)
            {
                PreferredContentSize = newSize;
                PresentationController.ContainerViewWillLayoutSubviews();
            }

            ScrollView.ScrollEnabled = ScrollViewContent.Bounds.Height > ScrollView.Bounds.Height;

            if (TraitCollection.HorizontalSizeClass == UIUserInterfaceSizeClass.Regular)
            {
                if (ScrollView.ScrollEnabled && keyboardHeight > 0)
                {
                    nfloat scrollViewContentBottomPadding = ViewModel.IsEditingGroup ? coveredByKeyboard : 0;
                    ScrollView.ContentSize = new CGSize(ScrollView.ContentSize.Width, ScrollViewContent.Bounds.Height + scrollViewContentBottomPadding);
                    ScrollView.SetContentOffset(new CGPoint(0, ScrollView.ContentSize.Height - ScrollView.Bounds.Height), false);
                }
                else
                {
                    ScrollView.ContentSize = new CGSize(ScrollView.ContentSize.Width, ScrollViewContent.Bounds.Height);
                }
            }
        }
Beispiel #11
0
 void ReleaseDesignerOutlets()
 {
     if (DescriptionView != null)
     {
         DescriptionView.Dispose();
         DescriptionView = null;
     }
     if (NameView != null)
     {
         NameView.Dispose();
         NameView = null;
     }
     if (SaveButton != null)
     {
         SaveButton.Dispose();
         SaveButton = null;
     }
 }
Beispiel #12
0
        private async void AnalyzeImageAsync(string imagePath)
        {
            CognitiveService.Instance.PlayAudio("Analizando foto");

            var imageDescription = await CognitiveService.Instance.AnalyzeImageAsync(imagePath);

            TranslatedDescription = await CognitiveService.Instance.TranslateTextAsync(imageDescription);

            FixTranslation();
            DescriptionView.Text = TranslatedDescription;

            await LoadingView.FadeTo(0, 500);

            await DescriptionView.FadeTo(1, 1000);

            await SpeakAgainView.FadeTo(1, 1000);

            SpeakDescriptionAsync();
        }
        public string HttpRequest()
        {
            var name      = "New Charakter";
            var repo      = new SQLCharakterRepository(Context);
            var charakter = repo.CreateDSACharakter(Context, name);

            var abstractcharakter = GetDSASQLCharakter(charakter.Id);

            //Attribute Default
            var descriptions = abstractcharakter.Description;
            var attributRepo = abstractcharakter.Attribute;

            var descriptionView = new DescriptionView()
            {
                Name = name
            };

            abstractcharakter.Description.SetByView(descriptionView);

            var attributList = new List <CharakterAttribut>
            {
                CharakterAttribut.Mut,
                CharakterAttribut.Klugheit,
                CharakterAttribut.Intuition,
                CharakterAttribut.Charisma,
                CharakterAttribut.Fingerfertigkeit,
                CharakterAttribut.Gewandheit,
                CharakterAttribut.Konstitution,
                CharakterAttribut.Körperkraft,
                CharakterAttribut.Sozialstatus
            };

            foreach (var attribut in attributList)
            {
                attributRepo.SetAKT(attribut, 9);
            }


            //CreateCharakterTestValues(abstractcharakter) ;

            return(CreateResponse(charakter));
        }
Beispiel #14
0
        private void prepareViews()
        {
            projectTaskClientToAttributedString = new ProjectTaskClientToAttributedString(
                ProjectTaskClientLabel.Font.CapHeight,
                Colors.EditTimeEntry.ClientText.ToNativeColor());

            tagsListToAttributedString = new TagsListToAttributedString(TagsTextView);

            centerTextVertically(TagsTextView);
            TagsTextView.TextContainer.LineFragmentPadding = 0;

            DescriptionTextView.TintColor       = Colors.StartTimeEntry.Cursor.ToNativeColor();
            DescriptionTextView.PlaceholderText = Resources.AddDescription;
            DescriptionTextView.TextColor       = ColorAssets.Text;

            DescriptionView.InsertSeparator();
            PasteFromClipboardHintView.InsertSeparator();
            SelectProjectView.InsertSeparator();
            SelectTagsView.InsertSeparator();
            BillableView.InsertSeparator();
        }
        public void UpdateCell(Post post, Action <string> TagAction)
        {
            var attributedLabel = new TTTAttributedLabel();

            attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            attributedLabel.LinkAttributes       = prop;
            attributedLabel.ActiveLinkAttributes = prop;

            DescriptionView.AddSubview(attributedLabel);
            attributedLabel.Font  = Helpers.Constants.Regular14;
            attributedLabel.Lines = 0;
            attributedLabel.UserInteractionEnabled = true;
            attributedLabel.Enabled = true;
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            attributedLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 15f);
            attributedLabel.Delegate = new TTTAttributedLabelFeedDelegate(TagAction);

            var separator = new UIView();

            separator.BackgroundColor = iOS.Helpers.Constants.R245G245B245;
            DescriptionView.AddSubview(separator);

            separator.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, attributedLabel, 15f);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            separator.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);
            separator.AutoSetDimension(ALDimension.Height, 1);

            var noLinkAttribute = new UIStringAttributes
            {
                Font            = Helpers.Constants.Regular14,
                ForegroundColor = Helpers.Constants.R15G24B30,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(post.Title, noLinkAttribute));
            if (!string.IsNullOrEmpty(post.Description))
            {
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(Environment.NewLine));
                at.Append(new NSAttributedString(post.Description, noLinkAttribute));
            }

            foreach (var tag in post.Tags)
            {
                if (tag == "steepshot")
                {
                    continue;
                }
                var linkAttribute = new UIStringAttributes
                {
                    Link            = new NSUrl(tag),
                    Font            = Helpers.Constants.Regular14,
                    ForegroundColor = Helpers.Constants.R231G72B0,
                };
                at.Append(new NSAttributedString($" #{tag}", linkAttribute));
            }
            attributedLabel.SetText(at);
        }
Beispiel #16
0
        void ReleaseDesignerOutlets()
        {
            if (AContentView != null)
            {
                AContentView.Dispose();
                AContentView = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (DotButton != null)
            {
                DotButton.Dispose();
                DotButton = null;
            }
        }
        private void adjustHeight()
        {
            double height;
            nfloat coveredByKeyboard = 0;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                height = nonScrollableContentHeight + ScrollViewContent.Bounds.Height;
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    height += UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Bottom;
                }

                if (keyboardHeight > 0)
                {
                    // this bit of code depends on the knowledge of the component tree:
                    // - description label is inside of a container view which is placed in a stack view
                    // - we want to know the vertical location of the container view in the whole view
                    // - we actually want to know the Y coordinate of the bottom of the container and make
                    //   sure we don't overaly it with the keyboard
                    var container                   = DescriptionTextView.Superview;
                    var absoluteLocation            = View.ConvertPointFromView(container.Frame.Location, container.Superview.Superview);
                    var minimumVisibleContentHeight = View.Frame.Height - absoluteLocation.Y - container.Frame.Height;

                    coveredByKeyboard = keyboardHeight - minimumVisibleContentHeight;

                    var safeAreaOffset = UIDevice.CurrentDevice.CheckSystemVersion(11, 0)
                        ? Math.Max(UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top, UIApplication.SharedApplication.StatusBarFrame.Height)
                        : 0;
                    var distanceFromTop = Math.Max(safeAreaOffset, View.Frame.Y - coveredByKeyboard);

                    height = UIScreen.MainScreen.Bounds.Height - distanceFromTop;
                }
            }
            else
            {
                var errorHeight = ErrorView.Hidden
                    ? 0
                    : ErrorView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var titleHeight      = DescriptionView.SizeThatFits(UIView.UILayoutFittingCompressedSize).Height;
                var isBillableHeight = BillableView.Hidden ? 0 : 56;
                var timeFieldsHeight = ViewModel.IsEditingGroup ? 0 : 167;
                height = preferredIpadHeight + errorHeight + titleHeight + timeFieldsHeight + isBillableHeight;
            }

            var newSize = new CGSize(0, height);

            if (newSize != PreferredContentSize)
            {
                PreferredContentSize = newSize;
                PresentationController.ContainerViewWillLayoutSubviews();
            }

            ScrollView.ScrollEnabled = ScrollViewContent.Bounds.Height > ScrollView.Bounds.Height;

            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                if (ScrollView.ScrollEnabled && keyboardHeight > 0)
                {
                    nfloat scrollViewContentBottomPadding = ViewModel.IsEditingGroup ? coveredByKeyboard : 0;
                    ScrollView.ContentSize = new CGSize(ScrollView.ContentSize.Width, ScrollViewContent.Bounds.Height + scrollViewContentBottomPadding);
                    ScrollView.SetContentOffset(new CGPoint(0, ScrollView.ContentSize.Height - ScrollView.Bounds.Height), false);
                }
                else
                {
                    ScrollView.ContentSize = new CGSize(ScrollView.ContentSize.Width, ScrollViewContent.Bounds.Height);
                }
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (AddSkillButton != null)
            {
                AddSkillButton.Dispose();
                AddSkillButton = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (SQButton != null)
            {
                SQButton.Dispose();
                SQButton = null;
            }
        }
Beispiel #19
0
        public PullRequestView()
        {
            _descriptionElement = new HtmlElement("body");
            _commentsElement    = new HtmlElement("comments");

            _milestoneElement = new StyledStringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1)
            {
                Image = Images.Milestone
            };
            _milestoneElement.Tapped += () => ViewModel.GoToMilestoneCommand.ExecuteIfCan();

            _assigneeElement = new StyledStringElement("Assigned", "Unassigned", UITableViewCellStyle.Value1)
            {
                Image = Images.Person
            };
            _assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.ExecuteIfCan();

            _labelsElement = new StyledStringElement("Labels", "None", UITableViewCellStyle.Value1)
            {
                Image = Images.Tag
            };
            _labelsElement.Tapped += () => ViewModel.GoToLabelsCommand.ExecuteIfCan();

            _addCommentElement = new StyledStringElement("Add Comment")
            {
                Image = Images.Pencil
            };
            _addCommentElement.Tapped += AddCommentTapped;

            _split1 = new SplitElement
            {
                Button1 = new SplitElement.SplitButton(Images.Cog, string.Empty),
                Button2 = new SplitElement.SplitButton(Images.Cog, string.Empty)
            };

            _split2 = new SplitElement
            {
                Button1 = new SplitElement.SplitButton(Images.Cog, string.Empty),
                Button2 = new SplitElement.SplitButton(Images.Cog, string.Empty)
            };

            _commitsElement = new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Images.Commit);
            _filesElement   = new StyledStringElement("Files", () => ViewModel.GoToFilesCommand.ExecuteIfCan(), Images.File);

            this.WhenViewModel(x => x.GoToUrlCommand).Subscribe(x =>
            {
                _commentsElement.UrlRequested    = x.Execute;
                _descriptionElement.UrlRequested = x.Execute;
            });

            this.WhenViewModel(x => x.MarkdownDescription).Subscribe(x =>
            {
                var markdown = new DescriptionView {
                    Model = x
                };
                var html = markdown.GenerateString();
                _descriptionElement.Value = html;
            });

            this.WhenViewModel(x => x.ShowMenuCommand).Subscribe(x =>
                                                                 NavigationItem.RightBarButtonItem = x.ToBarButtonItem(UIBarButtonSystemItem.Action));
        }
Beispiel #20
0
        void ReleaseDesignerOutlets()
        {
            if (AvailableField != null)
            {
                AvailableField.Dispose();
                AvailableField = null;
            }

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

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

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

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

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

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

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

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

            if (UploadButton != null)
            {
                UploadButton.Dispose();
                UploadButton = null;
            }
        }
 public abstract void SetByView(DescriptionView view);
Beispiel #22
0
        void LayoutSubViews()
        {
            if (BookInfo == null)
            {
                return;
            }

            //calculate the subview size
            CGSize infoViewSize     = InformationView.Frame.Size;
            CGSize whatsNewViewSize = WhatNewView.Frame.Size;

            CGSize casesViewSize;

            if (CaseView.Hidden)
            {
                casesViewSize = new CGSize(0, 0);
            }
            else
            {
                casesViewSize = CaseView.Frame.Size;
            }

            CGSize despViewSize = DescriptionView.Frame.Size;

            CGSize expiredViewSize;

            if (BookInfo.DaysRemaining < 0)
            {
                expiredViewSize = ExpiredView.Frame.Size;
            }
            else
            {
                expiredViewSize = new CGSize(0, 0);
            }

            CGSize titleViewSize = TitleView.Frame.Size;

            //set scrollview contentview size
            nfloat caseSpace   = casesViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat expirdSpace = expiredViewSize.Height == 0 ? 0 : VERTICAL_SPACING;
            nfloat height      = VERTICAL_SPACING +
                                 infoViewSize.Height + VERTICAL_SPACING +
                                 whatsNewViewSize.Height + VERTICAL_SPACING +
                                 casesViewSize.Height + caseSpace +
                                 despViewSize.Height + VERTICAL_SPACING +
                                 expiredViewSize.Height + expirdSpace +
                                 titleViewSize.Height;

            CGRect scrollFrame = ScrollView.Frame;

            nfloat contentHeight = scrollFrame.Bottom > height ? scrollFrame.Bottom : height;

            var contentSize = new CGSize(AContentView.Frame.Size.Width, contentHeight);

            AContentView.SetFrameSize(contentSize);

            //add subview to document view
            var docView = (NSView)ScrollView.DocumentView;

            docView.SetFrameSize(contentSize);

            foreach (NSView view in docView.Subviews)
            {
                view.RemoveFromSuperview();
            }

            docView.AddSubview(AContentView);
            AContentView.SetFrameOrigin(new CGPoint(0, 0));

            //recalulate subviews origin point
            nfloat startOffset = scrollFrame.Bottom >= height ? (scrollFrame.Bottom - height + VERTICAL_SPACING) : VERTICAL_SPACING;
            nfloat yOffset;

            var InfoViewPoint = InformationView.Frame.Location;

            InfoViewPoint.Y = startOffset;
            InformationView.SetFrameOrigin(InfoViewPoint);

            var WhatsViewPoint = new CGPoint(InfoViewPoint.X, InfoViewPoint.Y + infoViewSize.Height + VERTICAL_SPACING);

            WhatNewView.SetFrameOrigin(WhatsViewPoint);

            var CaseViewPoint = new CGPoint(InfoViewPoint.X, WhatsViewPoint.Y + whatsNewViewSize.Height + VERTICAL_SPACING);

            CaseView.SetFrameOrigin(CaseViewPoint);

            if (casesViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var DesViewPoint = new CGPoint(InfoViewPoint.X, CaseViewPoint.Y + casesViewSize.Height + yOffset);

            DescriptionView.SetFrameOrigin(DesViewPoint);

            var ExpireViewPoint = new CGPoint(InfoViewPoint.X, DesViewPoint.Y + despViewSize.Height + VERTICAL_SPACING);

            ExpiredView.SetFrameOrigin(ExpireViewPoint);

            if (expiredViewSize.Height > 0)
            {
                yOffset = VERTICAL_SPACING;
            }
            else
            {
                yOffset = 0;
            }

            var TitleViewPoint = new CGPoint(InfoViewPoint.X, ExpireViewPoint.Y + expiredViewSize.Height + yOffset);

            TitleView.SetFrameOrigin(TitleViewPoint);

            ScrollToTop();
        }
Beispiel #23
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (TagsTextView != null)
            {
                TagsTextView.Dispose();
                TagsTextView = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (cnCenterStatusWidth != null)
            {
                cnCenterStatusWidth.Dispose();
                cnCenterStatusWidth = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (vStatusCircleLeft != null)
            {
                vStatusCircleLeft.Dispose();
                vStatusCircleLeft = null;
            }
        }
Beispiel #25
0
 protected BaseAiDescriptionCell(AContext context, Cell cell) : base(context, cell)
 {
     _Icon        = IconView.Create(ContentView, this, Resource.Id.CellIcon);
     _Description = BaseTextView.Create <DescriptionView>(ContentView, this, Resource.Id.CellDescription);
 }
Beispiel #26
0
        void ReleaseDesignerOutlets()
        {
            if (AddProjectAndTaskView != null)
            {
                AddProjectAndTaskView.Dispose();
                AddProjectAndTaskView = null;
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
Beispiel #27
0
        protected BaseIssueView()
        {
            CommentsElement = new HtmlElement("comments");
            this.WhenAnyValue(x => x.ViewModel.GoToUrlCommand)
            .Subscribe(x => CommentsElement.UrlRequested = x.ExecuteIfCan);

            DescriptionElement = new HtmlElement("description");
            this.WhenAnyValue(x => x.ViewModel.GoToUrlCommand)
            .Subscribe(x => DescriptionElement.UrlRequested = x.ExecuteIfCan);

            this.WhenAnyValue(x => x.ViewModel.ShowMenuCommand)
            .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Action))
            .Subscribe(x => NavigationItem.RightBarButtonItem = x);

            this.WhenAnyValue(x => x.ViewModel.GoToAssigneesCommand)
            .Switch()
            .Subscribe(_ => ShowAssigneeSelector());

            this.WhenAnyValue(x => x.ViewModel.GoToMilestonesCommand)
            .Switch()
            .Subscribe(_ => ShowMilestonesSelector());

            this.WhenAnyValue(x => x.ViewModel.GoToLabelsCommand)
            .Switch()
            .Subscribe(_ => ShowLabelsSelector());

            this.WhenAnyValue(x => x.ViewModel.GoToOwnerCommand)
            .Subscribe(x => HeaderView.ImageButtonAction = x != null ? new Action(() => ViewModel.GoToOwnerCommand.ExecuteIfCan()) : null);

            Appeared.Take(1)
            .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.2f)))
            .Switch()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsClosed))
            .Switch()
            .Subscribe(x =>
            {
                HeaderView.SubImageView.TintColor = x ? UIColor.FromRGB(0xbd, 0x2c, 0) : UIColor.FromRGB(0x6c, 0xc6, 0x44);
                HeaderView.SetSubImage((x ? Octicon.IssueClosed :Octicon.IssueOpened).ToImage());
            });

            MilestoneElement = new StringElement("Milestone", string.Empty, UITableViewCellStyle.Value1)
            {
                Image = Octicon.Milestone.ToImage()
            };
            MilestoneElement.Tapped = () => ViewModel.GoToMilestonesCommand.ExecuteIfCan();
            this.WhenAnyValue(x => x.ViewModel.AssignedMilestone)
            .Select(x => x == null ? "No Milestone" : x.Title)
            .Subscribe(x => MilestoneElement.Value = x);

            AssigneeElement = new StringElement("Assigned", string.Empty, UITableViewCellStyle.Value1)
            {
                Image = Octicon.Person.ToImage()
            };
            AssigneeElement.Tapped = () => ViewModel.GoToAssigneesCommand.ExecuteIfCan();
            this.WhenAnyValue(x => x.ViewModel.AssignedUser)
            .Select(x => x == null ? "Unassigned" : x.Login)
            .Subscribe(x => AssigneeElement.Value = x);

            LabelsElement = new StringElement("Labels", string.Empty, UITableViewCellStyle.Value1)
            {
                Image = Octicon.Tag.ToImage()
            };
            LabelsElement.Tapped = () => ViewModel.GoToLabelsCommand.ExecuteIfCan();
            this.WhenAnyValue(x => x.ViewModel.AssignedLabels)
            .Select(x => (x == null || x.Count == 0) ? "None" : string.Join(",", x.Select(y => y.Name)))
            .Subscribe(x => LabelsElement.Value = x);

            this.WhenAnyValue(x => x.ViewModel.CanModify)
            .Select(x => x ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None)
            .Subscribe(x => MilestoneElement.Accessory = AssigneeElement.Accessory = LabelsElement.Accessory = x);

            DetailsSection.Add(MilestoneElement);
            DetailsSection.Add(AssigneeElement);
            DetailsSection.Add(LabelsElement);

            this.WhenAnyValue(x => x.ViewModel.Issue)
            .IsNotNull()
            .Subscribe(x =>
            {
                HeaderView.Text     = x.Title;
                HeaderView.ImageUri = x.User.AvatarUrl;

                if (x.UpdatedAt.HasValue)
                {
                    HeaderView.SubText = "Updated " + x.UpdatedAt.Value.UtcDateTime.Humanize();
                }
                else
                {
                    HeaderView.SubText = "Created " + x.CreatedAt.UtcDateTime.Humanize();
                }

                RefreshHeaderView();
            });

            this.WhenAnyValue(x => x.ViewModel.MarkdownDescription)
            .Subscribe(x =>
            {
                if (string.IsNullOrEmpty(x))
                {
                    DetailsSection.Remove(DescriptionElement);
                }
                else
                {
                    var model    = new DescriptionModel(x, (int)UIFont.PreferredSubheadline.PointSize);
                    var markdown = new DescriptionView {
                        Model = model
                    };
                    var html = markdown.GenerateString();
                    DescriptionElement.Value = html;

                    if (!DetailsSection.Contains(DescriptionElement))
                    {
                        DetailsSection.Insert(0, UITableViewRowAnimation.Fade, DescriptionElement);
                    }
                }
            });

            CommentsSection.FooterView = new TableFooterButton("Add Comment", () => ViewModel.AddCommentCommand.ExecuteIfCan());

            this.WhenAnyValue(x => x.ViewModel.Events)
            .Select(x => x.Changed)
            .Switch()
            .Select(x => ViewModel.Events)
            .Subscribe(events =>
            {
                var comments = events.Select(x =>
                {
                    var body    = string.Empty;
                    var comment = x as IssueCommentItemViewModel;
                    var @event  = x as IssueEventItemViewModel;

                    if (comment != null)
                    {
                        body = comment.Comment;
                    }
                    else if (@event != null)
                    {
                        body = CreateEventBody(@event.EventInfo, @event.Commit);
                    }

                    return(new Comment(x.AvatarUrl.ToUri(), x.Actor, body, x.CreatedAt.LocalDateTime.Humanize()));
                })
                               .Where(x => !string.IsNullOrEmpty(x.Body))
                               .ToList();

                if (comments.Count > 0)
                {
                    var commentModel = new CommentModel(comments, (int)UIFont.PreferredSubheadline.PointSize);
                    var razorView    = new CommentsView {
                        Model = commentModel
                    };
                    var html = razorView.GenerateString();
                    CommentsElement.Value = html;

                    if (!CommentsSection.Contains(CommentsElement))
                    {
                        CommentsSection.Insert(0, UITableViewRowAnimation.Fade, CommentsElement);
                    }
                }
                else
                {
                    CommentsSection.Remove(CommentsElement);
                }
            });

            var commentsButton     = SplitButton.AddButton("Comments", "-");
            var participantsButton = SplitButton.AddButton("Participants", "-");

            this.WhenAnyValue(x => x.ViewModel.Issue.Comments)
            .Subscribe(x => commentsButton.Text = x.ToString());

            this.WhenAnyValue(x => x.ViewModel.Participants)
            .Subscribe(x => participantsButton.Text = x.ToString());
        }
Beispiel #28
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var secDetails      = new Section();
            var commentsSection = new Section(null, new TableFooterButton("Add Comment", () => ViewModel.AddCommentCommand.ExecuteIfCan()));
            var commentsElement = new HtmlElement("comments");

            commentsElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan;

            var descriptionElement = new HtmlElement("description");

            descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan;

            secDetails.Add(_milestoneElement);
            secDetails.Add(_assigneeElement);
            secDetails.Add(_labelsElement);

            var addCommentElement = new StyledStringElement("Add Comment")
            {
                Image = Images.Pencil
            };

            this.WhenViewModel(x => x.MarkdownDescription).Subscribe(x =>
            {
                if (string.IsNullOrEmpty(x))
                {
                    secDetails.Remove(descriptionElement);
                }
                else
                {
                    var markdown = new DescriptionView {
                        Model = x
                    };
                    var html = markdown.GenerateString();
                    descriptionElement.Value = html;

                    if (!secDetails.Contains(descriptionElement))
                    {
                        secDetails.Insert(0, UITableViewRowAnimation.Fade, descriptionElement);
                    }
                }
            });

            ViewModel.Events.Changed.Subscribe(_ =>
            {
                var commentModels = ViewModel.Events
                                    .Select(x =>
                {
                    var body    = string.Empty;
                    var comment = x as IssueCommentItemViewModel;
                    var @event  = x as IssueEventItemViewModel;

                    if (comment != null)
                    {
                        body = comment.Comment;
                    }
                    else if (@event != null)
                    {
                        body = CreateEventBody(@event.EventInfo, @event.Commit);
                    }

                    return(new Comment(x.AvatarUrl, x.Actor, body, x.CreatedAt.LocalDateTime.Humanize()));
                })
                                    .Where(x => !string.IsNullOrEmpty(x.Body))
                                    .ToList();

                if (commentModels.Count > 0)
                {
                    var razorView = new CommentsView {
                        Model = commentModels
                    };
                    var html = razorView.GenerateString();
                    commentsElement.Value = html;

                    if (!commentsSection.Contains(commentsElement))
                    {
                        commentsSection.Insert(0, UITableViewRowAnimation.Fade, commentsElement);
                    }
                }
                else
                {
                    commentsSection.Remove(commentsElement);
                }
            });

            Root.Reset(new Section(), secDetails, commentsSection);
        }