Esempio n. 1
0
    protected virtual void DeleteLineButton(object sender, System.EventArgs e)
    {
        TreeIter      iter;
        TreeSelection t = mainTreeView.Selection;

        if (t.GetSelected(out iter))
        {
            CatalogueParser.GetInstance().DeleteByID((int)tModel.GetValue(iter, (int)Columns.COL_ID));
            tModel.Remove(ref iter);
        }
    }
Esempio n. 2
0
    public void LoadFile(string fileName)
    {
        tModel.Clear();
        LinkedList <CatalogueEntry> Entries = CatalogueParser.GetInstance().OpenFile(fileName);

        foreach (CatalogueEntry entry in Entries)
        {
            tModel.AppendValues(entry.ID, entry.Title, entry.PageNo, entry.Works);
        }

        Title = "Catalogue - " + CatalogueParser.GetInstance().OpenedDocumentName;
        statusbar.Push((uint)Context.DEFAULT_CONTEXT, "Opened file " + CatalogueParser.GetInstance().OpenedDocumentPath);
    }
Esempio n. 3
0
    protected virtual void AddLineButton(object sender, System.EventArgs e)
    {
        int      page = 0;
        TreeIter lastItem;
        bool     got = tModel.IterNthChild(out lastItem, tModel.IterNChildren() - 1);

        if (got)
        {
            page = (int)tModel.GetValue(lastItem, (int)Columns.COL_PAGE);
        }

        TreeIter iter = tModel.AppendValues(CatalogueParser.GetInstance().UpdateHighestID(),
                                            "Test", page, true);

        mainTreeView.ScrollToCell(tModel.GetPath(iter),
                                  mainTreeView.GetColumn((int)Columns.COL_TITLE),
                                  true, .0F, .0F);
    }
Esempio n. 4
0
    protected virtual void OpenFileButton(object sender, System.EventArgs e)
    {
        bool open = false;
        FileChooserDialog FChooser = new FileChooserDialog("Choose a file to open",
                                                           this, FileChooserAction.Open, this);

        FChooser.AddButton("Open", ResponseType.Accept);
        FChooser.AddButton("Cancel", ResponseType.Cancel);
        FChooser.AddFilter(this.catalogueFilter);

        FChooser.SetCurrentFolder(CatalogueParser.GetInstance().DocumentsDir);

        FChooser.Response += delegate(object o, ResponseArgs args) {
            switch (args.ResponseId)
            {
            case ResponseType.Accept:
                open = true;
                break;

            case ResponseType.Cancel:
                break;

            default:
                break;
            }
        };

        FChooser.Run();

        if (open)
        {
            LoadFile(FChooser.Filename);
        }


        FChooser.Destroy();
    }
Esempio n. 5
0
 protected virtual void NewActivate(object sender, System.EventArgs e)
 {
     CatalogueParser.GetInstance().Reset();
     tModel.Clear();
     Title = "Catalogue";
 }
