Ejemplo n.º 1
0
        public FileActions()
        {
            New = new Gtk.Action ("New", Mono.Unix.Catalog.GetString ("New..."), null, "gtk-new");
            Open = new Gtk.Action ("Open", Mono.Unix.Catalog.GetString ("Open..."), null, "gtk-open");
            OpenRecent = new RecentAction ("OpenRecent", Catalog.GetString ("Open Recent"), null, "gtk-open",
                                           RecentManager.Default);

            RecentFilter recentFilter = new RecentFilter ();
            recentFilter.AddApplication ("Pinta");

            (OpenRecent as RecentAction).AddFilter (recentFilter);

            recentData = new RecentData ();
            recentData.AppName = "Pinta";
            recentData.AppExec = GetExecutablePathname ();
            recentData.MimeType = "image/*";

            Close = new Gtk.Action ("Close", Mono.Unix.Catalog.GetString ("Close"), null, "gtk-close");
            Save = new Gtk.Action ("Save", Mono.Unix.Catalog.GetString ("Save"), null, "gtk-save");
            SaveAs = new Gtk.Action ("SaveAs", Mono.Unix.Catalog.GetString ("Save As..."), null, "gtk-save-as");
            Print = new Gtk.Action ("Print", Mono.Unix.Catalog.GetString ("Print"), null, "gtk-print");
            Exit = new Gtk.Action ("Exit", Mono.Unix.Catalog.GetString ("Quit"), null, "gtk-quit");

            //			OpenRecent.Sensitive = false;
            Close.Sensitive = false;
            Print.Sensitive = false;
        }
Ejemplo n.º 2
0
        public FileActions()
        {
            New = new Gtk.Action ("New", Catalog.GetString ("New..."), null, Stock.New);
            Open = new Gtk.Action ("Open", Catalog.GetString ("Open..."), null, Stock.Open);
            OpenRecent = new RecentAction ("OpenRecent", Catalog.GetString ("Open Recent"), null, Stock.Open, RecentManager.Default);

            RecentFilter recentFilter = new RecentFilter ();
            recentFilter.AddApplication ("Pinta");

            (OpenRecent as RecentAction).AddFilter (recentFilter);

            recentData = new RecentData ();
            recentData.AppName = "Pinta";
            recentData.AppExec = GetExecutablePathname ();
            recentData.MimeType = "image/*";

            lastDialogDir = System.Environment.GetFolderPath (Environment.SpecialFolder.MyPictures);

            Close = new Gtk.Action ("Close", Catalog.GetString ("Close"), null, Stock.Close);
            Save = new Gtk.Action ("Save", Catalog.GetString ("Save"), null, Stock.Save);
            SaveAs = new Gtk.Action ("SaveAs", Catalog.GetString ("Save As..."), null, Stock.SaveAs);
            Print = new Gtk.Action ("Print", Catalog.GetString ("Print"), null, Stock.Print);
            Exit = new Gtk.Action ("Exit", Catalog.GetString ("Quit"), null, Stock.Quit);

            New.ShortLabel = Catalog.GetString ("New");
            Open.ShortLabel = Catalog.GetString ("Open");
            Open.IsImportant = true;
            Save.IsImportant = true;

            Close.Sensitive = false;
            Print.Sensitive = false;
        }
Ejemplo n.º 3
0
        protected override async Task OnInitAsync()
        {
            var downloader     = new FileDownloader();
            var recentDataText = await downloader.DownloadFileFromSiteContentAsync(HttpClient, Config, "RecentData.json", "*/*");

            Recents = Microsoft.JSInterop.Json.Deserialize <RecentData>(recentDataText);

            await base.OnInitAsync();
        }
