public async void OkBtn_Click(object sender, RoutedEventArgs e)
        {
            _InProgressClosing            = true;
            chkBoxCreatePreview.IsEnabled = false;
            chkBoxCreateZip.IsEnabled     = false;
            OkBtn.IsEnabled = false;

            GenerateLivelyInfo(layout);
            Rect reviewPanel;

            #region previewgif
            //preview clip (animated gif file).
            if (SaveData.config.PreviewGIF.CaptureGif)
            {
                //generate screen capture images.
                for (int i = 0; i < gifTotalFrames; i++)
                {
                    reviewPanel = WindowOperations.GetAbsolutePlacement(PreviewBorder, true);
                    CaptureWindow.CopyScreen(saveDirectory, i.ToString(CultureInfo.InvariantCulture) + ".jpg",
                                             (int)(((int)reviewPanel.Left + (int)(reviewPanel.Right)) / 2f) - 192 / 2, (int)(((int)reviewPanel.Top + (int)(reviewPanel.Bottom)) / 2f) - 108 / 2, 192, 108); //384,216
                    await Task.Delay(gifAnimationDelay);

                    this.Dispatcher.Invoke(() =>
                    {
                        if ((i + 1) > gifProgressBar.Maximum)
                        {
                            gifProgressBar.Value = gifProgressBar.Maximum;
                        }
                        else
                        {
                            gifProgressBar.Value = i + 1;
                        }
                    });
                }
                //create animated gif from captured images.
                await Task.Run(() => CreateGif());
            }
            else
            {
                await Task.Delay(1000); //wait 1sec before capturing thumbnail..incase wallpaper is not loaded yet.
            }
            #endregion

            #region thumbnail
            // 200x200 thumbnail image capture.
            reviewPanel = WindowOperations.GetAbsolutePlacement(PreviewBorder, true);
            CaptureWindow.CopyScreen(saveDirectory, "lively_t.jpg",
                                     (int)(((int)reviewPanel.Left + (int)(reviewPanel.Right)) / 2f) - 200 / 2, (int)(((int)reviewPanel.Top + (int)(reviewPanel.Bottom)) / 2f) - 200 / 2, 200, 200);

            #endregion

            _InProgressClosing = false;
            this.Close();
        }
Esempio n. 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         IntPtr            maindHwnd = (IntPtr)263822;
         Bitmap            bitmap    = CaptureWindow.GetWindowCapture(maindHwnd);
         Image <Bgr, Byte> tempGame  = new Image <Bgr, byte>(bitmap);
         showLogSafePost("游戏窗口截屏", tempGame);
     }
     catch (Exception)
     {
         MessageBox.Show("窗体不存在");
     }
 }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.PropertyField(output_folder_, new GUIContent(
                                          "Output Folder"));
        if (GUILayout.Button("Choose Output Folder"))
        {
            string path = EditorUtility.SaveFolderPanel(
                "Choose Capture Output Folder", output_folder_.stringValue, "");
            if (path.Length != 0)
            {
                output_folder_.stringValue = path;
            }
        }

        EditorGUILayout.PropertyField(size_, new GUIContent("Headbox Size"));
        EditorGUILayout.PropertyField(samples_, new GUIContent("Sample Count"));
        EditorGUILayout.PropertyField(center_resolution_, new GUIContent(
                                          "Center Capture Resolution"));
        EditorGUILayout.PropertyField(resolution_, new GUIContent(
                                          "Default Resolution"));
        EditorGUILayout.PropertyField(dynamic_range_, new GUIContent(
                                          "Dynamic Range"));

        EditorGUILayout.PropertyField(last_output_dir_, new GUIContent(
                                          "Last Output Folder"));

        if (capture_status_ != null)
        {
            GUI.enabled = false;
        }
        if (GUILayout.Button("Capture"))
        {
            Capture();
        }
        GUI.enabled = true;

        serializedObject.ApplyModifiedProperties();

        // Poll the bake status.
        if (bake_progress_window_ != null && bake_progress_window_.IsComplete())
        {
            bake_progress_window_.Close();
            bake_progress_window_ = null;
            capture_builder_      = null;
            capture_status_       = null;
        }
    }