Esempio n. 6
0
    protected virtual void ExportAction(object sender, System.EventArgs e)
    {
        string            filename = "";
        FileChooserDialog FileSave = new FileChooserDialog("Select a filename to export to", this, FileChooserAction.Save, this);

        FileSave.AddFilter(htmlFilter);
        FileSave.AddButton("Export", ResponseType.Accept);
        FileSave.AddButton("Cancel", ResponseType.Cancel);
        FileSave.DoOverwriteConfirmation = true;

        FileSave.SetCurrentFolder(CatalogueParser.GetInstance().DocumentsDir);

        FileSave.Response += delegate(object o, ResponseArgs args) {
            switch (args.ResponseId)
            {
            case ResponseType.Accept:
                if (!FileSave.Filename.Contains(".htm"))
                {
                    filename = FileSave.Filename + ".html";
                }
                else
                {
                    filename = FileSave.Filename;
                }
                break;

            default:
                break;
            }
        };

        FileSave.Run();
        FileSave.Destroy();

        try {
            if (filename != "")
            {
                CatalogueExporter Exporter = new CatalogueExporter(ExportType.TO_HTML);
                Exporter.Export(filename);
                System.Diagnostics.Process.Start(filename);
                statusbar.Push((uint)Context.DEFAULT_CONTEXT, "Exported catalogue to " + filename);
            }
        }
        catch (System.UnauthorizedAccessException exc) {
            Dialog errDiag = new Dialog("You don't have the rights to write there!", this, DialogFlags.Modal, this);
            errDiag.VBox.Add(new Label(exc.Message + "\n\nPlease try again with another path"));
            errDiag.AddButton("Ok, I will. I promise.", ResponseType.Accept);
            errDiag.ShowAll();
            errDiag.Run();
            errDiag.Destroy();
        }
        catch (Exception exc) {
            Dialog errDiag = new Dialog("Unknown exception", this, DialogFlags.Modal, this);
            errDiag.VBox.Add(new Label(exc.Message));
            errDiag.AddButton("Dunno, lol :-(", ResponseType.Accept);
            errDiag.ShowAll();
            errDiag.Run();
            errDiag.Destroy();
            Utils.PrintDebug("XSLT Exception", exc.Message);
        }
    }
Esempio n. 7
0
    protected virtual void SaveFileButton(object sender, System.EventArgs e)
    {
        string   Filename = "";
        TreeIter iter;
        bool     save = false;

        if (!CatalogueParser.GetInstance().Locked || sender.Equals(this.saveAsAction))
        {
            FileChooserDialog FChooser = new FileChooserDialog("Filename to save",
                                                               this, FileChooserAction.Save, this);
            FChooser.AddButton("Save", ResponseType.Accept);
            FChooser.AddButton("Cancel", ResponseType.Cancel);
            FChooser.AddFilter(this.catalogueFilter);
            FChooser.DoOverwriteConfirmation = true;

            FChooser.SetCurrentFolder(CatalogueParser.GetInstance().DocumentsDir);

            FChooser.Response += delegate(object o, ResponseArgs args) {
                switch (args.ResponseId)
                {
                case ResponseType.Accept:
                    if (FChooser.Filename.Contains(".catalogue"))
                    {
                        Filename = FChooser.Filename;
                    }
                    else
                    {
                        Filename = FChooser.Filename + ".catalogue";
                    }

                    save = true;
                    break;

                case ResponseType.Cancel:
                    break;

                default:
                    break;
                }
            };

            FChooser.Run();
            FChooser.Destroy();
        }

        else
        {
            save     = true;
            Filename = CatalogueParser.GetInstance().OpenedDocumentPath;
        }

        if (save && (tModel.IterNChildren() > 0))
        {
            tModel.GetIterFirst(out iter);
            CatalogueParser Parser = CatalogueParser.GetInstance();

            Parser.SetCatalogueEntry(new CatalogueEntry(
                                         (int)tModel.GetValue(iter, (int)Columns.COL_ID),
                                         (string)tModel.GetValue(iter, (int)Columns.COL_TITLE),
                                         (int)tModel.GetValue(iter, (int)Columns.COL_PAGE),
                                         (bool)tModel.GetValue(iter, (int)Columns.COL_WORKS))
                                     );
            while (tModel.IterNext(ref iter))
            {
                Parser.SetCatalogueEntry(new CatalogueEntry(
                                             (int)tModel.GetValue(iter, (int)Columns.COL_ID),
                                             (string)tModel.GetValue(iter, (int)Columns.COL_TITLE),
                                             (int)tModel.GetValue(iter, (int)Columns.COL_PAGE),
                                             (bool)tModel.GetValue(iter, (int)Columns.COL_WORKS))
                                         );
            }

            Parser.SaveFileName(Filename);
            Title = "Catalogue - " + Parser.OpenedDocumentName;
            statusbar.Push((uint)Context.DEFAULT_CONTEXT, "Saved file " + Filename);
        }
    }