示例#1
0
        public void fontsInstalled(SmashOverlayGenerator form, string fontName)
        {
            try
            {
                float fontSize = 12;

                using (Font fontTester = new Font(
                           fontName,
                           fontSize,
                           FontStyle.Regular,
                           GraphicsUnit.Pixel))
                {
                    if (String.Equals(fontTester.Name, fontName, StringComparison.OrdinalIgnoreCase))
                    {
                        // Font exists
                    }
                    else
                    {
                        GenFcns.installFonts(form, fontName, pfc);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public static void installFonts(SmashOverlayGenerator form, string fontName, PrivateFontCollection pfc)
        {
            // Try install the font
            string fontPath   = ListBoxFcns.getResourcePath(form.ProductName, "font", fontName);
            Stream fontStream = form.myAssembly.GetManifestResourceStream(fontPath);

            //create an unsafe memory block for the data
            System.IntPtr data = Marshal.AllocCoTaskMem((int)fontStream.Length);
            //create a buffer to read in to
            Byte[] fontData = new Byte[fontStream.Length];
            //fetch the font program from the resource
            fontStream.Read(fontData, 0, (int)fontStream.Length);
            //copy the bytes to the unsafe memory block
            Marshal.Copy(fontData, 0, data, (int)fontStream.Length);

            // We HAVE to do this to register the font to the system (Weird .NET bug !)
            uint cFonts = 0;

            AddFontMemResourceEx(data, (uint)fontData.Length, IntPtr.Zero, ref cFonts);

            //pass the font to the font collection
            pfc.AddMemoryFont(data, (int)fontStream.Length);
            //close the resource stream
            fontStream.Close();
            //free the unsafe memory
            Marshal.FreeCoTaskMem(data);
        }
        public static void createDataFile(SmashOverlayGenerator form)
        {
            string        file = form.tempData;
            StringBuilder sb   = new StringBuilder(
                "TournamentName:" + form.TournamentName);

            sb.Append("|\nTournamentRound:" + form.TournamentRound);
            sb.Append("|\nGameType:" + form.GameType);
            sb.Append("|\nCompetitor1:" + form.Competitor1);
            sb.Append("|\nScore1:" + form.Score1);
            sb.Append("|\nCompetitor2:" + form.Competitor2);
            sb.Append("|\nScore2:" + form.Score2);
            sb.Append("|\nNameSwap:" + form.NameSwap);
            sb.Append("|\nNameSwapCam:" + form.NameSwapCam);
            sb.Append("|\nTemplateFileName:" + form.TemplateFileName);

            if (debug)
            {
                sb.Append("|\nMatchup1:" + form.MatchupCompetitor1);
                sb.Append("|\nMatchupChar1:" + form.MatchupCharacter1);
                sb.Append("|\nMatchup2:" + form.MatchupCompetitor2);
                sb.Append("|\nMatchupChar2:" + form.MatchupCharacter2);
                sb.Append("|\nMatchupPic:" + form.MatchupPicFileName);
            }

            if (!sb.ToString().Contains("null"))
            {
                if (!File.Exists(file))
                {
                    File.Create(file);
                }
                File.WriteAllText(file, sb.ToString(), Encoding.Default);
            }
        }
 public Accessor(SmashOverlayGenerator form)
 {
     if (form == null)
     {
         throw new Exception("Form parameter cannot be null");
     }
     this.form = form;
 }
        public Bitmap drawTextOnImage(SmashOverlayGenerator form, bool swap, bool camSwap)
        {
            string cam1 = GenFcns.removeWinLoseTags(form.Competitor1);
            string cam2 = GenFcns.removeWinLoseTags(form.Competitor2);

            setFontSizes(form.ResourceType, form.Competitor1, form.Competitor2);

            Bitmap   image = base.getImage();
            Graphics g     = Graphics.FromImage(image);

            if (!swap)
            {
                g.DrawString(form.Competitor1, Name1Font, Brushes.White, Competitor1Point.getPoint(), Player1Format);
                g.DrawString(form.Competitor2, Name2Font, Brushes.White, Competitor2Point.getPoint(), Player2Format);
                g.DrawString(form.Score1, ScoreFont, Brushes.White, Score1Point.getPoint(), ScoreFormat);
                g.DrawString(form.Score2, ScoreFont, Brushes.White, Score2Point.getPoint(), ScoreFormat);
            }
            else
            {
                g.DrawString(form.Competitor1, Name1Font, Brushes.White, Competitor2Point.getPoint(), Player2Format);
                g.DrawString(form.Competitor2, Name2Font, Brushes.White, Competitor1Point.getPoint(), Player1Format);
                g.DrawString(form.Score1, ScoreFont, Brushes.White, Score2Point.getPoint(), ScoreFormat);
                g.DrawString(form.Score2, ScoreFont, Brushes.White, Score1Point.getPoint(), ScoreFormat);
            }

            if (!camSwap)
            {
                g.DrawString(cam1, Name1Font, Brushes.White, Competitor1WebcamPoint.getPoint(), NameFormat);
                g.DrawString(cam2, Name2Font, Brushes.White, Competitor2WebcamPoint.getPoint(), NameFormat);
            }
            else
            {
                g.DrawString(cam2, Name1Font, Brushes.White, Competitor1WebcamPoint.getPoint(), NameFormat);
                g.DrawString(cam1, Name2Font, Brushes.White, Competitor2WebcamPoint.getPoint(), NameFormat);
            }

            if (RoundPoint == null)
            {
                g.DrawString(form.TournamentName + " | " + form.TournamentRound,
                             TournamentFont, Brushes.White, TournamentNameRoundPoint.getPoint(), NameFormat);
            }
            else
            {
                g.DrawString(form.TournamentName, TournamentFont, Brushes.White, TournamentNameRoundPoint.getPoint(), TourneyFormat);

                RoundFont = new Font(FontFamily.GenericSerif, 25, FontStyle.Bold);
                g.DrawString(form.TournamentRound, RoundFont, Brushes.White, RoundPoint.getPoint(), NameFormat);
            }

            if (DatePoint != null)
            {
                g.DrawString(form.CurrentDateTime.ToString("MMMM dd, yyyy"), TournamentFont, Brushes.White, DatePoint.getPoint(), DateFormat);
            }

            return(image);
        }
        public static void determineGrandFinalsTags(SmashOverlayGenerator form, CheckBox box1, CheckBox box2, bool nameSwap)
        {
            string        win  = "[W]";
            string        lose = "[L]";
            StringBuilder sb   = new StringBuilder("");

            removeGrandFinalsTags(form);
            if (box1.Checked && box2.Checked)
            {
                if (!nameSwap)
                {
                    form.Competitor1 = form.Competitor1 + " " + lose;
                    form.Competitor2 = lose + " " + form.Competitor2;
                }
                else
                {
                    form.Competitor2 = form.Competitor2 + " " + lose;
                    form.Competitor1 = lose + " " + form.Competitor1;
                }
            }
            else if (box1.Checked)
            {
                if (!nameSwap)
                {
                    form.Competitor1 = form.Competitor1 + " " + lose;
                    form.Competitor2 = win + " " + form.Competitor2;
                }
                else
                {
                    form.Competitor1 = lose + " " + form.Competitor1;
                    form.Competitor2 = form.Competitor2 + " " + win;
                }
            }
            else if (box2.Checked)
            {
                if (!nameSwap)
                {
                    form.Competitor1 = form.Competitor1 + " " + win;
                    form.Competitor2 = lose + " " + form.Competitor2;
                }
                else
                {
                    form.Competitor1 = win + " " + form.Competitor1;
                    form.Competitor2 = form.Competitor2 + " " + lose;
                }
            }
        }
示例#7
0
        public override Bitmap drawTextOnImage(SmashOverlayGenerator form)
        {
            setFontSizes(form.Caster1, form.Caster2);

            //CENTER NAME TEXT
            StringFormat nameFormat    = new StringFormat();
            StringFormat twitterFormat = new StringFormat();

            nameFormat.LineAlignment = StringAlignment.Near;
            nameFormat.Alignment     = StringAlignment.Near;
            twitterFormat.Alignment  = StringAlignment.Near;

            Bitmap   image = base.getImage();
            Graphics g     = Graphics.FromImage(image);

            g.DrawString(form.Caster1, Caster1Font, Brushes.White, Caster1Point.getPoint(), nameFormat);
            g.DrawString(form.Caster2, Caster2Font, Brushes.White, Caster2Point.getPoint(), nameFormat);
            g.DrawString(form.Caster1Twitter, TwitterFont, Brushes.White, Caster1TwitterPoint.getPoint(), twitterFormat);
            g.DrawString(form.Caster2Twitter, TwitterFont, Brushes.White, Caster2TwitterPoint.getPoint(), twitterFormat);

            return(image);
        }
 public static void removeGrandFinalsTags(SmashOverlayGenerator form)
 {
     form.Competitor1 = removeWinLoseTags(form.Competitor1);
     form.Competitor2 = removeWinLoseTags(form.Competitor2);
 }
        public static bool loadDataFile(SmashOverlayGenerator form)
        {
            string file = form.tempData;

            if (File.Exists(file))
            {
                string content = "";
                foreach (string s in (File.ReadAllLines(file)))
                {
                    content += s.Replace("\n", "");
                }

                string[] titles = content.Split('|');
                foreach (string s in titles)
                {
                    string[] data = s.Split(':');
                    switch (data[0])
                    {
                    case "TournamentName":
                        form.TournamentName = data[1];
                        break;

                    case "TournamentRound":
                        form.TournamentRound = data[1];
                        break;

                    case "GameType":
                        form.GameType = data[1];
                        break;

                    case "Competitor1":
                        form.Competitor1 = data[1];
                        break;

                    case "Competitor2":
                        form.Competitor2 = data[1];
                        break;

                    case "Score1":
                        form.Score1 = data[1];
                        break;

                    case "Score2":
                        form.Score2 = data[1];
                        break;

                    case "NameSwap":
                        form.NameSwap = Boolean.Parse(data[1]);
                        break;

                    case "NameSwapCam":
                        form.NameSwapCam = Boolean.Parse(data[1]);
                        break;

                    case "TemplateFileName":
                        form.TemplateFileName = data[1];
                        break;

                    case "Matchup1":
                        form.MatchupCompetitor1 = data[1];
                        break;

                    case "Matchup2":
                        form.MatchupCompetitor2 = data[1];
                        break;

                    case "MatchupChar1":
                        form.MatchupCharacter1File = data[1];
                        break;

                    case "MatchupChar2":
                        form.MatchupCharacter2File = data[1];
                        break;

                    case "MatchupPic":
                        form.MatchupPicFileName = data[1];
                        break;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public override Bitmap drawTextOnImage(SmashOverlayGenerator form)
 {
     return(null);
 }
示例#11
0
        public override System.Drawing.Bitmap drawTextOnImage(SmashOverlayGenerator form)
        {
            //IF FONT IS NOT INSTALLED WE INSTALL IT

            GenFcns.installFonts(form, "EARTHQUAKE.TTF", pfc);
            GenFcns.installFonts(form, "FLAPHEAD.TTF", pfc);

            //fontsInstalled(form, "EARTHQUAKE");
            //fontsInstalled(form, "FLAPHEAD");
            //fontsInstalled(form, "zekton rg");

            setFontSizes(form.ResourceType, form.MatchupCompetitor1, form.MatchupCompetitor2);
            if (!GenFcns.isNullOrEmpty(Gametype) && Gametype.Equals("doubles"))
            {
                setFontSizes(form.ResourceType, Competitor3, Competitor4);
            }

            TournamentName  = form.TournamentName;
            TournamentRound = form.TournamentRound;
            Competitor1     = form.MatchupCompetitor1;
            Competitor2     = form.MatchupCompetitor2;

            StringFormat nameFormat       = new StringFormat();
            StringFormat tournamentFormat = new StringFormat();
            Bitmap       image            = base.getImage();
            Graphics     g = Graphics.FromImage(image);

            nameFormat.LineAlignment   = StringAlignment.Center;
            nameFormat.Alignment       = StringAlignment.Center;
            tournamentFormat.Alignment = StringAlignment.Center;

            //DRAW CHARACTERS
            drawCharactersOnImage(g, Character1Path, Character1Point, Character2Path, Character2Point);


            //DRAW BANNER
            Pen        p       = new Pen(Color.LightCyan, (float)50.0);
            SolidBrush b       = new SolidBrush(Color.MediumPurple);
            SolidBrush bBorder = new SolidBrush(Color.White);
            Rectangle  r       = new Rectangle(new Point(0, 800), new Size(1920, 200));
            Rectangle  rBorder = new Rectangle(new Point(0, 780), new Size(1920, 240));

            g.FillRectangle(bBorder, rBorder);
            g.FillRectangle(b, r);

            FontFamily earthquakeFamily = pfc.Families[0];
            FontFamily flapheadFamily   = pfc.Families[1];
            Font       earthquake       = new Font(earthquakeFamily, 120);
            Font       flaphead         = new Font(flapheadFamily, 120);

            //DRAW COMPETITOR INFORMATION
            g.DrawString(form.MatchupCompetitor1, earthquake, Brushes.White, Competitor1Point.getPoint(), nameFormat);
            g.DrawString(form.MatchupCompetitor2, earthquake, Brushes.White, Competitor2Point.getPoint(), nameFormat);
            //g.DrawString("THIS IS A TEST", f1, Brushes.Yellow, new Point(0, 0), nameFormat);
            //g.DrawString(form.TournamentName, TournamentFont, Brushes.White, TournamentPoint.getPoint(), tournamentFormat);


            //DRAW TOURNAMENT STUFFS
            string tournamentLogoPath = ListBoxFcns.getResourcePath(form.ProductName, "tournament", "*****@*****.**");
            Image  logoImage          = base.getImage(tournamentLogoPath);

            g.DrawImage(logoImage, TournamentPoint.getPoint());
            g.DrawString(form.TournamentRound, flaphead, Brushes.White, TournamentRoundPoint.getPoint(), tournamentFormat);


            Image  img      = (Image)image;
            Bitmap newImage = new Bitmap(img, new Size(640, 400));

            return(newImage);
        }
 public abstract Bitmap drawTextOnImage(SmashOverlayGenerator form);
示例#13
0
 public static void addNameToRecentNames(SmashOverlayGenerator form)
 {
 }