コード例 #1
0
 public MainPage()
 {
     InitializeComponent();
     Wb.Navigated        += new EventHandler <System.Windows.Navigation.NavigationEventArgs>(Wb_Navigated);
     MouseLeftButtonDown += new MouseButtonEventHandler(MainPage_MouseLeftButtonDown);
     Wb.NavigateToString("<html><body><form action='http://google.com/'></form></body></html>");
 }
コード例 #2
0
        public async Task <IActionResult> Edit(string id, [Bind("Seq,Id,Name,Kana,Ip,Status,Place,Back,StartDay,StartTime,EndDay,Ok,EndTime,Phone,Mail1,Mail2,Memo1,Memo2,Memo3,Memo4,Memo5,Message,UpdateDay,UpdateTime,FullName,Business,UpdateIp,InterPhone")] Wb wb)
        {
            if (id != wb.Seq)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(wb);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WbExists(wb.Seq))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(wb));
        }
コード例 #3
0
        public Map(string width, string height)
        {
            InitializeComponent();
            string a = "https://www.google.com/maps/dir//" + width + "," + height + "/@" + width + "," + height + "z/data=!4m2!4m1!3e0";

            Wb.Navigate(a);
        }
コード例 #4
0
        public int Run()
        {
            bool result = InitPara();

            if (!result)
            {
                return(-999);
            }

            int failCount = 0;

            result = FailCount(ref failCount);
            if (!result)
            {
                Wb.Close(false, Type.Missing, Type.Missing);
                Excel.Quit();
                return(-998);
            }

            Wb.Close(false, Type.Missing, Type.Missing);
            Excel.Quit();

            if (failCount < 0)
            {
                failCount = failCount * -1;
            }

            return(0);
        }
コード例 #5
0
        public WatinWebBrowserExample()
        {
            InitializeComponent();
            DataContext = new MainWindowViewModel();

            Wb.Navigate("http://google.com");
            Wb.LoadCompleted += ((sender, args) =>
            {
                if (_docEvent != null)
                {
                    _docEvent.oncontextmenu -= x =>
                    {
                        WbShowContextMenu();
                        return(false);
                    };
                }
                if (Wb.Document != null)
                {
                    _docEvent = (HTMLDocumentEvents2_Event)Wb.Document;
                    _docEvent.oncontextmenu += x =>
                    {
                        WbShowContextMenu();
                        return(false);
                    };
                }
            });
        }
