コード例 #1
0
ファイル: SourceView.cs プロジェクト: sjn1978/CodeHub
        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());
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        private new void LoadContent(string theme)
        {
            try
            {
                var assembly = Assembly.GetExecutingAssembly();
                using (var stream = assembly.GetManifestResourceStream(_resourceName))
                    using (var reader = new StreamReader(stream))
                    {
                        var razorView = new SyntaxHighlighterView
                        {
                            Model = new SourceBrowserModel
                            {
                                Content = reader.ReadToEnd(),
                                Theme   = theme ?? "idea"
                            }
                        };

                        base.LoadContent(razorView.GenerateString());
                    }
            }
            catch (Exception e)
            {
                this.Log().ErrorException("Unable to load Syntax Highlighter", e);
                _alertDialogFactory.Alert("Unable to load example!", "Can't load the example code. Looks like you're on your own...");
            }
        }
コード例 #4
0
        protected virtual void LoadSource(Uri fileUri)
        {
            var content   = System.IO.File.ReadAllText(fileUri.LocalPath, System.Text.Encoding.UTF8);
            var razorView = new SyntaxHighlighterView
            {
                Model = new SourceBrowserModel
                {
                    Content = content,
                    Theme   = ViewModel.Theme ?? "idea"
                }
            };

            LoadContent(razorView.GenerateString());
        }
コード例 #5
0
ファイル: FileSourceView.cs プロジェクト: yhtsnda/CodeHub
        private new void LoadContent(string filePath)
        {
            var content   = System.IO.File.ReadAllText(filePath, System.Text.Encoding.UTF8);
            var razorView = new SyntaxHighlighterView
            {
                Model = new SourceBrowserModel
                {
                    Content = content,
                    Theme   = ViewModel.Theme ?? "idea"
                }
            };

            var html = razorView.GenerateString();

            base.LoadContent(html);
        }
コード例 #6
0
ファイル: SourceView.cs プロジェクト: xNUTs/CodeBucket
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

            ViewModel.Bind(x => x.FilePath, true).IsNotNull().Subscribe(x =>
            {
                if (ViewModel.IsText)
                {
                    var content = System.IO.File.ReadAllText(x, System.Text.Encoding.UTF8);
                    var fontSize = (int)UIFont.PreferredSubheadline.PointSize;
                    var model = new SourceBrowserModel(content, "idea", fontSize);
                    var v = new SyntaxHighlighterView { Model = model };
                    LoadContent(v.GenerateString());
                }
                else
                {
                    LoadFile(x);
                }
            });
		}
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel.Bind(x => x.FilePath, true).IsNotNull().Subscribe(x =>
            {
                if (ViewModel.IsText)
                {
                    var content  = System.IO.File.ReadAllText(x, System.Text.Encoding.UTF8);
                    var fontSize = (int)UIFont.PreferredSubheadline.PointSize;
                    var model    = new SourceBrowserModel(content, "idea", fontSize);
                    var v        = new SyntaxHighlighterView {
                        Model = model
                    };
                    LoadContent(v.GenerateString());
                }
                else
                {
                    LoadFile(x);
                }
            });
        }
コード例 #9
0
        protected virtual void 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 model       = new DescriptionModel(content, fontSize);
                var htmlContent = new MarkdownView {
                    Model = model
                };
                LoadContent(htmlContent.GenerateString());
            }
            else
            {
                var model       = new SourceBrowserModel(content, ViewModel.Theme ?? "idea", fontSize, fileUri.LocalPath);
                var contentView = new SyntaxHighlighterView {
                    Model = model
                };
                LoadContent(contentView.GenerateString());
            }
        }