Exemplo n.º 1
0
    private void Pressed()
    {
        string path = window.GetFilePath();

        if (!path.Empty())
        {
            string fileContents = editor.Text;
            using (StreamWriter swriter = new StreamWriter(path, false))
            {
                swriter.Write(fileContents);
            }
            editor.Text = "";

            // Reapply text
            TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
            textPreview.SetTextFromFile(path);
            textPreview.Show();

            VSeparator seperator = GetNode <VSeparator>("/root/Window/VB/MainHB/VSeparator");
            seperator.Show();
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
        this.Hide();
        addButton.Show();
        editButton.Show();
    }
Exemplo n.º 2
0
    private void Pressed()
    {
        string path = window.GetFilePath();

        if (!path.Empty())
        {
            string fileContents = System.IO.File.ReadAllText(path);
            editor.Text = fileContents;

            // Hide unneeded
            TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
            textPreview.Hide();

            VSeparator seperator = GetNode <VSeparator>("/root/Window/VB/MainHB/VSeparator");
            seperator.Hide();
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
        this.Hide();
        addButton.Hide();
        saveButton.Show();
    }
Exemplo n.º 3
0
    private void AddEntry()
    {
        Window w    = GetNode <Window>("/root/Window");
        string path = w.GetFilePath();

        if (!path.Empty())
        {
            if (!editor.Text.Empty())
            {
                string date  = DateTime.Now.ToString("dd.MM.yy");
                bool   found = false;
                LinkedList <string> fileContents = new LinkedList <string>();

                foreach (string line in System.IO.File.ReadLines(path))
                {
                    GD.Print($"{date} in {line}? -> {line.Contains(date)}");
                    if (!found && line.Contains(date))
                    {
                        found = true;

                        fileContents.AddLast(line);
                        fileContents.AddLast($"* {editor.Text}");
                        continue;
                    }
                    fileContents.AddLast(line);
                }

                if (!found)
                {
                    // Have to add in reverse order because we're adding to the top
                    fileContents.AddFirst($"* {editor.Text}");
                    fileContents.AddFirst($"# {date}");
                }

                using (StreamWriter swriter = new StreamWriter(path, false))
                {
                    foreach (string line in fileContents)
                    {
                        swriter.WriteLine(line);
                    }
                }

                // Reapply text
                TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
                textPreview.SetTextFromFile(path);

                // Clear editor
                editor.Text = "";
            }
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
    }
 private void SaveDialog()
 {
     SaveConfig(currentConfigPath);
     saveDialog.Show();
 }