Exemple #1
0
 public GistFileViewController(GistFileModel model, string gistUrl, string content = null)
     : base(model.RawUrl, gistUrl)
 {
     _model   = model;
     Title    = model.Filename;
     _content = content;
 }
Exemple #2
0
        public GistViewableFileController(GistFileModel model, string gistUrl)
            : base(true)
        {
            _model = model;
            Title  = model.Filename;

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(Theme.CurrentTheme.ViewButton, () => {
                NavigationController.PushViewController(new GistFileViewController(model, gistUrl, _rawContent), true);
            }));
        }
 public GistFileViewModel(GistFileModel file, GistViewModel parent, IGistClientService gistClientService, IAsyncOperationStatusManager commandStatusManager, IErrorHandler errorHandler) : this(parent, gistClientService, commandStatusManager, errorHandler)
 {
     this.GistFile         = file;
     fileName              = file.Name;
     History               = new ObservableRangeCollection <GistHistoryEntryViewModel>();
     Url                   = file.Url;
     DeleteGistFileCommand = new AsyncRelayCommand(DeleteGistFileAsync, commandStatusManager, errorHandler)
     {
         ExecutionInfo = "Deleting file from gist"
     };
     CopyGistFileUrlCommand = new RelayCommand(CopyGistFileUrl, errorHandler);
 }
        public GistFileController(GistFileModel model)
        {
            Title  = model.Filename;
            _model = model;

            //We can view markdown!
            if (model.Language != null && (model.Language.Equals("Markdown") || model.Language.Equals("HTML")))
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(Images.Buttons.View, () => {
                    NavigationController.PushViewController(new GistViewableFileController(model, _content), true);
                }));
            }
        }
        public GistFileController(GistFileModel model)
        {
            Title = model.Filename;
            _model = model;

            //We can view markdown!
            if (model.Language != null && (model.Language.Equals("Markdown") || model.Language.Equals("HTML")))
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(Images.Buttons.View, () => {
                    NavigationController.PushViewController(new GistViewableFileController(model, _content), true);
                }));
            }
        }
Exemple #6
0
		public void Init(NavObject navObject)
        {
			//Create the filename
			var fileName = System.IO.Path.GetFileName(navObject.Filename);
			if (fileName == null)
				fileName = navObject.Filename.Substring(navObject.Filename.LastIndexOf('/') + 1);

			//Create the temp file path
			Title = fileName;

			_id = navObject.GistId;
			_filename = navObject.Filename;

			//Grab the data
			_fileModel = GetService<IViewModelTxService>().Get() as GistFileModel;
        }
        public void Init(NavObject navObject)
        {
            //Create the filename
            var fileName = System.IO.Path.GetFileName(navObject.Filename);

            if (fileName == null)
            {
                fileName = navObject.Filename.Substring(navObject.Filename.LastIndexOf('/') + 1);
            }

            //Create the temp file path
            Title = fileName;

            _id       = navObject.GistId;
            _filename = navObject.Filename;

            //Grab the data
            _fileModel = GetService <IViewModelTxService>().Get() as GistFileModel;
        }
Exemple #8
0
		protected override async Task Load(bool forceCacheInvalidation)
		{
			if (_fileModel == null)
			{
				var data = await this.GetApplication().Client.ExecuteAsync(this.GetApplication().Client.Gists[_id].Get());
				_fileModel = data.Data.Files[_filename];
			}

			//Check to make sure...
			if (_fileModel == null || _fileModel.Content == null)
			{
				throw new Exception("Unable to retreive gist!");
			}

			var content = _fileModel.Content;
			var filePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetFileName(_fileModel.Filename));
			System.IO.File.WriteAllText(filePath, content, System.Text.Encoding.UTF8);
			FilePath = filePath;
			ContentPath = CreateContentFile();
		}
        protected override async Task Load(bool forceCacheInvalidation)
        {
            if (_fileModel == null)
            {
                var data = await this.GetApplication().Client.ExecuteAsync(this.GetApplication().Client.Gists[_id].Get());

                _fileModel = data.Data.Files[_filename];
            }

            //Check to make sure...
            if (_fileModel == null || _fileModel.Content == null)
            {
                throw new Exception("Unable to retreive gist!");
            }

            var content  = _fileModel.Content;
            var filePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetFileName(_fileModel.Filename));

            System.IO.File.WriteAllText(filePath, content, System.Text.Encoding.UTF8);
            FilePath    = filePath;
            ContentPath = CreateContentFile();
        }
        protected override async Task Load()
        {
            if (Gist == null)
            {
                var data = await this.GetApplication().Client.ExecuteAsync(this.GetApplication().Client.Gists[_id].Get());

                Gist = data.Data.Files[_filename];
            }

            if (Gist == null || Gist.Content == null)
            {
                throw new Exception("Unable to retreive gist!");
            }

            IsMarkdown = string.Equals(Gist?.Language, "Markdown");
            Gist       = Gist;

            var filepath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), FileName);

            System.IO.File.WriteAllText(filepath, Gist.Content, System.Text.Encoding.UTF8);
            ContentPath = FilePath = filepath;
        }
 public GistViewableFileController(GistFileModel model, string content)
 {
     _content = content;
     _model   = model;
     Title    = model.Filename;
 }
 public GistViewableFileController(GistFileModel model, string content)
 {
     _content = content;
     _model = model;
     Title = model.Filename;
 }
Exemple #13
0
 private static Action<object> MakeCallback(WeakReference<GistViewModel> weakVm, GistFileModel model)
 {
     return new Action<object>(_ => weakVm.Get()?.GoToFileSourceCommand.Execute(model));
 }
Exemple #14
0
 private static Action <object> MakeCallback(WeakReference <GistViewModel> weakVm, GistFileModel model)
 {
     return(new Action <object>(_ => weakVm.Get()?.GoToFileSourceCommand.Execute(model)));
 }