Exemple #1
0
        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, _synLock1);
            BindingOperations.EnableCollectionSynchronization(_context.ImageFlowItems, _synLock2);
            BindingOperations.EnableCollectionSynchronization(_context.DataFlowItems, _synLock3);


            // 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();
        }
Exemple #2
0
        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();
        }