public MainWindow() { //Global Exception Handling var currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += GlobalExceptionHandler; InitializeComponent(); // Window Title var currentAssembly = Assembly.GetExecutingAssembly(); string versionNumber = currentAssembly.GetName().Version.ToString(); Title = Title + " (" + versionNumber + ")"; _context = (ManagerContext)DataContext; //Enable the cross acces to this collection elsewhere BindingOperations.EnableCollectionSynchronization(_context.Carts, _synLock); // Start Processes _running = true; var t1 = new Thread(AutoProcessing); t1.Start(); // Standalone no DataItemConfigurations Settings if (_context?.Config?.DataConfiguration?.DataItemConfigurations.Count == 0) { // Column 4 is the data column - would be changed back if any layout stored HorizontalSystemGrid.ColumnDefinitions[4].Width = new GridLength(0.0); // Also hide Data Buttons and Bar autoDataButton.Visibility = Visibility.Hidden; dataOverrideInterval.Visibility = Visibility.Hidden; dataOverrideProgress.Visibility = Visibility.Hidden; // Start Watchfolder if incoming picture defined if (!string.IsNullOrEmpty(_context.Config.DataConfiguration.IncomingPictureFolder)) { _imageWatchFolder = new SystemWatchfolder(_context.Config.DataConfiguration.IncomingPictureFolder, "*.jpg|*.png|*.gif", false, _context); _imageWatchFolder.Start(); } } // Restore RestoreLayout(); }
private void onAirPreviewCartButton_Click(object sender, RoutedEventArgs e) { _context = (ManagerContext)DataContext; if (_context.PreviewCart.Slides.Count > 0) { _context.ActiveCart = _context.PreviewCart; _context.ReloadPreview(); } else { // TODO Error } }
private void newCartButton_Click(object sender, RoutedEventArgs e) { _context = (ManagerContext)DataContext; var name = NewCartWindow.Show(this); if (!string.IsNullOrEmpty(name)) { var c = new ManagerCart(name) { CanBeDeleted = true, ShowInCartList = true }; _context.Carts.Add(c); _context.PreviewCart = c; } }
private void mainImg_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2) { // Copy public URL to Clipboard Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { try { _context = (ManagerContext)DataContext; if (_context.MainImage != null) Clipboard.SetText(_context.MainImage.PublicImageUrl); } catch (Exception) { // TODO Log } }, null); } }
private void ListBox_KeyDown(object sender, KeyEventArgs e) { // Remove the last selected Cart from the list if (e.Key == Key.Delete) { _context = (ManagerContext)DataContext; if (_lastSelectedCart != null) { if (_context.Carts.Contains(_lastSelectedCart)) { _context.Carts.Remove(_lastSelectedCart); } } } }
private void AutoProcessing() { while (_running) { lock (_synLock) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; // Automation Mode and Slide change if (_context.InAutomationMode) { if (_lastAutomationChange.AddSeconds(_context.AutomationInterval) < DateTime.Now) { // Switch to next slide if in Automation _context.SwitchToNextSlide(); _lastAutomationChange = DateTime.Now; _context.AutomationProgress = 1.0; } // Update internal values progresses var millisToNextChange = Math.Max(0, _lastAutomationChange.AddSeconds(_context.AutomationInterval).Subtract(DateTime.Now).TotalMilliseconds); _context.AutomationProgress = (0.0 + millisToNextChange) / (_context.AutomationInterval * 1000); if (_context.IsInOverrideCart) { _context.OverrideProgress = (0.0 + millisToNextChange + 1000 * _context.OverrideSlideCountDown * _context.AutomationInterval) / (_context.OverrideRotationCount * _context.ActiveCart.Slides.Count * _context.AutomationInterval * 1000); } } else { _context.AutomationProgress = 0.0; } // Override Mode and Back to INITIAL Cart if (_context.IsInOverrideCart && _context.OverrideSlideCountDown == 0) { var initCart = _context.Carts.FirstOrDefault(x => x.Name == "INITIAL"); if (initCart != null) { _context.ActiveCart = initCart; _context.IsInOverrideCart = false; _context.ReloadPreview(); } _context.OverrideProgress = 0.0; } DataContext = _context; }, null); Monitor.Wait(_synLock, 100); } } }
private void TemplateListBox_Drop(object sender, DragEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) { string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (droppedFilePaths != null) foreach (var path in droppedFilePaths) { if (path.EndsWith(".html")) { // Add the template as slide to the Templates list _context.AddEditorTemplate(path); } } } }, null); }
private void rendreButtonTest_Click(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (_context.EditorImage != null) { _context.EditorImage.ReRender(true); _context.EditorImage = _context.EditorImage; } }, null); }
private void DataFlowList_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { // Reset the preview cart to the active cart _context = (ManagerContext)DataContext; if (_context.ActiveCart != _context.PreviewCart) { _context.PreviewCart = _context.ActiveCart; } } }
private void clearAllCartsButton_Click(object sender, RoutedEventArgs e) { _context = (ManagerContext)DataContext; while (_context.Carts.Count(x => x.CanBeDeleted && x != _context.ActiveCart && x != _context.PreviewCart) > 0) { var todelCart = _context.Carts.FirstOrDefault(x => x.CanBeDeleted && x != _context.ActiveCart && x != _context.PreviewCart); if (todelCart != null) { _context.Carts.Remove(todelCart); } } }
private void ClearImageFlowFilter_Click(object sender, RoutedEventArgs e) { _context = (ManagerContext)DataContext; _context.ImageFlowFilterString = ""; }
private void CartListBox_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2 && e.LeftButton == MouseButtonState.Pressed) { // Selected other Slide to be pushed ! Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (_lastSelectedCart != null) { _context.PreviewCart = _lastSelectedCart; _context.ReloadPreview(); } }, null); e.Handled = true; } }
private void CartListBox_Drop(object sender, DragEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) { string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (droppedFilePaths != null) foreach (var path in droppedFilePaths) { if (path.EndsWith(".cartjson")) { var json = File.ReadAllText(path); try { var newCart = JsonSerializer.Deserialize<ManagerCart>(json); newCart.CanBeDeleted = true; newCart.ShowInCartList = true; newCart.IsActive = false; foreach (var s in newCart.Slides) s.Config = _context.Config; _context.Carts.Add(newCart); } catch (Exception) { // TODO LOG } } } } }, null); }
private void cancelPreviewCartButton_Click(object sender, RoutedEventArgs e) { _context = (ManagerContext)DataContext; _context.PreviewCart = _context.ActiveCart; _context.ReloadPreview(); }
private void PreviewListBox_KeyDown(object sender, KeyEventArgs e) { // Remove the last selected Slide from the active Cart if (e.Key == Key.Delete) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (_lastSelectedManagerImageRef != null) { if (_context.PreviewCart.Slides.Contains(_lastSelectedManagerImageRef) && _context.PreviewCart.Slides.Count > 1) { _context.PreviewCart.Slides.Remove(_lastSelectedManagerImageRef); _context.ReloadPreview(); } } }, null); } }
private void editorAddButtonAndMain_Click(object sender, RoutedEventArgs e) { // Add the image to the current Active Cart and set it active Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { if (_context.EditorImage != null) { _context = (ManagerContext)DataContext; var newImg = _context.EditorImage.Clone(); _context.PreviewCart.Slides.Add(newImg); _context.ReloadPreview(); _lastAutomationChange = DateTime.Now; _context.SwitchToSlide(newImg); } }, null); }
private void PreviewListBox_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount == 2 && e.LeftButton == MouseButtonState.Pressed) { // Selected other Slide to be pushed ! Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (_lastSelectedManagerImageRef != null) { _lastAutomationChange = DateTime.Now; _context.SwitchToSlide(_lastSelectedManagerImageRef); } }, null); } if (e.ClickCount == 1 && e.RightButton == MouseButtonState.Pressed) { // Right mouse click, to edit _context = (ManagerContext)DataContext; if (_lastSelectedManagerImageRef != null) { _context.EditorImage = _lastSelectedManagerImageRef; } } }
private void editorAddButton_Click(object sender, RoutedEventArgs e) { // Add the image to the current Active Cart Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; _context.PreviewCart.Slides.Add(_context.EditorImage.Clone()); _context.ReloadPreview(); }, null); }
public void CtxMenu_SaveCart(object sender, ExecutedRoutedEventArgs e) { _context = (ManagerContext)DataContext; var item = e.OriginalSource as ListBoxItem; if (item != null) { var lbi = item; var managerCart = lbi.Content as ManagerCart; if (managerCart != null) { var cart = managerCart; SaveFileDialog dlg = new SaveFileDialog { FileName = cart.Name, DefaultExt = ".cartjson", Filter = "Cart JSON File (.cartjson)|*.cartjson" }; bool? result = dlg.ShowDialog(); if (result == true) { string filename = dlg.FileName; var json = JsonSerializer.Serialize(cart); File.WriteAllText(filename, json); } } } }
private void ImageFlowList_Drop(object sender, DragEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Render, (SendOrPostCallback)delegate { _context = (ManagerContext)DataContext; if (e.Data.GetDataPresent(DataFormats.FileDrop, true)) { string[] droppedFilePaths = e.Data.GetData(DataFormats.FileDrop, true) as string[]; if (droppedFilePaths != null) foreach (var path in droppedFilePaths) { _context.IngestImage(path); } } }, null); }
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 Window_Closing(object sender, CancelEventArgs e) { // Stop Watchfolder _imageWatchFolder.Start(); _context = (ManagerContext)DataContext; _running = false; lock (_synLock) { Monitor.PulseAll(_synLock); } _context.Dispose(); _context.SerializeToFile(); }