Ejemplo n.º 4
0
        public SystemManager()
        {
            ImageFormats   = new ImageConverterManager();
            PaletteFormats = new PaletteFormats();
            RenderThreads  = Environment.ProcessorCount;

            last_dialog_directory = DefaultDialogDirectory;

            recent_data          = new RecentData();
            recent_data.AppName  = "Pinta";
            recent_data.AppExec  = GetExecutablePathName();
            recent_data.MimeType = "image/*";
        }
Ejemplo n.º 5
0
	protected void Open_FileSelected(object sender, EventArgs e)
	{
		FileSelectorDialog fileSelector = sender as FileSelectorDialog;	
		
		string filename = fileSelector.Filename;
		FileInfo info = new FileInfo(filename);
		
		// recent manager wants a uri
		string uri = string.Format("file://{0}", filename);
		
		Gtk.RecentData data = new RecentData();
		data.AppName = MainClass.AppName;
		data.AppExec = string.Format("{0} %f", MainClass.AppName);
		data.DisplayName = info.Name;
		data.IsPrivate = false;
		data.MimeType = "application/x-gedcom";
		
		_recentManager.AddFull(uri, data);
		
		DoReadGedcom(filename, false);		
	}
Ejemplo n.º 6
0
		public void LoadFile(string filePath)
		{
			// First, ensure a clean state.
			CloseFile();
			this.statusbar1.Pop(_SbCtxState);

			// Indicate what we are there for early.
			//
			// (The idea is that a hypothetically long loading process
			// with the user placing the window in the background
			// would show up in the window list identifiably already.)
			this.FilePath = filePath;

			// Register file as recently used, so that it can be opened easily
			// via the File -> Recent submenu.
			try {
				this.statusbar1.Push(_SbCtxActivity, string.Format(
					"Registering file \"{0}\" as recently used...",
					_FilePath));
				Application.RunIteration(false);

				RecentManager manager = RecentManager.Default;
				var data = new RecentData();
				data.MimeType = "text/plain";
				data.AppName = this.RecentApplicationName;
				// Rather don't record current binary location,
				// it could be a development version...
				// But we have to enter something so that Gtk
				// will let us record the recent info at all,
				// so we make something up here that will be used
				// when the program would be installed system-wide...
				data.AppExec = this.RecentApplicationExec;
				if (manager.AddFull(_FilePath, data) == false) {
					// (I, Fabian, wanted to make this an error
					// that is always somehow reported, but I was told
					// that someone who disables the recent files list
					// would not want log info spam in return ...  So,)
					Debug.Print("[MainWindow] LoadFile(): " +
						"Adding file \"{0}\" to recently used files list did not work.",
						_FilePath);
				}
			}
			finally {
				this.statusbar1.Pop(_SbCtxActivity);
			}

			// Load file from stable storage.
			try {
				this.statusbar1.Push(_SbCtxActivity, string.Format(
					"Loading file \"{0}\"...",
					_FilePath));
				Application.RunIteration(false);

				using (var reader = new StreamReader(_FilePath)) {
					// TODO: Read in text for TextView and for Notes in parallel.
					//       Otherwise, they could diverge...
					// Read in text for TextView.
					TextBuffer buf = this.textviewText.Buffer;
					TextIter end = buf.EndIter;
					buf.Insert(ref end, reader.ReadToEnd());

					// For now, reset the reader to beginning
					// and read everything in again.
					// TODO: (Or can/should we read the data from the TextView?)
					reader.BaseStream.Seek(0, SeekOrigin.Begin);

					// Parse text as Notes.
					var notes = new Notes(reader);

					// Make parse visible to the user.
					AddNotesTree(notes);
				}
			}
			catch (IOException ex) {
				VisualizeError("Error processing file \"{0}\": {1}",
					_FilePath, ex.Message);
				this.FilePath = null;
				return;
			}
			catch (Exception ex) {
				VisualizeError("Unexpected error (file was \"{0}\"): {1}",
					_FilePath, ex.Message);
				this.FilePath = null;
				return;
			}
			finally {
				this.statusbar1.Pop(_SbCtxActivity);
			}

			// Consider file loaded.
			this.statusbar1.Push(_SbCtxState, "File loaded.");
		}
