<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EDDiscovery.DB;
using EMK.LightGeometry;

namespace EDDiscovery.UserControls
{
    public partial class UserControlTrippanel : UserControlCommonBase
    {
        private EDDiscoveryForm discoveryform;
        private TravelHistoryControl travelhistorycontrol;

        static String TITLE = "Trip panel";

        private int displaynumber = 0;
        private string DbSave { get { return "TripPanel" + ((displaynumber > 0) ? displaynumber.ToString() : ""); } }

        HistoryEntry lastHE;

        private Font displayfont;

        public UserControlTrippanel()
        {
            InitializeComponent();
        }

        public override void Init(EDDiscoveryForm ed, int vn) //0=primary, 1 = first windowed version, etc
        {
            discoveryform = ed;
            travelhistorycontrol = ed.TravelControl;
            displaynumber = vn;

            discoveryform.OnHistoryChange += Display;
            discoveryform.OnNewEntry += NewEntry;
            discoveryform.OnNewTarget += NewTarget;

            displayfont = discoveryform.theme.GetFont;
        }


        public override void Closing()
        {
            discoveryform.OnHistoryChange -= Display;
            discoveryform.OnNewEntry -= NewEntry;
            discoveryform.OnNewTarget -= NewTarget;
        }

        public override Color ColorTransparency { get { return Color.Green; } }
        public override void SetTransparency(bool on, Color curcol)
        {
            pictureBox.BackColor = this.BackColor = curcol;
            displayLastFSDOrScoop(lastHE);
        }

        #region Display

        public void Display(HistoryList hl)            // when user clicks around..  HE may be null here
        {
            HistoryEntry lfs = hl.GetLastFuelScoop;
            HistoryEntry hex = hl.GetLastFSD;
            if (lfs != null && lfs.EventTimeUTC >= hex.EventTimeUTC)
                hex = lfs;

            displayLastFSDOrScoop(hex);
        }

        public void NewTarget()
        {
            displayLastFSDOrScoop(lastHE);
        }

        public void NewEntry(HistoryEntry he, HistoryList hl)               // called when a new entry is made..
        {
            Display(hl);
        }

        void displayLastFSDOrScoop(HistoryEntry he)
        {
            pictureBox.ClearImageList();

            lastHE = he;

            if (he != null)
            {
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? Color.Black : this.BackColor;

                ExtendedControls.PictureBoxHotspot.ImageElement edsm = pictureBox.AddTextFixedSizeC(new Point(5, 5), new Size(80, 20), "EDSM", displayfont, backcolour, textcolour, 0.5F, true, he, "View system on EDSM");
                edsm.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("EDSM", edsm.img.Size, displayfont, backcolour, ExtendedControls.ButtonExt.Multiply(textcolour, 1.2F), 0.5F, true), edsm.pos, true);

                ExtendedControls.PictureBoxHotspot.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(5, 35), new Size(80, 20), "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point");
                start.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("Start", edsm.img.Size, displayfont, backcolour, ExtendedControls.ButtonExt.Multiply(textcolour, 1.2F), 0.5F, true), start.pos , true);

                backcolour = IsTransparent ? Color.Transparent : this.BackColor;

                string name;
                Point3D tpos;
                bool targetpresent = TargetClass.GetTargetPosition(out name, out tpos);

                String topline = "  Route Not Set";

                if (targetpresent)
                {
                    double dist = SystemClass.Distance(he.System, tpos.X, tpos.Y, tpos.Z);

                    var jumpRange = SQLiteDBClass.GetSettingDouble(DbSave + "JumpRange", -1.0);
                    string mesg = "Left";
                    if (jumpRange > 0)
                    {
                        int jumps =(int) Math.Ceiling(dist / jumpRange);
                        if(jumps>0)
                            mesg = "@ " + jumps.ToString() + ( (jumps == 1) ? " jump" : " jumps");
                    }
                    topline = String.Format("{0} | {1:N1}ly {2}", name, dist, mesg);
                }
<commit_msg>Set target distance to 2 points not 1<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EDDiscovery.DB;
using EMK.LightGeometry;

namespace EDDiscovery.UserControls
{
    public partial class UserControlTrippanel : UserControlCommonBase
    {
        private EDDiscoveryForm discoveryform;
        private TravelHistoryControl travelhistorycontrol;

