Пример #1
0
        public Form1()
        {
            InitializeComponent();
            System.Media.SoundPlayer sp = new System.Media.SoundPlayer();

            System.Drawing.Text.PrivateFontCollection f = new System.Drawing.Text.PrivateFontCollection();
            f.AddFontFile("660_pricedown_rus.ttf");
            f.AddFontFile("662_old_english.ttf");
            button1.Font = new Font(f.Families[1], 35);
            button2.Font = new Font(f.Families[1], 35);
            button3.Font = new Font(f.Families[1], 35);
            button4.Font = new Font(f.Families[1], 35);
            button5.Font = new Font(f.Families[1], 35);
            button6.Font = new Font(f.Families[1], 35);

            label1.Font = new Font(f.Families[0], 35);

            if (Desktop.a == true)
            {
                sp = new SoundPlayer("sound.wav");
                sp.Play();
                panel1.Visible       = true;
                progressBar1.Visible = true;
                timer1.Interval      = 350;
                timer1.Enabled       = true;
                timer1.Tick         += timer1_Tick;
            }
        }
Пример #2
0
        private void Placar_Load(object sender, EventArgs e)
        {
            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile("Crayon.ttf");

            lblTotalJogadas.Font = new Font(privateFonts.Families[0], 20);
        }
Пример #3
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            this.Loaded -= OnLoaded;
            this.MainGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Program.GameEngine.Definition.NoteBackgroundColor));
            this.TextBox.Foreground  = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Program.GameEngine.Definition.NoteForegroundColor));

            if (Prefs.UseGameFonts)
            {
                var font = Program.GameEngine.Definition.Fonts.FirstOrDefault(
                    x => x.Target.Equals("notes", StringComparison.InvariantCultureIgnoreCase));
                if (font != null)
                {
                    Log.Info("Loading font");
                    if (!File.Exists(font.Src))
                    {
                        Log.WarnFormat("Note Font {0} does not exist", font.Src);
                        return;
                    }
                    var pf = new System.Drawing.Text.PrivateFontCollection();
                    pf.AddFontFile(font.Src);
                    if (pf.Families.Length > 0)
                    {
                        Log.Info("Loaded font into collection");
                    }
                    string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + pf.Families[0].Name;
                    Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/"));
                    this.TextBox.FontFamily = new FontFamily(font1.Replace("\\", "/"));
                    this.TextBox.FontSize   = font.Size;
                    Log.Info(string.Format("Loaded font with source: {0}", this.TextBox.FontFamily.Source));
                }
            }
            this.BeginAnimation(OpacityProperty, showAnimation);
        }
Пример #4
0
        private void SetFont()
        {
            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(Environment.CurrentDirectory + "\\Font\\야놀자 야체 Regular.ttf");
            Font font12 = new Font(privateFonts.Families[0], 12f);
            Font font23 = new Font(privateFonts.Families[0], 23f);

            foreach (Control c in this.Controls)
            {
                if (c is Label)
                {
                    if (c.Tag.ToString() == "12")
                    {
                        c.Font = font12;
                    }
                    else if (c.Tag.ToString() == "23")
                    {
                        c.Font = font23;
                    }
                }
                else if (c is RadioButton)
                {
                    c.Font = font12;
                }
            }
            richTextBox1.Font = font12;
            txtBox_user.Font  = font12;
            answerLabel.Font  = font12;
        }
Пример #5
0
        /// <summary>
        /// Find the font family name of an specified TTF font file. Only available for Net Framework 4.5 builds.
        /// </summary>
        /// <param name="ttfFont">TTF font file.</param>
        /// <returns>The font family name of the specified TTF font file.</returns>
        /// <remarks>This method will return an empty string if the specified font is not found in its path or the system font folder or if it is not a valid TTF font.</remarks>
        public static string TrueTypeFontFamilyName(string ttfFont)
        {
            if (string.IsNullOrEmpty(ttfFont))
            {
                throw new ArgumentNullException(nameof(ttfFont));
            }

            // the following information is only applied to TTF not SHX fonts
            if (!Path.GetExtension(ttfFont).Equals(".TTF", StringComparison.InvariantCultureIgnoreCase))
            {
                return(string.Empty);
            }

            // try to find the file in the specified directory, if not try it in the fonts system folder
            string fontFile = File.Exists(ttfFont) ?
                              Path.GetFullPath(ttfFont) :
                              string.Format("{0}{1}{2}", Environment.GetFolderPath(Environment.SpecialFolder.Fonts), Path.DirectorySeparatorChar, Path.GetFileName(ttfFont));

            System.Drawing.Text.PrivateFontCollection fontCollection = new System.Drawing.Text.PrivateFontCollection();
            try
            {
                fontCollection.AddFontFile(fontFile);
                return(fontCollection.Families[0].Name);
            }
            catch (FileNotFoundException)
            {
                return(string.Empty);
            }
            finally
            {
                fontCollection.Dispose();
            }
        }
Пример #6
0
 private void LoadFonts(Control control)
 {
     if (Game == null)
     {
         return;
     }
     if (!Prefs.UseGameFonts)
     {
         return;
     }
     if (Game.Fonts.Count > 0)
     {
         foreach (Font font in Game.Fonts)
         {
             if (font.Target.ToLower().Equals("deckeditor"))
             {
                 if (!File.Exists(font.Src))
                 {
                     return;
                 }
                 System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                 control.FontSize = font.Size;
                 pfc.AddFontFile(font.Src);
                 string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + pfc.Families[0].Name;
                 control.FontFamily = new System.Windows.Media.FontFamily(font1.Replace("\\", "/"));
             }
         }
     }
 }
Пример #7
0
        private async void syori(FontFamily cfont)
        {
            await Task.Run(() =>
            {
                List <string> fontpathlist1 = fontlistkun();
                foreach (string pathstr in fontpathlist1)
                {
                    System.Drawing.Text.PrivateFontCollection pfc =
                        new System.Drawing.Text.PrivateFontCollection();
                    pfc.AddFontFile(pathstr);
                    string fntname         = pfc.Families[0].Name;
                    KeyValuePairstr newobj = new KeyValuePairstr(pathstr, fntname);
                    FontPathNamelist.Add(newobj);
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        logText.Content = fntname + " : " + pathstr;
                    }));
                    //pfc.Families[0].Name;
                }
            });

            this.TaskbarItemInfo.ProgressState
                = System.Windows.Shell.TaskbarItemProgressState.None;
            sintyokubar.IsIndeterminate = false;
            this.Close();
        }
Пример #8
0
        private void FontChenge()
        {
            //PrivateFontCollectionオブジェクトを作成する
            System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
            //PrivateFontCollectionにフォントを追加する
            pfc.AddFontFile(@"./FONT/A-OTF-UDShinMGoPr6-Regular.otf");
            //同様にして、複数のフォントを追加できる
            //pfc.AddFontFile(@"FONT/AdobeFnt19.lst");

            //PrivateFontCollectionに追加されているフォントの名前を列挙する
            foreach (System.Drawing.FontFamily ff in pfc.Families)
            {
                Console.WriteLine(ff.Name);
            }

            //PrivateFontCollectionの先頭のフォントのFontオブジェクトを作成する
            System.Drawing.Font f =
                new System.Drawing.Font(pfc.Families[0], 12);

            //Labelコントロールのフォントに設定する
            infobox.Font = f;

            //後始末
            pfc.Dispose();
        }
Пример #9
0
        //internal PrivateFontCollection PrivateFontCollection
        //{
        //  get { return privateFontCollection; }
        //  set { privateFontCollection = value; }
        //}

        GdiPrivateFontCollection GetPrivateFontCollection()
        {
            // Create only if really needed.
            if (_privateFontCollection == null)
                _privateFontCollection = new GdiPrivateFontCollection();
            return _privateFontCollection;
        }
Пример #10
0
        private void OnDragDrophandler(object sender, DragEventArgs e)
        {
            object o = e.Data.GetData(DataFormats.Text);

            if (o != null)
            {
                this.fontListBox.NewItem(o.ToString());
            }
            else
            {
                System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                try
                {
                    string[] FontName = (string[])e.Data.GetData(DataFormats.FileDrop, true);
                    for (int f = 0; f < FontName.Length; f++)
                    {
                        pfc.AddFontFile(FontName[f]);
                    }
                    if (pfc.Families.Length > 0)
                    {
                        for (int i = 0; i < pfc.Families.Length; i++)
                        {
                            this.fontListBox.NewItem(((FontFamily)pfc.Families[i]).Name);
                        }
                    }
                }
                finally
                {
                    pfc.Dispose();
                }
            }
        }
Пример #11
0
        /// <summary>从文件中获取字体</summary>
        public static Font GetFontFromFile(string fontPath, int size, FontStyle style)
        {
            var fonts = new System.Drawing.Text.PrivateFontCollection();

            fonts.AddFontFile(fontPath);
            return(new Font(fonts.Families[0], size, style));
        }
Пример #12
0
        public Bitmap Create(string text, float fontsize)
        {
            Bitmap       img     = new Bitmap(170, 42);
            Graphics     g       = Graphics.FromImage(img);
            StringFormat format1 = new StringFormat();

            format1.Alignment     = StringAlignment.Center;
            format1.LineAlignment = StringAlignment.Center;
            g.PixelOffsetMode     = PixelOffsetMode.Half;
            g.SmoothingMode       = SmoothingMode.AntiAlias;
            g.CompositingMode     = CompositingMode.SourceOver;
            g.CompositingQuality  = CompositingQuality.HighQuality;
            //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            g.Clear(System.Drawing.Color.FromArgb(30, 30, 30));
            g.DrawImage(Frame, 0, 0, 170, 42);
            Rectangle rectangletxt = new Rectangle(18, 5, 134, 32);

            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(@"bin\Tools\font2.ttf");

            Font font = new Font(privateFonts.Families[0], fontsize, System.Drawing.FontStyle.Bold, GraphicsUnit.Pixel);

            /*g.SmoothingMode = SmoothingMode.AntiAlias;
             * g.InterpolationMode = InterpolationMode.HighQualityBicubic;
             * g.PixelOffsetMode = PixelOffsetMode.HighQuality;*/
            // g.DrawString(text, font, new SolidBrush(System.Drawing.Color.FromArgb(180, 180, 180)), rectangletxt, format1);
            SizeF size = g.MeasureString(text, font);

            // g.DrawString(text, font, new SolidBrush(System.Drawing.Color.FromArgb(180, 180, 180)), (rectangletxt.Width - size.Width) / 2, (rectangletxt.Height - size.Height) / 2);
            TextRenderer.DrawText(g, text, font, rectangletxt, System.Drawing.Color.FromArgb(180, 180, 180), Color.White, TextFormatFlags.HorizontalCenter |
                                  TextFormatFlags.VerticalCenter |
                                  TextFormatFlags.GlyphOverhangPadding);
            return(img);
        }