Esempio n. 4
0
        public MainWindowViewModel()
        {
            FriendServer friendServer = new FriendServer();
            DataTable    table        = friendServer.GetTable();

            foreach (DataRow item in table.Rows)
            {
                using (MemoryStream memory = new MemoryStream((byte[])item["Head"]))
                {
                    Bitmap       bitmap = (Bitmap)System.Drawing.Image.FromStream(memory);
                    BitmapSource source = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                    friends.Add(new Friend()
                    {
                        Nickname = item["Nickname"].ToString(), Head = source
                    });
                }
            }
            CloseCommand = new DelegateCommand(() => {
                Application.Current.Shutdown();
            });

            SelectItemChangedCommand = new DelegateCommand <object>((p) => {
                ListView lv = p as ListView;
                friend      = lv.SelectedItem as Friend;

                //Head= friend.Head;
                //Nickname = friend.Nickname;
            });
            AddCommand = new DelegateCommand(() =>
            {
                addWindow = new AddWindow();
                addWindow.ShowDialog();
            });
            ClickCommand = new DelegateCommand(() =>
            {
                MessageBox.Show("你好");
            });
            CaptureCommand = new DelegateCommand(() =>
            {
                CaptureWindow captureWindow = new CaptureWindow();
                captureWindow.ShowDialog();
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Opens a window for contour settings and capturing
        /// </summary>
        private void Menu_contourSubItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            CaptureWindow        capture      = new CaptureWindow();
            CaptureSetController capture_ctrl = new CaptureSetController();
            CaptureSetManager    capture_mng  = new CaptureSetManager();

            capture_ctrl.CaptureWindow    = capture;
            capture_ctrl.CaptureManager   = capture_mng;
            capture_mng.CaptureSetWindow  = capture;
            capture_mng.CaptureSetControl = capture_ctrl;
            capture_ctrl.SetDefaultValues();
            capture_ctrl.SetHandlers();
            capture_mng.Initialize(); // initialize a thread for camera capture
            if (CommonAttribService.DEFAULT_TEMPLATES != null)
            {
                capture.Processor.templates = CommonAttribService.DEFAULT_TEMPLATES;
            }
            capture.Show();
        }
Esempio n. 6
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            string PIDNew = "";

            if (e.Args.Length > 0)
            {
                PIDNew = e.Args[0].ToString();
            }

            if (PIDNew == "")
            {
                // Default Parameters
                CaptureWindow captureWindow = new CaptureWindow();
                captureWindow.Show();
            }
            else
            {
                // Specific Parameters
                CaptureWindow captureWindow = new CaptureWindow("P" + PIDNew);
                captureWindow.Show();
            }
        }
    public void Capture()
    {
        CaptureHeadbox headbox = (CaptureHeadbox)target;

        string capture_output_folder = headbox.output_folder_;

        if (capture_output_folder.Length <= 0)
        {
            capture_output_folder = FileUtil.GetUniqueTempPathInProject();
        }
        headbox.last_output_dir_ = capture_output_folder;
        Directory.CreateDirectory(capture_output_folder);

        capture_status_  = new EditorBakeStatus();
        capture_builder_ = new CaptureBuilder();

        // Kick off the interactive Editor bake window.
        bake_progress_window_ = (CaptureWindow)EditorWindow.GetWindow(typeof(CaptureWindow));
        bake_progress_window_.SetupStatus(capture_status_);

        capture_builder_.BeginCapture(headbox, capture_output_folder, 1, capture_status_);
        bake_progress_window_.SetupCaptureProcess(headbox, capture_builder_);
    }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CaptureWindow captureWindow = new CaptureWindow();

            captureWindow.Show();
        }
Esempio n. 9
0
        public async void OkBtn_Click(object sender, RoutedEventArgs e)
        {
            _InProgressClosing            = true;
            chkBoxCreatePreview.IsEnabled = false;
            chkBoxCreateZip.IsEnabled     = false;
            OkBtn.IsEnabled = false;

            GenerateLivelyInfo(layout);
            Rect previewPanelPos;
            Size previewPanelSize = WindowOperations.GetElementPixelSize(PreviewBorder);

            #region preview_images
            //preview clip (animated gif file).
            if (SaveData.config.PreviewGIF.CaptureGif)
            {
                //generate screen capture images.
                for (int i = 0; i < gifTotalFrames; i++)
                {
                    //updating the position incase window is moved.
                    previewPanelPos = WindowOperations.GetAbsolutePlacement(PreviewBorder, true);
                    CaptureWindow.CopyScreen(
                        saveDirectory,
                        i.ToString(CultureInfo.InvariantCulture) + ".jpg",
                        (int)previewPanelPos.Left,
                        (int)previewPanelPos.Top,
                        (int)previewPanelSize.Width,
                        (int)previewPanelSize.Height);
                    //SaveData.config.PreviewGIF.GifSize.Width + SaveData.config.PreviewGIF.GifOffsets.X,
                    //SaveData.config.PreviewGIF.GifSize.Height + SaveData.config.PreviewGIF.GifOffsets.Y); //384,216

                    await Task.Delay(gifAnimationDelay);

                    if ((i + 1) > gifProgressBar.Maximum)
                    {
                        gifProgressBar.Value = gifProgressBar.Maximum;
                    }
                    else
                    {
                        gifProgressBar.Value = i + 1;
                    }
                }
                //create animated gif from captured images.
                await Task.Run(() => CreateGif());
            }
            else
            {
                //wait before capturing thumbnail..incase wallpaper is not loaded yet.
                await Task.Delay(100);
            }

            //200x200 thumbnail image capture.
            //updating the position incase window is moved.
            previewPanelPos = WindowOperations.GetAbsolutePlacement(PreviewBorder, true);
            CaptureWindow.CopyScreen(
                saveDirectory,
                "lively_t.jpg",
                (int)previewPanelPos.Left + (int)previewPanelSize.Width / 5,
                (int)previewPanelPos.Top,
                (int)previewPanelSize.Height,
                (int)previewPanelSize.Height);

            #endregion

            _InProgressClosing = false;
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
            {
                App.W.LoadWallpaperFromWpDataFolder();
            }));

            this.Close();
        }
 public void SetGUI(CaptureWindow bake_gui)
 {
     bake_gui_ = bake_gui;
 }