Example #1
0
        private int GetCurrentXPostion(int i, int spacing, int modImgWidth, int widthOfGeneratedMods,
                                       int imageWidth, DrawSide drawSide, DrawDirection drawDirection)
        {
            int xPos = i * (modImgWidth + spacing);

            if (drawSide == DrawSide.Left)
            {
                if (drawDirection == DrawDirection.FromRightToLeft)
                {
                    xPos = widthOfGeneratedMods - xPos - modImgWidth;
                }
                return(xPos);
            }
            else
            {
                if (drawDirection == DrawDirection.FromRightToLeft)
                {
                    xPos = imageWidth - xPos - modImgWidth;
                }
                else
                {
                    xPos += imageWidth - widthOfGeneratedMods;
                }
                return(xPos);
            }
        }
Example #2
0
        public Bitmap GenerateImage(string[] modsList)
        {
            int           imageWidth    = _settings.Get <int>(_names.ImageWidth);
            int           modHeight     = _settings.Get <int>(_names.ModHeight);
            int           modWidth      = _settings.Get <int>(_names.ModWidth);
            int           spacing       = _settings.Get <int>(_names.ModImageSpacing);
            float         opacity       = (float)_settings.Get <int>(_names.ModImageOpacity) / 100;
            DrawSide      drawSide      = _settings.Get <bool>(_names.DrawOnRightSide) ? DrawSide.Right : DrawSide.Left;
            DrawDirection drawDirection = _settings.Get <bool>(_names.DrawFromRightToLeft) ? DrawDirection.FromRightToLeft : DrawDirection.FromLeftToRight;
            List <string> validModPaths = new List <string>();

            foreach (var mod in modsList)
            {
                string effectiveModPath = Path.Combine(_saver.SaveDirectory, ImagesFolderName, mod.ToUpper() + ".png");
                if (ModImageExists(effectiveModPath))
                {
                    validModPaths.Add(effectiveModPath);
                }
            }
            int widthOfGeneratedMods = GetWidthOfGeneratedMods(validModPaths.Count, modWidth, spacing);

            if (drawDirection == DrawDirection.FromRightToLeft)
            {
                validModPaths.Reverse();
            }
            Bitmap bitmap = new Bitmap(imageWidth, modHeight);

            bitmap.MakeTransparent();
            using (var g = Graphics.FromImage(bitmap))
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                for (int i = 0; i < validModPaths.Count; i++)
                {
                    var singleModImage = Image.FromFile(validModPaths[i]);

                    using (var singleModImageWithOpacity = SetImageOpacity(singleModImage, opacity))
                    {
                        int xPos = GetCurrentXPostion(i, spacing, modWidth, widthOfGeneratedMods, imageWidth, drawSide,
                                                      drawDirection);
                        g.DrawImage(singleModImageWithOpacity, new Point(xPos, 0));
                    }
                    singleModImage.Dispose();
                }
                g.Save();
            }
            //bitmap.Save(ImageFullPath, ImageFormat.Png);
            return(bitmap);
        }