Пример #13
0
        static void CreateBarCode(string text, string path)
        {
            // Get the font
            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile("barcode.ttf");
            Font fn = new System.Drawing.Font(privateFonts.Families[0], 72, FontStyle.Regular, GraphicsUnit.Point);

            // Measure the barcode on a temporary drawing surface:
            Bitmap   bmTemp = new Bitmap(100, 100, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Graphics grTemp = Graphics.FromImage(bmTemp);
            SizeF    sf     = grTemp.MeasureString(text, fn);

            // Draw the barcode on a bitmap:
            Bitmap bm = new Bitmap(Convert.ToInt32(sf.Width), Convert.ToInt32(sf.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Graphics gr = Graphics.FromImage(bm);

            gr.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
            gr.FillRectangle(Brushes.White, 0, 0, sf.Width, sf.Height);
            gr.DrawString(text, fn, Brushes.Black, 0, 0);

            //Stream the image back as a GIF:
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            bm.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            bm.Save(path);
        }
Пример #14
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("字体安装");
                #region 字体不注册直接添加内存中使用
                System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
                privateFonts.AddFontFile($@"{AppDomain.CurrentDomain.BaseDirectory}\CFonts\STSONG.ttf");
                System.Drawing.Font font = new Font(privateFonts.Families[0], 12);
                #endregion

                //注册
                DirectoryInfo folder = new DirectoryInfo($@"{AppDomain.CurrentDomain.BaseDirectory}\CFonts");
                foreach (FileInfo file in folder.GetFiles())
                {
                    Console.WriteLine(file.FullName);
                    Console.WriteLine($"安装字体结果:{FontOperate.InstallFont(file.FullName, file.Name)}");
                }

                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #15
0
        /// <summary>
        /// Add a font to the Content Manager from an external path
        /// </summary>
        /// <param name="filePath">File path which leads to a font file</param>
        /// <param name="fileName">Name of the file that should be opened</param>
        public void AddFont(string filePath, string fileName)
        {
            if (string.IsNullOrEmpty(filePath) || string.IsNullOrEmpty(fileName))
            {
                return;
            }

            if (fonts.ContainsKey(fileName))
            {
                return;
            }

            if (!File.Exists(filePath) || Path.GetExtension(filePath).ToLower() != ".ttf")
            {
                return;
            }

            try
            {
                using (System.Drawing.Text.PrivateFontCollection collection = new System.Drawing.Text.PrivateFontCollection())
                {
                    collection.AddFontFile(filePath);
                    fonts.Add(fileName, new FontCache(collection.Families[0]));
                }
            }
            catch
            {
            }
        }
Пример #16
0
        private System.Drawing.Font CreateFont(string fontPath, double fontSize)
        {
            //var fontPath = "data/font/migmix-2p-bold.ttf";
            var pfc = new System.Drawing.Text.PrivateFontCollection();
            var id  = pfc.Families.Length;

            pfc.AddFontFile(fontPath);
            var fontFamily = pfc.Families[id];
            var fontStyle  = System.Drawing.FontStyle.Regular;

            if (fontFamily.IsStyleAvailable(System.Drawing.FontStyle.Regular))
            {
                fontStyle = System.Drawing.FontStyle.Regular;
            }
            else if (fontFamily.IsStyleAvailable(System.Drawing.FontStyle.Bold))
            {
                fontStyle = System.Drawing.FontStyle.Bold;
            }
            else if (fontFamily.IsStyleAvailable(System.Drawing.FontStyle.Italic))
            {
                fontStyle = System.Drawing.FontStyle.Italic;
            }
            else if (fontFamily.IsStyleAvailable(System.Drawing.FontStyle.Strikeout))
            {
                fontStyle = System.Drawing.FontStyle.Strikeout;
            }
            else if (fontFamily.IsStyleAvailable(System.Drawing.FontStyle.Underline))
            {
                fontStyle = System.Drawing.FontStyle.Strikeout;
            }

            var font = new System.Drawing.Font(fontFamily, (float)fontSize, fontStyle);

            return(font);
        }
Пример #17
0
        private static void LoadFont()
        {
            System.Drawing.Text.PrivateFontCollection fontCollection=new System.Drawing.Text.PrivateFontCollection();

            foreach (var font in fontCollection.Families)
                ApplicationState.Fonts.Add(font.Name);
        }
Пример #18
0
/*        Load custom font by font file stream*/
        public void setFontByStream()
        {
            string AppPath  = Application.StartupPath;
            string fontPath = AppPath + @"\汉仪刚艺体-35W.ttf";

            if (System.IO.File.Exists(fontPath))
            {
                System.IO.Stream fileStream = new System.IO.StreamReader(fontPath).BaseStream;

                byte[] bytes = new byte[fileStream.Length];
                fileStream.Read(bytes, 0, bytes.Length);
                // 设置当前流的位置为流的开始
                fileStream.Seek(0, System.IO.SeekOrigin.Begin);
                System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                unsafe
                {
                    fixed(byte *pFontData = &bytes[0])
                    {
                        pfc.AddMemoryFont((System.IntPtr)pFontData, bytes.Length);
                    }
                }

                Font myFont = new Font(pfc.Families[0], 20f);
                this.label3.Font = myFont;
            }
        }
Пример #19
0
 public void load()
 {
     _default = load(FontResources.Inconsolata_ttf);
     _button  = load(FontResources.atari_full);
     _title   = load(FontResources.tlpsmb);
     _message = load(FontResources.Inconsolata_ttf);
     _label   = load(FontResources.Antique_526);
 }
Пример #20
0
        private System.Drawing.Text.PrivateFontCollection load(byte[] data)
        {
            var fonts = new System.Drawing.Text.PrivateFontCollection();

            fonts.AddMemoryFont(_bytes2Ptr(data), data.Length);

            return(fonts);
        }
Пример #21
0
 static Form1()
 {
     _pfc = new System.Drawing.Text.PrivateFontCollection();
     _pfc.AddFontFile("DS-Digital.ttf");
     _pfc.AddFontFile("SUBWT.ttf");
     DsDigital = new Font(_pfc.Families[0], 18f, FontStyle.Regular, GraphicsUnit.Point, 0);
     Subwt     = new Font(_pfc.Families[1], 16f, FontStyle.Regular, GraphicsUnit.Point, 0);
 }
Пример #22
0
        public override Font GetFont()
        {
            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(FontPath);
            Font font = new Font(privateFonts.Families[0], FontSize);

            return(font);
        }
Пример #23
0
        public static void LoadFont()
        {
            if (bInitialized)
            {
                return;
            }
            try
            {
                string[] tempFiles = System.IO.Directory.GetFiles(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Fonts"), "*.ttf");
                if (tempFiles != null)
                {
                    foreach (var filePath in tempFiles)
                    {
                        if (System.IO.File.Exists(filePath))
                        {
                            using (System.IO.FileStream fonstStream =
                                       /*System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(filePath)*/
                                       new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                            {
                                if (fonstStream != null)
                                {
                                    IntPtr data = IntPtr.Zero;
                                    try
                                    {
                                        if (_fonts == null)
                                        {
                                            _fonts = new System.Drawing.Text.PrivateFontCollection();
                                        }
                                        data = System.Runtime.InteropServices.Marshal.AllocCoTaskMem((int)fonstStream.Length);
                                        byte[] fontData = new byte[fonstStream.Length];
                                        fonstStream.Read(fontData, 0, (int)fonstStream.Length);
                                        System.Runtime.InteropServices.Marshal.Copy(fontData, 0, data, (int)fonstStream.Length);
                                        _fonts.AddMemoryFont(data, (int)fonstStream.Length);
                                    }
                                    finally
                                    {
                                        if (data != IntPtr.Zero)
                                        {
                                            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(data);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Couldn't find font path : {filePath= " + filePath + "}");
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("LoadFont : {Error= " + ex.Message + "}");
            }

            bInitialized = true;
        }
Пример #24
0
        private static void LoadFont()
        {
            System.Drawing.Text.PrivateFontCollection fontCollection = new System.Drawing.Text.PrivateFontCollection();

            foreach (var font in fontCollection.Families)
            {
                ApplicationState.Fonts.Add(font.Name);
            }
        }
Пример #25
0
        static LiveTile()
        {
            var ttf = String.Format(
                @"{0}\images\segoeui.ttf",
                HttpRuntime.AppDomainAppPath);

            _FontCollection = new System.Drawing.Text.PrivateFontCollection();
            _FontCollection.AddFontFile(ttf);
        }
Пример #26
0
        static LiveTile()
        {
            var ttf = String.Format(
                @"{0}\images\segoeui.ttf",
                HttpRuntime.AppDomainAppPath);

            _FontCollection = new System.Drawing.Text.PrivateFontCollection();
            _FontCollection.AddFontFile(ttf);
        }
Пример #27
0
        public Film()
        {
            InitializeComponent();
            System.Drawing.Text.PrivateFontCollection fonts = new System.Drawing.Text.PrivateFontCollection();
            fonts.AddFontFile("JOURNALISM.ttf");
            fonts.AddFontFile("Montserrat-Regular.ttf");

            label1.Font = new Font(fonts.Families[0], 48);
        }
Пример #28
0
        public void DrawPage(PdfPage page)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);

            DrawTitle(page, gfx, "Images");

            //DrawImage(gfx, 1);
            //DrawImageScaled(gfx, 2);
            //DrawImageRotated(gfx, 3);
            //DrawImageSheared(gfx, 4);
            //DrawGif(gfx, 5);
            //DrawPng(gfx, 6);
            //DrawTiff(gfx, 5);
            DrawFormXObject(gfx, 6);

            string strFontPath = @"C:/Windows/Fonts/simhei.ttf";

            System.Drawing.Text.PrivateFontCollection pfcFonts = new System.Drawing.Text.PrivateFontCollection();
            //string strFontPath = @"C:/Windows/Fonts/msyhl.ttc";
            pfcFonts.AddFontFile(strFontPath);
            XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
            XFont           font    = new XFont(pfcFonts.Families[0], 30, XFontStyle.Regular, options);//.Families[0], 15

            //Document document1 = new Document();
            //Style style = document1.Styles["Normal"];
            //style.Font = new MigraDoc.DocumentObjectModel.Font(pfcFonts.Families[0].Name, 12);

            // Create a new PDF document
            //PdfDocument document = new PdfDocument();
            //document.Info.Title = "Created with PDFsharp";

            //// Create an empty page
            //PdfPage page = document.AddPage();

            //// Get an XGraphics object for drawing
            //XGraphics gfx = XGraphics.FromPdfPage(page);
            string st = "pdf测试文字";

            gfx.DrawString(st, font, XBrushes.Black,
                           new XRect(200, 100, page.Width, page.Height),
                           XStringFormats.Center);

            ////格式框
            //XTextFormatter tf = new XTextFormatter(gfx);

            //XRect rect = new XRect(310, 100, 250, 232);
            //gfx.DrawRectangle(XBrushes.SeaShell, rect);
            //tf.Alignment = XParagraphAlignment.Right;
            //tf.DrawString(st, font, XBrushes.Black, rect, XStringFormats.TopLeft);
            ////格式框止

            //// Save the document...
            //const string filename = "HelloWorld_tempfile.pdf";
            //document.Save(filename);
            //// ...and start a viewer.
            //Process.Start(filename);
        }
Пример #29
0
        static XFontSource()
        {
            var searchingPaths = new List <string>();
            // Application
            var executingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            searchingPaths.Add(executingPath);
            // Windows
            var systemFontsPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);

            if (!string.IsNullOrWhiteSpace(systemFontsPath))
            {
                searchingPaths.Add(systemFontsPath);
            }
            else
            {
                // Debian
                searchingPaths.Add("/usr/share/fonts/truetype");
                //searchingPaths.Add("/usr/share/X11/fonts");
                //searchingPaths.Add("/usr/X11R6/lib/X11/fonts");
                //searchingPaths.Add("~/.fonts");
            }

            foreach (var searchingPath in searchingPaths)
            {
                // TODO: *.ttc not supported yet!
                var fileNames = new List <string>();
                try
                {
                    fileNames = Directory.GetFiles(searchingPath, "*.ttf", SearchOption.AllDirectories).ToList();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                    continue;
                }

                foreach (var fileName in fileNames)
                {
                    try
                    {
                        var fontCollection = new System.Drawing.Text.PrivateFontCollection();
                        fontCollection.AddFontFile(fileName);
                        var fontName = fontCollection.Families[0].Name;
                        if (!FontFilePaths.ContainsKey(fontName))
                        {
                            FontFilePaths.Add(fontName, fileName);
                            Debug.WriteLine($"Add font {fontName}: {fileName}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                    }
                }
            }
        }
Пример #30
0
        }                               // button 벗어나면 마우스 커서 변경

        private void SetFont()          // 글꼴 설정
        {
            System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
            privateFonts.AddFontFile(Environment.CurrentDirectory + "\\Font\\야놀자 야체 Regular.ttf");
            Font font23 = new Font(privateFonts.Families[0], 23f);

            hostLabel.Font  = font23;
            guestLabel.Font = font23;
        }
Пример #31
0
        //internal PrivateFontCollection PrivateFontCollection
        //{
        //  get { return privateFontCollection; }
        //  set { privateFontCollection = value; }
        //}

        GdiPrivateFontCollection GetPrivateFontCollection()
        {
            // Create only if really needed.
            if (_privateFontCollection == null)
            {
                _privateFontCollection = new GdiPrivateFontCollection();
            }
            return(_privateFontCollection);
        }
        //zorgt ervoor dat we custom fonts kunnen inladen en gebruiken.
        public void UseCustomFont(string name, int size, Label label)
        {
            string FontPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Fonts/" + name + ".otf");

            System.Drawing.Text.PrivateFontCollection ModernFont = new System.Drawing.Text.PrivateFontCollection();

            ModernFont.AddFontFile(FontPath);

            label.Font = new Font(ModernFont.Families[0], size);
        }
Пример #33
0
        public static void LoadFonts()
        {
            if (_load)
            {
                return;
            }

            _load = true;
            Fonts = new System.Drawing.Text.PrivateFontCollection();
        }
Пример #34
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            float length = 0;
            float width = 0;
            float height = 0;
            float insuranceAmount = 0;
            int zip = 0;

            if (float.TryParse(lengthTextbox.Text, out length) && float.TryParse(widthTextBox.Text, out width) && float.TryParse(heightTextBox.Text, out height) &&
                ( insuranceCheckBox.Checked == float.TryParse(insuranceAmountTextBox.Text, out insuranceAmount)) && destinationZipTextBox.Text.Length == 5 && int.TryParse(destinationZipTextBox.Text, out zip) &&
                sourceZipTextBox.Text.Length == 5 && int.TryParse(sourceZipTextBox.Text, out zip) && (sourceStreetTextbox.Text != "") && (destinationAddresseeTextBox.Text != "") &&
                (sourceStreetTextbox.Text != "") && (destinationStreetTextBox.Text != ""))
            {
                //TODO: Add error checking: empty fields, non-numeric, etc...
                Address source = new Address(sourceAddresseeTextBox.Text, sourceStreetTextbox.Text, sourceZipTextBox.Text);
                Address destination = new Address(destinationAddresseeTextBox.Text, destinationStreetTextBox.Text, destinationZipTextBox.Text);
                float[] lhw = { length, width, height};
                Package p = shippingSystem.addPackage(weightClassComboBox.SelectedIndex, lhw, (serviceTypeComboBox.SelectedIndex == 0) ? Package.SERVICE_TYPE.Economy : Package.SERVICE_TYPE.Air, fragileCheckBox.Checked, irregularCheckBox.Checked, perishableCheckBox.Checked, source, destination);
                if (p != null)
                {
                    (parentForm as StoreFrontForm).updatePackageList();

                    PrintDialog pd = new PrintDialog();
                    PrinterSettings ps = new PrinterSettings();
                    pd.PrinterSettings = ps;
                    DialogResult dr = pd.ShowDialog();

                    if (dr == DialogResult.OK)
                    {
                        System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
                        privateFonts.AddFontFile("free3of9.ttf");
                        Font font = new Font(privateFonts.Families[0], 64);

                        PCPrint printer = new PCPrint(p.TrackingNumber);
                        printer.PrinterSettings.PrinterName = pd.PrinterSettings.PrinterName;
                        printer.PrinterFont = font;
                        printer.Print();
                    }

                    Close();
                }
                else
                {
                    MessageBox.Show("There was a problem creating this package. \r\nMaybe the destination zipcode is not in the system.");
                }
            }
            else
            {
                MessageBox.Show("Invalid input");
            }
        }
 /// <summary>
 /// FontFamily Name
 /// </summary>
 /// <param name="fontName"></param>
 /// <returns></returns>
 public System.Drawing.FontFamily GetFont(string fontName)
 {
     if (fontName.IsNullOrEmptyOrSpace()) return null;
     using (var stream = GetType().Assembly.GetManifestResourceStream("App.Font.Fonts." + fontName))
     {
         if (stream.IsEmpty()) return null;
         using (var pFont = new System.Drawing.Text.PrivateFontCollection())
         {
             var bFont = stream.ToBytes();
             if (bFont.IsEmpty()) return null;
             var meAdd = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(byte)) * bFont.Length);
             System.Runtime.InteropServices.Marshal.Copy(bFont, 0, meAdd, bFont.Length);
             pFont.AddMemoryFont(meAdd, bFont.Length);
             return pFont.Families[0];
         }
     }
 }
Пример #36
0
        public static FontFamily GetFontFamily(this DataNew.Entities.Font font, FontFamily defaultFont)
        {
            if (!System.IO.File.Exists(font.Src))
                return defaultFont;

            using(var pf = new System.Drawing.Text.PrivateFontCollection())
            {
                pf.AddFontFile(font.Src);
                if(pf.Families.Length == 0)
                {
                    Log.WarnFormat("Could not load font {0}", font.Src);
                    return defaultFont;
                }

                string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + pf.Families[0].Name;
                Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/"));
                var ret = new FontFamily(font1.Replace("\\", "/") + ", " + defaultFont.Source);
                return ret;
            }
        }
 /// <summary>
 /// 取得字体家族
 /// </summary>
 /// <param name="resxname"></param>
 /// <returns></returns>
 public System.Drawing.FontFamily GetFont(string resxname)
 {
     if (string.IsNullOrEmpty(resxname)) return null;
     var pFont = new System.Drawing.Text.PrivateFontCollection();
     try
     {
         var stream = GetType().Assembly.GetManifestResourceStream("KCPlayer.Plugin.WatchTV.Fonts." + resxname);
         if (stream == null)
         {
             return null;
         }
         var bFont = StreamToBytes(stream);
         var meAdd =
             System.Runtime.InteropServices.Marshal.AllocHGlobal(
                 System.Runtime.InteropServices.Marshal.SizeOf(typeof (byte))*bFont.Length);
         System.Runtime.InteropServices.Marshal.Copy(bFont, 0, meAdd, bFont.Length);
         pFont.AddMemoryFont(meAdd, bFont.Length);
     }
     catch
     {
         return null;
     }
     return pFont.Families[0];
 }
Пример #38
0
		public static void ClearFonts() {
			mFontColection = new System.Drawing.Text.PrivateFontCollection();
		}
Пример #39
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     // Affichage du splash screen
     SplashScreen s = new SplashScreen();
     s.Show();
     // Police de caractères de l'écran LCD
     try
     {
         System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
         pfc.AddFontFile(Application.StartupPath + "\\AlphaSmart3000.ttf");
         screenLabel.Font = new Font(pfc.Families[0], 15, FontStyle.Regular);
     }
     catch
     {
         MessageBox.Show("Police de caractères 'AlphaSmart3000.ttf' introuvable.\nL'affichage à l'écran sera probablement anormal.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     System.Threading.Thread.Sleep(1500);
     UpdateScreen();
 }
Пример #40
0
        private void cmdFontSearchFolder_Click(object sender, System.EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
                int index = 0;
                bool stopnow = false;

                System.Drawing.Text.PrivateFontCollection pfc;
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(folderBrowserDialog1.SelectedPath);
                System.IO.FileInfo[] FileArray = dir.GetFiles("*.ttf");
                for (int outerindex = 0; outerindex != 2; outerindex+=1) {
                    foreach (System.IO.FileInfo f in FileArray) {
                        try {
                            stopnow = true;
                            index+=1;
                            labelFontNum.Text = index.ToString(Util.cfi);
                            Application.DoEvents();
                            pfc = new System.Drawing.Text.PrivateFontCollection();
                            pfc.AddFontFile(f.FullName);

                            if (pfc.Families.Length != 0) {
                                foreach (ListViewItem lvi in lstFonts.Items) {
                                    stopnow = false;
                                    try {
                                        string familyName = lvi.Text.TrimStart("@".ToCharArray());

                                        foreach (System.Drawing.FontFamily pFamily in pfc.Families) {
                                            if (String.Equals(pFamily.Name, familyName, StringComparison.OrdinalIgnoreCase)) {
                                                lvi.SubItems[1].Text = "Found In Folder";
                                                lvi.SubItems[2].Text = f.FullName;
                                            }
                                        }
                                    } catch { }
                                }
                            }
                            pfc.Dispose();
                        } catch {
                            stopnow = false;
                            MessageBox.Show("Couldn't add font " + f.FullName);
                        }
                        if (stopnow) break;
                    }
                    FileArray = dir.GetFiles("*.ttc");
                }

                System.GC.Collect();
            }
            labelFontNum.Text = "done";
        }
Пример #41
0
		/// <summary>
		/// Initializes the button by loading the texture, creating the sprite and figure out the scaling.
		/// 
		/// Called on the GUI thread.
		/// </summary>
		/// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param>
		public void Initialize(DrawArgs drawArgs)
		{
			if(!m_enabled)
				return;

			if (m_TitleFont == null)
			{
				System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 8.0f, FontStyle.Bold);
				m_TitleFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

				System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
				m_wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

                AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
                System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
                fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
                System.Drawing.Font m_worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
                m_worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, m_worldwinddings);
			}

			m_TextFont = drawArgs.defaultDrawingFont;

			UpdateLocation();

			m_isInitialized = true;
		}
Пример #42
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                // Create table
                DataTable tbl = new DataTable();
                tbl.Columns.Add(new DataColumn() { ColumnName = "Name" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Type" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Path" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Filename" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Filesize" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Create" });
                tbl.Columns.Add(new DataColumn() { ColumnName = "Modification" });

                DataRow headline = tbl.NewRow();
                headline["Name"] = "Font Name";
                headline["Type"] = "Font Type";
                headline["Path"] = "Font Path";
                headline["Filename"] = "Font Filename";
                headline["Filesize"] = "Filesize";
                headline["Create"] = "Create Date";
                headline["Modification"] = "Modification Date";
                tbl.Rows.Add(headline);

                // Scan folder
                String fontfolder = "";
                bool includeunknown = false;
                this.Dispatcher.Invoke(new Action(() => {
                    fontfolder = this.FontFolder;
                    includeunknown = this.IncludeUnknown;
                }));
                string[] files = Directory.GetFiles(fontfolder);
                this.Dispatcher.Invoke(new Action(() =>
                {
                    this.ProMax = files.Length;
                    this.ProText = "0/" + files.Length;
                }));

                foreach (String file in files)
                {
                    FileInfo fontfile = new FileInfo(file);
                    String extension = fontfile.Extension.ToLower();
                    DataRow newrow = tbl.NewRow();

                    if ((extension.Equals(".pfa") || extension.Equals(".pfb") ||
                        extension.Equals(".afm") || extension.Equals(".ttf")) == false &&
                        includeunknown == false)
                    {
                        this.ProVal++;
                        continue;
                    }

                    // Default values
                    newrow["Name"] = "ERR: File extension not supported";
                    newrow["Type"] = extension.Trim(new char[] { '.' }).ToUpper();
                    newrow["Path"] = fontfile.Directory.FullName;
                    newrow["Filename"] = fontfile.Name;
                    newrow["Filesize"] = "ERR";
                    newrow["Create"] = "ERR";
                    newrow["Modification"] = "ERR";

                    // Get real values
                    try
                    {
                        // Size
                        newrow["Filesize"] = Convert.ToInt32((fontfile.Length / 1024)) + "KB";

                        // Create Date
                        newrow["Create"] = fontfile.CreationTime.ToString("yyyy-MM-dd H:mm:ss");

                        // Mod Date
                        newrow["Modification"] = fontfile.LastWriteTime.ToString("yyyy-MM-dd H:mm:ss");

                        // Font Name
                        if (extension.Equals(".ttf"))
                        {
                            System.Drawing.Text.PrivateFontCollection fontCol = new System.Drawing.Text.PrivateFontCollection();
                            try
                            {
                                fontCol.AddFontFile(file);
                                newrow["Name"] = fontCol.Families[0].Name;
                            }
                            catch (Exception)
                            {
                                newrow["Name"] = "ERR: No valid font file";
                            }
                        }
                        else
                        {
                            Regex rgx = null;
                            if (extension.Equals(".pfa"))
                            {
                                rgx = new Regex(@"%%FontName: ([^\s]*)", RegexOptions.Multiline);
                            }
                            else if(extension.Equals(".pfb"))
                            {
                                rgx = new Regex(@"/FontName /([^\s]*)", RegexOptions.Multiline);
                            }
                            else if (extension.Equals(".afm"))
                            {
                                rgx = new Regex(@"FullName ([^\s]*)", RegexOptions.Multiline);
                            }

                            if (rgx != null)
                            {
                                String content = File.ReadAllText(fontfile.FullName);
                                if (rgx.IsMatch(content))
                                {
                                    Match match = rgx.Match(content);
                                    newrow["Name"] = match.Groups[1].Value.ToString();
                                }
                                else
                                {
                                    newrow["Name"] = "ERR: Name not found";
                                }
                            }
                            else
                            {
                                newrow["Name"] = "ERR: Unexpected file extension";
                            }
                        }

                    }
                    catch (Exception exx)
                    {
                        newrow["Name"] = "Exception: "+exx.Message.Replace("\"", "'");
                    }
                    finally
                    {
                        tbl.Rows.Add(newrow);
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            this.ProVal++;
                            this.ProText = this.ProVal + "/" + this.ProMax;
                        }));
                    }
                }

                // Generate CSV File
                StringBuilder builder = new StringBuilder();
                foreach (DataRow row in tbl.AsEnumerable())
                {
                    String[] stringArray = row.ItemArray.Cast<string>().ToArray();
                    builder.AppendLine("\"" + string.Join("\";\"", stringArray) + "\"");
                }

                String csvfile = "";
                this.Dispatcher.Invoke(new Action(() => { csvfile = this.CsvFile; }));
                File.WriteAllText(csvfile, builder.ToString());

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #43
0
        private void UpdateFont()
        {
            string curDir = Path.Combine(SimpleConfig.DataDirectory, "Games", Program.Game.Definition.Id.ToString());
            string uri = "file:///" + curDir.Replace('\\', '/') + "/#";
            System.Drawing.Text.PrivateFontCollection context = new System.Drawing.Text.PrivateFontCollection();
            System.Drawing.Text.PrivateFontCollection chatname = new System.Drawing.Text.PrivateFontCollection();

            Boolean inchat = false;
            foreach (List<string> s in fontName)
            {
                if (s[1] == "chat")
                {
                    inchat = true;
                    chatname.AddFontFile(curDir + "\\" + s[0]);
                }
                else
                    context.AddFontFile(curDir + "\\" + s[0]);
            }      

            // self = player tab information
            // watermark = type to chat (ctrl+t)
            // output = chatbox

            int chatsize = 12;
            int fontsize = 12;
            foreach (GlobalVariableDef varD in Program.Game.Definition.GlobalVariables)
            {
                if (varD.Name == "chatsize")
                    chatsize = Convert.ToInt16(varD.Value);
                if (varD.Name == "fontsize")
                    fontsize = Convert.ToInt16(varD.Value);
            }
                
            chat.watermark.FontFamily = new FontFamily(uri + context.Families[0].Name);
            GroupControl.groupFont = new FontFamily(uri + context.Families[0].Name);
            GroupControl.fontsize = fontsize;
            if (inchat)
            {
                chat.output.FontFamily = new FontFamily(uri + chatname.Families[0].Name);
                chat.output.FontSize = chatsize;
            }
        }
Пример #44
0
        /// <summary>
        /// 创建字体
        /// </summary>
        /// <param name="fontFile">字体文件</param>
        /// <param name="fontSize">字体大小</param>
        /// <returns></returns>
        private Font createWatermarkFont(string fontFile, float fontSize)
        {
            Font font = null;

            if (!File.Exists(fontFile)) return new Font("arial", fontSize, FontStyle.Regular);

            System.Drawing.Text.PrivateFontCollection FM = new System.Drawing.Text.PrivateFontCollection();
            FM.AddFontFile(fontFile);
            FontFamily fontFamily = FM.Families[0];
            font = new Font(fontFamily, fontSize, FontStyle.Regular, GraphicsUnit.Point);

            return font;
        }
Пример #45
0
		public override void RenderContents(DrawArgs drawArgs)
		{
			m_DrawArgs = drawArgs;
			try
			{
				if(itemFont == null)
				{
					itemFont = drawArgs.CreateFont( World.Settings.LayerManagerFontName, 
						World.Settings.LayerManagerFontSize, World.Settings.LayerManagerFontStyle );

					// TODO: Fix wingdings menu problems
					System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold);
					headerFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);

					System.Drawing.Font wingdings = new System.Drawing.Font("Wingdings", 12.0f);
					wingdingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, wingdings);

					AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
					fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf"));
					System.Drawing.Font worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
					worldwinddingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
				}

				this.updateList();
				
				this.worldwinddingsFont.DrawText(
					null,
					"E",
					new System.Drawing.Rectangle(this.Right - 16, this.Top + 2, 20, topBorder),
					DrawTextFormat.None,
					TextColor);

				int numItems = GetNumberOfUncollapsedItems();
				int totalHeight = GetItemsHeight(drawArgs);//numItems * ItemHeight;
				showScrollbar = totalHeight > ClientHeight;
				if(showScrollbar)
				{
					double percentHeight = (double)ClientHeight / totalHeight;
					int scrollbarHeight = (int)(ClientHeight * percentHeight);

					int maxScroll = totalHeight-ClientHeight;

					if(scrollBarPosition < 0)
						scrollBarPosition = 0;
					else if(scrollBarPosition > maxScroll)
						scrollBarPosition = maxScroll;

					// Smooth scroll
					const float scrollSpeed = 0.3f;
					float smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*scrollSpeed;
					float absDelta = Math.Abs(smoothScrollDelta);
					if(absDelta > 100f || absDelta < 3f) 
						// Scroll > 100 pixels and < 1.5 pixels faster
						smoothScrollDelta = (scrollBarPosition - scrollSmoothPosition)*(float)Math.Sqrt(scrollSpeed);
					
					scrollSmoothPosition += smoothScrollDelta;

					if(scrollSmoothPosition > maxScroll)
						scrollSmoothPosition = maxScroll;

					int scrollPos = (int)((float)percentHeight * scrollBarPosition );

					int color = isScrolling ? World.Settings.scrollbarHotColor : World.Settings.scrollbarColor;
					MenuUtils.DrawBox(
						Right - ScrollBarSize + 2,
						ClientTop + scrollPos,
						ScrollBarSize - 3,
						scrollbarHeight + 1,
						0.0f,
						color,
						drawArgs.device);

					scrollbarLine[0].X = this.Right - ScrollBarSize;
					scrollbarLine[0].Y = this.ClientTop;
					scrollbarLine[1].X = this.Right - ScrollBarSize;
					scrollbarLine[1].Y = this.Bottom;
					MenuUtils.DrawLine(scrollbarLine, 
						DialogColor,
						drawArgs.device);
				}

				this.headerFont.DrawText(
					null, "Layer Manager",
					new System.Drawing.Rectangle( Left+5, Top+1, Width, topBorder-2 ),
					DrawTextFormat.VerticalCenter, TextColor);

				Microsoft.DirectX.Vector2[] headerLinePoints = new Microsoft.DirectX.Vector2[2];
				headerLinePoints[0].X = this.Left;
				headerLinePoints[0].Y = this.Top + topBorder - 1;

				headerLinePoints[1].X = this.Right;
				headerLinePoints[1].Y = this.Top + topBorder - 1;

				MenuUtils.DrawLine(headerLinePoints, DialogColor, drawArgs.device);

				int runningItemHeight = 0;
				if( showScrollbar )
					runningItemHeight = -(int)Math.Round(scrollSmoothPosition);

				// Set the Direct3D viewport to match the layer manager client area
				// to clip the text to the window when scrolling
				Viewport lmClientAreaViewPort = new Viewport();
				lmClientAreaViewPort.X = ClientLeft;
				lmClientAreaViewPort.Y = ClientTop;
				lmClientAreaViewPort.Width = ClientWidth;
				lmClientAreaViewPort.Height = ClientHeight;
				Viewport defaultViewPort = drawArgs.device.Viewport;
				drawArgs.device.Viewport = lmClientAreaViewPort;
				for(int i = 0; i < _itemList.Count; i++)
				{
					if(runningItemHeight > ClientHeight)
						// No more space for items
						break;
					LayerMenuItem lmi = (LayerMenuItem)_itemList[i];
					runningItemHeight += lmi.Render(
						drawArgs, 
						ClientLeft,
						ClientTop,
						runningItemHeight,
						ClientWidth,
						ClientBottom,
						itemFont,
						wingdingsFont,
						worldwinddingsFont, 
						MouseOverItem);
				}
				drawArgs.device.Viewport = defaultViewPort;
			}
			catch(Exception caught)
			{
				Log.Write( caught );
			}
		}
Пример #46
0
        private void PreviewAsset(AssetPreloadData asset)
        {
            switch (asset.Type2)
            {
                #region Texture2D
                case 28: //Texture2D
                    {
                        Texture2D m_Texture2D = new Texture2D(asset, true);
                        
                        if (m_Texture2D.m_TextureFormat < 30)
                        {
                            byte[] imageBuffer = new byte[128 + m_Texture2D.image_data_size];

                            imageBuffer[0] = 0x44;
                            imageBuffer[1] = 0x44;
                            imageBuffer[2] = 0x53;
                            imageBuffer[3] = 0x20;
                            imageBuffer[4] = 0x7c;
                            
                            BitConverter.GetBytes(m_Texture2D.dwFlags).CopyTo(imageBuffer, 8);
                            BitConverter.GetBytes(m_Texture2D.m_Height).CopyTo(imageBuffer, 12);
                            BitConverter.GetBytes(m_Texture2D.m_Width).CopyTo(imageBuffer, 16);
                            BitConverter.GetBytes(m_Texture2D.dwPitchOrLinearSize).CopyTo(imageBuffer, 20);
                            BitConverter.GetBytes(m_Texture2D.dwMipMapCount).CopyTo(imageBuffer, 28);
                            BitConverter.GetBytes(m_Texture2D.dwSize).CopyTo(imageBuffer, 76);
                            BitConverter.GetBytes(m_Texture2D.dwFlags2).CopyTo(imageBuffer, 80);
                            BitConverter.GetBytes(m_Texture2D.dwFourCC).CopyTo(imageBuffer, 84);
                            BitConverter.GetBytes(m_Texture2D.dwRGBBitCount).CopyTo(imageBuffer, 88);
                            BitConverter.GetBytes(m_Texture2D.dwRBitMask).CopyTo(imageBuffer, 92);
                            BitConverter.GetBytes(m_Texture2D.dwGBitMask).CopyTo(imageBuffer, 96);
                            BitConverter.GetBytes(m_Texture2D.dwBBitMask).CopyTo(imageBuffer, 100);
                            BitConverter.GetBytes(m_Texture2D.dwABitMask).CopyTo(imageBuffer, 104);
                            BitConverter.GetBytes(m_Texture2D.dwCaps).CopyTo(imageBuffer, 108);
                            BitConverter.GetBytes(m_Texture2D.dwCaps2).CopyTo(imageBuffer, 112);
                            
                            m_Texture2D.image_data.CopyTo(imageBuffer, 128);

                            imageTexture = DDSDataToBMP(imageBuffer);
                            imageTexture.RotateFlip(RotateFlipType.RotateNoneFlipY);
                            previewPanel.BackgroundImage = imageTexture;
                            previewPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
                        }
                        else { StatusStripUpdate("Unsupported image for preview. Try to export."); }
                        break;
                    }
                #endregion
                #region AudioClip
                case 83: //AudioClip
                    {
                        AudioClip m_AudioClip = new AudioClip(asset, true);

                        //MemoryStream memoryStream = new MemoryStream(m_AudioData, true);
                        //System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer(memoryStream);
                        //soundPlayer.Play();

                        FMOD.RESULT result;
                        FMOD.CREATESOUNDEXINFO exinfo = new FMOD.CREATESOUNDEXINFO();
                        
                        exinfo.cbsize = Marshal.SizeOf(exinfo);
                        exinfo.length = (uint)m_AudioClip.m_Size;

                        result = system.createSound(m_AudioClip.m_AudioData, (FMOD.MODE.OPENMEMORY | loopMode), ref exinfo, out sound);
                        if (ERRCHECK(result)) { break; }

                        result = sound.getLength(out FMODlenms, FMOD.TIMEUNIT.MS);
                        if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE))
                        {
                            if (ERRCHECK(result)) { break; }
                        }

                        result = system.playSound(sound, null, false, out channel);
                        if (ERRCHECK(result)) { break; }

                        timer.Start();
                        FMODstatusLabel.Text = "Playing";
                        FMODpanel.Visible = true;

                        //result = channel.getChannelGroup(out channelGroup);
                        //if (ERRCHECK(result)) { break; }

                        result = channel.getFrequency(out FMODfrequency);
                        ERRCHECK(result);

                        FMODinfoLabel.Text = FMODfrequency.ToString() + " Hz";
                        break;
                    }
                #endregion
                #region Shader & TextAsset
                case 48:
                case 49:
                    {
                        TextAsset m_TextAsset = new TextAsset(asset, true);
                        
                        string m_Script_Text = UnicodeEncoding.UTF8.GetString(m_TextAsset.m_Script);
                        m_Script_Text = Regex.Replace(m_Script_Text, "(?<!\r)\n", "\r\n");
                        textPreviewBox.Text = m_Script_Text;
                        textPreviewBox.Visible = true;

                        break;
                    }
                #endregion
                #region Font
                case 128: //Font
                    {
                        unityFont m_Font = new unityFont(asset);
                        
                        if (m_Font.extension != ".otf" && m_Font.m_FontData != null)
                        {
                            IntPtr data = Marshal.AllocCoTaskMem(m_Font.m_FontData.Length);
                            Marshal.Copy(m_Font.m_FontData, 0, data, m_Font.m_FontData.Length);

                            System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                            // We HAVE to do this to register the font to the system (Weird .NET bug !)
                            uint cFonts = 0;
                            AddFontMemResourceEx(data, (uint)m_Font.m_FontData.Length, IntPtr.Zero, ref cFonts);

                            pfc.AddMemoryFont(data, m_Font.m_FontData.Length);
                            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(data);

                            //textPreviewBox.Font = new Font(pfc.Families[0], 16, FontStyle.Regular);
                            //textPreviewBox.Text = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWYZ\r\n1234567890.:,;'\"(!?)+-*/=\r\nThe quick brown fox jumps over the lazy dog. 1234567890";
                            fontPreviewBox.SelectionStart = 0;
                            fontPreviewBox.SelectionLength = 80;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 16, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 81;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 12, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 138;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 18, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 195;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 24, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 252;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 36, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 309;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 48, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 366;
                            fontPreviewBox.SelectionLength = 56;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 60, FontStyle.Regular);
                            fontPreviewBox.SelectionStart = 423;
                            fontPreviewBox.SelectionLength = 55;
                            fontPreviewBox.SelectionFont = new Font(pfc.Families[0], 72, FontStyle.Regular);
                            fontPreviewBox.Visible = true;
                        }
                        else { StatusStripUpdate("Unsupported font for preview. Try to export."); }

                        break;
                    }
                #endregion
            }
        }
		public virtual void Render(DrawArgs drawArgs)
		{
			if(!Visible)
				return;

			if(m_TextFont == null)
			{
				System.Drawing.Font localHeaderFont = new System.Drawing.Font("Arial", 12.0f, System.Drawing.FontStyle.Italic | System.Drawing.FontStyle.Bold);
				m_TextFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, localHeaderFont);
			}

			if(m_WorldWindDingsFont == null)
			{
				AddFontResource(Path.Combine(System.Windows.Forms.Application.StartupPath, "World Wind Dings 1.04.ttf"));
				System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection();
				fpc.AddFontFile(Path.Combine(System.Windows.Forms.Application.StartupPath, "World Wind Dings 1.04.ttf"));
				System.Drawing.Font worldwinddings = new System.Drawing.Font(fpc.Families[0], 12.0f);
			
				m_WorldWindDingsFont = new Microsoft.DirectX.Direct3D.Font(drawArgs.device, worldwinddings);
			}

			if(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer)
			{
				DrawArgs.MouseCursor = CursorType.SizeNWSE;
			}
			else if(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer)
			{
				DrawArgs.MouseCursor = CursorType.SizeNESW;
			}
			else if(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
			{
				DrawArgs.MouseCursor = CursorType.SizeNESW;
			}
			else if(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height)
			{
				DrawArgs.MouseCursor = CursorType.SizeNWSE;
			}
			else if(
				(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height) ||
				(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height))
			{
				DrawArgs.MouseCursor = CursorType.SizeWE;
			}
			else if(
				(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer) ||
				(DrawArgs.LastMousePosition.X > AbsoluteLocation.X - resizeBuffer &&
				DrawArgs.LastMousePosition.X < AbsoluteLocation.X + resizeBuffer + ClientSize.Width &&
				DrawArgs.LastMousePosition.Y > AbsoluteLocation.Y - resizeBuffer + ClientSize.Height &&
				DrawArgs.LastMousePosition.Y < AbsoluteLocation.Y + resizeBuffer + ClientSize.Height))
			{
				DrawArgs.MouseCursor = CursorType.SizeNS;
			}

			if(ClientSize.Height > drawArgs.parentControl.Height)
			{
				ClientSize = new System.Drawing.Size(ClientSize.Width, drawArgs.parentControl.Height);
			}

			if(ClientSize.Width > drawArgs.parentControl.Width)
			{
				ClientSize = new System.Drawing.Size(drawArgs.parentControl.Width, ClientSize.Height);
			}

            if (!m_HideHeader && 
                (!m_AutoHideHeader || (DrawArgs.LastMousePosition.X >= ClientLocation.X &&
                DrawArgs.LastMousePosition.X <= ClientLocation.X + m_Size.Width &&
                DrawArgs.LastMousePosition.Y >= ClientLocation.Y &&
                DrawArgs.LastMousePosition.Y <= ClientLocation.Y + m_Size.Height)))
			{
				
				Widgets.Utilities.DrawBox(
                    ClientLocation.X,
                    ClientLocation.Y,
					m_Size.Width,
					m_HeaderHeight,
					0.0f,
					m_HeaderColor.ToArgb(),
					drawArgs.device);

				m_TextFont.DrawText(
					null,
					m_Text,
                    new System.Drawing.Rectangle(ClientLocation.X + 2, ClientLocation.Y, m_Size.Width, m_HeaderHeight),
					DrawTextFormat.None,
					m_TextColor.ToArgb());

				m_WorldWindDingsFont.DrawText(
					null,
					"E",
                    new System.Drawing.Rectangle(ClientLocation.X + m_Size.Width - 15, ClientLocation.Y + 2, m_Size.Width, m_Size.Height),
					DrawTextFormat.NoClip,
					System.Drawing.Color.White.ToArgb());

				m_OutlineVertsHeader[0].X = AbsoluteLocation.X;
				m_OutlineVertsHeader[0].Y = AbsoluteLocation.Y;

				m_OutlineVertsHeader[1].X = AbsoluteLocation.X + ClientSize.Width;
				m_OutlineVertsHeader[1].Y = AbsoluteLocation.Y;

				m_OutlineVertsHeader[2].X = AbsoluteLocation.X + ClientSize.Width;
				m_OutlineVertsHeader[2].Y = AbsoluteLocation.Y + m_HeaderHeight;
		
				m_OutlineVertsHeader[3].X = AbsoluteLocation.X;
				m_OutlineVertsHeader[3].Y = AbsoluteLocation.Y + m_HeaderHeight;

				m_OutlineVertsHeader[4].X = AbsoluteLocation.X;
				m_OutlineVertsHeader[4].Y = AbsoluteLocation.Y;

				if(!m_HideBorder)
					Widgets.Utilities.DrawLine(m_OutlineVertsHeader, m_BorderColor.ToArgb(), drawArgs.device);

			}

			Widgets.Utilities.DrawBox(
                ClientLocation.X,
                ClientLocation.Y + m_HeaderHeight,
				m_Size.Width,
				m_Size.Height - m_HeaderHeight,
				0.0f,
				m_BackgroundColor.ToArgb(),
				drawArgs.device);
			
			for(int index = m_ChildWidgets.Count - 1; index >= 0; index--)
			{
				IWidget currentChildWidget = m_ChildWidgets[index] as IWidget;
				if(currentChildWidget != null)
				{
					if(currentChildWidget.ParentWidget == null || currentChildWidget.ParentWidget != this)
					{
						currentChildWidget.ParentWidget = this;
					}
					currentChildWidget.Render(drawArgs);
				}
			}

			m_OutlineVerts[0].X = AbsoluteLocation.X;
			m_OutlineVerts[0].Y = AbsoluteLocation.Y + m_HeaderHeight;

			m_OutlineVerts[1].X = AbsoluteLocation.X + ClientSize.Width;
			m_OutlineVerts[1].Y = AbsoluteLocation.Y + m_HeaderHeight;

			m_OutlineVerts[2].X = AbsoluteLocation.X + ClientSize.Width;
			m_OutlineVerts[2].Y = AbsoluteLocation.Y + ClientSize.Height;
		
			m_OutlineVerts[3].X = AbsoluteLocation.X;
			m_OutlineVerts[3].Y = AbsoluteLocation.Y + ClientSize.Height;

			m_OutlineVerts[4].X = AbsoluteLocation.X;
			m_OutlineVerts[4].Y = AbsoluteLocation.Y + m_HeaderHeight;

			if(!m_HideBorder)
				Widgets.Utilities.DrawLine(m_OutlineVerts, m_BorderColor.ToArgb(), drawArgs.device);			
		}