コード例 #6
0
ファイル: Wbs2Controller.cs プロジェクト: Hatahata-77/webapi
        public async Task <IActionResult> PutWb(string id, Wb wb)
        {
            if (id != wb.Seq)
            {
                return(BadRequest());
            }

            _context.Entry(wb).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WbExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
コード例 #7
0
 public Worldboss(Device device, Routine routine, Wb config, Smartrune smartune)
 {
     _device     = device;
     _routine    = routine;
     _config     = config;
     _smartune   = smartune;
     _alreadyDid = 0;
 }
コード例 #8
0
ファイル: MfVaultView.xaml.cs プロジェクト: weijx-xa/test
 public void GoForward()
 {
     if (Wb.CanGoForward)
     {
         Wb.GoForward();
         NavigatedFromBrowser = true;
     }
 }
コード例 #9
0
ファイル: MfVaultView.xaml.cs プロジェクト: weijx-xa/test
 public void GoBack()
 {
     if (Wb.CanGoBack)
     {
         Wb.GoBack();
         NavigatedFromBrowser = true;
     }
 }
コード例 #10
0
ファイル: Range_Active.cs プロジェクト: ZhangZiFei/RPAAction
 protected override void Action()
 {
     base.Action();
     Wb.Activate();
     Ws.Select();
     if (Range != null && (!Range.Equals("")))
     {
         App.Range[Range].Select();
     }
 }
コード例 #11
0
        public async Task <IActionResult> Create([Bind("Seq,Id,Name,Kana,Ip,Status,Place,Back,StartDay,StartTime,EndDay,Ok,EndTime,Phone,Mail1,Mail2,Memo1,Memo2,Memo3,Memo4,Memo5,Message,UpdateDay,UpdateTime,FullName,Business,UpdateIp,InterPhone")] Wb wb)
        {
            if (ModelState.IsValid)
            {
                _context.Add(wb);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(wb));
        }
コード例 #12
0
ファイル: MfVaultView.xaml.cs プロジェクト: weijx-xa/test
 public void SetAddressBar(string path)
 {
     //if (System.IO.Directory.Exists(path))
     //{
     //var uri = new Uri(path);
     //if (Wb.WebBrowser.Source != uri)
     //{
     Wb.Navigate(new Uri(path));
     //}
     //}
 }
コード例 #13
0
        protected override void Action()
        {
            base.Action();

            if (File.Exists(newWbPath))
            {
                throw new ActionException($"文件({newWbPath})已经存在");
            }

            Directory.CreateDirectory(Path.GetDirectoryName(newWbPath));
            Wb.SaveAs(newWbPath, GetXlFileFormatByWbPath(newWbPath));
        }
コード例 #14
0
ファイル: MfVaultView.xaml.cs プロジェクト: weijx-xa/test
 private void MfVaultView_Loaded(object sender, RoutedEventArgs e)
 {
     _viewModel = DataContext as MfVaultViewModel;
     if (_viewModel != null)
     {
         _viewModel.BrowserView = this;
         if (_viewModel.SourcePath != null)
         {
             Wb.Navigate(new Uri(_viewModel.SourcePath));
         }
     }
 }
コード例 #15
0
 protected override void Action()
 {
     Wb = AttachWorkbook(WbPath);
     if (Wb != null)
     {
         AttachOrOpenApp();
         bool Visible = App.Visible;
         Wb.Close(false);
         App.Visible = Visible;
     }
     Wb = OpenWorkbook(WbPath, readOnly, pwd, delimiter, writePwd);
 }
コード例 #16
0
 protected override void Action()
 {
     if (WbPath.CheckNoVoid())
     {
         Wb = AttachWorkbook(WbPath);
         if (Wb != null)
         {
             Wb.Close(isSave);
         }
     }
     else
     {
         base.Action();
         Wb.Close(isSave);
     }
 }
コード例 #17
0
 public MainWindow()
 {
     InitializeComponent();
     Wb.Navigate("http://google.com");
     Wb.LoadCompleted += delegate {
         if (_docEvent != null)
         {
             _docEvent.oncontextmenu -= _docEvent_oncontextmenu;
         }
         if (Wb.Document != null)
         {
             _docEvent = (HTMLDocumentEvents2_Event)Wb.Document;
             _docEvent.oncontextmenu += _docEvent_oncontextmenu;
         }
     };
 }
コード例 #18
0
        public void DrawFullCarcass()
        {
            Wb.Clear();

            ////Z - buffer
            //int[,] Z = new int[Wb.PixelWidth, Wb.PixelHeight];
            //for (int i = 0; i < Wb.PixelWidth; i++)
            //{
            //    for (int j = 0; j < Wb.PixelHeight; j++)
            //    {
            //        Z[i, j] = Int32.MinValue;
            //    }
            //}
            Point[] buffer = new Point[(BetaDo - BetaOt)];
            for (int alfa = AlfaOt; alfa < AlfaDo; alfa += resolution)
            {
                for (int beta = BetaOt; beta < BetaDo; beta += resolution * 2)
                {
                    var res = MainModel.Axonometry(MainModel.Func(R, alfa * Math.PI / 180, beta * Math.PI / 180),
                                                   Alfa * Math.PI / 180,
                                                   Beta * Math.PI / 180);
                    if (!double.IsNegativeInfinity(pointHorizontal.X))
                    {
                        MainModel.Line(wb, (int)pointHorizontal.X, (int)pointHorizontal.Y,
                                       (int)res.Item1 + Wb.PixelWidth / 2, (int)res.Item2 + Wb.PixelHeight / 2,
                                       color);// ,ref Z, (int)res.Item3);
                        if (alfa > 0)
                        {
                            MainModel.Line(wb, (int)buffer[beta].X, (int)buffer[beta].Y,
                                           (int)res.Item1 + Wb.PixelWidth / 2, (int)res.Item2 + Wb.PixelHeight / 2,
                                           color);
                        }
                    }
                    buffer[beta] = new Point(res.Item1 + Wb.PixelWidth / 2, res.Item2 + Wb.PixelHeight / 2);
                    if (alfa < AlfaDo - resolution)
                    {
                        pointHorizontal = new Point(res.Item1 + Wb.PixelWidth / 2, res.Item2 + Wb.PixelHeight / 2);
                    }
                    else
                    {
                        pointHorizontal.X = double.NegativeInfinity;
                    }
                }
            }
        }
コード例 #19
0
        public void DrawHorizontalCarcass(Func <Tuple <double, double, double>, int, Tuple <double, double, double> > scaling,
                                          Func <Tuple <double, double, double>, int, int, int, Tuple <double, double, double> > moving,
                                          Func <Tuple <double, double, double>, int, Tuple <double, double, double> > rX,
                                          Func <Tuple <double, double, double>, int, Tuple <double, double, double> > rY,
                                          Func <Tuple <double, double, double>, int, Tuple <double, double, double> > rZ)
        {
            Wb.Clear();

            ////Z - buffer
            //int[,] Z = new int[Wb.PixelWidth, Wb.PixelHeight];
            //for (int i = 0; i < Wb.PixelWidth; i++)
            //{
            //    for (int j = 0; j < Wb.PixelHeight; j++)
            //    {
            //        Z[i, j] = Int32.MinValue;
            //    }
            //}
            for (int alfa = AlfaOt; alfa < AlfaDo; alfa += resolution)
            {
                for (int beta = BetaOt; beta < BetaDo; beta += resolution * 2)
                {
                    var res = MainModel.Axonometry(rZ(rY(rX(moving(scaling(MainModel.Func(R, alfa * Math.PI / 180, beta * Math.PI / 180), K), Dx, Dy, Dz), AffineAngleX), AffineAngleY), AffineAngleZ),
                                                   Alfa * Math.PI / 180,
                                                   Beta * Math.PI / 180);
                    if (!double.IsNegativeInfinity(pointHorizontal.X))
                    {
                        MainModel.Line(wb, (int)pointHorizontal.X, (int)pointHorizontal.Y,
                                       (int)res.Item1 + Wb.PixelWidth / 2, (int)res.Item2 + Wb.PixelHeight / 2,
                                       color);//,ref Z, (int)res.Item3);
                    }
                    if (alfa < AlfaDo - resolution)
                    {
                        pointHorizontal = new Point(res.Item1 + Wb.PixelWidth / 2, res.Item2 + Wb.PixelHeight / 2);
                    }
                    else
                    {
                        pointHorizontal.X = double.NegativeInfinity;
                    }
                }
            }
        }
コード例 #20
0
ファイル: Wbs2Controller.cs プロジェクト: Hatahata-77/webapi
        public async Task <ActionResult <Wb> > PostWb(Wb wb)
        {
            _context.Wb.Add(wb);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (WbExists(wb.Seq))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetWb", new { id = wb.Seq }, wb));
        }
コード例 #21
0
        private bool SaveReport()
        {
            Console.WriteLine("Save Report...");
            try
            {
                bool   allPass      = IsAllPass();
                string resultStr    = allPass ? "(Pass)" : "(Fail)";
                string savePathFile = ExcelFileDirectory + @"\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + resultStr + ".xlsx";
                Wb.SaveAs(savePathFile);

                Wb.Close(false, Type.Missing, Type.Missing);
                Excel.Quit();

                MoveReportToPreFolder(savePathFile);
            }
            catch (Exception ex)
            {
                Console.WriteLine("儲存檔案出錯,檔案可能正在使用" + Environment.NewLine + ex.Message);
                return(false);
            }

            return(true);
        }
コード例 #22
0
 protected override void Action()
 {
     base.Action();
     //运行宏
     if (FunctionName.CheckNoVoid())
     {
         Wb.Activate();
         try
         {
             RunVBA();
         }
         //沒有信任存取VAB專案物件模型
         catch (System.Runtime.InteropServices.COMException come)
         {
             //插入VBA代码
             if (VBACode.CheckNoVoid())
             {
                 try
                 {
                     VBE         vbe = App.VBE;
                     VBComponent vbComponent;
                     vbComponent = Wb.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule);
                     vbComponent.CodeModule.AddFromString(VBACode);
                 }
                 catch (Exception e)
                 {
                     throw new ActionException("添加vb函數失敗\n" + e.ToString());
                 }
                 RunVBA();
             }
             else
             {
                 throw come;
             }
         }
     }
 }
