public View GetDescription(string resource) { // Get our markdown content. string readmeContent; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource)) { using (StreamReader reader = new StreamReader(stream)) { readmeContent = reader.ReadToEnd(); } } // Create our markdown description. var view = new MarkdownView { Markdown = readmeContent }; var scrollContainer = new ScrollView() { Content = view.Content, HeightRequest = 1000, Margin = 5 }; var stack = new StackLayout() { Children = { scrollContainer } }; return(stack); }
public MarkDownSample() { var openFileDialog = new OpenFileDialog("Select File"); var markdown = new MarkdownView() { Markdown = MarkDownText, LineSpacing = 3, }; var scrolled = new ScrollView(markdown) { MinHeight = 400 }; var button = new Button("Open File"); button.Clicked += delegate { if (openFileDialog.Run(ParentWindow)) { markdown.Markdown = File.ReadAllText(openFileDialog.FileName); } }; PackStart(button, true); PackStart(scrolled, true); }
protected virtual void LoadSource(Uri fileUri) { if (ViewModel.IsMarkdown) { var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); var htmlContent = new MarkdownView { Model = content }; LoadContent(htmlContent.GenerateString()); } else { var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); var contentStr = new SyntaxHighlighterView { Model = new SourceBrowserModel { Content = content, Theme = ViewModel.Theme ?? "idea" } }.GenerateString(); LoadContent(contentStr); } }
async Task LoadSource(Uri fileUri) { var fontSize = (int)UIFont.PreferredSubheadline.PointSize; var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); if (ViewModel.IsMarkdown) { var markdownContent = await Mvx.Resolve <IApplicationService>().Client.Markdown.GetMarkdown(content); var model = new DescriptionModel(markdownContent, fontSize); var htmlContent = new MarkdownView { Model = model }; LoadContent(htmlContent.GenerateString()); } else { var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var model = new SourceBrowserModel(content, "idea", fontSize, zoom, fileUri.LocalPath); var contentView = new SyntaxHighlighterView { Model = model }; LoadContent(contentView.GenerateString()); } }
private void InitPreviewWnd() { if (_previewWnd != null) { return; } _previewWnd = new Window { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Height = 600, Width = 800, ShowInTaskbar = true, Title = "Previewing" }; _previewWnd.Closing += (sender, args) => { _previewWnd.Hide(); args.Cancel = true; Activate(); }; _previewBrowser = new MarkdownView(); _previewWnd.Content = _previewBrowser; _previewBrowser.OpenLinkInExternalBrowser = true; }
public void DownloadFile() { //WebClient client = new WebClient(); //Stream stream = client.OpenRead("https://raw.githubusercontent.com/VDTS/docs/main/PrivacyPolicy.md"); //StreamReader reader = new StreamReader(stream); //var view = new MarkdownView(); //view.Markdown = reader.ReadToEnd(); ////view.Theme = new DarkMarkdownTheme(); // Default is white, you also modify various values //Content = view; var view = new MarkdownView(); view.Markdown = $@"# Privacy Policy version: 1.0 beta - Tracking users __GPS__ information for detecting fraud behavior in fields - __Collecting device information__ of users for feedback; device number, device version and platform for diagnosing which device can cause affliction to the Application. - In case of crashes in the app, the complete __diagnostic information__ will be sent to the maintenance team. - The app buttons and other components usage __statistics and analytics__ will be shared with product management team for improving user experience based on it. - Any __deleted data__ in the app will take 90 days to be completely deleted from the database; this feature is for data integrity. - Each data __edit history__ is kept. - The App __usage wellbeing__ will be kept for tracking user activity duration. - In case of the __Beta version__ of the app, each user is required to update the latest release of the app; as the maintenance team consists of few members and can not support many updates at once. ### - [TheCodeX Team 2021](https://github.com/VDTS) "; Content = view; }
void SegmentValueChanged(object sender, EventArgs e) { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new WKWebView(this.View.Bounds, new WKWebViewConfiguration()); } TextView.RemoveFromSuperview(); Add(_previewView); var markdownService = Mvx.Resolve <IMarkdownService>(); var markdownText = markdownService.Convert(Text); var model = new DescriptionModel(markdownText, (int)UIFont.PreferredSubheadline.PointSize); var view = new MarkdownView { Model = model }.GenerateString(); _previewView.LoadHtmlString(view, NSBundle.MainBundle.BundleUrl); } }
void SegmentValueChanged(object sender, EventArgs e) { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdownService = IoC.Resolve <IMarkdownService>(); var markdownView = new MarkdownView() { Model = markdownService.Convert(TextView.Text) }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }
public LogViewerHelpDialog() { var label = new Label("Log viewer help"); label.Font = label.Font.WithSize(15).WithWeight(Xwt.Drawing.FontWeight.Bold); var markdown = new MarkdownView(); using (var stream = typeof(LogViewerHelpDialog).Assembly.GetManifestResourceStream("Antmicro.Renode.Plugins.AdvancedLoggerViewer.LogViewerHelpFile.txt")) { using (var reader = new StreamReader(stream)) { markdown.Markdown = reader.ReadToEnd(); } } var box = new VBox(); box.PackStart(label); box.PackStart(markdown, true); Content = box; Buttons.Add(new DialogButton(Command.Ok)); Width = 1000; Height = 300; }
public void test_background_color_override() { var view = new MarkdownView { BackgroundColorOverride = Color.Aqua }; view.Markdown = @"* This is a test"; Assert.AreEqual(Color.Aqua, view.BackgroundColor); }
/// <summary>Display a view on the right hand panel in view.</summary> public void ShowRightHandPanel() { if (this.view.Tree.SelectedNode != string.Empty) { object model = this.ApsimXFile.FindByPath(this.view.Tree.SelectedNode)?.Value; if (model != null) { ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute; PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute; DescriptionAttribute descriptionName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(DescriptionAttribute), false) as DescriptionAttribute; if (descriptionName != null && model.GetType().Namespace.Contains("CLEM")) { viewName = new ViewNameAttribute("UserInterface.Views.ModelDetailsWrapperView"); presenterName = new PresenterNameAttribute("UserInterface.Presenters.ModelDetailsWrapperPresenter"); } if (Configuration.Settings.UseNewPropertyPresenter && presenterName != null) { if (presenterName.ToString().Contains(".PropertyPresenter")) { presenterName = new PresenterNameAttribute("UserInterface.Presenters.SimplePropertyPresenter"); viewName = new ViewNameAttribute("UserInterface.Views.PropertyView"); } else if (presenterName.ToString().Contains(".BiomassRemovalPresenter")) { presenterName = new PresenterNameAttribute("UserInterface.Presenters.CompositePropertyPresenter"); viewName = new ViewNameAttribute("UserInterface.Views.PropertyView"); } } // if a clem model ignore the newly added description box that is handled by CLEM wrapper if (!model.GetType().Namespace.Contains("CLEM")) { ShowDescriptionInRightHandPanel(descriptionName?.ToString()); } if (viewName != null && viewName.ToString().Contains(".glade")) { ShowInRightHandPanel(model, newView: new ViewBase(view as ViewBase, viewName.ToString()), presenter: Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter); } else if (viewName != null && presenterName != null) { ShowInRightHandPanel(model, viewName.ToString(), presenterName.ToString()); } else { var view = new MarkdownView(this.view as ViewBase); var presenter = new DocumentationPresenter(); ShowInRightHandPanel(model, view, presenter); } } } }
private async void UserControl_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { if (IsVisible) { var result = await UpdatePreview(); MarkdownView.NavigateToString(result); } }
private async void UserControl_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { if (this.IsVisible) { LoadingProgess.Visibility = System.Windows.Visibility.Visible; string result = await UpdatePreview(); MarkdownView.NavigateToString(result); LoadingProgess.Visibility = System.Windows.Visibility.Hidden; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Thanks); _thanksMarkdown = FindViewById <MarkdownView>(Resource.Id.ThanksMarkdown); _thanksMarkdown.LoadMarkdownFile( "file:///android_asset/thanks.md", "file:///android_asset/github-markdown.css"); }
/// <summary> /// Attach inherited class additional presenters is needed /// </summary> public void AttachExtraPresenters(CLEMPresenter clemPresenter) { object newView = new MarkdownView(clemPresenter.View as ViewBase); IPresenter labourPresenter = new LabourAllocationPresenter(); if (newView != null && labourPresenter != null) { clemPresenter.View.AddTabView("Display", newView); labourPresenter.Attach(clemPresenter.Model, newView, clemPresenter.ExplorerPresenter); clemPresenter.PresenterList.Add("Display", labourPresenter); } }
public void test_non_markdown_urls() { var view = new MarkdownView(); const string mardownText = "https://www.google.com"; view.Markdown = mardownText; var hasLinks = view.Content.LogicalChildren.Any(x => x is Label label && label.GestureRecognizers.Any()); Assert.IsTrue(hasLinks); }
public void test_email_markdown_url() { var view = new MarkdownView(); const string mardownText = "[Email me]([email protected])"; view.Markdown = mardownText; var hasLinks = view.Content.LogicalChildren.Any(x => x is Label label && label.GestureRecognizers.Any()); Assert.IsTrue(hasLinks); }
public void test_phone_no_url() { var view = new MarkdownView(); const string mardownText = "555-123-4567"; view.Markdown = mardownText; var hasLinks = view.Content.LogicalChildren.Any(x => x is Label label && label.GestureRecognizers.Any()); Assert.IsFalse(hasLinks); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.IssueDetailView, container, false); _issueBodyTextView = view.FindViewById <MarkdownView>(Resource.Id.IssueBodyTextView); _issueMilestoneDate = view.FindViewById <TextView>(Resource.Id.IssueMilestoneDate); _issueTitleTextView = view.FindViewById <TextView>(Resource.Id.IssueTitle); _issueStatusTextView = view.FindViewById <TextView>(Resource.Id.IssueStatusTextView); _issueCreatedAtTextView = view.FindViewById <TextView>(Resource.Id.IssueCreatedAtTextView); _issueMilestoneInfo = view.FindViewById <TextView>(Resource.Id.IssueMilestoneInfo); _labelsRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.LabelsRecyclerView); return(view); }
public ViewPage() { _fileManager = DependencyService.Get <IFileManager>(); _webView = new MarkdownView { Markdown = Samples.AboutDocument, VerticalOptions = LayoutOptions.FillAndExpand }; // Accomodate iPhone status bar. this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); // Build the page. this.Content = _webView; var openFileButton = new ToolbarItem { Text = "Open" }; openFileButton.Clicked += async(s, a) => { var mdFile = await _fileManager.LoadFile(); if (mdFile != null) { SetExternDocument(mdFile); } }; int i = 0; var changeCssButton = new ToolbarItem { Text = "CSS" }; changeCssButton.Clicked += async(s, a) => { _webView.Stylesheet = _stylesheets[i++ % _stylesheets.Length]; }; if (Device.OS == TargetPlatform.Windows) { ToolbarItems.Add(openFileButton); } ToolbarItems.Add(changeCssButton); }
protected override void LoadSource(Uri fileUri) { if (ViewModel.IsMarkdown) { var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); var htmlContent = new MarkdownView { Model = content }; LoadContent(htmlContent.GenerateString()); } else { base.LoadSource(fileUri); } }
/// <summary> /// Create components /// </summary> public override void _initializeComponents() { var markdown = new MarkdownView() { Markdown = MarkDownText }; markdown.Margin = 10; var scrolled = new ScrollView(markdown) { MinHeight = 400 }; PackStart(scrolled, true); }
protected MarkdownComposerView(IMarkdownService markdownService) { TextView.Font = UIFont.SystemFontOfSize(16f); TextView.Changed += (sender, e) => ViewModel.Text = TextView.Text; this.WhenAnyValue(x => x.ViewModel.Text) .Subscribe(x => Text = x); this.WhenAnyValue(x => x.ViewModel.PostToImgurCommand) .Select(x => x == null ? null : new MarkdownAccessoryView(TextView, ViewModel.PostToImgurCommand)) .Subscribe(x => TextView.InputAccessoryView = x); _viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" }); _viewSegment.SelectedSegment = 0; NavigationItem.TitleView = _viewSegment; _viewSegment.ValueChanged += (sender, e) => { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdownView = new MarkdownView { Model = markdownService.Convert(TextView.Text) }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }; }
public App() { InitializeComponent(); var _webView = new MarkdownView { Markdown = Md, VerticalOptions = LayoutOptions.FillAndExpand }; MainPage = new ContentPage() { // Accomodate iPhone status bar. Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0), Content = _webView }; }
protected MarkdownComposerViewController(IMarkdownService markdownService) { TextView.Font = UIFont.PreferredBody; TextView.Changed += (sender, e) => ViewModel.Text = TextView.Text; TextView.InputAccessoryView = new MarkdownAccessoryView(TextView); this.WhenAnyValue(x => x.ViewModel.Text) .Subscribe(x => Text = x); var viewSegment = new UISegmentedControl(new [] { "Compose", "Preview" }); viewSegment.SelectedSegment = 0; NavigationItem.TitleView = viewSegment; viewSegment.ValueChanged += (sender, e) => { if (viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) { _previewView = new UIWebView(this.View.Bounds); } TextView.RemoveFromSuperview(); Add(_previewView); var markdown = markdownService.Convert(TextView.Text); var model = new DescriptionModel(markdown, (int)UIFont.PreferredSubheadline.PointSize); var markdownView = new MarkdownView { Model = model }; _previewView.LoadHtmlString(markdownView.GenerateString(), null); } }; }
/// <summary> /// Attach inherited class additional presenters is needed /// </summary> public void AttachExtraPresenters(CLEMPresenter clemPresenter) { //Display try { object newView = new MarkdownView(clemPresenter.view as ViewBase); IPresenter labourPresenter = new LabourAllocationPresenter(); if (newView != null && labourPresenter != null) { clemPresenter.view.AddTabView("Display", newView); labourPresenter.Attach(clemPresenter.model, newView, clemPresenter.explorerPresenter); clemPresenter.presenterList.Add("Display", labourPresenter); } } catch (Exception err) { this.explorerPresenter.MainPresenter.ShowError(err); } }
/// <summary> /// Attach the 'Model' and the 'View' to this presenter. /// </summary> /// <param name="model">The model to use</param> /// <param name="view">The view object</param> /// <param name="parentPresenter">The explorer presenter used</param> public void Attach(object model, object view, ExplorerPresenter parentPresenter) { memoModel = model as Memo; explorerPresenter = parentPresenter; markdownView = (view as ViewBase).GetControl <MarkdownView>("markdownView"); textView = (view as ViewBase).GetControl <EditorView>("textEditor"); editButton = (view as ViewBase).GetControl <ButtonView>("editButton"); helpButton = (view as ViewBase).GetControl <ButtonView>("helpButton"); helpButton.Clicked += HelpBtnClicked; textView.Mode = EditorType.Other; textView.Visible = false; textView.Text = memoModel.Text; textView.TextHasChangedByUser += OnTextHasChanged; markdownView.ImagePath = Path.GetDirectoryName(explorerPresenter.ApsimXFile.FileName); markdownView.Text = memoModel.Text; editButton.Clicked += OnEditButtonClick; helpButton.Visible = false; //this.memoViewer.SetContents(this.memoModel.Text, true); }
/// <summary> /// Attach the 'Model' and the 'View' to this presenter. /// </summary> /// <param name="model">The model to use</param> /// <param name="view">The view object</param> /// <param name="parentPresenter">The explorer presenter used</param> public void Attach(object model, object view, ExplorerPresenter parentPresenter) { memoModel = model as Memo; explorerPresenter = parentPresenter; markdownView = (view as ViewBase).GetControl <MarkdownView>("markdownView"); textView = (view as ViewBase).GetControl <TextInputView>("textEditor"); editButton = (view as ViewBase).GetControl <ButtonView>("editButton"); helpButton = (view as ViewBase).GetControl <ButtonView>("helpButton"); helpButton.Clicked += HelpBtnClicked; textView.Visible = false; textView.WrapText = true; textView.ModifyFont(Utility.Configuration.Settings.EditorFontName); textView.Text = memoModel.Text; textView.Changed += OnTextHasChanged; markdownView.ImagePath = Path.GetDirectoryName(explorerPresenter.ApsimXFile.FileName); markdownView.Text = memoModel.Text; editButton.Clicked += OnEditButtonClick; helpButton.Visible = false; }
async Task LoadSource(Uri fileUri) { var fontSize = (int)UIFont.PreferredSubheadline.PointSize; var content = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8); if (ViewModel.IsMarkdown) { var markdownContent = await Mvx.Resolve<IApplicationService>().Client.Markdown.GetMarkdown(content); var model = new DescriptionModel(markdownContent, fontSize); var htmlContent = new MarkdownView { Model = model }; LoadContent(htmlContent.GenerateString()); } else { var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var model = new SourceBrowserModel(content, "idea", fontSize, zoom, fileUri.LocalPath); var contentView = new SyntaxHighlighterView { Model = model }; LoadContent(contentView.GenerateString()); } }
public void ShowFor(MarkdownView markdown) { View = markdown; window1.TransientFor = View.MainWidget.Toplevel as Window; TextView[] editors = GetEditorsInView(); if (editors.Length == 1 && editors[0].Buffer.GetSelectionBounds(out TextIter start, out TextIter end)) { selectionOnly = true; txtLookFor.Text = editors[0].Buffer.GetText(start, end, false); } else { selectionOnly = false; } //window1.Parent = View.MainWidget.Toplevel; UpdateTitleBar(); window1.WindowPosition = WindowPosition.CenterOnParent; window1.Show(); txtLookFor.GrabFocus(); }
private void Load(string path) { if (path == _loadedPath) { return; } _loadedPath = path; if (ViewModel.IsText) { if (ViewModel.IsMarkdown) { var converter = Locator.Current.GetService <IMarkdownService>(); var content = System.IO.File.ReadAllText(path, System.Text.Encoding.UTF8); var fontSize = (int)UIFont.PreferredSubheadline.PointSize; var markdownContent = converter.ConvertMarkdown(content); var model = new DescriptionModel(markdownContent, fontSize); var v = new MarkdownView { Model = model }; LoadContent(v.GenerateString()); } else { var content = System.IO.File.ReadAllText(path, System.Text.Encoding.UTF8); var fontSize = (int)UIFont.PreferredSubheadline.PointSize; var zoom = UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone; var model = new SourceBrowserModel(content, "idea", fontSize, zoom, path); var v = new SyntaxHighlighterView { Model = model }; LoadContent(v.GenerateString()); } } else { LoadFile(path); } }
public override void ViewDidLoad() { base.ViewDidLoad(); _splitButton1 = _split.AddButton("Comments", "-"); _splitButton2 = _split.AddButton("Participants", "-"); Title = "Issue #" + ViewModel.Id; HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = Title; Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.2f))) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Select(_ => ViewModel.Bind(x => x.IsClosed, true).Where(x => x.HasValue).Select(x => x.Value)) .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", "No Milestone", UITableViewCellStyle.Value1) {Image = Octicon.Milestone.ToImage() }; _assigneeElement = new StringElement("Assigned", "Unassigned", UITableViewCellStyle.Value1) {Image = Octicon.Person.ToImage() }; _labelsElement = new StringElement("Labels", "None", UITableViewCellStyle.Value1) {Image = Octicon.Tag.ToImage() }; _addCommentElement = new StringElement("Add Comment") { Image = Octicon.Pencil.ToImage() }; var actionButton = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; NavigationItem.RightBarButtonItem = actionButton; ViewModel.Bind(x => x.IsModifying).SubscribeStatus("Loading..."); ViewModel.Bind(x => x.Issue).Subscribe(x => { _assigneeElement.Value = x.Assignee != null ? x.Assignee.Login : "******"; _milestoneElement.Value = x.Milestone != null ? x.Milestone.Title : "No Milestone"; _labelsElement.Value = x.Labels.Count == 0 ? "None" : string.Join(", ", x.Labels.Select(i => i.Name)); var model = new DescriptionModel(ViewModel.MarkdownDescription, (int)UIFont.PreferredSubheadline.PointSize, true); var markdown = new MarkdownView { Model = model }; var html = markdown.GenerateString(); _descriptionElement.SetValue(string.IsNullOrEmpty(ViewModel.MarkdownDescription) ? null : html); HeaderView.Text = x.Title; HeaderView.SubText = "Updated " + x.UpdatedAt.Humanize(); HeaderView.SetImage(x.User?.AvatarUrl, Images.Avatar); RefreshHeaderView(); Render(); }); ViewModel.BindCollection(x => x.Comments).Subscribe(_ => RenderComments()); ViewModel.BindCollection(x => x.Events).Subscribe(_ => RenderComments()); ViewModel.Bind(x => x.ShouldShowPro).Subscribe(x => { if (x) this.ShowPrivateView(); }); OnActivation(d => { d(_milestoneElement.Clicked.BindCommand(ViewModel.GoToMilestoneCommand)); d(_assigneeElement.Clicked.BindCommand(ViewModel.GoToAssigneeCommand)); d(_labelsElement.Clicked.BindCommand(ViewModel.GoToLabelsCommand)); d(_addCommentElement.Clicked.Subscribe(_ => AddCommentTapped())); d(_descriptionElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(_commentsElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(actionButton.GetClickedObservable().Subscribe(ShowExtraMenu)); d(HeaderView.Clicked.BindCommand(ViewModel.GoToOwner)); d(ViewModel.Bind(x => x.IsCollaborator, true).Subscribe(x => { foreach (var i in new [] { _assigneeElement, _milestoneElement, _labelsElement }) i.Accessory = x ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; })); d(ViewModel.Bind(x => x.IsLoading).Subscribe(x => actionButton.Enabled = !x)); }); }
void SegmentValueChanged (object sender, EventArgs e) { if (_viewSegment.SelectedSegment == 0) { if (_previewView != null) { _previewView.RemoveFromSuperview(); _previewView.Dispose(); _previewView = null; } Add(TextView); TextView.BecomeFirstResponder(); } else { if (_previewView == null) _previewView = new WKWebView(this.View.Bounds, new WKWebViewConfiguration()); TextView.RemoveFromSuperview(); Add(_previewView); var markdownService = Mvx.Resolve<IMarkdownService>(); var markdownText = markdownService.Convert(Text); var model = new DescriptionModel(markdownText, (int)UIFont.PreferredSubheadline.PointSize); var view = new MarkdownView { Model = model }.GenerateString(); _previewView.LoadHtmlString(view, NSBundle.MainBundle.BundleUrl); } }