Пример #48
0
        private void InitDevice()
        {
            // Use D3DEx for Vista/Win7+
            _is3D9Ex = false;
            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
            {
                _is3D9Ex = true;
            }

            DeviceType devType = DeviceType.Hardware;
            int adapterOrdinal = 0;

            Direct3D d3d = null;
            Direct3DEx d3dex = null;

            if (_is3D9Ex)
            {
                try
                {
                    // Create Ex, fallback if it fails
                    d3dex = new Direct3DEx();
                }
                catch
                {
                    d3d = new Direct3D();
                    _is3D9Ex = false;
                }
            }
            else
                d3d = new Direct3D();

            // Look for PerfHUD
            AdapterCollection adapters = (_is3D9Ex ? d3dex : d3d).Adapters;
            foreach (AdapterInformation adap in adapters)
            {
                if (adap.Details.Description.Contains("PerfH"))
                {
                    adapterOrdinal = adap.Adapter;
                    devType = DeviceType.Reference;
                }
            }

            foreach (var item in adapters[adapterOrdinal].GetDisplayModes(Format.X8R8G8B8))
            {
                string val = item.Width + "x" + item.Height;
                bool found = false;
                for (int i = 0; i < ValidResolutions.Count; i++)
                {
                    if (ValidResolutions[i].Equals(val))
                    {
                        found = true;
                        break;
                    }
                }
                if(!found)
                    ValidResolutions.Add(val);
            }

            // Get resolution
            Size res = GetResolution();
            RenderSize = res;
            form.ClientSize = res;

            // Set present parameters
            _pp = new PresentParameters();
            _pp.Windowed = r_fs.Integer==0?true:false;
            _pp.SwapEffect = SwapEffect.Discard;
            _pp.EnableAutoDepthStencil = true;
            _pp.AutoDepthStencilFormat = Format.D24S8;
            _pp.PresentationInterval = (r_vsync.Integer==1? PresentInterval.One: PresentInterval.Immediate);
            _pp.Multisample = MultiSampling;
            _pp.BackBufferWidth = RenderSize.Width;
            _pp.BackBufferHeight = RenderSize.Height;
            _pp.BackBufferFormat = Format.X8R8G8B8;
            _pp.DeviceWindowHandle = form.Handle;

            // Handle Capabilities
            Capabilities caps =  adapters[adapterOrdinal].GetCaps(devType);
            CreateFlags createFlags = CreateFlags.SoftwareVertexProcessing;

            // Got hardare vertex?
            if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) == DeviceCaps.HWTransformAndLight)
            {
                createFlags = CreateFlags.HardwareVertexProcessing;
                // Support pure device?
                if ((caps.DeviceCaps & DeviceCaps.PureDevice) == DeviceCaps.PureDevice)
                    createFlags |= CreateFlags.PureDevice;
            }

            createFlags |= CreateFlags.FpuPreserve;

            // Create d3d device + behemoth fallback
            try
            {
                if (_is3D9Ex)
                {
                    if (r_fs.Bool)
                    {
                        DisplayModeEx dsp = new DisplayModeEx();
                        dsp.Width = _pp.BackBufferWidth;
                        dsp.Height = _pp.BackBufferHeight;
                        dsp.Format = _pp.BackBufferFormat;
                        dsp.RefreshRate = 60;
                        _pp.FullScreenRefreshRateInHertz = 60;
                        //DisplayModeEx dispMode = d3dex.GetAdapterDisplayModeEx(adapterOrdinal);
                        //RenderSize = new Size(dispMode.Width, dispMode.Height);
                        //form.ClientSize = new Size(dispMode.Width, dispMode.Height);
                        //_pp.BackBufferFormat = dispMode.Format;
                        //_pp.BackBufferWidth = dispMode.Width;
                        //_pp.BackBufferHeight = dispMode.Height;
                        //_pp.FullScreenRefreshRateInHertz = dispMode.RefreshRate;
                        device = new DeviceEx(d3dex, adapterOrdinal, devType, form.Handle, createFlags, _pp, dsp);
                    }
                    else
                        device = new DeviceEx(d3dex, adapterOrdinal, devType, form.Handle, createFlags, _pp);
                }
                else
                    device = new Device(d3d, adapterOrdinal, devType, form.Handle, createFlags, _pp);

            }
            catch (Direct3D9Exception ex)
            {
                if (ex.ResultCode == ResultCode.NotAvailable)
                {
                    // Try again with different settings
                    RenderSize = new Size(800, 600);
                    form.ClientSize = new Size(800, 600);
                    _pp.BackBufferWidth = 800;
                    _pp.BackBufferHeight = 600;
                    _pp.BackBufferCount = 1;
                    _pp.SwapEffect = SwapEffect.Discard;
                    createFlags &= ~(CreateFlags.PureDevice | CreateFlags.HardwareVertexProcessing);
                    createFlags |= CreateFlags.SoftwareVertexProcessing;
                    try
                    {
                        if (_is3D9Ex)
                        {
                            if (r_fs.Bool)
                            {
                                DisplayModeEx dispMode = d3dex.GetAdapterDisplayModeEx(adapterOrdinal);
                                RenderSize = new Size(dispMode.Width, dispMode.Height);
                                form.ClientSize = new Size(dispMode.Width, dispMode.Height);
                                _pp.BackBufferFormat = dispMode.Format;
                                _pp.BackBufferWidth = dispMode.Width;
                                _pp.BackBufferHeight = dispMode.Height;
                                _pp.FullScreenRefreshRateInHertz = dispMode.RefreshRate;
                                device = new DeviceEx(d3dex, adapterOrdinal, devType, form.Handle, createFlags, _pp, dispMode);
                            }
                            else
                                device = new DeviceEx(d3dex, adapterOrdinal, devType, form.Handle, createFlags, _pp);
                        }
                        else
                            device = new Device(d3d, adapterOrdinal, devType, form.Handle, createFlags, _pp);
                    }
                    catch (Exception ex2)
                    {
                        if (_is3D9Ex)
                        {
                            // 3. fallback.. disable ex
                            _is3D9Ex = false;
                            Size ress = GetResolution();
                            RenderSize = ress;
                            form.ClientSize = ress;
                            _pp.BackBufferWidth = ress.Width;
                            _pp.BackBufferHeight = ress.Height;
                            _pp.BackBufferCount = 1;
                            _pp.SwapEffect = SwapEffect.Discard;
                            d3dex.Dispose();
                            device = new Device(new Direct3D(), adapterOrdinal, devType, form.Handle, createFlags, _pp);
                        }
                        else
                            throw ex2;
                    }
                }
                else
                    throw ex;
            }

            // Load main shader
            if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath+"/client/render/simple.fx"))
            {
                string shaderOutput = null;
                SlimDX.Configuration.ThrowOnError = false;
                effect = Effect.FromFile(device, System.Windows.Forms.Application.StartupPath + "/client/render/simple.fx", null, null, null, ShaderFlags.None, null, out shaderOutput);

                if (shaderOutput != null && shaderOutput != "" && effect == null)
                {
                    // Shader problem :..(
                    System.Windows.Forms.MessageBox.Show(shaderOutput, "Shader Compilation error :(", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    Shutdown();
                    return;
                }
                SlimDX.Configuration.ThrowOnError = true;
            }
            else
            {
                System.Console.WriteLine("Could not find shader..");
            }

            // Add fonts
            if (Fonts.Count == 0)
            {
                System.Drawing.Text.PrivateFontCollection col = new System.Drawing.Text.PrivateFontCollection();
                col.AddFontFile(System.Windows.Forms.Application.StartupPath + @"\data\gui\Candara.ttf");

                // UI Title
                System.Drawing.Font localFont = new System.Drawing.Font(col.Families[0], 10.5f, System.Drawing.FontStyle.Regular);
                SlimDX.Direct3D9.Font font = new SlimDX.Direct3D9.Font(Renderer.Instance.device, localFont);
                Fonts.Add("title", font);

                // FPS, etc.
                font = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font("Lucidia Console", 10f, System.Drawing.FontStyle.Regular));
                Fonts.Add("diag", font);

                // Labels and UI elements
                localFont = new System.Drawing.Font(col.Families[0], 10f, System.Drawing.FontStyle.Regular);
                font = new SlimDX.Direct3D9.Font(Renderer.Instance.device, localFont);
                Fonts.Add("label", font);

                localFont = new System.Drawing.Font(col.Families[0], 15f, System.Drawing.FontStyle.Regular);
                font = new SlimDX.Direct3D9.Font(Renderer.Instance.device, localFont);
                Fonts.Add("biglabel", font);

                localFont = new System.Drawing.Font(col.Families[0], 23f, System.Drawing.FontStyle.Regular);
                font = new SlimDX.Direct3D9.Font(Renderer.Instance.device, localFont);
                Fonts.Add("biggerlabel", font);

                // Textbox
                col = new System.Drawing.Text.PrivateFontCollection();
                col.AddFontFile(System.Windows.Forms.Application.StartupPath + @"\data\gui\dina10px.ttf");
                localFont = new System.Drawing.Font(col.Families[0], 12f, FontStyle.Regular);
                font = new SlimDX.Direct3D9.Font(Renderer.Instance.device, localFont);
                Fonts.Add("textbox", font);
            }

            // Init backbuffers, etc.
            OnResetDevice();

            bloom = new Bloom(this);
            tonemap = new ToneMap(this);

            // Init windowing system
            WindowManager.Instance.Init(device);
        }
        protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            base.OnPrintPage(e);
            int printHeight;
            int printWidth;
            int leftMargin;
            int rightMargin;
            //            Int32 lines;
            //            Int32 chars;

            //Set print area size and margins
            {
                printHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom;
                printWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right;
                leftMargin = base.DefaultPageSettings.Margins.Left;
                //X
                rightMargin = base.DefaultPageSettings.Margins.Top;
                //Y
            }

            for (int i = 0; i < 16; i++) {

                int eachheight=120;

                switch (PrintMode) {

                    case PrintModes.PubPrivQR:
                        if (i >= 8) i = 999;
                        eachheight = 120;
                        break;

                    case PrintModes.PsyBanknote:
                        if (i >= 3) i = 999;
                        eachheight = 365;
                        break;
                }

                if (i == 999) break;

                if (PrintMode == PrintModes.PubPrivQR && i >= 8) break;

                if (PrintMode == PrintModes.PsyBanknote && i >= NotesPerPage) break;

                if (keys.Count == 0) break;

                int thiscodeX = 50;
                int thiscodeY = 50 + eachheight * i;
                if (i >= 8) {
                    thiscodeX = 450;
                    thiscodeY = 50 + eachheight * (i - 8);
                }

                //    T-------------------------------|
                //    |                               |
                //    |                               |
                //    |                               |
                //    |                               |
                //    |                               |
                //    |-------------------------------|
                //
                //    T = thiscodeX,thiscodeY
                //

                // Load the Ubuntu font directly from a file so it doesn't need to be installed on the system.
                if (UbuntuFontLoaded == false) {
                    UbuntuFontLoaded = true;
                    try {
                        System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
                        pfc.AddFontFile("Ubuntu-R.ttf");
                    } catch { }
                }

                ubuntufont = new Font("Ubuntu", 6);
                ubuntumid = new Font("Ubuntu", 9);
                ubuntubig = new Font("Ubuntu", 17);

                KeyCollectionItem k = (KeyCollectionItem)keys[0];
                keys.RemoveAt(0);

                string privkey = k.PrivateKey;
                if (PreferUnencryptedPrivateKeys) {
                    if (k.EncryptedKeyPair != null && k.EncryptedKeyPair.IsUnencryptedPrivateKeyAvailable()) {
                        privkey = k.EncryptedKeyPair.GetUnencryptedPrivateKey().PrivateKey;
                    }
                }

                Bitmap b = QR.EncodeQRCode(privkey);

                if (PrintMode == PrintModes.PsyBanknote) {

                    if (BitcoinNote == null) {
                        BitcoinNote = Image.FromFile(ImageFilename);

                    }

                    float desiredScale = 550F;

                    float scalefactor = (desiredScale / 650.0F);
                    float leftOffset = (float)printWidth - desiredScale;

                    // draw the note
                    e.Graphics.DrawImage(BitcoinNote,
                                        leftOffset + scalefactor * (float)thiscodeX,
                                        scalefactor * (float)thiscodeY, (float)650F * scalefactor,
                                        (float)650F * scalefactor * (float)BitcoinNote.Height / (float)BitcoinNote.Width);

                    // draw the private QR
                    e.Graphics.DrawImage(b, leftOffset + scalefactor * (float)(thiscodeX + 472),
                        scalefactor * (float)(thiscodeY + 140),
                        scalefactor * 145F,
                        scalefactor * 147F);

                    // draw the public QR
                    Bitmap b2 = QR.EncodeQRCode(k.GetAddressBase58());
                    e.Graphics.DrawImage(b2,
                        leftOffset + scalefactor * (float)(thiscodeX + 39),
                        scalefactor * (float)(thiscodeY + 70), scalefactor * 128F, scalefactor * 128F);

                    // write bitcoin address
                    StringFormat sf = new StringFormat();
                    //sf.FormatFlags |= StringFormatFlags.DirectionVertical | StringFormatFlags.DirectionRightToLeft;

                    e.Graphics.RotateTransform(-90F);
                    e.Graphics.DrawString("Groestlcoin Address\r\n" + k.GetAddressBase58(), ubuntumid, Brushes.Black,
                        -scalefactor * (float)(thiscodeY + 338),
                        leftOffset + scalefactor * (float)(thiscodeX + 170),

                        sf);

                    // write private key
                    string whattoprint = privkey;
                    float xpos =  460;
                    if (privkey.StartsWith("6")) {
                        whattoprint = "Password Required\r\n" + whattoprint;
                        xpos -=  10;
                    }

                    e.Graphics.DrawString(whattoprint, ubuntufont, Brushes.Black,
                        -scalefactor * (float)(thiscodeY + 300),
                        leftOffset + scalefactor * (float)(thiscodeX + xpos),
                        sf);

                    e.Graphics.RotateTransform(90F);

                    // write denomination, if any
                    if ((Denomination ?? "") != "") {
                        e.Graphics.DrawString(Denomination, ubuntubig, Brushes.Black,
                            leftOffset + scalefactor * (float)(thiscodeX + 330),
                            scalefactor * (float)(thiscodeY + 310)

                            );
                    }

                    if (PrintMiniKeysWith1DBarcode && k.Address is MiniKeyPair) {
                        Bitmap barcode1d = Barcode128b.GetBarcode(k.PrivateKey);
                        float aspect1d = (float)barcode1d.Width / (float)barcode1d.Height;
                        e.Graphics.DrawImage(barcode1d, leftOffset + scalefactor * (float)(thiscodeX + 231F),
                            scalefactor * (float)(thiscodeY + 293),
                            scalefactor * 420F,
                            scalefactor * 50F);

                    }

                } else if (PrintMode == PrintModes.PrivQR) {

                    // ----------------------------------------------------------------
                    // Paper wallet with only private key QR code.  Fits 16 to a page.
                    // ----------------------------------------------------------------
                    e.Graphics.DrawImage(b, thiscodeX, thiscodeY, 100, 100);

                    e.Graphics.DrawString("Groestlcoin address: " + k.GetAddressBase58(), fontsmall, Brushes.Black, thiscodeX + 110, thiscodeY);

                    string whattowrite;
                    if (privkey.Length > 30) {
                        whattowrite = privkey.Substring(0, 25) + "\r\n" + privkey.Substring(25);
                    } else {
                        whattowrite = "\r\n" + privkey;
                    }
                    if (privkey.StartsWith("6")) {
                        whattowrite = whattowrite + "\r\nPassword Required";
                    }

                    e.Graphics.DrawString(whattowrite, font, Brushes.Black, thiscodeX + 110, thiscodeY + 15);

                    if ((Denomination ?? "") != "") {
                        e.Graphics.DrawString(Denomination + " BTC", fontbig, Brushes.Black, thiscodeX + 110, thiscodeY + 75);
                    }

                } else if (PrintMode == PrintModes.PubPrivQR) {

                    // ----------------------------------------------------------------
                    // Paper wallet with public and private QR codes.  Fits 8 to a page.
                    // ----------------------------------------------------------------

                    e.Graphics.DrawImage(b, thiscodeX + 600, thiscodeY, 100, 100);
                    QRCodeEncoder qr2 = new QRCodeEncoder();
                    qr2.QRCodeVersion = 3;

                    Bitmap b2 = qr2.Encode(k.GetAddressBase58());
                    e.Graphics.DrawImage(b2, thiscodeX, thiscodeY, 100, 100);

                    e.Graphics.DrawString("Groestlcoin address:\r\n" + k.GetAddressBase58(), font, Brushes.Black, thiscodeX + 110, thiscodeY);

                    StringFormat sf = new StringFormat();
                    sf.Alignment = StringAlignment.Far; // right justify
                    string whattoprint = privkey;
                    if (privkey.StartsWith("6")) {
                        whattoprint = whattoprint + "\r\nPassword Required";
                    }

                    e.Graphics.DrawString("Private key:\r\n" + whattoprint, font, Brushes.Black, thiscodeX + 597, thiscodeY + 65, sf);

                }

            }

            e.HasMorePages = keys.Count > 0;
        }
