protected override void OnNavigatedTo(NavigationEventArgs e) { string url = e.Uri.ToString(); if (url.Contains("new")) { _newConnection = true; _connection = new XbmcConnection { Xbmc = KodiRemote.Core.Connection.Default() }; } else { int index = url.IndexOf('?'); _newConnection = false; _connection = App.Context.Connections.FirstOrDefault(c => c.Id == url.Substring(index + 1)); } Address = _connection.Xbmc.Address; Port = _connection.Xbmc.Port; Login = _connection.Xbmc.Login; Password = _connection.Xbmc.Password; MacAddress = _connection.Xbmc.MacAddress; DataContext = this; }
private void EpisodeForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); Episodes = JsonClient.VideoLibrary.GetEpisodesAllFields(Show, Season, null); foreach (Episode ep in Episodes) { StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(ep._id.ToString()); itm.ButtonAnimation = true; itm.PrimaryText = ep.Label; itm.SecondaryText = "Episode: " + ep.EpisodeNum.ToString(); itm.Tag = ep._id; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
public Context() { try { var serialization = IsolatedStorage.ReadFromIsolatedStorage("Connections", string.Empty); var array = JsonConvert.DeserializeObject <XbmcConnection[]>(serialization); Connections = new ObservableCollection <XbmcConnection>(array); } catch (Exception) { Connections = new ObservableCollection <XbmcConnection>(); } #if DEBUG if (!Connections.Any()) { var cnx = new XbmcConnection { IsDefault = true, Xbmc = new KodiRemote.Core.Connection("123", "80", "xbmc", "") }; Connections.Add(cnx); } #endif }
private void ArtistForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); Artists = JsonClient.AudioLibrary.GetArtists(new SortParams("artist", null, null, null)); foreach (Artist a in Artists) { StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(a._id.ToString()); itm.ButtonAnimation = true; itm.PrimaryText = a.Label; itm.Tag = a._id; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { string url = e.Uri.ToString(); int index = url.IndexOf('?'); Connection = App.Context.Connections.FirstOrDefault(c => c.Id == url.Substring(index + 1)); DataContext = this; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromMilliseconds(TIMER_INTERVAL); _timer.Tick += TimerTick; _timer.Start(); }
private void AlbumForm_load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); if (Artist != null) Albums = JsonClient.AudioLibrary.GetAlbumsByArtist((int)Artist); else Albums = JsonClient.AudioLibrary.GetAlbums(new string[] { "artist" }, new SortParams("label", null, null, null)); foreach (Album a in Albums) { StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(a._id.ToString()); itm.ButtonAnimation = true; itm.PrimaryText = a.Label; itm.SecondaryText = a.Artist; itm.Tag = a._id; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } if (Artist != null) { StedySoft.SenseSDK.SensePanelDividerItem divider = new StedySoft.SenseSDK.SensePanelDividerItem(); this.senseListCtrl.AddItem(divider); StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem("PanelItemAll"); itm.ButtonAnimation = true; itm.PrimaryText = "All Songs"; itm.Tag = -1; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
private void TvForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); TvShows = JsonClient.VideoLibrary.GetTvShows(); if (TvShows == null) { if (SenseAPIs.SenseMessageBox.Show("There are no TV Shows in your library", "Error", SenseMessageBoxButtons.OK) == DialogResult.OK) { this.Close(); } } foreach (TvShow t in TvShows) { SenseSDKExtended.SensePanelPictureBox.Style1 itm = new SenseSDKExtended.SensePanelPictureBox.Style1(t._id.ToString()); IImage iimg = Functions.GetTvShowThumbnail(JsonClient, t.Thumbnail); iimg.GetThumbnail((uint)StedySoft.SenseSDK.DrawingCE.Resolution.ScreenWidth, 100, out iimg); ImageInfo imageinfo; iimg.GetImageInfo(out imageinfo); itm.Image = iimg; itm.ImageSize = new Size((int)(imageinfo.Width), (int)(imageinfo.Height)); iimg = null; itm.ButtonAnimation = true; itm.Height = (int)(imageinfo.Height); itm.Tag = t._id; itm.OnClick += new SenseSDKExtended.SensePanelPictureBox.Style1.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
private void SongForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); if (artistId != null) { if (albumId == null) Songs = JsonClient.AudioLibrary.GetSongsByArtistAllFields((int)artistId); else Songs = JsonClient.AudioLibrary.GetSongsByArtistAndAlbumAllFields((int)artistId, (int)albumId); } else { Songs = JsonClient.AudioLibrary.GetSongsByAlbumAllFields((int)albumId); } foreach (Song s in Songs) { StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(s._id.ToString()); itm.ButtonAnimation = true; itm.PrimaryText = s.Label; itm.SecondaryText = s.Artist; itm.Tag = s._id; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { string url = e.Uri.ToString(); int index = url.IndexOf('?'); _connection = App.Context.Connections.FirstOrDefault(c => c.Id == url.Substring(index + 1)); if (_connection != null) { if (_connection.Xbmc.IsMocked) { ButtonMovies.Visibility = Visibility.Collapsed; ButtonMusic.Visibility = Visibility.Collapsed; ButtonAddons.Visibility = Visibility.Collapsed; ButtonPlaylists.Visibility = Visibility.Collapsed; } else { ButtonMovies.Visibility = Visibility.Visible; ButtonMusic.Visibility = Visibility.Visible; ButtonAddons.Visibility = Visibility.Visible; ButtonPlaylists.Visibility = Visibility.Visible; } BtActions.DataContext = _connection; App.Context.SetDefaultConnection(_connection); App.Context.Save(); await _connection.TestConnectionAsync(); return; } if (NavigationService.CanGoBack) { NavigationService.GoBack(); } }
private void MusicForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); List<Song> Songs = JsonClient.AudioLibrary.GetSongs(); if (Songs == null) { if (SenseAPIs.SenseMessageBox.Show("There is no music in your library", "Error", SenseMessageBoxButtons.OK) == DialogResult.OK) { this.Close(); } } string[] list = {"By Genre", "By Artist", "By Album"}; foreach (string Label in list) { StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(); itm.ButtonAnimation = true; itm.PrimaryText = Label; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
private void SeasonForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); // set the list scroll fluidness this.senseListCtrl.MinimumMovement = App.Configuration.MinimumMovement; this.senseListCtrl.ThreadSleep = App.Configuration.ThreadSleep; this.senseListCtrl.Velocity = App.Configuration.Velocity; this.senseListCtrl.Springback = App.Configuration.Springback; // turn off UI updating this.senseListCtrl.BeginUpdate(); Seasons = JsonClient.VideoLibrary.GetSeasonsAllFields(Show, new SortParams("label", null, null, null)); foreach (Season s in Seasons) { var episodes = JsonClient.VideoLibrary.GetEpisodes(Show, s._Season); StedySoft.SenseSDK.SensePanelItem itm = new StedySoft.SenseSDK.SensePanelItem(s._Season.ToString()); itm.ButtonAnimation = true; itm.PrimaryText = s.Label; itm.SecondaryText = episodes.Count.ToString() + " episodes"; itm.Tag = s._Season; IImage thumbImage = Functions.GetTvSeasonThumbnail(JsonClient, s.Thumbnail); ImageInfo info; thumbImage.GetImageInfo(out info); itm.IThumbnail = thumbImage; itm.Height = (int)(info.Height); thumbImage = null; itm.OnClick += new SensePanelItem.ClickEventHandler(OnClickGeneric); this.senseListCtrl.AddItem(itm); } // we are done so turn on UI updating this.senseListCtrl.EndUpdate(); }
private static IImage ResizeImageAndSave(XbmcConnection JsonClient, string url, int width, int height) { string fullpath = StorageCardUtils.GetFirstFlashCardPath() + "\\XBMC_Remote\\cache\\" + url.Replace("special://", "").Replace("/", "\\"); Image originalImage = JsonClient.Files.GetImageFromThumbnail(url); IImage originalIImage = SenseSDKExtended.DrawingCEEx.SenseAPIsEx.SenseImageEx.ImageToIImage(originalImage, originalImage.Size); originalImage.Dispose(); IImage thumbIImage; Rectangle destination = new Rectangle(0, 0, width, height); Bitmap thumbB = new Bitmap(width, height); using (Graphics g = Graphics.FromImage(thumbB)) { IntPtr hdc = g.GetHdc(); originalIImage.GetThumbnail((uint)width, (uint)height, out thumbIImage); thumbIImage.Draw(hdc, ref destination, (IntPtr)null); g.ReleaseHdc(hdc); } thumbB.Save(fullpath, System.Drawing.Imaging.ImageFormat.Png); thumbB.Dispose(); return thumbIImage; }
public static IImage GetTvShowThumbnail(XbmcConnection JsonClient, string url) { if (CheckExist(url) == true) { return LoadImageFromDisk(url); } else { return ResizeImageAndSave(JsonClient, url, Resolution.ScreenWidth, 100); } }
public static IImage GetTvSeasonThumbnail(XbmcConnection JsonClient, string url) { if (CheckExist(url) == true) { return LoadImageFromDisk(url); } else { return ResizeImageAndSave(JsonClient, url, 150, 225); } }
public void load() { loading = true; int intNumberOfDevices = TelldusAPI.tdGetNumberOfDevices(); int dynamicHeight = 36; allLights.Clear(); lights.Clear(); lightProcess = new Thread(stoppedstate); for (int i = 0; i < intNumberOfDevices; i++) { int id = TelldusAPI.tdGetDeviceId(i); string name = TelldusAPI.tdGetNameString(id); int methods = TelldusAPI.tdMethods(id, TelldusAPI.TELLSTICK_TURNON | TelldusAPI.TELLSTICK_TURNOFF | TelldusAPI.TELLSTICK_DIM); int[] arr = new int[2] { id, methods }; allLights.Add(arr); //Generate label, checkboxes and lines if (methods == 16 || methods == 17 || methods == 18 || methods == 19) name = name + " [dimmable]"; System.Windows.Forms.Label lbl = new System.Windows.Forms.Label(); lbl.Location = new System.Drawing.Point(6, dynamicHeight + (i * 20)); lbl.Name = "lblLight_" + id.ToString(); lbl.Size = new System.Drawing.Size(165, 14); lbl.TabIndex = 7; lbl.Text = name; // // chkboxPlay // System.Windows.Forms.CheckBox chkboxPlay = new System.Windows.Forms.CheckBox(); chkboxPlay.AutoSize = true; chkboxPlay.Location = new System.Drawing.Point(177, dynamicHeight + (i * 20)); chkboxPlay.Name = "chkboxPlay" + id.ToString(); chkboxPlay.Size = new System.Drawing.Size(15, 14); chkboxPlay.TabIndex = 1 + (i * 3); chkboxPlay.UseVisualStyleBackColor = true; chkboxPlay.CheckedChanged += new System.EventHandler(this.checkBoxChangedSave); // // chkboxPause // System.Windows.Forms.CheckBox chkboxPause = new System.Windows.Forms.CheckBox(); chkboxPause.AutoSize = true; chkboxPause.Location = new System.Drawing.Point(213, dynamicHeight + (i * 20)); chkboxPause.Name = "chkboxPause" + id.ToString(); chkboxPause.Size = new System.Drawing.Size(15, 14); chkboxPause.TabIndex = 2 + (i * 3); chkboxPause.UseVisualStyleBackColor = true; chkboxPause.CheckedChanged += new System.EventHandler(this.checkBoxChangedSave); // // chkboxStop // System.Windows.Forms.CheckBox chkboxStop = new System.Windows.Forms.CheckBox(); chkboxStop.AutoSize = true; chkboxStop.Location = new System.Drawing.Point(253, dynamicHeight + (i * 20)); chkboxStop.Name = "chkboxStop" + id.ToString(); chkboxStop.Size = new System.Drawing.Size(15, 14); chkboxStop.TabIndex = 3 + (i * 3); chkboxStop.UseVisualStyleBackColor = true; chkboxStop.CheckedChanged += new System.EventHandler(this.checkBoxChangedSave); this.groupBox1.Controls.Add(lbl); this.groupBox1.Controls.Add(chkboxPlay); this.groupBox1.Controls.Add(chkboxPause); this.groupBox1.Controls.Add(chkboxStop); } using (StreamReader sr = new StreamReader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "settings.ini")) { Version = sr.ReadLine(); Ip = sr.ReadLine(); if (Version == "10") { Port = sr.ReadLine(); User = sr.ReadLine(); Password = sr.ReadLine(); } else Port = "9090"; // // Read values for dimlevel. Telldus API requires values from 0 to 255. // Values in config is stored in values from 0 to 100. Therefore multiply by 2.55 // try { DimlevelPause = Convert.ToInt32(int.Parse(sr.ReadLine()) * 2.55); } catch { DimlevelPause = Convert.ToInt32(50 * 2.55); } try { DimlevelPlay = Convert.ToInt32(int.Parse(sr.ReadLine()) * 2.55); } catch { DimlevelPlay = Convert.ToInt32(50 * 2.55); } try { DimlevelStop = Convert.ToInt32(int.Parse(sr.ReadLine()) * 2.55); } catch { DimlevelStop = Convert.ToInt32(50 * 2.55); } sr.Close(); } using (StreamReader sr = new StreamReader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "lights.ini")) { while (sr.Peek() != -1) { string tempLine = sr.ReadLine().Trim(); if (tempLine != "") { try { string[] line = tempLine.Split(','); var play = this.Controls.Find("chkboxPlay" + line[0], true).FirstOrDefault(); var pause = this.Controls.Find("chkboxPause" + line[0], true).FirstOrDefault(); var stop = this.Controls.Find("chkboxStop" + line[0], true).FirstOrDefault(); if (play != null && pause != null && stop != null) { CheckBox checkPlay = play as CheckBox; CheckBox checkPause = pause as CheckBox; CheckBox checkStop = stop as CheckBox; if (int.Parse(line[1]) == 1) checkPlay.Checked = true; if (int.Parse(line[2]) == 1) checkPause.Checked = true; if (int.Parse(line[3]) == 1) checkStop.Checked = true; } } catch(Exception e) { MessageBox.Show(e.ToString()); MessageBox.Show("Failure while reading lights.ini, please edit lightsources"); load(); return; } } } sr.Close(); } if (Ip == null || Port == null) { if (settingsread) { this.Close(); return; } else { Settings set = new Settings(); set.ShowDialog(); settingsread = true; set.Dispose(); load(); return; } } else { if (Version == "10") { Xbmc = new XbmcConnection(Ip, Convert.ToInt32(Port), User, Password); UpdateTimerOne.Interval = 1000; UpdateTimerOne.Tick += new EventHandler(UpdateTimerOne_Tick); UpdateTimerOne.Start(); UpdateTimerLights.Interval = 1000; UpdateTimerLights.Tick += new EventHandler(UpdateTimerLights_Tick); UpdateTimerLights.Start(); UpdateTimerTen.Interval = 10000; UpdateTimerTen.Tick += new EventHandler(UpdateTimerTen_Tick); UpdateTimerTen.Start(); if (Xbmc.Status.IsConnected) { lblConnected.Text = "Connected"; lblConnected.ForeColor = System.Drawing.Color.Green; } } else //Since not version 10, it must be 11 (Eden)! { new Thread(eden).Start(); UpdateTimerLights.Interval = 1000; UpdateTimerLights.Tick += new EventHandler(UpdateTimerLights_Tick); UpdateTimerLights.Start(); } } loading = false; }
private void NowPlayingForm_Closing(object sender, CancelEventArgs e) { updateTimer.Enabled = false; JsonClient = null; EventClient = null; }
public void SetDefaultConnection(XbmcConnection connection) { Connection = connection; }
private void NowPlayingForm_Load(object sender, EventArgs e) { JsonClient = new XbmcConnection(App.Configuration.IpAddress, Convert.ToInt32(App.Configuration.WebPort), App.Configuration.Username, App.Configuration.Password); EventClient.Connect(App.Configuration.IpAddress); InitializeTimer(); }