コード例 #23
0
 public void DrawPolygons()
 {
     Wb.Clear();
     Point[] bufferUp   = new Point[(BetaDo - BetaOt)];
     Point[] bufferDown = new Point[(BetaDo - BetaOt)];
     for (int alfa = AlfaOt; alfa < AlfaDo; alfa += resolution)
     {
         for (int beta = BetaOt; beta < BetaDo; beta += resolution)
         {
             var res = MainModel.Axonometry(MainModel.Func(R, alfa * Math.PI / 180, beta * Math.PI / 180),
                                            Alfa * Math.PI / 180,
                                            Beta * Math.PI / 180);
             bufferDown[beta] = new Point(res.Item1 + Wb.PixelWidth / 2, res.Item2 + Wb.PixelHeight / 2);
             if (alfa > 1 && beta > 0)
             {
                 MainModel.Polygon(wb, bufferUp[beta - 1], bufferUp[beta], bufferDown[beta - 1], bufferDown[beta], color);
             }
             if (alfa > 0 && beta > 0)
             {
                 bufferUp[beta - 1] = bufferDown[beta - 1];
             }
         }
     }
 }
コード例 #24
0
        private void Xuat_kehoachsx(System.Data.DataTable dt, string filename)//Xuất phiếu
        {
            if (dt.Rows.Count == 0)
            {
                return;
            }
            Excel.Application App = null;
            Excel.Workbook    Wb;
            Excel.Worksheet   Ws;
            int isExcelOpen = 0;

            try
            {
                App = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                App         = new Excel.Application();
                isExcelOpen = 1;
            }

            //oXL.Visible = true;

            Wb = (Excel.Workbook)(App.Workbooks.Add(Missing.Value));
            Ws = (Excel.Worksheet)Wb.ActiveSheet;

            try
            {
                Ws = (Excel.Worksheet)App.Worksheets.Add();

                // Xử lý tiêu đề cột

                int rowCount = dt.Rows.Count;
                int colCount = dt.Columns.Count;
                int c        = 0;
                int r        = 0;

                Excel.Range HeaderRow = Ws.get_Range("A1");

                foreach (System.Data.DataColumn dc in dt.Columns)
                {
                    HeaderRow.get_Offset(0, r).Value2 = dc.ColumnName;
                    r++;
                }

                HeaderRow.EntireRow.Font.Bold         = true;
                HeaderRow.EntireRow.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;

                // Xử lý data-> mảng 2 chiều

                object[,] rowData = new object[rowCount, colCount];

                foreach (System.Data.DataRow row in dt.Rows)
                {
                    for (int col = 0; col < colCount; col++)
                    {
                        if (IsNumeric(row[col].GetType().ToString()))
                        {
                            rowData[c, col] = System.Convert.ToDouble(row[col].ToString());
                        }
                        else
                        {
                            rowData[c, col] = row[col].ToString();
                        }
                    }
                    c++;
                }

                // Paste mảng vào excel

                Ws.get_Range("A2").get_Resize(c, colCount).Value2 = rowData;
                Ws.get_Range("A1").get_Resize(1, colCount).EntireColumn.AutoFit();

                // Lưu file

                string ExcelPath = AppDomain.CurrentDomain.BaseDirectory + string.Format("{0}.xlsx", filename);

                if (System.IO.File.Exists(ExcelPath))
                {
                    System.IO.File.Delete(ExcelPath);
                }

                Wb.SaveAs(ExcelPath, AccessMode: Excel.XlSaveAsAccessMode.xlShared);
                Wb.Close();
                if (isExcelOpen == 1)
                {
                    App.Quit();
                }
                dt.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            // Dọn rác
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Ws);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Wb);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(App);
        }