Пример #50
0
        private static Font CreateFont(string name, FontStyle style, float size, GraphicsUnit unit)
        {
            // create a new font collection
            fonts = new System.Drawing.Text.PrivateFontCollection();
            fonts.AddFontFile(name);
            NewFont_FF = fonts.Families[0];

            return new Font(NewFont_FF, size, style, unit);
        }
Пример #51
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            this.Loaded -= OnLoaded;
            this.MainGrid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Program.GameEngine.Definition.NoteBackgroundColor));
            this.TextBox.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(Program.GameEngine.Definition.NoteForegroundColor));

            if (Prefs.UseGameFonts)
            {
                var font = Program.GameEngine.Definition.Fonts.FirstOrDefault(
                    x => x.Target.Equals("notes", StringComparison.InvariantCultureIgnoreCase));
                if (font != null)
                {
                    Log.Info("Loading font");
                    var pf = new System.Drawing.Text.PrivateFontCollection();
                    pf.AddFontFile(font.Src);
                    if (pf.Families.Length > 0)
                    {
                        Log.Info("Loaded font into collection");
                    }
                    string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + pf.Families[0].Name;
                    Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/"));
                    this.TextBox.FontFamily = new FontFamily(font1.Replace("\\", "/"));
                    this.TextBox.FontSize = font.Size;
                    Log.Info(string.Format("Loaded font with source: {0}", this.TextBox.FontFamily.Source));
                }
            }
            this.BeginAnimation(OpacityProperty,showAnimation);
        }
