public override void Run(DeckHandler dh) { if (dh.PageStack.Count > 0) { dh.CurrentPage = dh.PageStack.Pop(); dh.renderPage(); } else { MessageBox.Show("No page to go back to"); } }
private void iconChangeButton_Click(object sender, EventArgs e) { if (selectedIndex == -1) { MessageBox.Show("No key selected"); return; } OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "Image Files(*.BMP;*.JPG;*.PNG)|*.BMP;*.JPG;*.PNG|All files (*.*)|*.*"; fd.InitialDirectory = String.Format(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\OpenStreamDeck\\images\\"); fd.Multiselect = false; fd.ValidateNames = true; if (fd.ShowDialog() == DialogResult.OK) { try { Image img = Image.FromFile(fd.FileName); if ((img.Height != 72) && (img.Width != 72)) { MessageBox.Show("Images must be 72x72. Please resize your image to prevent potential issues!"); return; } var newPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\OpenStreamDeck\\images\\" + fd.SafeFileName; if (File.Exists(newPath)) { if (newPath == fd.FileName) { } else if (MessageBox.Show("A file with this name already exists in the OpenStreamDeck image cache, would you like to overwrite it?", "Overwrite File", MessageBoxButtons.YesNo) == DialogResult.Yes) { File.Delete(newPath); File.Copy(fd.FileName, newPath); } } else { File.Copy(fd.FileName, newPath); } currentPage.Keys[selectedIndex].setImage(newPath); keyPictureBoxes[selectedIndex].Image = currentPage.Keys[selectedIndex].getImageForForm(); iconPreview.Image = currentPage.Keys[selectedIndex].getImageForForm(); deckHandler.renderPage(); ProfileManager.saveProfile(deckHandler.CurrentProfile); } catch (Exception ex) { MessageBox.Show(String.Format("Error: Could not open file. ({0})", ex.Message)); } } }
public override void Run(DeckHandler dh) { Page PageReference = new Page("Twitch Live Subs"); PageReference.Keys[4].setImage("Resources\\back.png"); PageReference.Keys[4].KeyPressedFunction = new GoBack(dh); PageReference.Keys[4].KeyHeldFunction = new GoHome(dh); //Wait for liveChannels to be populated while (liveChannels == null) { Thread.Sleep(1); } var i = 0; foreach (var stream in liveChannels.Streams) { string saveLocation = "image_cache\\" + stream.Channel.DisplayName + ".jpeg"; if (!File.Exists(saveLocation)) { var logoUrl = stream.Channel.Logo.Replace("300x300", "70x70"); Console.WriteLine(logoUrl); WebClient wc = new WebClient(); byte[] bytes = wc.DownloadData(logoUrl); MemoryStream ms = new MemoryStream(bytes); Image img = Image.FromStream(ms); img = ResizeImage(img, 72, 72); if (!Directory.Exists("image_cache\\")) { Directory.CreateDirectory("image_cache\\"); } img.Save(saveLocation, System.Drawing.Imaging.ImageFormat.Jpeg); } PageReference.Keys[i].setImage(saveLocation); PageReference.Keys[i].KeyPressedFunction = new OpenWebLink(stream.Channel.Url); i++; if (i == 4) { i++; } } dh.PageStack.Push(dh.CurrentPage); dh.CurrentPage = PageReference; dh.renderPage(); }
public override void Run(DeckHandler dh) { dh.CurrentPage = dh.CurrentProfile.MainPage; dh.renderPage(); }
public override void Run(DeckHandler dh) { dh.PageStack.Push(dh.CurrentPage); dh.CurrentPage = PageReference; dh.renderPage(); }