コード例 #25
0
        public static void DataTableToExcel(System.Data.DataTable dt, string filename)
        {
            string ExcelPathx = AppDomain.CurrentDomain.BaseDirectory + "\\FILE TRIEN KHAI.xlsm";

            if (dt.Rows.Count == 0)
            {
                return;
            }
            Excel.Application App = null;
            Excel.Workbook    Wb;
            Excel.Worksheet   Ws;
            int isExcelOpen = 0;

            try
            {
                App = (Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                App         = new Excel.Application();
                isExcelOpen = 1;
            }
            //catch(Exception){}
            //finally
            //{
            //    App = new Excel.Application();
            //    isExcelOpen = 1;
            //}
            //oXL.Visible = true;
            Wb = (Excel.Workbook)(App.Workbooks.Open(ExcelPathx, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
            //Wb = (Excel.Workbook)(App.Workbooks.Add(Missing.Value));
            Ws = (Excel.Worksheet)Wb.Worksheets["Sheet"];
            //Ws = (Excel.Worksheet)Wb.ActiveSheet;
            try
            {
                //Ws = (Excel.Worksheet)App.Worksheets.Add();

                // Xử lý tiêu đề cột

                int rowCount = dt.Rows.Count;
                int colCount = dt.Columns.Count;
                int c        = 0;
                //int r = 0;

                //Excel.Range HeaderRow = Ws.get_Range("A1");

                //foreach (System.Data.DataColumn dc in dt.Columns)
                //{
                //    HeaderRow.get_Offset(0, r).Value2 = dc.ColumnName;
                //    r++;
                //}

                //HeaderRow.EntireRow.Font.Bold = true;
                //HeaderRow.EntireRow.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;

                // Xử lý data-> mảng 2 chiều

                object[,] rowData = new object[rowCount, colCount];

                foreach (System.Data.DataRow row in dt.Rows)
                {
                    for (int col = 0; col < colCount; col++)
                    {
                        if (IsNumeric(row[col].GetType().ToString()))
                        {
                            rowData[c, col] = System.Convert.ToDouble(row[col].ToString());
                        }
                        else
                        {
                            rowData[c, col] = row[col].ToString();
                        }
                    }
                    c++;
                }
                //xóa mảng trước khi pass
                //Ws.get_Range("A2:AZ600").get_Resize(rowCount, colCount).Value2 = rowData; Xóa mảng trùng với mảng copy lên excel
                Ws.get_Range("A2:AZ600").Cells.ClearContents();
                // Paste mảng vào excel

                Ws.get_Range("A2").get_Resize(rowCount, colCount).Value2 = rowData;
                //Ws.get_Range("A1").get_Resize(1, colCount).EntireColumn.AutoFit();
                // Giãn cột

                // Lưu file

                string ExcelPath = AppDomain.CurrentDomain.BaseDirectory + string.Format("{0}.xlsm", "FILE TRIEN KHAI");

                if (System.IO.File.Exists(ExcelPath))
                {
                    System.IO.File.Delete(ExcelPath);
                }

                Wb.SaveAs(ExcelPath, AccessMode: Excel.XlSaveAsAccessMode.xlShared);
                Wb.Close();
                //App.Quit();
                if (isExcelOpen == 1)
                {
                    App.Quit();
                }
                dt.Dispose();
            }
            catch
            {
                //throw ex;
            }

            // Dọn rác
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Ws);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(Wb);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(App);
            System.Threading.Thread.Sleep(400);
        }
コード例 #26
0
 void Wb_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     Wb.InvokeScript("eval", "document.forms[0].submit();");     // Throws 80020101
 }
コード例 #27
0
        private void buttonSaveExcel_Click(object sender, EventArgs e)
        {
            Microsoft.Office.Interop.Excel.Application App;
            Microsoft.Office.Interop.Excel._Workbook   Wb;
            Microsoft.Office.Interop.Excel._Worksheet  oS;
            Microsoft.Office.Interop.Excel.Range       oRan;
            object misvalue = System.Reflection.Missing.Value;
            int    count;
            string count_str;

            try
            {
                count     = save_time_str.Count();
                count_str = count.ToString();
                count_str = "A" + count_str;

                List <string> output = Clear(save_time_str);


                List <int>    int_time_list = new List <int>();
                List <string> output_temp   = new List <string>();

                int x = 0;
                foreach (string el in output)
                {
                    Int32.TryParse(el, out x);
                    int_time_list.Add(x);
                }

                int temp_val = int_time_list[5];
                for (int j = 5; j < 17; j++)
                {
                    if (int_time_list[j] > temp_val)
                    {
                        temp_val = int_time_list[j];
                    }
                }
                //eliminacja ujemnych i błędnych wartosci
                for (int i = 1; i < int_time_list.Count; i++)
                {
                    if (int_time_list[i] < 0)
                    {
                        int_time_list.RemoveAt(i);
                        int_time_list.RemoveAt(i - 1);
                    }
                    if (int_time_list[i] > 10 * temp_val)
                    {
                        int_time_list.RemoveAt(i);
                        int_time_list.RemoveAt(i - 1);
                    }
                }
                int_time_list.RemoveAt(int_time_list.Count - 1);

                foreach (int el in int_time_list)
                {
                    output_temp.Add(el.ToString());
                }

                string[,] output2 = new string[count, 1];
                int it = 0;
                foreach (string el in output_temp)
                {
                    output2[it, 0] = el;
                    it++;
                }



                App         = new Microsoft.Office.Interop.Excel.Application();
                App.Visible = true;

                Wb = (Microsoft.Office.Interop.Excel._Workbook)(App.Workbooks.Add(""));
                oS = (Microsoft.Office.Interop.Excel._Worksheet)Wb.ActiveSheet;

                oS.Cells[1, 1] = "times";

                oS.get_Range("A1", "B1").Font.Bold         = true;
                oS.get_Range("A1", "B1").VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;

                oS.get_Range("A2", count_str).Value2 = output2;


                oRan = oS.get_Range("A1", "B1");
                oRan.EntireColumn.AutoFit();

                App.Visible     = false;
                App.UserControl = false;
                Wb.SaveAs("test505.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
                          false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
                          Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                textBox3.Visible = true;
                textBox3.Text    = "saved in documents folder";
                Wb.Close();
            }
            catch (UnauthorizedAccessException)
            { }
        }
コード例 #28
0
        /// <summary>
        /// 播放线程执行方法
        /// </summary>
        private unsafe void DeCoding()
        {
            try
            {
                Console.WriteLine("DeCoding run...");
                //Bitmap oldBmp = null;


                // 更新图片显示
                tstRtmp.ShowBitmap show = (width, height, stride, data) =>
                {
                    //    //    this.Invoke(new MethodInvoker(() =>
                    //    //    {
                    //    //        this.pic.Image = bmp;
                    //    //        if (oldBmp != null)
                    //    //        {
                    //    //            oldBmp.Dispose();
                    //    //        }
                    //    //        oldBmp = bmp;
                    //    //    }));
                    WriteableBitmap Wb  = null;
                    Int32Rect       rec = Int32Rect.Empty;
                    this.Dispatcher.Invoke(new Action(delegate {
                        //this.LiveImg.Source = bmp;

                        //Solution 1: Official Way
                        //IntPtr ptr = bmp.GetHbitmap();
                        //BitmapSource Bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                        //        ptr, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        ////release resource
                        //DeleteObject(ptr);
                        //this.LiveImg.Source = Bs;

                        //Solution 2: Memory Way
                        //BitmapImage Bi = BitmapToBitmapImage(bmp);
                        //LiveLU.Source = Bi;

                        //Solution 3: WriteableBitmap
                        //Low Frame Rate
                        if (Wb == null)
                        {
                            Wb  = new WriteableBitmap(width, height, 96, 96, System.Windows.Media.PixelFormats.Bgr24, null);
                            rec = new Int32Rect(0, 0, width, height);
                        }
                        Wb.Lock();
                        Wb.AddDirtyRect(rec);
                        Wb.WritePixels(rec, data, width * height * 4, stride);
                        //Debug.WriteLine(frameNumber);
                        Wb.Unlock();
                        this.LiveImg.Source = Wb;
                    }));
                };
                rtmp.Start(show, "rtmp://127.0.0.1/live");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.WriteLine("DeCoding exit");
                rtmp.Stop();

                thPlayer = null;
                //this.Invoke(new MethodInvoker(() =>
                //{
                //    btnStart.Text = "开始播放";
                //    btnStart.Enabled = true;
                //}));
            }
        }
コード例 #29
0
 private void MainPage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     Wb.InvokeScript("eval", "document.forms[0].submit();");     // Works
 }
コード例 #30
0
 public Map()
 {
     InitializeComponent();
     Wb.Navigate("https://www.google.com/maps/dir//53.8913847,27.5592104/@53.8908151,27.5572328,17.79z/data=!4m2!4m1!3e0");
 }