Пример #52
0
        private void LoadCustomFont()
        {
            byte[] myFont = Properties.Resources.CPMono_v07_Bold;
            using (var ms = new MemoryStream(myFont))
            {
                pfc = new System.Drawing.Text.PrivateFontCollection();

                byte[] buffer = new byte[ms.Length];
                ms.Read(buffer, 0, (int)ms.Length);

                System.Runtime.InteropServices.GCHandle handle = System.Runtime.InteropServices.GCHandle.Alloc(buffer, System.Runtime.InteropServices.GCHandleType.Pinned);

                checked
                {
                    pfc.AddMemoryFont(handle.AddrOfPinnedObject(), (int)ms.Length);

                    WebsiteLink.Font = new System.Drawing.Font(pfc.Families[0], WebsiteLink.Font.Size, System.Drawing.FontStyle.Bold);
                    ForumsLink.Font = new System.Drawing.Font(pfc.Families[0], ForumsLink.Font.Size, System.Drawing.FontStyle.Bold);
                    OptionsLink.Font = new System.Drawing.Font(pfc.Families[0], OptionsLink.Font.Size, System.Drawing.FontStyle.Bold);
                    eulaLink.Font = new System.Drawing.Font(pfc.Families[0], eulaLink.Font.Size, System.Drawing.FontStyle.Bold);
                    registerLink.Font = new System.Drawing.Font(pfc.Families[0], registerLink.Font.Size, System.Drawing.FontStyle.Bold);
                    forgotPassLink.Font = new System.Drawing.Font(pfc.Families[0], forgotPassLink.Font.Size, System.Drawing.FontStyle.Bold);

                    infoLBL.Font = new System.Drawing.Font(pfc.Families[0], infoLBL.Font.Size, System.Drawing.FontStyle.Bold);
                    passLBL.Font = new System.Drawing.Font(pfc.Families[0], passLBL.Font.Size, System.Drawing.FontStyle.Bold);
                    middleLBL.Font = new System.Drawing.Font(pfc.Families[0], middleLBL.Font.Size, System.Drawing.FontStyle.Bold);

                    actionBtn.Font = new System.Drawing.Font(pfc.Families[0], actionBtn.Font.Size, System.Drawing.FontStyle.Bold);
                    downloadBtn.Font = new System.Drawing.Font(pfc.Families[0], downloadBtn.Font.Size, System.Drawing.FontStyle.Bold);
                }

            }
        }
