private IEnumerable <ScreenshotItem> MakeScreenshots() { // Determine the size of the "virtual screen", which includes all monitors. int screenLeft = SystemInformation.VirtualScreen.Left; int screenTop = SystemInformation.VirtualScreen.Top; int screenWidth = SystemInformation.VirtualScreen.Width; int screenHeight = SystemInformation.VirtualScreen.Height; var item = new ScreenshotItem { Height = screenHeight, Width = screenWidth, }; // Create a bitmap of the appropriate size to receive the screenshot. using (Bitmap bmp = new Bitmap(screenWidth, screenHeight)) { // Draw the screenshot into our bitmap. using (Graphics g = Graphics.FromImage(bmp)) { g.CopyFromScreen(screenLeft, screenTop, 0, 0, bmp.Size); } item.Image = ImageToByte(bmp); } return(new List <ScreenshotItem>() { item }); }
public MainForm() { Title = "Player 255"; MinimumSize = new Size(700, 800); var layout = new DynamicLayout { DefaultPadding = 10, DefaultSpacing = new Size(10, 10), }; layout.BeginVertical(yscale: true); layout.BeginGroup("Now Playing"); PlayingLabel = new(); layout.AddRow(PlayingLabel); layout.EndGroup(); layout.BeginGroup("Status"); StatusDropDown = new(){ SelectedValue = Status.Complete }; StatusText = new(){ Enabled = false, ReadOnly = true }; StatusDropDown.SelectedValueChanged += OnStatusChanged; layout.AddRow(null, StatusDropDown, StatusText); layout.EndGroup(); layout.BeginGroup("Rating"); var oneStar = new RadioButton { Text = "1" }; oneStar.Checked = true; StarButtons = new() { oneStar }; layout.BeginHorizontal(); layout.Add(null); layout.Add(oneStar); for (var i = 2; i <= 5; i++) { var r = new RadioButton(oneStar) { Text = $"{i}" }; StarButtons.Add(r); layout.Add(r); } layout.EndGroup(); layout.BeginGroup("Screenshots", yscale: true); var grid = new GridView(); grid.Columns.Add(new GridColumn { HeaderText = "Image Path", DataCell = new TextBoxCell("ImagePath"), Editable = true, Width = 250 }); grid.Columns.Add(new GridColumn { HeaderText = "Title", DataCell = new TextBoxCell("Title"), Editable = true, Width = 250 }); Screenshots = new(); grid.DataStore = Screenshots; grid.AllowDrop = true; grid.DragEnter += (s, e) => e.Effects = DragEffects.Link; grid.DragDrop += OnScreenshotDropped; layout.AddRow(grid); layout.EndGroup(); layout.BeginGroup("Notes", yscale: true); NotesText = new(); layout.AddRow(NotesText); layout.EndGroup(); layout.EndVertical(); layout.BeginVertical(yscale: false); var submitCommand = new Command(); submitCommand.Executed += DoSubmit; SubmitButton = new Button { Text = "Submit", Command = submitCommand }; layout.AddRow(null, SubmitButton); layout.EndVertical(); Content = layout; var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); var aboutCommand = new Command { MenuText = "About..." }; aboutCommand.Executed += (sender, e) => new AboutDialog().ShowDialog(this); var regenerateCommand = new Command { MenuText = "Regenerate Website" }; regenerateCommand.Executed += (sender, e) => WebsiteManager.GenerateWebsite(); Menu = new MenuBar { QuitItem = quitCommand, AboutItem = aboutCommand, Items = { new ButtonMenuItem { Text = "&Tools", Items = { regenerateCommand, } } } }; ResetState(); // TODO: Move out, just here so I remember basics of DotLiquid. var template = Template.Parse("hi {{name}}"); var rendered = template.Render(Hash.FromAnonymousObject(new { name = "tobi" })); Console.WriteLine(rendered); } private void OnScreenshotDropped(object?sender, DragEventArgs e) { if (!e.Data.ContainsUris) { return; } foreach (var u in e.Data.Uris) { var s = new ScreenshotItem(); s.ImagePath = u.LocalPath; switch (Screenshots.Count) { case 0: s.Title = "title"; break; case 1: s.Title = "gameplay"; break; case 2: s.Title = "credits"; break; default: break; } Screenshots.Add(s); } }