private void PreviewListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0 && e.AddedItems[0] is ManagerImageReference) { _lastSelectedManagerImageRef = (ManagerImageReference)e.AddedItems[0]; } }
private void TemplateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Selected other Slide to be pushed ! Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback) delegate { _context = (ManagerContext)DataContext; if (e.AddedItems.Count > 0 && e.AddedItems[0] is ManagerImageReference) { _lastSelectedEditorImageRef = (ManagerImageReference)e.AddedItems[0]; //_context.EditorImage = _lastSelectedEditorImageRef.Clone(); } }, null); }
private void ImageFlowList_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { try { var grid = sender as Grid; if (grid != null) { var item = grid.DataContext as DataFlowItem; if (item != null) { var m = item; //if (_context.Config.DataConfiguration.AutoCartClearTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to clear the current active cart // _context.ActiveCart.Slides.Clear(); //} //if (_context.Config.DataConfiguration.AutoCartAppendTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to append to current active cart // _context.CreateCartForDataFlowItem(m, true); //} //if (_context.Config.DataConfiguration.AutoCartGenerationTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to create a new cart // _context.CreateCartForDataFlowItem(m, false); //} if (_context.Config.DataConfiguration.AutoEditorTypes.Split(';').Contains(m.DataMessage.DataType)) { // Need to update the editor's template if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("Template")) { // Load template to editor // Find appropriate template var conf = _context.Config.DataConfiguration.DataItemConfigurations.Cast <DataItemConfiguration>().FirstOrDefault(c => c.DataType == m.DataMessage.DataType); // Load corresponding template if (conf != null) { var newTemplate = new ManagerImageReference(_context.Config) { Template = conf.DefaultTemplate, Link = _context.Config.SlidesConfiguration.DefaultLink, CanRepeate = false }; _context.EditorImage = newTemplate; } } if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("BackgroundUrl")) { // Set the background Uri _context.EditorImage.Background = m.Url; } if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("Context")) { // Set the context _context.EditorImage.Context = m.DataMessage; } _context.EditorImage.ReRender(true); _context.EditorImage = _context.EditorImage; } } } } catch (Exception) { // TODO HAndle and not generic Exceltion } }
public void OnReceive(DataMessage message) { if (_config.DataConfiguration.DataFlowTypes.Split(';').Contains(message.DataType)) { // TODO Generalize Message creation // Add the message to the data flow var d = new DataFlowItem() { DataMessage = message, Name = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).NamePath), Category = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).CategoryPath), Type = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).TypePath), Short = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).ShortPath), Priority = DataFlowPriority.Neglectable, Timestamp = DateTime.Now }; if (!string.IsNullOrEmpty(_config.DataConfiguration.GetPathByDataType(message.DataType).UrlPath)) { // Set Url if available d.Url = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).UrlPath); } SetFlowItemPriority(d); DataFlowItems.Add(d); // Cleanup while (DataFlowItems.Count > 300) { DataFlowItems.RemoveAt(0); } // Handle auto if (DataDoesAutoOnAirCart(d) && AllowOverride) { // Create the cart // CreateCartForDataFlowItem(d, false); // Put cart on air // ActiveCart = PreviewCart; // ReloadPreview(); // IsInOverrideCart = true; // OverrideProgress = 1.0; // OverrideSlideCountDown = ActiveCart.Slides.Count * OverrideRotationCount; var autoCart = Carts.FirstOrDefault(x => x.Name == "AUTO"); if (autoCart == null) { autoCart = new ManagerCart("AUTO"); Carts.Insert(0, autoCart); } // TODO NEW HANDLING if (Config.DataConfiguration.AutoCartClearTypes.Split(';').Contains(d.DataMessage.DataType)) { // Need to clear the current active cart autoCart.Slides.Clear(); } if (Config.DataConfiguration.AutoCartAppendTypes.Split(';').Contains(d.DataMessage.DataType)) { // Need to append to current active cart CreateCartForDataFlowItem(d, autoCart); } if (Config.DataConfiguration.AutoCartGenerationTypes.Split(';').Contains(d.DataMessage.DataType)) { // Need to create a new cart CreateCartForDataFlowItem(d, autoCart); } if (Config.DataConfiguration.AutoEditorTypes.Split(';').Contains(d.DataMessage.DataType)) { // Need to update the editor's template if (Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Template")) { // Load template to editor // Find appropriate template var conf = Config.DataConfiguration.DataItemConfigurations.Cast<DataItemConfiguration>().FirstOrDefault(c => c.DataType == d.DataMessage.DataType); // Load corresponding template if (conf != null) { var newTemplate = new ManagerImageReference(Config) { Template = conf.DefaultTemplate, Link = Config.SlidesConfiguration.DefaultLink, CanRepeate = false }; EditorImage = newTemplate; } } if (Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("BackgroundUrl")) { // Set the background Uri EditorImage.Background = d.Url; } if (Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Context")) { // Set the context EditorImage.Context = d.DataMessage; EditorImage.ReRender(GlobalData); } EditorImage.ReRender(true); EditorImage = EditorImage; } } } if (_config.DataConfiguration.ImageFlowTypes.Split(';').Contains(message.DataType) || (string.IsNullOrEmpty(_config.DataConfiguration.ImageFlowTypes) && message.DataType.CompareTo("IMAGE") == 0)) { // Add the message to the image flow var d = new DataFlowItem() { DataMessage = message, Name = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).NamePath), Category = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).CategoryPath), Type = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).TypePath), Short = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).ShortPath), Url = message.GetValue(_config.DataConfiguration.GetPathByDataType(message.DataType).UrlPath), Priority = DataFlowPriority.Neglectable, Timestamp = DateTime.Now }; // Handle dupplicates in http if (ImageFlowItems.Any(x => x.Timestamp > DateTime.Now.AddMinutes(-1) && x.Url == d.Url)) { // We already have it since less than a minute thus return and ignore it return; } // Handle empty names if (string.IsNullOrEmpty(d.Name)) { //Generate random name d.Name = Guid.NewGuid().ToString() + ".jpg"; } if (d.Name.StartsWith("INSTAGRAM")) { d.Name = Guid.NewGuid().ToString() + "_instagram.jpg"; } // Save the image to local folder if (d.Url.StartsWith("http")) { var filepath = Path.Combine(_config.DataConfiguration.IncomingPictureFolder, d.Name); var dli = new Thread(() => DownloadImageToLocal(d.Url, filepath)); dli.Start(); } // Set the priority according to config SetFlowItemPriority(d); // Add element to the list ImageFlowItems.Add(d); // Cleanup, keep the last 200 images only while (ImageFlowItems.Count > 200) { ImageFlowItems.RemoveAt(0); } } if (_config.DataConfiguration.DataBaseTypes.Split(';').Contains(message.DataType)) { // Add the message to the database UpdateDataBase(message); } }
public void ReloadPreview() { if (ActiveCart != null) { PreviewImage = ActiveCart.PreviewNextSlide(); // Pregenerate Preview if (PreviewImage.RegenerateOnPublish && !PreviewImage.IsValid) PreviewImage.ReRender(true); } }
public void CreateCartForDataFlowItem(DataFlowItem m, ManagerCart appentToThisCart) { var conf = Config.DataConfiguration.DataItemConfigurations.Cast<DataItemConfiguration>().FirstOrDefault(c => c.DataType == m.DataMessage.DataType); // Configure which DataTypes generate Carts //var cartName = ""; //var types = _config.DataConfiguration.AutoCartGenerationTypes.Split(';'); //if (types.Contains(m.DataMessage.DataType)) // cartName = m.DataMessage.DataType; if (conf != null) { var existingCart = Carts.FirstOrDefault(x => x.Name.ToUpper() == conf.DefaultCartName.ToUpper()); if (existingCart != null) { // TODO ASK IF Switch Cart or add to cart var newCart = existingCart.Clone(); newCart.Name = newCart.Name + " - " + m.DataMessage.GetValue("EVENTNAME"); if (newCart.Slides.Count == 1 && newCart.Slides.First().CanRepeate) { if (conf.DefaultCartName.ToUpper() == "STARTLIST") { // We might need to repeate the slide due to data and slit the context // We assume 4 line per slide // TODO This needs to be generic ! var context = m.DataMessage.Clone(); var ath = context.Data.FirstOrDefault(x => x.Key == "STARTPOSITIONS"); // Sort the list first try by int then by alpha num bool ordered = false; try { if (ath != null) { ath.Data = ath.Data.OrderBy(s => string.IsNullOrWhiteSpace(s.Key)) .ThenBy(x => Convert.ToInt32("0" + x.Key)) .ToList(); ordered = true; } } catch (Exception) { // TODO Log } if (!ordered) { // Try alpha order try { if (ath != null) { ath.Data = ath.Data.OrderBy(s => string.IsNullOrWhiteSpace(s.Key)) .ThenBy(x => x.Key) .ToList(); } } catch (Exception) { // TODO Log } } newCart.Slides.First().Context = context; newCart.Slides.First().ReRender(GlobalData); var itemsPerSlide = newCart.Slides.First().ItemsPerSlide; var offset = itemsPerSlide; while (ath != null && ath.Data.Count > itemsPerSlide) { var clone = ath.Clone(); clone.Data.RemoveRange(0, itemsPerSlide); ath.Data.RemoveRange(itemsPerSlide, ath.Data.Count - itemsPerSlide); var newSlide = newCart.Slides.First().Clone(); newSlide.IndexOffset = offset; var contextClone = context.Clone(); contextClone.Data.First(x => x.Key == "STARTPOSITIONS").Data = clone.Data; newSlide.Context = contextClone; newSlide.ReRender(GlobalData); newCart.Slides.Add(newSlide); ath = clone; offset = offset + itemsPerSlide; } } else if (conf.DefaultCartName.ToUpper() == "RESULTLIST") { // We might need to repeate the slide due to data and slit the context // We assume 4 line per slide // TODO This needs to be generic ! var context = m.DataMessage.Clone(); var ath = context.Data.FirstOrDefault(x => x.Key == "RESULTS"); // Sort the list first try by int then by alpha num bool ordered = false; try { if (ath != null) { ath.Data = ath.Data.OrderBy(s => string.IsNullOrWhiteSpace(s.Key)) .ThenBy(x => Convert.ToInt32("0" + x.Key)) .ToList(); ordered = true; } } catch (Exception) { // TODO Log } if (!ordered) { // Try alpha order try { if (ath != null) { ath.Data = ath.Data.OrderBy(s => string.IsNullOrWhiteSpace(s.Key)) .ThenBy(x => x.Key) .ToList(); } } catch (Exception) { // TODO Log } } newCart.Slides.First().Context = context; newCart.Slides.First().ReRender(GlobalData); var itemsPerSlide = newCart.Slides.First().ItemsPerSlide; var offset = itemsPerSlide; while (ath != null && ath.Data.Count > itemsPerSlide) { var clone = ath.Clone(); clone.Data.RemoveRange(0, itemsPerSlide); ath.Data.RemoveRange(itemsPerSlide, ath.Data.Count - itemsPerSlide); var newSlide = newCart.Slides.First().Clone(); newSlide.IndexOffset = offset; var contextCLone = context.Clone(); contextCLone.Data.First(x => x.Key == "RESULTS").Data = clone.Data; newSlide.Context = contextCLone; newSlide.ReRender(GlobalData); newCart.Slides.Add(newSlide); ath = clone; offset = offset + itemsPerSlide; } } else { // Set Context for all slides var context = m.DataMessage.Clone(); foreach (var s in newCart.Slides) { s.Context = context; s.ReRender(GlobalData); } } } else { foreach (var s in newCart.Slides) { // Set the context on all slides s.Context = m.DataMessage; s.ReRender(GlobalData); } } if (appentToThisCart != null) { // Append i.e. merge to current foreach (var s in newCart.Slides) { // Add to open cart (not the currently active one) appentToThisCart.Slides.Add(s); } } else { // Generate new cart otherwise Carts.Add(newCart); PreviewCart = newCart; } } else { // No Cart, try with template only if (!string.IsNullOrEmpty(conf.DefaultTemplate)) { // Create new ImageRef var newImgRef = new ManagerImageReference(Config) { Template = conf.DefaultTemplate, Link = Config.SlidesConfiguration.DefaultLink, Context = m.DataMessage, CanRepeate = false }; // Handle if (appentToThisCart != null) { // Add to open cart (not the currently active one) appentToThisCart.Slides.Add(newImgRef); } else { var newCart = new ManagerCart("TEMP " + conf.DataType); newCart.Slides.Add(newImgRef); Carts.Add(newCart); PreviewCart = newCart; } } } } else { // No cart defined for that event type } }
public void LoadCarts(bool loadAll, bool cleanReload) { if (cleanReload) { // Cleanup existing Carts.Clear(); } foreach (CartConfiguration cart in _config.SlidesConfiguration.CartConfigurations) { if (loadAll || Carts.Count(x => x.Name == cart.Name) == 0) { var c = new ManagerCart(cart.Name) { CanBeDeleted = false, ShowInCartList = cart.ShowInCartList }; Carts.Add(c); foreach (SlideConfiguration s in cart.Slides) { var sl = new ManagerImageReference(_config) { Template = s.Filename, Link = s.DefaultLink, Text = s.DefaultText, RegenerateOnPublish = s.RegenerateOnPublish, ValidityPeriod = TimeSpan.FromSeconds(s.ValidityPeriodSeconds), CanRepeate = s.CanRepeat, ItemsPerSlide = s.ItemsPerSlide, Context = new DataMessage() }; c.Slides.Add(sl); } if (cart.Active) { // Set current cart as active ActiveCart = c; PreviewCart = c; } if (cart.EditorDefault) { // Set current editor cart EditorCart = c; } } } }
public void AddEditorTemplate(string path) { var newTemplate = new ManagerImageReference(_config) { Template = path, Link = _config.SlidesConfiguration.DefaultLink, CanRepeate = false }; EditorCart.Slides.Add(newTemplate); }
public void AddSlides(List<string> slideNames) { // For all slide names foreach (var slideName in slideNames) { // Find Slides that match that name foreach (CartConfiguration cart in _config.SlidesConfiguration.CartConfigurations) { foreach (SlideConfiguration s in cart.Slides) { if (s.Filename.StartsWith(slideName)) { var sl = new ManagerImageReference(_config) { Template = s.Filename, Link = s.DefaultLink, Text = s.DefaultText, RegenerateOnPublish = s.RegenerateOnPublish, ValidityPeriod = TimeSpan.FromSeconds(s.ValidityPeriodSeconds), CanRepeate = s.CanRepeat, ItemsPerSlide = s.ItemsPerSlide, Context = new DataMessage() }; // Add the slide to the active cart ActiveCart.Slides.Add(sl); } } } } }
public void SwitchToSlide(ManagerImageReference newImage) { // We can switch to the next one. ActiveCart.SetAllSlidesInactive(); MainImage = newImage; newImage.IsActive = true; ReloadPreview(); }
private void DataFlowList_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { var grid1 = sender as Grid; if (grid1 != null) { var grid = grid1; var item = grid.DataContext as DataFlowItem; if (item != null) { var m = item; //if (_context.Config.DataConfiguration.AutoCartClearTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to clear the current active cart // _context.ActiveCart.Slides.Clear(); //} if (_context.Config.DataConfiguration.AutoCartAppendTypes.Split(';').Contains(m.DataMessage.DataType)) { // Need to append to current active cart _context.CreateCartForDataFlowItem(m, _context.PreviewCart); } if (_context.Config.DataConfiguration.AutoCartGenerationTypes.Split(';').Contains(m.DataMessage.DataType)) { // Need to create a new cart _context.CreateCartForDataFlowItem(m, null); } if (_context.Config.DataConfiguration.AutoEditorTypes.Split(';').Contains(m.DataMessage.DataType)) { // Need to update the editor's template if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Template")) { // Load template to editor // Find appropriate template var conf = _context.Config.DataConfiguration.DataItemConfigurations.Cast <DataItemConfiguration>().FirstOrDefault(c => c.DataType == m.DataMessage.DataType); // Load corresponding template if (conf != null) { var newTemplate = new ManagerImageReference(_context.Config, _context) { Template = conf.DefaultTemplate, Link = _context.Config.SlidesConfiguration.DefaultLink, CanRepeate = false }; _context.EditorImage = newTemplate; } } if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("BackgroundUrl")) { // Set the background Uri _context.EditorImage.Background = m.Url; } if (_context.Config.DataConfiguration.DataFlowLeftActions.Split(';').Contains("Context")) { // Set the context _context.EditorImage.Context = m.DataMessage; } _context.EditorImage.ReRender(true); _context.EditorImage = _context.EditorImage; } } } } catch (Exception ex) { // TODO HAndle and not generic Exceltion using (EventLog eventLog = new EventLog("Application")) { eventLog.Source = "Application"; eventLog.WriteEntry($"EIS Content Manager unable to handle MouseLeftButton Down on data.\n{ex.Message}\n\n{ex.StackTrace}", EventLogEntryType.Error, 101, 1); } } }
private void TemplateListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Selected other Slide to be pushed ! Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (e.AddedItems.Count > 0 && e.AddedItems[0] is ManagerImageReference) { _lastSelectedEditorImageRef = (ManagerImageReference)e.AddedItems[0]; //_context.EditorImage = _lastSelectedEditorImageRef.Clone(); } }, null); }
private void PreviewListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0 && e.AddedItems[0] is ManagerImageReference) { _lastSelectedManagerImageRef = (ManagerImageReference)e.AddedItems[0]; } }
private void ImageFlowList_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { try { var grid = sender as Grid; if (grid != null) { var item = grid.DataContext as DataFlowItem; if (item != null) { var m = item; //if (_context.Config.DataConfiguration.AutoCartClearTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to clear the current active cart // _context.ActiveCart.Slides.Clear(); //} //if (_context.Config.DataConfiguration.AutoCartAppendTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to append to current active cart // _context.CreateCartForDataFlowItem(m, true); //} //if (_context.Config.DataConfiguration.AutoCartGenerationTypes.Split(';').Contains(m.DataMessage.DataType)) //{ // // Need to create a new cart // _context.CreateCartForDataFlowItem(m, false); //} if (_context.Config.DataConfiguration.AutoEditorTypes.Split(';').Contains(m.DataMessage.DataType)) { // Need to update the editor's template if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("Template")) { // Load template to editor // Find appropriate template var conf = _context.Config.DataConfiguration.DataItemConfigurations.Cast<DataItemConfiguration>().FirstOrDefault(c => c.DataType == m.DataMessage.DataType); // Load corresponding template if (conf != null) { var newTemplate = new ManagerImageReference(_context.Config) { Template = conf.DefaultTemplate, Link = _context.Config.SlidesConfiguration.DefaultLink, CanRepeate = false }; _context.EditorImage = newTemplate; } } if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("BackgroundUrl")) { // Set the background Uri _context.EditorImage.Background = m.Url; } if (_context.Config.DataConfiguration.ImageFlowRightActions.Split(';').Contains("Context")) { // Set the context _context.EditorImage.Context = m.DataMessage; } _context.EditorImage.ReRender(true); _context.EditorImage = _context.EditorImage; } } } } catch (Exception) { // TODO HAndle and not generic Exceltion } }