Пример #53
0
        private void UpdateFont()
        {
            string curDir = Path.Combine(SimpleConfig.DataDirectory, "Games", Program.Game.Definition.Id.ToString());
            string uri = "file:///" + curDir.Replace('\\', '/') + "/#";
            System.Drawing.Text.PrivateFontCollection context = new System.Drawing.Text.PrivateFontCollection();
            System.Drawing.Text.PrivateFontCollection chatname = new System.Drawing.Text.PrivateFontCollection();


            int chatFontsize = 12;
            int contextFontsize = 12;
            Boolean inchat = false;
            foreach (FontDef font in Program.Game.Definition.Fonts)
            {
                if (font.Target.ToLower().Equals("chat"))
                {
                    chatname.AddFontFile(Path.Combine(curDir, font.FileName.TrimStart('/')));
                    chatFontsize = font.Size;
                    inchat = true;
                }
                if (font.Target.ToLower().Equals("context"))
                {
                    context.AddFontFile(Path.Combine(curDir, font.FileName.TrimStart('/')));
                    contextFontsize = font.Size;
                }
            }

            chat.watermark.FontFamily = new FontFamily(uri + context.Families[0].Name);
            GroupControl.groupFont = new FontFamily(uri + context.Families[0].Name);
            GroupControl.fontsize = contextFontsize;
            if (inchat)
            {
                chat.output.FontFamily = new FontFamily(uri + chatname.Families[0].Name);
                chat.output.FontSize = chatFontsize;
            }

            // self = player tab information
            // watermark = type to chat (ctrl+t)
            // output = chatbox
        }