Example #3
0
        public List <ulong> DrawRectFrame()
        {
            List <ulong> rectFrameLst = new List <ulong>();
            double       frameHeight  = FrameControlData.GetMainFrameHeight();
            double       frameWidth   = FrameControlData.GetMainFrameWidth();

            _frameHeight = frameHeight;
            _frameWidth  = frameWidth;
            LJJSPoint     startPt     = new LJJSPoint(DrawCommonData.xStart, DrawCommonData.yStart);
            DrawDirection ddMainFrame = new DrawDirection();

            ddMainFrame.HorDirection = 1;
            ddMainFrame.VerDirection = -1;

            DrawDirection ddTitleFrame = new DrawDirection();

            ddTitleFrame.HorDirection = 1;
            ddTitleFrame.VerDirection = 1;

            Rect.AddBlackRect(startPt, frameHeight, frameWidth, FrameDesign.PictureFrameLineWidth, ddMainFrame);
            Rect.AddBlackRect(startPt, FrameDesign.LineRoadTitleBarHeigh, frameWidth, FrameDesign.PictureFrameLineWidth, ddTitleFrame);

            if (FrameDesign.JdStrLst.Count() > 1 && FrameControlData.LineRoadControlLst.Count() > 0)
            {
                List <JDStruc> firstLineRoadJDStrucLst = FrameControlData.LineRoadControlLst[0].LineRoadJDStructLst;
                //fff
                for (int i = 0; i < firstLineRoadJDStrucLst.Count(); i++) //2560-2590 2660-2690
                {
                    JDStruc   tmpJDStruc = firstLineRoadJDStrucLst[i];
                    double    xStart     = tmpJDStruc.JDPtStart.XValue;
                    double    yStart     = tmpJDStruc.JDPtStart.YValue + DrawCommonData.DirectionDown * tmpJDStruc.JDHeight;
                    LJJSPoint tmpstartPt = new LJJSPoint(xStart, yStart);
                    Line.BuildHorToRightBlackSolidLine(tmpstartPt, frameWidth, FrameDesign.PictureFrameLineWidth, "");

                    tmpstartPt = new LJJSPoint(xStart, yStart + DrawCommonData.DirectionDown * FrameDesign.JdSpace);
                    Line.BuildHorToRightBlackSolidLine(tmpstartPt, frameWidth, FrameDesign.PictureFrameLineWidth, "");
                }
            }

            return(rectFrameLst);
        }
Example #4
0
 public static ulong AddBlackRect(LJJSPoint insertPoint, double rectHeight, double rectWidth, double penWidth, DrawDirection drawDirection)
 {
     return(VectorDrawHelper.AddRect(DrawCommonData.activeDocument, FigureStrucConvert.ConvertLJJSPointToGPoint(insertPoint), rectHeight, rectWidth, 0, penWidth, drawDirection));
 }
Example #5
0
        public static ulong AddRect(vdDocument activeDocument, gPoint insertPoint, double rectHeight, double rectWidth, int rectColor, double penWidth, DrawDirection drawDirection)
        {
            //We will create a vdRect object and add it to the Active Layout which is the basic Model Layout always existing in a Document.
            VectorDraw.Professional.vdFigures.vdRect onerect = new VectorDraw.Professional.vdFigures.vdRect();
            //We set the document where the rect is going to be added.This is important for the vdRect in order to obtain initial properties with setDocumentDefaults.
            onerect.SetUnRegisterDocument(activeDocument);
            onerect.setDocumentDefaults();

            //The two previus steps are important if a vdFigure object is going to be added to a document.
            //Now we will change some properties of the rect.
            onerect.InsertionPoint       = insertPoint;//Initial value for a gPoint is (0.0,0.0)
            onerect.Width                = rectWidth * drawDirection.HorDirection;
            onerect.Height               = rectHeight * drawDirection.VerDirection;
            onerect.PenColor.SystemColor = Color.FromArgb(rectColor);

            onerect.PenWidth = penWidth;
            ////LineWeight is indipended from the zoom.
            //onerect.LineWeight = VectorDraw.Professional.Constants.VdConstLineWeight.LW_140;

            //Now we will add this object to the Entities collection of the Model Layout(ActiveLayout).
            DrawCommonData.activeDocument.ActiveLayOut.Entities.AddItem(onerect);
            return(onerect.Handle.Value);
        }
 private int GetCurrentXPostion(int i, int spacing, int modImgWidth, int widthOfGeneratedMods,
     int imageWidth, DrawSide drawSide, DrawDirection drawDirection)
 {
     int xPos = i * (modImgWidth + spacing);
     if (drawSide == DrawSide.Left)
     {
         if (drawDirection == DrawDirection.FromRightToLeft)
             xPos = widthOfGeneratedMods - xPos - modImgWidth;
         return xPos;
     }
     else
     {
         if (drawDirection == DrawDirection.FromRightToLeft)
             xPos = imageWidth - xPos - modImgWidth;
         else
             xPos += imageWidth - widthOfGeneratedMods;
         return xPos;
     }
 }