        static String TITLE = "Trip panel";

        private int displaynumber = 0;
        private string DbSave { get { return "TripPanel" + ((displaynumber > 0) ? displaynumber.ToString() : ""); } }

        HistoryEntry lastHE;

        private Font displayfont;

        public UserControlTrippanel()
        {
            InitializeComponent();
        }

        public override void Init(EDDiscoveryForm ed, int vn) //0=primary, 1 = first windowed version, etc
        {
            discoveryform = ed;
            travelhistorycontrol = ed.TravelControl;
            displaynumber = vn;

            discoveryform.OnHistoryChange += Display;
            discoveryform.OnNewEntry += NewEntry;
            discoveryform.OnNewTarget += NewTarget;

            displayfont = discoveryform.theme.GetFont;
        }


        public override void Closing()
        {
            discoveryform.OnHistoryChange -= Display;
            discoveryform.OnNewEntry -= NewEntry;
            discoveryform.OnNewTarget -= NewTarget;
        }

        public override Color ColorTransparency { get { return Color.Green; } }
        public override void SetTransparency(bool on, Color curcol)
        {
            pictureBox.BackColor = this.BackColor = curcol;
            displayLastFSDOrScoop(lastHE);
        }

        #region Display

        public void Display(HistoryList hl)            // when user clicks around..  HE may be null here
        {
            HistoryEntry lfs = hl.GetLastFuelScoop;
            HistoryEntry hex = hl.GetLastFSD;
            if (lfs != null && lfs.EventTimeUTC >= hex.EventTimeUTC)
                hex = lfs;

            displayLastFSDOrScoop(hex);
        }

        public void NewTarget()
        {
            displayLastFSDOrScoop(lastHE);
        }

        public void NewEntry(HistoryEntry he, HistoryList hl)               // called when a new entry is made..
        {
            Display(hl);
        }

        void displayLastFSDOrScoop(HistoryEntry he)
        {
            pictureBox.ClearImageList();

            lastHE = he;

            if (he != null)
            {
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? Color.Black : this.BackColor;

                ExtendedControls.PictureBoxHotspot.ImageElement edsm = pictureBox.AddTextFixedSizeC(new Point(5, 5), new Size(80, 20), "EDSM", displayfont, backcolour, textcolour, 0.5F, true, he, "View system on EDSM");
                edsm.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("EDSM", edsm.img.Size, displayfont, backcolour, ExtendedControls.ButtonExt.Multiply(textcolour, 1.2F), 0.5F, true), edsm.pos, true);

                ExtendedControls.PictureBoxHotspot.ImageElement start = pictureBox.AddTextFixedSizeC(new Point(5, 35), new Size(80, 20), "Start", displayfont, backcolour, textcolour, 0.5F, true, "Start", "Set a journey start point");
                start.SetAlternateImage(ExtendedControls.ControlHelpers.DrawTextIntoFixedSizeBitmapC("Start", edsm.img.Size, displayfont, backcolour, ExtendedControls.ButtonExt.Multiply(textcolour, 1.2F), 0.5F, true), start.pos , true);

                backcolour = IsTransparent ? Color.Transparent : this.BackColor;

                string name;
                Point3D tpos;
                bool targetpresent = TargetClass.GetTargetPosition(out name, out tpos);

                String topline = "  Route Not Set";

                if (targetpresent)
                {
                    double dist = SystemClass.Distance(he.System, tpos.X, tpos.Y, tpos.Z);

                    var jumpRange = SQLiteDBClass.GetSettingDouble(DbSave + "JumpRange", -1.0);
                    string mesg = "Left";
                    if (jumpRange > 0)
                    {
                        int jumps =(int) Math.Ceiling(dist / jumpRange);
                        if(jumps>0)
                            mesg = "@ " + jumps.ToString() + ( (jumps == 1) ? " jump" : " jumps");
                    }
                    topline = String.Format("{0} | {1:N2}ly {2}", name, dist, mesg);
                }

{'fraction_non_alphanumeric': 0.09135123704800169, 'fraction_numerical': 0.008458447874814971, 'mean_word_length': 2.0691109669046073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6027368', 'n_tokens_mistral': 2680, 'n_tokens_neox': 2487, 'n_words': 603}