Пример #54
0
        private void UpdateFont()
        {
            if (!Prefs.UseGameFonts) return;

            System.Drawing.Text.PrivateFontCollection context = new System.Drawing.Text.PrivateFontCollection();
            System.Drawing.Text.PrivateFontCollection chatname = new System.Drawing.Text.PrivateFontCollection();

            var game = Program.GameEngine.Definition;

            int chatFontsize = 12;
            int contextFontsize = 12;

            foreach (Font font in game.Fonts)
            {
                Log.Info(string.Format("Found font with target({0}) and has path({1})", font.Target, font.Src));
                if (!File.Exists(font.Src)) continue;
                if (font.Target.ToLower().Equals("chat"))
                {
                    Log.Info("Loading font");
                    chatFontsize = font.Size;
                    chatname.AddFontFile(font.Src);
                    if (chatname.Families.Length > 0)
                    {
                        Log.Info("Loaded font into collection");
                    }
                    string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + chatname.Families[0].Name;
                    Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/"));
                    chat.output.FontFamily = new FontFamily(font1.Replace("\\", "/"));
                    chat.output.FontSize = chatFontsize;
                    Log.Info(string.Format("Loaded font with source: {0}", chat.output.FontFamily.Source));
                }
                if (font.Target.ToLower().Equals("context"))
                {
                    Log.Info(string.Format("Loading font"));
                    contextFontsize = font.Size;
                    context.AddFontFile(font.Src);
                    if (context.Families.Length > 0)
                    {
                        Log.Info("Loaded font into collection");
                    }
                    string font1 = "file:///" + Path.GetDirectoryName(font.Src) + "/#" + context.Families[0].Name;
                    Log.Info(string.Format("Loading font with path: {0}", font1).Replace("\\", "/"));
                    chat.watermark.FontFamily = new FontFamily(font1.Replace("\\", "/"));
                    GroupControl.groupFont = new FontFamily(font1.Replace("\\", "/"));
                    GroupControl.fontsize = contextFontsize;
                    Log.Info(string.Format("Loaded font with source: {0}", GroupControl.groupFont.Source));
                }
            }
        }
