public NetworkedUIElement(NetworkClient Client, UIScreen Screen, string StrID, DrawLevel DLevel)
        {
            m_Screen = Screen;
            m_StringID = StrID;

            m_Client = Client;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Движение проводов за точками или сетевыми элементами
 /// </summary>
 /// <param name="x">Координата Х</param>
 /// <param name="y">Координата У</param>
 /// <param name="id">Идентификатор</param>
 /// <param name="IW">Показывает, вход провода или сетевой элемент</param>
 /// <param name="build">Идентификатор здания</param>
 /// <param name="dl">Уровень отображения</param>
 public void CheckNW(int x, int y, int id, bool IW, int build, DrawLevel dl)
 {
     foreach (var nw in NetworkWires)
     {
         if (!IW)
         {
             if (nw.idiw1.IW == IW & id == nw.idiw1.ID & nw.idiw1.Build == build & nw.DL == dl)
             {
                 nw.Points[0] = new Point(x, y);
             }
             if (nw.idiw2.IW == IW & id == nw.idiw2.ID & nw.idiw2.Build == build & nw.DL == dl)
             {
                 nw.Points[nw.Points.Count - 1] = new Point(x, y);
             }
         }
         else
         {
             if (nw.idiw1.IW == IW & id == nw.idiw1.ID & nw.idiw1.Build == build & nw.DL == dl)
             {
                 nw.Points[0] = new Point(x, y);
             }
             if (nw.idiw2.IW == IW & id == nw.idiw2.ID & nw.idiw2.Build == build & nw.DL == dl)
             {
                 nw.Points[nw.Points.Count - 1] = new Point(x, y);
             }
         }
     }
 }
        public NetworkedUIElement(string IP, int Port, UIScreen Screen, string StrID, DrawLevel DLevel)
        {
            m_Screen = Screen;
            m_StringID = StrID;

            m_Client = new NetworkClient(IP, Port);
        }
Ejemplo n.º 4
0
        public override int Search(int x, int y, DrawLevel dl)
        {
            int    _i     = -1;
            double _count = Double.MaxValue;

            for (int i = 0; i < NetworkWires.Count; i++)
            {
                if (dl == NetworkWires[i].DL & !NetworkWires[i].delete)
                {
                    double count = NetworkWires[i].Search(x, y);
                    if (count < _count & count != -1)
                    {
                        _count = count;
                        _i     = i;
                    }
                }
            }
            if (_i != -1)
            {
                return(_i);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="dL">Уровень отображения</param>
 /// <param name="location">Расположение</param>
 /// <param name="textBox">Текст бокс</param>
 public MyText(DrawLevel dL, Point location, TextBox textBox)
 {
     delete        = false;
     DL            = dL;
     this.location = MainForm._GenZoomPoint(location);
     this.text     = textBox.Text;
     InitText(textBox);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="dL">Уровень отображения</param>
 /// <param name="location">Расположение</param>
 /// <param name="size">Размер</param>
 /// <param name="text">Текст</param>
 public MyText(DrawLevel dL, Point location, Size size, string text)
 {
     delete        = false;
     DL            = dL;
     this.location = location;
     this.text     = text;
     this.size     = size;
     GenTextureFromBuild();
 }
Ejemplo n.º 7
0
        public UIListBox(int X, int Y, int Width, int Spacing, UIScreen Screen, string StrID, DrawLevel DLevel)
            : base(Screen, StrID, DLevel)
        {
            m_X = X;
            m_Y = Y;
            m_Width = Width;

            m_ListItems = new List<string>();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="x">Координата Х</param>
 /// <param name="y">Координата У</param>
 /// <param name="_drawLevel">Уровень отображения</param>
 /// <param name="_idiw1">Закрепленный элемент 1</param>
 public NetworkWire(int x, int y, DrawLevel _drawLevel, IDandIW _idiw1)
 {
     TempPoint.X = x;
     TempPoint.Y = y;
     Points.Add(TempPoint);
     //ClearTempPoint();
     idiw1  = _idiw1;
     DL     = _drawLevel;
     delete = false;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="dL">Уровень отображения</param>
 /// <param name="location">Расположение</param>
 /// <param name="size">Размер</param>
 /// <param name="text">Текст</param>
 /// <param name="fontsize">Размер шрифта</param>
 public MyText(DrawLevel dL, Point location, Size size, string text, float fontsize)
 {
     delete        = false;
     DL            = dL;
     this.fontsize = fontsize;
     this.location = location;
     this.text     = text;
     this.size     = size;
     GenTextureFromNE();
 }
Ejemplo n.º 10
0
 public override int Search(int x, int y, DrawLevel dl)
 {
     for (int i = 0; i < NetworkElements.Count; i++)
     {
         if (dl == NetworkElements[i].DL & !NetworkElements[i].delete)
         {
             if (NetworkElements[i].Search(x, y) != -1)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new Geometry Object
 /// </summary>
 /// <param name="model">The Model</param>
 /// <param name="drawlevel">The Render Level</param>
 /// <param name="lvl">The Detail Level</param>
 /// <param name="x">World X</param>
 /// <param name="y">World Y</param>
 /// <param name="z">World Z</param>
 /// <param name="yaw">Yaw</param>
 /// <param name="pitch">Pitch</param>
 /// <param name="roll">Roll</param>
 public GeometryObj(IModul modul, Model model, DrawLevel drawlevel, DetailLevel lvl, float x, float y, float z, float yaw,
                    float pitch, float roll, Vector3 scale, bool isMovable, Boolean showHeading)
 {
     Modul       = modul;
     Model       = model;
     DrawLevel   = drawlevel;
     DetailLevel = lvl;
     X           = x;
     Y           = y;
     Z           = z;
     Yaw         = yaw;
     Pitch       = pitch;
     Roll        = roll;
     ScaleVector = scale;
     IsMovable   = isMovable;
     ShowHeading = showHeading;
 }
Ejemplo n.º 12
0
        Dictionary <Bitmap, float> imageintensities = new Dictionary <Bitmap, float>();       // cached

        // return right bottom of area used from curpos

        Point DrawNode(List <ExtPictureBox.ImageElement> pc,
                       StarScan.ScanNode sn,
                       MaterialCommoditiesList curmats,     // curmats may be null
                       HistoryList hl,
                       Image notscanned,                    // image if sn is not known
                       Point position,                      // position is normally left/middle, unless xiscentre is set.
                       bool xiscentre,
                       out Rectangle imagepos,
                       Size size,                        // nominal size
                       DrawLevel drawtype,               // drawing..
                       Color?backwash         = null,    // optional back wash on image
                       string appendlabeltext = ""       // any label text to append
                       )
        {
            string tip;
            Point  endpoint = position;

            imagepos = Rectangle.Empty;

            JournalScan sc = sn.ScanData;

            if (sc != null && (!sc.IsEDSMBody || CheckEDSM))     // has a scan and its our scan, or we are showing EDSM
            {
                if (sn.NodeType != StarScan.ScanNodeType.ring)   // not rings
                {
                    tip = sc.DisplayString(historicmatlist: curmats, currentmatlist: hl.GetLast?.MaterialCommodity);
                    if (sn.Signals != null)
                    {
                        tip += "\n" + "Signals".T(EDTx.ScanDisplayUserControl_Signals) + ":\n" + JournalSAASignalsFound.SignalList(sn.Signals, 4, "\n");
                    }

                    Bitmap nodeimage = (Bitmap)(sc.IsStar ? sc.GetStarTypeImage() : sc.GetPlanetClassImage());

                    string overlaytext = "";
                    var    nodelabels  = new string[2] {
                        "", ""
                    };

                    nodelabels[0] = sn.CustomNameOrOwnname;
                    if (sc.IsEDSMBody)
                    {
                        nodelabels[0] = "_" + nodelabels[0];
                    }

                    if (sc.IsStar)
                    {
                        if (ShowStarClasses)
                        {
                            overlaytext = sc.StarClassificationAbv;
                        }

                        if (sc.nStellarMass.HasValue)
                        {
                            nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nStellarMass.Value:N2} SM", Environment.NewLine);
                        }

                        if (drawtype == DrawLevel.TopLevelStar)
                        {
                            if (sc.nAge.HasValue)
                            {
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{sc.nAge.Value:N0} MY", Environment.NewLine);
                            }

                            if (ShowHabZone)
                            {
                                var habZone = sc.GetHabZoneStringLs();
                                if (habZone.HasChars())
                                {
                                    nodelabels[1] = nodelabels[1].AppendPrePad($"{habZone}", Environment.NewLine);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ShowPlanetClasses)
                        {
                            overlaytext = Bodies.PlanetAbv(sc.PlanetTypeID);
                        }

                        if ((sn.ScanData.IsLandable || ShowAllG) && sn.ScanData.nSurfaceGravity != null)
                        {
                            nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSurfaceGravity / JournalScan.oneGee_m_s2):N2}g", Environment.NewLine);
                        }
                    }

                    if (ShowDist)
                    {
                        if (drawtype != DrawLevel.MoonLevel)       // other than moons
                        {
                            if (sn.ScanData.IsOrbitingBaryCentre)  // if in orbit of barycentre
                            {
                                string s = $"{(sn.ScanData.DistanceFromArrivalLS):N1}ls";
                                if (sn.ScanData.nSemiMajorAxis.HasValue)
                                {
                                    s += "/" + sn.ScanData.SemiMajorAxisLSKM;
                                }
                                nodelabels[1] = nodelabels[1].AppendPrePad(s, Environment.NewLine);
                            }
                            else
                            {
                                //System.Diagnostics.Debug.WriteLine(sn.ScanData.BodyName + " SMA " + sn.ScanData.nSemiMajorAxis + " " + sn.ScanData.DistanceFromArrivalm);
                                string s = sn.ScanData.nSemiMajorAxis.HasValue && Math.Abs(sn.ScanData.nSemiMajorAxis.Value - sn.ScanData.DistanceFromArrivalm) > JournalScan.oneAU_m ? (" / " + sn.ScanData.SemiMajorAxisLSKM) : "";
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{sn.ScanData.DistanceFromArrivalLS:N1}ls" + s, Environment.NewLine);
                            }
                        }
                        else
                        {
                            if (!sn.ScanData.IsOrbitingBaryCentre && sn.ScanData.nSemiMajorAxis.HasValue)          // if not in orbit of barycentre
                            {
                                nodelabels[1] = nodelabels[1].AppendPrePad($"{(sn.ScanData.nSemiMajorAxis / JournalScan.oneLS_m):N1}ls", Environment.NewLine);
                            }
                        }
                    }

                    nodelabels[1] = nodelabels[1].AppendPrePad(appendlabeltext, Environment.NewLine);

                    //  nodelabels[1] = nodelabels[1].AppendPrePad("" + sn.ScanData?.BodyID, Environment.NewLine);

                    bool valuable     = sc.EstimatedValue >= ValueLimit;
                    bool isdiscovered = sc.IsPreviouslyDiscovered && sc.IsPlanet;
                    int  iconoverlays = ShowOverlays ? ((sc.Terraformable ? 1 : 0) + (sc.HasMeaningfulVolcanism ? 1 : 0) +
                                                        (valuable ? 1 : 0) + (sc.Mapped ? 1 : 0) + (isdiscovered ? 1 : 0) + (sc.IsPreviouslyMapped ? 1 : 0) +
                                                        (sn.Signals != null ? 1 : 0)) : 0;

                    //   if (sc.BodyName.Contains("4 b"))  iconoverlays = 0;

                    bool materialsicon = sc.HasMaterials && !ShowMaterials;
                    bool imageoverlays = sc.IsLandable || (sc.HasRings && drawtype != DrawLevel.TopLevelStar) || materialsicon;

                    int bitmapheight   = size.Height * nodeheightratio / noderatiodivider;
                    int overlaywidth   = bitmapheight / 6;
                    int imagewidtharea = (imageoverlays ? 2 : 1) * size.Width;             // area used by image+overlay if any
                    int iconwidtharea  = (iconoverlays > 0 ? overlaywidth : 0);            // area used by icon width area on left

                    int bitmapwidth = iconwidtharea + imagewidtharea;                      // total width
                    int imageleft   = iconwidtharea + imagewidtharea / 2 - size.Width / 2; // calculate where the left of the image is
                    int imagetop    = bitmapheight / 2 - size.Height / 2;                  // and the top

                    Bitmap bmp = new Bitmap(bitmapwidth, bitmapheight);

                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        //  backwash = Color.FromArgb(128, 40, 40, 40); // debug

                        if (backwash.HasValue)
                        {
                            using (Brush b = new SolidBrush(backwash.Value))
                            {
                                g.FillRectangle(b, new Rectangle(iconwidtharea, 0, imagewidtharea, bitmapheight));
                            }
                        }

                        g.DrawImage(nodeimage, imageleft, imagetop, size.Width, size.Height);

                        if (sc.IsLandable)
                        {
                            int offset = size.Height * 4 / 16;
                            int scale  = 5;
                            g.DrawImage(Icons.Controls.Scan_Bodies_Landable, new Rectangle(imageleft + size.Width / 2 - offset * scale / 2,
                                                                                           imagetop + size.Height / 2 - offset * scale / 2, offset * scale, offset * scale));
                        }

                        if (sc.HasRings && drawtype != DrawLevel.TopLevelStar)
                        {
                            g.DrawImage(sc.Rings.Count() > 1 ? Icons.Controls.Scan_Bodies_RingGap : Icons.Controls.Scan_Bodies_RingOnly,
                                        new Rectangle(imageleft - size.Width / 2, imagetop, size.Width * 2, size.Height));
                        }

                        if (iconoverlays > 0)
                        {
                            int ovsize = bmp.Height / 6;
                            int pos    = 4;

                            if (sc.Terraformable)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Terraformable, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.HasMeaningfulVolcanism) //this renders below the terraformable icon if present
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Volcanism, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (valuable)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_HighValue, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.Mapped)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Mapped, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sc.IsPreviouslyMapped)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_MappedByOthers, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (isdiscovered)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_DiscoveredByOthers, new Rectangle(0, pos, ovsize, ovsize));
                                pos += ovsize + 1;
                            }

                            if (sn.Signals != null)
                            {
                                g.DrawImage(Icons.Controls.Scan_Bodies_Signals, new Rectangle(0, pos, ovsize, ovsize));
                            }
                        }

                        if (materialsicon)
                        {
                            Image mm = Icons.Controls.Scan_Bodies_MaterialMore;
                            g.DrawImage(mm, new Rectangle(bmp.Width - mm.Width, bmp.Height - mm.Height, mm.Width, mm.Height));
                        }

                        if (overlaytext.HasChars())
                        {
                            float ii;
                            if (imageintensities.ContainsKey(nodeimage))        // find cache
                            {
                                ii = imageintensities[nodeimage];
                                //System.Diagnostics.Debug.WriteLine("Cached Image intensity of " + sn.fullname + " " + ii);
                            }
                            else
                            {
                                var imageintensity = nodeimage.Function(BitMapHelpers.BitmapFunction.Brightness, nodeimage.Width * 3 / 8, nodeimage.Height * 3 / 8, nodeimage.Width * 2 / 8, nodeimage.Height * 2 / 8);
                                ii = imageintensity.Item2;
                                imageintensities[nodeimage] = ii;
                                //System.Diagnostics.Debug.WriteLine("Calculated Image intensity of " + sn.fullname + " " + ii);
                            }

                            Color text = ii > 0.3f ? Color.Black : Color.FromArgb(255, 200, 200, 200);

                            using (Font f = new Font(EDDTheme.Instance.FontName, size.Width / 5.0f))
                            {
                                using (Brush b = new SolidBrush(text))
                                {
                                    g.DrawString(overlaytext, f, b, new Rectangle(iconwidtharea, 0, bitmapwidth - iconwidtharea, bitmapheight), new StringFormat()
                                    {
                                        Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
                                    });
                                }
                            }
                        }
                    }

                    // need left middle, if xiscentre, translate to it
                    Point postoplot = xiscentre ? new Point(position.X - bmp.Width / 2, position.Y) : position;

                    //System.Diagnostics.Debug.WriteLine("Body " + sc.BodyName + " plot at "  + postoplot + " " + bmp.Size + " " + (postoplot.X+imageleft) + "," + (postoplot.Y-bmp.Height/2+imagetop));
                    endpoint = CreateImageAndLabel(pc, bmp, postoplot, bmp.Size, out imagepos, nodelabels, tip);
                    //System.Diagnostics.Debug.WriteLine("Draw {0} at {1} {2} out {3}", nodelabels[0], postoplot, bmp.Size, imagepos);

                    if (sc.HasMaterials && ShowMaterials)
                    {
                        Point matpos = new Point(endpoint.X + 4, position.Y);
                        Point endmat = CreateMaterialNodes(pc, sc, curmats, hl, matpos, materialsize);
                        endpoint = new Point(Math.Max(endpoint.X, endmat.X), Math.Max(endpoint.Y, endmat.Y)); // record new right point..
                    }
                }
            }
            else if (sn.NodeType == StarScan.ScanNodeType.belt)
            {
                if (sn.BeltData != null)
                {
                    tip = sn.BeltData.RingInformationMoons(true, "");
                }
                else
                {
                    tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                if (sn.Children != null && sn.Children.Count != 0)
                {
                    foreach (StarScan.ScanNode snc in sn.Children.Values)
                    {
                        if (snc.ScanData != null)
                        {
                            string sd = snc.ScanData.DisplayString() + "\n";
                            tip += "\n" + sd;
                        }
                    }
                }

                Size bmpsize = new Size(size.Width, planetsize.Height * nodeheightratio / noderatiodivider);

                endpoint = CreateImageAndLabel(pc, Icons.Controls.Scan_Bodies_Belt, position, bmpsize, out imagepos, new string[] { sn.OwnName.AppendPrePad(appendlabeltext, Environment.NewLine) }, tip, false);
            }
            else
            {
                if (sn.NodeType == StarScan.ScanNodeType.barycentre)
                {
                    tip = string.Format("Barycentre of {0}".T(EDTx.ScanDisplayUserControl_BC), sn.OwnName);
                }
                else
                {
                    tip = sn.OwnName + Environment.NewLine + Environment.NewLine + "No scan data available".T(EDTx.ScanDisplayUserControl_NSD);
                }

                string nodelabel = sn.CustomName ?? sn.OwnName;
                nodelabel = nodelabel.AppendPrePad(appendlabeltext, Environment.NewLine);

                endpoint = CreateImageAndLabel(pc, notscanned, position, size, out imagepos, new string[] { nodelabel }, tip, false);
            }

            //    System.Diagnostics.Debug.WriteLine("Node " + sn.ownname + " " + position + " " + size + " -> "+ endpoint);
            return(endpoint);
        }
Ejemplo n.º 13
0
 public override int Search(int x, int y, out double dist, DrawLevel dl)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 14
0
 public UIElement(UIScreen Screen, string StrID, DrawLevel Level)
 {
     m_Screen = Screen;
     m_StringID = StrID;
     m_DrawLevel = Level;
 }