Ejemplo n.º 7
0
        private void InitializeFileActions()
        {
            lastDialogDir = System.Environment.GetFolderPath (Environment.SpecialFolder.MyPictures);

            recentData = new RecentData ();
            recentData.AppName = "Pinta";
            recentData.AppExec = PintaCore.System.GetExecutablePathName ();
            recentData.MimeType = "image/*";
        }
Ejemplo n.º 8
0
        static async Task Main(string[] args)
        {
            Options parsedArgs = null;

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(opts => parsedArgs = opts)
            .WithNotParsed((errs) =>
            {
                Console.WriteLine(errs);
                return;
            });

            HardCodedConfig config = new HardCodedConfig();
            BlogPostParser  parser = new BlogPostParser(config);

            var contentPath = parsedArgs.AppRootPath + "/ProgrammerAl.Site.Content";

            ImmutableList <BlogPostInfo> allPosts = LoadAllBlogPostInfo(contentPath, parser);

            ImmutableList <BlogPostInfo> parsedBlogEntries = allPosts
                                                             .OrderBy(x => x.FileNameWithoutExtension)//All blog posts start with a number. So the higher the number, the newer the post
                                                             .ToImmutableList();

            int blogPostNumber = 1;

            BlogPostSummary[] allBlogPostSummaries = parsedBlogEntries.Select(x => new BlogPostSummary
            {
                Title          = x.Entry.Title,
                PostedDate     = x.Entry.ReleaseDate,
                FirstParagraph = x.Entry.FirstParagraph,
                PostNumber     = blogPostNumber++,
                TitleLink      = x.FileNameWithoutExtension,
            }).ToArray();

            BlogPostSummary[] mostRecentBlogPosts = allBlogPostSummaries
                                                    .OrderByDescending(x => x.PostNumber)
                                                    .Take(FrontPageBlogsDisplayed)
                                                    .ToArray();

            RecentData recentData = new RecentData {
                RecentBlogPosts = mostRecentBlogPosts
            };

            WriteOutFileAsJson(recentData, contentPath, RecentDataFile);
            WriteOutFileAsJson(allBlogPostSummaries, contentPath, BlogPostsFile);

            //Load up the static templating engine
            var fullPathToTemplates = Path.Combine(Environment.CurrentDirectory, "StaticTemplates");
            var engine = new RazorLightEngineBuilder()
                         .UseFilesystemProject(fullPathToTemplates)
                         .UseMemoryCachingProvider()
                         .Build();

            string outputfolderPath = Path.Combine(contentPath, "BlogPosts");

            if (!Directory.Exists(outputfolderPath))
            {
                Directory.CreateDirectory(outputfolderPath);
            }

            //Create static html files for each blog post entry
            foreach (BlogPostInfo blogEntry in parsedBlogEntries)
            {
                var htmlContent           = Markdig.Markdown.ToHtml(blogEntry.Entry.Post);
                var blogPostEntryWithHtml = new BlogPostEntry(blogEntry.Entry.Title, blogEntry.Entry.ReleaseDate, blogEntry.Entry.Tags, htmlContent, blogEntry.Entry.FirstParagraph);

                string staticHtml = await engine.CompileRenderAsync <BlogPostEntry>("BlogPost.cshtml", blogPostEntryWithHtml);

                string outputFilePath = Path.Combine(outputfolderPath, blogEntry.FileNameWithoutExtension) + ".html";
                File.WriteAllText(outputFilePath, staticHtml);
            }

            var sitemapFilePath = parsedArgs.AppRootPath + "/ProgrammerAl.Site/ProgrammerAl.Site/wwwroot/sitemap.xml";
            var sitemapText     = GenerateSitemapFile("https://www.programmeral.com/", allPosts);

            File.WriteAllText(sitemapFilePath, sitemapText);
        }