Пример #55
0
        public virtual void OnLoad(EventArgs e)
        {
            _time.Start();

            if (!IsHeadless)
            {
                Renderer = new Renderer(CanvasSize);

                // Load textures from file
                Renderer.Textures.Add("default.png", new TextureFile(Path.Combine(textureFolder, "default.png")));
                Renderer.Textures.Add("grid.png", new TextureFile(Path.Combine(textureFolder, "grid.png")));
                Renderer.Textures.Add("lineBlur.png", new TextureFile(Path.Combine(textureFolder, "lineBlur.png")));

                //Create the default font
                System.Drawing.Text.PrivateFontCollection privateFonts = new System.Drawing.Text.PrivateFontCollection();
                privateFonts.AddFontFile(Path.Combine(fontFolder, "times.ttf"));
                Default = new Font(privateFonts.Families[0], 14);
                FontRenderer = new FontRenderer(Default);

                // Load shaders from file
                Renderer.Shaders.Add("uber", new Shader(
                    Path.Combine(shaderFolder, "vs_uber.glsl"),
                    Path.Combine(shaderFolder, "fs_uber.glsl"),
                    true));

                SoundEnabled = false;
                if (SoundEnabled)
                {
                    SoundSystem = new SoundSystem();
                    SoundSystem.Initialize();
                    SoundSystem.Start();
                }
            }

            /*if (programArgs.Length == 1)
            {
                Serializer serializer = new Serializer();
                Scene scene = serializer.Deserialize(programArgs[0]);
                scene.SetActiveCamera(new Camera2(scene, new Transform2(new Vector2(), 10), CanvasSize.Width / (float)CanvasSize.Height));
                Renderer.AddLayer(scene);
                Portals.PortalCommon.UpdateWorldTransform(scene);
                if (programArgs[0].StartsWith(tempLevelPrefix))
                {
                    File.Delete(programArgs[0]);
                }
            }*/
        }
        public ScoreboardCompetitiveTeamRenderer(XAML.TeamScoreboard parent, List<playersData> TeamData, string TeamName)
        {
            m_parent = parent;
            m_parent.image.Source = null;

            //set the current directory and filename for the template
            string scoreboardTemplate = Directory.GetCurrentDirectory() + "\\images\\background\\team_bg.png";
            string teamLogoDirectory = Directory.GetCurrentDirectory() + "\\images\\team_logos\\";
            string fontLocation = Directory.GetCurrentDirectory() + "\\fonts\\orbitron-black.ttf";
            // 'PrivateFontCollection' is in the 'System.Drawing.Text' namespace
            var foo = new Gdi.Text.PrivateFontCollection();
            // Provide the path to the font on the filesystem
            foo.AddFontFile(fontLocation);
            //Make variable for the custom font
            var myCustomFont = new Gdi.Font((Gdi.FontFamily)foo.Families[0], 24f);
            Gdi.Bitmap bitmap = null;
            //try and load the background as a bitmap
            try
            {
                bitmap = new Gdi.Bitmap(scoreboardTemplate);
            }
            catch (Exception)
            {
                bitmap = Properties.Resources.bg;
            }
            //Clone the bitmap for nicer transparancy
            Gdi.Bitmap clone = new Gdi.Bitmap(bitmap.Width, bitmap.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

            //convert the bitmap to a graphic
            Gdi.Graphics gr = Gdi.Graphics.FromImage(clone);
            //draw the bitmap the the graphic
            gr.DrawImage(bitmap, new Gdi.Rectangle(0, 0, clone.Width, clone.Height));

            //Load the bitmap to a gdi graphic and add some nice antialisasing to it
            Gdi.Graphics g = Gdi.Graphics.FromImage(bitmap);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.TextRenderingHint = Gdi.Text.TextRenderingHint.AntiAliasGridFit;

            g.DrawString("Team Stats", myCustomFont, Gdi.Brushes.White, 230, 350);
            g.DrawString(TeamName, myCustomFont, Gdi.Brushes.White,  1500, 350);

            //Start drawing graphics for team members
            int rightOffset = 320;
            int heightOffset = 330;
            Gdi.StringFormat format = new Gdi.StringFormat();
            format.LineAlignment = Gdi.StringAlignment.Center;
            format.Alignment = Gdi.StringAlignment.Center;

            foreach (var player in TeamData)
            {
                bool renderOrNot = true;
                foreach( var team in MainWindow.CompetitiveTeamData)
                {
                    if(TeamName == team.TeamName)
                    {
                        foreach(var players in team.TeamMembers)
                        {
                            if (player.name == players.MemberName && players.MemberIsCoreOrSub == Structs.TeamMember.CoreOrSub.substitute)
                            {
                                renderOrNot = false;
                            }

                        }
                    }
                }
                if (renderOrNot == false)
                    continue;
                //Draw player name
                g.DrawString(player.name, myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);
                heightOffset += 72;
                //Draw player kills
                g.DrawString(player.kills.ToString(), myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);
                heightOffset += 72;
                //Draw player deaths
                g.DrawString(player.deaths.ToString(), myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);
                heightOffset += 72;
                //Draw player kdr
                g.DrawString((Math.Round((decimal)player.kills / (decimal)player.deaths, 2)).ToString(), myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);
                heightOffset += 72;
                //draw bombs detonated
                g.DrawString(player.score.ToString(), myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);

                heightOffset += 72;
                //draw score
                g.DrawString(player.bombsDetonated.ToString(), myCustomFont, Gdi.Brushes.White, rightOffset, 150f + heightOffset, format);

                rightOffset += 320;
                heightOffset = 330;
            }

            //Convert to ui readable image
            ImageSource bitmapSource = loadBitmap(bitmap);
            m_parent.image.Source = bitmapSource;
            clone.Dispose();
            g.Dispose();
            bitmap.Dispose();
            foo.Dispose();
            gr.Dispose();
        }