Example #1
0
 private void ShowPlato()
 {
     bool.TryParse(FileSettings.GetSettingItem(SettingForm.PLOT_WINDOW_IN_THREAD), out bool runInThread);
     if (runInThread)
     {
         Thread t = new Thread(new ThreadStart(() =>
         {
             PlotMainWindow.application = ExcelDnaUtil.Application as Microsoft.Office.Interop.Excel.Application;
             PlotMainWindow plotPlato   = new PlotMainWindow();
             plotPlato.GetRange        += RibbonUI.GetSelectRange;
             plotPlato.Show();
             System.Windows.Threading.Dispatcher.Run();
         }));
         t.SetApartmentState(ApartmentState.STA);
         // Make the thread a background thread
         t.IsBackground = true;
         // Start the thread
         t.Start();
     }
     else
     {
         PlotMainWindow.application = ExcelDnaUtil.Application as Microsoft.Office.Interop.Excel.Application;
         PlotMainWindow plotPlato = new PlotMainWindow();
         plotPlato.GetRange += RibbonUI.GetSelectRange;
         plotPlato.ShowDialog();
     }
     //System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(plotPlato);
     //plotPlato.Show();
     //IntPtr handle = GetHwnd(plotPlato);
     //SetFocus(handle);
     //PlotFormSetup.LoadWindow(plotPlato);
 }
Example #2
0
        private void btnStartExcelPlot_Click(object sender, EventArgs e)
        {
            PlotMainWindow.application = ExcelDnaUtil.Application as Microsoft.Office.Interop.Excel.Application;
            PlotMainWindow plotPlato = new PlotMainWindow();

            //System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(plotPlato);
            plotPlato.GetRange += RibbonUI.GetSelectRange;
            plotPlato.Show();
        }
        private void cmSaveAsImage_Click(object sender, RoutedEventArgs e)
        {
            BitmapSource imageData = PlotMainWindow.CreateElementScreenshot(gridMain);

            try
            {
                if (imageData == null)
                {
                    return;
                }
                dlg        = new Microsoft.Win32.SaveFileDialog();
                dlg.Filter = "PNG图片(*.png)|*.png|JPEG图片(*.jpg)|*.jpg|所有文件(*.*)|*.*";
                var rst = dlg.ShowDialog();
                if (rst == true)
                {
                    var fileName = dlg.FileName;
                    SaveImageToFile(imageData, fileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }