示例#1
0
文件: Capture.cs 项目: hitboxer/rori
        private static Bitmap CreateScreenshot()
        {
            using (var bmp = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight))
            {
                using (var graphic = Graphics.FromImage(bmp))
                {
                    graphic.CopyFromScreen((int)SystemParameters.VirtualScreenLeft, (int)SystemParameters.VirtualScreenTop, 0, 0, bmp.Size);

                    var hBitmap = bmp.GetHbitmap();

                    var selection = new SelectionWindow(new ImageBrush(Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())));
                    if (selection.ShowDialog() != true)
                    {
                        return(default(Bitmap));
                    }

                    var result = new Bitmap(selection.Result.Width, selection.Result.Height, PixelFormat.Format24bppRgb);
                    using (var resultgraphic = Graphics.FromImage(result))
                    {
                        resultgraphic.DrawImage(bmp, new Rectangle(0, 0, selection.Result.Width, selection.Result.Height), selection.Result, GraphicsUnit.Pixel);
                    }

                    NativeMethods.DeleteObject(hBitmap);
                    return(result);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Add genre to content
        /// </summary>
        private void AddGenre()
        {
            // Create array of genre string for selection
            GenreCollection allGenres;

            if (this.Content is Movie)
            {
                allGenres = Organization.AllMovieGenres;
            }
            else
            {
                allGenres = Organization.AllTvGenres;
            }

            List <string> selectableGenres = new List <string>();

            for (int i = 0; i < allGenres.Count; i++)
            {
                // Don't list genres already added
                if (content.DisplayGenres.Contains(allGenres[i]))
                {
                    continue;
                }

                // Add genre name
                selectableGenres.Add(allGenres[i]);
            }
            string[] selectableGenresArray = selectableGenres.ToArray();

            SelectionWindow selWindow = new SelectionWindow("Select Genre to Add", selectableGenresArray);

            selWindow.ShowDialog();

            // If selection is valid set sub-folder as sub-content folder
            if (!string.IsNullOrEmpty(selWindow.Results))
            {
                foreach (string genre in allGenres)
                {
                    if (genre == selWindow.Results)
                    {
                        this.content.DisplayGenres.Add(genre);
                        break;
                    }
                }
            }
        }
示例#3
0
        public StorageBarcodeViewModel SelectStorageBarcode(object parentViewModel, List <StorageBarcodeViewModel> barcodes)
        {
            var selectedBarcode = barcodes.First();
            var input           = new SelectionInput <StorageBarcodeViewModel>
            {
                Title             = "Barcodes - Import",
                ContentHeader     = "Select barcode",
                Label             = "Barcode:",
                Items             = barcodes,
                SelectedItem      = selectedBarcode,
                DisplayMemberPath = "Title"
            };
            var dataContext = new SelectionViewModel <StorageBarcodeViewModel>(input);
            var window      = new SelectionWindow(dataContext)
            {
                Owner = GetWindowWithDataContext(parentViewModel)
            };

            window.ShowDialog();
            return(dataContext.Result);
        }
示例#4
0
        public WorkspaceViewModel SelectBarcodesWorkspace(IEnumerable <WorkspaceViewModel> workspaces)
        {
            var selectedWorkspace = workspaces.First();
            var input             = new SelectionInput <WorkspaceViewModel>
            {
                Title             = "Barcodes - Workspaces",
                ContentHeader     = "Select desired workspace",
                Label             = "Workspace:",
                Items             = workspaces,
                SelectedItem      = selectedWorkspace,
                DisplayMemberPath = "Name"
            };
            var dataContext = new SelectionViewModel <WorkspaceViewModel>(input);
            var window      = new SelectionWindow(dataContext)
            {
                Owner = MainWindow
            };

            window.ShowDialog();
            return(dataContext.Result);
        }
示例#5
0
        private void AddChild()
        {
            if (this.SelectedRootFolder != null)
            {
                // Get list of sub-directories in content folder
                string[] subDirs = this.SelectedRootFolder.GetFolderSubDirectoryNamesThatArentChildren().ToArray();

                // open selection form to allow user to chose a sub-folder
                SelectionWindow selForm = new SelectionWindow("Select Folder", subDirs);
                selForm.ShowDialog();

                // If selection is valid set sub-folder as sub-content folder
                if (!string.IsNullOrEmpty(selForm.Results))
                {
                    ContentRootFolder newChild = new ContentRootFolder(this.ContentType, selForm.Results, System.IO.Path.Combine(this.SelectedRootFolder.FullPath, selForm.Results));
                    newChild.PropertyChanged += cloneFolder_PropertyChanged;
                    this.SelectedRootFolder.ChildFolders.Add(newChild);
                }
                UpdateAvailableFolders();
            }
        }
        private void AddChild()
        {
            if (this.SelectedRootFolder != null)
            {
                // Get list of sub-directories in content folder
                string[] subDirs = this.SelectedRootFolder.GetFolderSubDirectoryNamesThatArentChildren().ToArray();

                // open selection form to allow user to chose a sub-folder
                SelectionWindow selForm = new SelectionWindow("Select Folder", subDirs);
                selForm.ShowDialog();

                // If selection is valid set sub-folder as sub-content folder
                if (!string.IsNullOrEmpty(selForm.Results))
                {
                    ContentRootFolder newChild = new ContentRootFolder(this.ContentType, selForm.Results, System.IO.Path.Combine(this.SelectedRootFolder.FullPath, selForm.Results));
                    newChild.PropertyChanged += cloneFolder_PropertyChanged;
                    this.SelectedRootFolder.ChildFolders.Add(newChild);
                }
                UpdateAvailableFolders();
            }
        }
        /// <summary>
        /// Add genre to content
        /// </summary>
        private void AddGenre()
        {
            // Create array of genre string for selection
            GenreCollection allGenres;
            if (this.Content is Movie)
                allGenres = Organization.AllMovieGenres;
            else
                allGenres = Organization.AllTvGenres;

            List<string> selectableGenres = new List<string>();
            for (int i = 0; i < allGenres.Count; i++)
            {
                // Don't list genres already added
                if (content.DisplayGenres.Contains(allGenres[i]))
                    continue;

                // Add genre name
                selectableGenres.Add(allGenres[i]);
            }
            string[] selectableGenresArray = selectableGenres.ToArray();

            SelectionWindow selWindow = new SelectionWindow("Select Genre to Add", selectableGenresArray);
            selWindow.ShowDialog();

            // If selection is valid set sub-folder as sub-content folder
            if (!string.IsNullOrEmpty(selWindow.Results))
                foreach (string genre in allGenres)
                    if (genre == selWindow.Results)
                    {
                        this.content.DisplayGenres.Add(genre);
                        break;
                    }
        }