Example #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            BitmapSource bms = ((MainWindow)this.Owner).CreateSnap();

            Image1.Source = bms;
            string navstr = "<html><body style=\"margin: 0px; background: #0e0e0e;\"></body></html>";

            WebBrowser1.NavigateToString(navstr);
        }
Example #2
0
        private void OnShow(object sender, DependencyPropertyChangedEventArgs e)
        {
            try
            {
                WebBrowser1.NavigateToString(Properties.Resources.map);
            }
            catch (Exception)
            {
                //hmmm
            }

            WebBrowser1.ObjectForScripting = new HtmlInteropInternalClass();
        }
Example #3
0
        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            _bIsBusy          = true;
            Button1.IsEnabled = false;

            try
            {
                bool   bCompleteRound = false;
                Slider slider         = ((MainWindow)this.Owner).hscroll;
                float  deltaXDeg      = 5f;
                int    nDirChanged    = 0;

                AnimatedGifEncoder enc            = new AnimatedGifEncoder();
                String             outputFilePath = AppDomain.CurrentDomain.BaseDirectory + "temp\\~gif.gif";
                enc.Start(outputFilePath);
                enc.SetDelay(100);
                //-1:no repeat,0:always repeat
                enc.SetRepeat(0);
                int maxwidth  = 0;
                int maxheight = 0;

                int    frameno    = 0;
                string savedTitle = this.Title;
                while (!bCompleteRound)
                {
                    var deg = slider.Value;
                    System.Diagnostics.Debug.Print("Deg=" + deg);
                    BitmapSource bms = ((MainWindow)this.Owner).CreateSnap();


                    Image1.Source = bms;
                    Image1.Refresh();


                    System.Drawing.Bitmap bm = CCommon.BitmapImage2Bitmap(bms);
                    if (bm.Width > maxwidth)
                    {
                        maxwidth = bm.Width;
                    }
                    if (bm.Height > maxheight)
                    {
                        maxheight = bm.Height;
                    }


                    enc.AddFrame(bm);
                    frameno++;
                    this.Title = "Processing Frame no:" + frameno;

                    if (deg > 50 || deg < -50)
                    {
                        deltaXDeg = -1 * deltaXDeg;
                        nDirChanged++;
                    }
                    slider.Value += deltaXDeg;

                    System.Windows.Forms.Application.DoEvents();

                    if (nDirChanged >= 2 && slider.Value > 0 && slider.Value < 10)
                    {
                        bCompleteRound = true;
                    }

                    bm.Dispose();
                    bm = null;
                }
                enc.Finish();

                this.Title = savedTitle;
                string path2gif = "file:///" + AppDomain.CurrentDomain.BaseDirectory + "temp/~gif.gif";

                int    height = 0, width = 0;
                double ratio = ((double)maxwidth) / maxheight;
                if (ratio > 1.0)     //long
                {
                    width  = (int)WebBrowser1.Width;
                    height = (int)(width / ratio);
                }
                else     //tall;
                {
                    height = (int)WebBrowser1.Height;
                    width  = (int)(height * ratio);
                }



                string imgstr = "<img width=\"" + width + "\" height=\"" + height + "\" src=\"" + path2gif + "\">";


                // string imgstr = "<img src=\"" + path2gif + "\">";
                string strdiv = "<div style=\"width:100%; text-align:center\">" + imgstr + "</div>";

                string navstr = "<html><body style=\"margin: 0px; background: #0e0e0e;\">" + strdiv + "</body></html>";

                WebBrowser1.NavigateToString(navstr);
            }
            catch
            {
            }

            Button2.IsEnabled = true;
            _bIsBusy          = false;
        }