Beispiel #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();
    }
Beispiel #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();
    }
Beispiel #3
0
 public override void _Ready()
 {
     editor     = GetNode <TextEdit>("/root/Window/VB/MainHB/Editor");
     preview    = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
     window     = GetNode <Window>("/root/Window");
     editButton = GetNode <EditButton>("/root/Window/VB/BottomHB/EditButton");
     addButton  = GetNode <AddButton>("/root/Window/VB/BottomHB/AddButton");
 }
Beispiel #4
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");
        }
    }
Beispiel #5
0
    public void CloseFile()
    {
        SaveFilePath("");

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

        textPreview.ClearText();

        HBoxContainer bottomButtons = GetNode <HBoxContainer>("/root/Window/VB/BottomHB");

        bottomButtons.Hide();
    }
Beispiel #6
0
    public void OpenFile(string path)
    {
        if (File.Exists(path))
        {
            SaveFilePath(path);

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

            HBoxContainer bottomButtons = GetNode <HBoxContainer>("/root/Window/VB/BottomHB");
            bottomButtons.Show();
        }
    }
Beispiel #7
0
        void Core_LoadPreview()
        {
            try
            {
                string[] text   = FireEmblem.Text.RemoveBracketCodes(Text_CodeBox.Text.Split('\r', '\n'));
                bool     bubble = ((string)Font_ComboBox.SelectedValue).Equals("Text Bubble Font");

                CurrentTextPreview = new TextPreview(CurrentFont, bubble, text, Text_Line_NumBox.Value);

                Text_Line_NumBox.Maximum = Math.Max(0, text.Length - (bubble ? 2 : 4));
                Text_Preview_ImageBox.Load(CurrentTextPreview);
            }
            catch (Exception ex)
            {
                Program.ShowError("There has been an error while loading the text preview image.", ex);
            }
        }
Beispiel #8
0
 public override void _Ready()
 {
     editor  = GetNode <TextEdit>("/root/Window/VB/MainHB/Editor");
     preview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
 }
        private void BuildPreview()
        {
            double CenterPoint = Canvas.GetLeft(Screen) + Screen.Width / 2d;

            double Ratio = WpfScreenHelper.Screen.PrimaryScreen.Bounds.Width / WpfScreenHelper.Screen.PrimaryScreen.Bounds.Height;

            Screen.Width = Screen.Height * Ratio;
            Canvas.SetLeft(Screen, CenterPoint - Screen.Width / 2d);

            var OverlayPreviewBindX = new Binding("Text");

            OverlayPreviewBindX.Source = XBox;
            var OverlayPreviewBindY = new Binding("Text");

            OverlayPreviewBindY.Source = YBox;
            var OverlayPreviewBindWidth = new Binding("Text");

            OverlayPreviewBindWidth.Source = WidthBox;
            var OverlayPreviewBindHeight = new Binding("Text");

            OverlayPreviewBindHeight.Source = HeightBox;

            var _OverlayPreview = new OverlayPreview();

            BaseCanvas.Children.Add(_OverlayPreview);
            BaseCanvas.Children.Add(_OverlayPreview.InternalRect);
            _OverlayPreview.AnchorX = Canvas.GetLeft(Screen);
            _OverlayPreview.AnchorY = Canvas.GetTop(Screen);
            _OverlayPreview.Scale   = Screen.Width / WpfScreenHelper.Screen.PrimaryScreen.Bounds.Width;
            _OverlayPreview.SetBinding(OverlayPreview.AbsoluteXProperty, OverlayPreviewBindX);
            _OverlayPreview.SetBinding(OverlayPreview.AbsoluteYProperty, OverlayPreviewBindY);
            _OverlayPreview.SetBinding(OverlayPreview.AbsoluteWidthProperty, OverlayPreviewBindWidth);
            _OverlayPreview.SetBinding(OverlayPreview.AbsoluteHeightProperty, OverlayPreviewBindHeight);
            _OverlayPreview.InternalRect.Fill = new SolidColorBrush(Colors.Gray);

            _OverlayPreview.UpdateInternalRect();

            PreviewLabel.Content = WpfScreenHelper.Screen.PrimaryScreen.Bounds.Width.ToString() + " x " + WpfScreenHelper.Screen.PrimaryScreen.Bounds.Height.ToString() + " Preview";

            var TextPreviewBindFill = new Binding("SelectedColor");

            TextPreviewBindFill.Source    = ChatColorPicker;
            TextPreviewBindFill.Converter = new NullableColorSolidBrushConverter();
            var TextPreviewBindStroke = new Binding("SelectedColor");

            TextPreviewBindStroke.Source    = ChatOutlineColorPicker;
            TextPreviewBindStroke.Converter = new NullableColorSolidBrushConverter();
            var TextPreviewBindSize = new Binding("Text");

            TextPreviewBindSize.Source = ChatSizeBox;
            var TextPreviewBindStrokeSize = new Binding("Text");

            TextPreviewBindStrokeSize.Source = ChatOutlineThicknessBox;
            var TextPreviewBindBold = new Binding("IsChecked");

            TextPreviewBindBold.Source    = BoldButton;
            TextPreviewBindBold.Converter = new NullableBooleanFontWeightConverter();

            TextPreview.SetBinding(OutlinedTextBlock.FillProperty, TextPreviewBindFill);
            TextPreview.SetBinding(OutlinedTextBlock.StrokeProperty, TextPreviewBindStroke);
            TextPreview.SetBinding(OutlinedTextBlock.FontSizeProperty, TextPreviewBindSize);
            TextPreview.SetBinding(OutlinedTextBlock.StrokeThicknessProperty, TextPreviewBindStrokeSize);
            TextPreview.SetBinding(OutlinedTextBlock.FontWeightProperty, TextPreviewBindBold);
        }
Beispiel #10
0
 private void Awake()
 {
     instance = this;
 }