Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode service.
 /// </param>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public LogViewModel(IEncode encodeService, IScan scanService)
 {
     this.encodeService  = encodeService;
     this.scanService    = scanService;
     this.Title          = "Log Viewer";
     this.encodeLogIndex = 0;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanServiceWrapper"/> class.
 /// </summary>
 /// <param name="userSettingService">
 /// The user Setting Service.
 /// </param>
 public ScanServiceWrapper(IUserSettingService userSettingService)
 {
     this.scanService = new LibScan(userSettingService);
     this.scanService.ScanCompleted     += this.ScanServiceScanCompleted;
     this.scanService.ScanStared        += this.ScanServiceScanStared;
     this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 /// <param name="windowManager">
 /// The window manager.
 /// </param>
 /// <param name="encodeService">
 /// The encode service.
 /// </param>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public LogViewModel(IWindowManager windowManager, IEncode encodeService, IScan scanService)
 {
     this.encodeService = encodeService;
     this.scanService   = scanService;
     this.Title         = "Log Viewer";
     this.SelectedMode  = 0;
 }
        public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService, IErrorService errorService, ILog logService, ILogInstanceManager logInstanceManager, IPortService portService)
        {
            this.scanService = scanService;
            this.selectedPreviewImage = 1;
            this.Title = Resources.Preview;
            this.PreviewNotAvailable = true;

            // Live Preview
            this.userSettingService = userSettingService;
            this.errorService = errorService;
            this.logService = logService;
            this.logInstanceManager = logInstanceManager;
            this.portService = portService;

            this.Title = "Preview";
            this.Percentage = "0.00%";
            this.PercentageValue = 0;
            this.Duration = 30;
            this.CanPlay = true;

            this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
            this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration);
            this.previewRotateFlip = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewRotationFlip);
            this.NotifyOfPropertyChange(() => this.previewRotateFlip); // Don't want to trigger an Update, so setting the backing variable.
        }
Esempio n. 5
0
File: Term.cs Progetto: SaberMK/BiBi
        public bool IsSatisfied(IScan scan)
        {
            var left  = _left.Evaluate(scan);
            var right = _right.Evaluate(scan);

            return(right == left);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode service.
 /// </param>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public LogViewModel(IEncode encodeService, IScan scanService)
 {
     this.encodeService = encodeService;
     this.scanService = scanService;
     this.Title = "Log Viewer";
     this.SelectedMode = 0;
 }
Esempio n. 7
0
 public ScanDisplayItem(IScan scan)
 {
     ScanNumber = scan.ScanNumber;
     CTDI = scan.CTDI;
     DLP = scan.DLP;
     Weight = scan.Weight;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LogViewModel"/> class.
 /// </summary>
 /// <param name="encodeService">
 /// The encode service.
 /// </param>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public LogViewModel(IEncode encodeService, IScan scanService)
 {
     this.encodeService = encodeService;
     this.scanService = scanService;
     this.Title = "Log Viewer";
     this.encodeLogIndex = 0;
 }
 /// <summary>
 /// Scan a file for viruses
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='inputFile'>
 /// Input file to perform the operation on.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <FileOKResponse> FileAsync(this IScan operations, System.IO.Stream inputFile, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.FileWithHttpMessagesAsync(inputFile, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Esempio n. 10
0
 // Notice how the dependencies are injected through constructor (constructor dependency injection)
 public Machine(IPrinter printer, IFax fax, IScan scan, IPhotoCopy photocopy, IStaple staple)
 {
     this.Printer   = printer;
     this.Faxer     = fax;
     this.Scanner   = scan;
     this.Photocopy = photocopy;
     this.Stapler   = staple;
 }
            // decorator pattern
            public MultiFunctionMachine(IPrint printer, IScan scanner)
            {
                this._printer = printer ?? throw new ArgumentNullException(nameof(printer));
                this._scanner = scanner ?? throw new ArgumentNullException(nameof(scanner));

                this._scanner = scanner;
                this._printer = printer;
            }
Esempio n. 12
0
 public ScanShipBarCodeForm()
 {
     InitializeComponent();
     // 初始化扫描设备
     scanManager = ScanFactory.CreateScan();
     scanManager.Init();
     scanManager.AttachScanNotify(ScanNotifyHandler);
 }
 public POSTerminalService()
 {
     _calculatorService           = new CalculatorService();
     _createProductDetailsService = new CreateProductDetailsService();
     _productDiscountService      = new ProductDiscountService();
     _scanService    = new ScanService();
     _receiptService = new ReceiptService();
     _paymentService = new PaymentService(_paymentProcessor);
 }
 public DynamoDbController(IGetItem getItem, IPutItem putItem, IUpdateItem updateItem, IDeleteItem deleteItem, IQuery queryItem, IScan scanItem)
 {
     _getItem    = getItem;
     _putItem    = putItem;
     _updateItem = updateItem;
     _deleteItem = deleteItem;
     _queryItem  = queryItem;
     _scanItem   = scanItem;
 }
Esempio n. 15
0
 public bool IsSatisfied(IScan scan)
 {
     foreach (var term in _terms)
     {
         if (!term.IsSatisfied(scan))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 16
0
        public ScanDetailsView(IScan scan, string computerName, ITreeService treeService = null)
        {
            InitializeComponent();

            // IOC injection
            treeService = treeService ?? new TreeService();

            TreScan.Nodes.Clear();
            LblScanTitle.Text = $"Computer: {computerName ?? string.Empty} | Scan: {scan.Id.ToString()} from {scan.ScanDate.ToString("dd-MM-yyyy HH:mm")}";
            treeService.BuildTree(TreScan, scan);
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.Domain                = new Domain(this);
     this.Email                 = new Email(this);
     this.IPAddress             = new IPAddress(this);
     this.ExtractEntitiesString = new ExtractEntitiesString(this);
     this.LanguageDetection     = new LanguageDetection(this);
     this.ParseString           = new ParseString(this);
     this.PosTaggerJson         = new PosTaggerJson(this);
     this.PosTaggerString       = new PosTaggerString(this);
     this.Sentences             = new Sentences(this);
     this.SpellCheck            = new SpellCheck(this);
     this.Words                 = new Words(this);
     this.ImageOcr              = new ImageOcr(this);
     this.BarcodeLookup         = new BarcodeLookup(this);
     this.GenerateBarcode       = new GenerateBarcode(this);
     this.Face             = new Face(this);
     this.Nsfw             = new Nsfw(this);
     this.Recognize        = new Recognize(this);
     this.Resize           = new Resize(this);
     this.ConvertData      = new ConvertData(this);
     this.ConvertDocument  = new ConvertDocument(this);
     this.ConvertImage     = new ConvertImage(this);
     this.ConvertTemplate  = new ConvertTemplate(this);
     this.ConvertWeb       = new ConvertWeb(this);
     this.Scan             = new Scan(this);
     this.BaseUri          = new Uri("https://api.cloudmersive.com");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PrePostActionService"/> class.
        /// </summary>
        /// <param name="queueProcessor">
        /// The queue processor.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        public PrePostActionService(IQueueService queueProcessor, IUserSettingService userSettingService, IWindowManager windowManager, IScan scanService)
        {
            this.queueProcessor     = queueProcessor;
            this.userSettingService = userSettingService;
            this.windowManager      = windowManager;
            this.scanService        = scanService;

            this.queueProcessor.QueueCompleted += QueueProcessorQueueCompleted;
            this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted;
            this.queueProcessor.EncodeService.EncodeStarted   += EncodeService_EncodeStarted;
        }
Esempio n. 19
0
        public MultiCopyFunctional(IPrint print, IScan scan, ICopy copy)
        {
            print = print ?? throw new ArgumentNullException(nameof(print));
            scan  = scan ?? throw new ArgumentNullException(nameof(scan));
            copy  = copy ?? throw new ArgumentNullException(nameof(copy));


            this.print = print;
            this.scan  = scan;
            this.copy  = copy;
        }
Esempio n. 20
0
        /* Constructor */
        /// <summary>
        /// Initializes a new instance of the <see cref="frmActivityWindow"/> class.
        /// </summary>
        /// <param name="encode">
        /// The encode.
        /// </param>
        /// <param name="scan">
        /// The scan.
        /// </param>
        public frmActivityWindow(IEncode encode, IScan scan)
        {
            InitializeComponent();

            this.encode = encode;
            this.scan = scan;
            this.position = 0;

            // Listen for Scan and Encode Starting Events
            scan.ScanStared += scan_ScanStared;
            encode.EncodeStarted += encode_EncodeStarted;
        }
Esempio n. 21
0
        public PrePostActionService(IQueueService queueProcessor, IUserSettingService userSettingService, IWindowManager windowManager, IScan scanService, ILog logService)
        {
            this.log = logService;
            this.userSettingService = userSettingService;
            this.windowManager      = windowManager;
            this.scanService        = scanService;

            queueProcessor.QueueCompleted       += this.QueueProcessorQueueCompleted;
            queueProcessor.QueuePaused          += this.QueueProcessor_QueuePaused;
            queueProcessor.EncodeCompleted      += this.EncodeService_EncodeCompleted;
            queueProcessor.JobProcessingStarted += this.EncodeService_EncodeStarted;
        }
Esempio n. 22
0
        /* Constructor */

        /// <summary>
        /// Initializes a new instance of the <see cref="frmActivityWindow"/> class.
        /// </summary>
        /// <param name="encode">
        /// The encode.
        /// </param>
        /// <param name="scan">
        /// The scan.
        /// </param>
        public frmActivityWindow(IEncode encode, IScan scan)
        {
            InitializeComponent();

            this.encode   = encode;
            this.scan     = scan;
            this.position = 0;

            // Listen for Scan and Encode Starting Events
            scan.ScanStared      += scan_ScanStared;
            encode.EncodeStarted += encode_EncodeStarted;
        }
Esempio n. 23
0
 public SuperMegaPrinterMachine(
     IPrinter printer,
     IScan scanner,
     IStaple stapler,
     IFax fax,
     ICopy copier)
 {
     _printer = printer;
     _scanner = scanner;
     _stapler = stapler;
     _fax     = fax;
     _copier  = copier;
 }
Esempio n. 24
0
 public SuperMegaPrinterMachine(
     IPrinter printer,
     IScan scanner,
     IStaple stapler,
     IFax fax,
     ICopy copier)
 {
     _printer = printer;
     _scanner = scanner;
     _stapler = stapler;
     _fax = fax;
     _copier = copier;
 }
Esempio n. 25
0
 private void initmain()
 {
     ilaser          = formlist[2] as Ilaser;
     icv             = new CvMeasure();
     i840d           = formlist[3] as I840D;
     iscan           = formlist[1] as IScan;
     iMachParahandle = formlist[0] as IMachParahandle;
     CV840Dmotion();
     timermain.Enabled = true;
     timersub.Enabled  = true;
     currentstatus     = "init";
     iMachParahandle.richboxclear();
 }
Esempio n. 26
0
 /** Build Treeview*/
 public void BuildTree(TreeView tv, IScan scan)
 {
     foreach (IScanInformationGroup sig in scan.ScanInformationGroup.OrderBy(g => g.Type))
     {
         var treeNode = new TreeNode(sig.ToString());
         treeNode.ForeColor = Color.White;
         treeNode.Expand();
         var propertiesSorted = sig.Properties.OrderBy(p => p.Name).ToList();
         foreach (IScanInformation si in propertiesSorted)
         {
             var childNode = new TreeNode(si.ToString());
             childNode.ForeColor = Color.White;
             treeNode.Nodes.Add(childNode);
         }
         tv.Nodes.Add(treeNode);
     }
 }
Esempio n. 27
0
        public ScanCompareView(IScan leftScan, IScan rightScan, string computerNameLeft, string computerNameRight, ITreeService treeService = null)
        {
            InitializeComponent();

            // IOC injection
            treeService = treeService ?? new TreeService();

            TreLeft.Nodes.Clear();
            TreRight.Nodes.Clear();

            LblScanTitleLeft.Text  = $"Computer: {computerNameLeft ?? string.Empty} | Scan: {leftScan.Id.ToString()} from {leftScan.ScanDate.ToString("dd-MM-yyyy HH:mm")}";
            LblScanTitleRight.Text = $"Computer: {computerNameRight ?? string.Empty} | Scan: {rightScan.Id.ToString()} from {rightScan.ScanDate.ToString("dd-MM-yyyy HH:mm")}";

            // Build the tree structures
            treeService.BuildTree(TreLeft, leftScan);
            BuildCompareTree(TreRight, leftScan, rightScan);
        }
Esempio n. 28
0
        public FormDetails(IScan scan)
        {
            Scan = scan;

            InitializeComponent();

            switch (Scan)
            {
            case FileScan fileScan:
                InitializeFileScanContol(fileScan);
                break;

            case UrlScan urlScan:
                InitializeUrlScanContol(urlScan);
                break;
            }
        }
Esempio n. 29
0
        void handleOperation4(IList <MPI.Request> reqList_complete)
        {
            int[] arg1_values = new int[channel.RemoteSize];
            int[] arg2_values = new int[channel.RemoteSize];
            int[] arg3_values = new int[channel.RemoteSize];
            int[] arg4_values = new int[channel.RemoteSize];
            int[] arg5_values = new int[channel.RemoteSize];
            int[] arg6_values = new int[channel.RemoteSize];

            foreach (MPI.Request req in reqList_complete)
            {
                MPI.ReceiveRequest  recv_req = (MPI.ReceiveRequest)req;
                MPI.CompletedStatus status   = recv_req.Test();
                Tuple <int, int, int, int, int, int> value = (Tuple <int, int, int, int, int, int>)recv_req.GetValue();
                arg1_values [status.Source] = value.Item1;
                arg2_values [status.Source] = value.Item2;
                arg3_values [status.Source] = value.Item3;
                arg4_values [status.Source] = value.Item4;
                arg5_values [status.Source] = value.Item5;
                arg6_values [status.Source] = value.Item6;
            }

            IGather <int> arg1 = Gather <int> .create(channel, arg1_values);

            IReduce <int> arg2 = Reduce <int> .create(channel, arg2_values, sum, 0);

            IScan <int> arg3 = Scan <int> .create(channel, arg3_values, sum, 0);

            IGather <int> arg4 = Gather <int> .create(channel, arg4_values);

            IReduce <int> arg5 = Reduce <int> .create(channel, arg5_values, sum, 0);

            IScan <int> arg6 = Scan <int> .create(channel, arg6_values, sum, 0);

            int result = service.some_method_4(arg1, arg2, arg3, arg4, arg5, arg6);

            int[] broadcast_result = new int[channel.RemoteSize];
            for (int i = 0; i < broadcast_result.Length; i++)
            {
                broadcast_result [i] = result;
            }

            returnResult(broadcast_result, OPERATION_4);
        }
Esempio n. 30
0
        public FormDetection(IScan scan)
        {
            InitializeComponent();
            Scan = scan;
            InitializeDetectionListView();

            switch (scan)
            {
            case FileScan fileScan:
                InitializeFileScanList();
                SettingDetectionList(fileScan);
                break;

            case UrlScan urlScan:
                InitializeUrlScanList();
                SettingDetectionList(urlScan);
                break;
            }
        }
        /// <summary>
        /// Start the service
        /// </summary>
        /// <param name="port">
        /// The port.
        /// </param>
        public void Start(string port)
        {
            using (host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))
            {
                // Setup a listener
                host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");
                host.Open();
                Console.WriteLine("::: HandBrake Isolation Server - Debug Console:::");
                Console.WriteLine("Service Started. Waiting for Clients...");

                // Setup the services we are going to use.
                IHandBrakeInstance instance = new HandBrakeInstance();
                scanService   = new LibScan(instance);
                encodeService = new LibEncode(new UserSettingService(), instance); // TODO this needs wired up with castle

                shutdownFlag = new ManualResetEvent(false);
                shutdownFlag.WaitOne();
            }
        }
        //ISystemic
        //тип сенгментації

        //-------------------------------------------------------Constructor(string)------------------
        public PhysicalDrive(string driveName)
        {
            const uint SectorSize = 512;

            byte[] buff = new byte[512];
            uint   nBytesRead;

            name = driveName;
            SafeFileHandle shFile = WinApi.CreateFile(driveName, FileAccess.Read, FileShare.Read, (IntPtr)0, FileMode.Open, 0, (IntPtr)0);

            if (shFile.IsInvalid)
            {
                throw new DriveNotFoundException("Drive" + driveName + "is not avalible");
            }

            WinApi.ReadFile(shFile, buff, SectorSize, out nBytesRead, (IntPtr)0);
            if (shFile.IsInvalid)
            {
                throw new InvalidDataException("Reading data form " + driveName + " is not avalible");
            }

            //---------------------------------------------------
            MBR protectiveMbr = new MBR(buff);

            if (protectiveMbr.isProtective())
            {
                Scanner = new GPTScan(name);
            }
            else
            {
                Scanner = new MBRScan(name);
            }
            //---------------------------------------------------

            //---------------------------------------------------
            for (int i = 0; i < Scanner.Length; i++)
            {
                volumes.Add(new Volume(driveName, Scanner[i]));
            }
            //---------------------------------------------------

            shFile.Close();
        }
Esempio n. 33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        public MainViewModel()
        {
            // Setup Services
            this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
        /// </summary>
        /// <param name="scanService">
        /// The scan service.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService)
        {
            this.scanService          = scanService;
            this.selectedPreviewImage = 1;
            this.Title = Properties.Resources.Preview;
            this.PreviewNotAvailable = true;

            // Live Preview
            this.userSettingService = userSettingService;
            this.encodeService      = new EncodeServiceWrapper(userSettingService); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point

            this.Title           = "Preview";
            this.Percentage      = "0.00%";
            this.PercentageValue = 0;
            this.Duration        = 30;
            this.CanPlay         = true;

            UseSystemDefaultPlayer = userSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer);
            this.Duration          = userSettingService.GetUserSetting <int>(UserSettingConstants.LastPreviewDuration);
        }
Esempio n. 35
0
        public MainViewModel(IWindowManager windowManager) : base(windowManager)
        {
            // Setup Services (TODO - Bring Castle back into the project to wire these up for us)
            this.scanService    = File.Exists("hb.dll") ? (IScan) new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
            this.presetService  = new PresetService();

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared        += this.ScanStared;
            this.scanService.ScanCompleted     += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused    += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted       += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 36
0
        public MainViewModel(IWindowManager windowManager) : base(windowManager) 
        {
            // Setup Services (TODO - Bring Castle back into the project to wire these up for us)
            this.scanService = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);
            this.presetService = new PresetService();

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 37
0
        /** Constructs the right hand side tree and highlights changes, insertions and deletions*/
        public void BuildCompareTree(TreeView tv, IScan source, IScan compare)
        {
            var groupsOfSameType = 0;
            var lastType         = string.Empty;

            foreach (IScanInformationGroup sig in compare.ScanInformationGroup.OrderBy(g => g.Type))
            {
                // create a tree node
                var treeNode = new TreeNode(sig.ToString());
                treeNode.ForeColor = Color.White;
                treeNode.Expand();

                // last iteration properties
                groupsOfSameType = lastType == sig.Type ? groupsOfSameType + 1 : 0;
                lastType         = sig.Type;

                // tree to compare to
                var correspondingSoureGroup = source.ScanInformationGroup
                                              .Where(g => g.Type == sig.Type).ElementAtOrDefault(groupsOfSameType);

                // all properties that exist in the compare tree but not in the current
                var removedProperties = correspondingSoureGroup?.Properties
                                        .Where(p => !sig.Properties.Any(sp => sp.Name == p.Name));

                // all Properties
                var mergedSourceAndCompareProperties = new List <IScanInformation>(sig.Properties);

                if (removedProperties != null)
                {
                    mergedSourceAndCompareProperties.AddRange(removedProperties);
                }

                foreach (IScanInformation si in mergedSourceAndCompareProperties.OrderBy(p => p.Name))
                {
                    var childNode = new TreeNode(si.ToString());
                    childNode.ForeColor = GetColorForProperty(removedProperties, correspondingSoureGroup, si);;
                    treeNode.Nodes.Add(childNode);
                }
                tv.Nodes.Add(treeNode);
            }
        }
Esempio n. 38
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScanServiceWrapper"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user setting service.
        /// </param>
        public ScanServiceWrapper(IUserSettingService userSettingService)
        {
            var useLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb);
            var useProcessIsolation =
                userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation);
            string port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort);

            if (useLibHb)
            {
                try
                {
                    if (useProcessIsolation)
                    {
                        this.scanService = new IsolatedScanService(port);
                    }
                    else
                    {
                        HandbrakeInstance = new HandBrakeInstance();
                        this.scanService = new LibScan(userSettingService, HandbrakeInstance);
                    }
                }
                catch(Exception exc)
                {
                    // Try to recover from errors.
                    userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false);
                    throw new GeneralApplicationException("Unable to initialise LibHB or Background worker service", "Falling back to using HandBrakeCLI.exe. Setting has been reset", exc);
                }
            }
            else
            {
                this.scanService = new ScanService(userSettingService);
            }

            this.scanService.ScanCompleted += this.ScanServiceScanCompleted;
            this.scanService.ScanStared += this.ScanServiceScanStared;
            this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
        }
Esempio n. 39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CancelScanCommand"/> class.
 /// </summary>
 /// <param name="ssw">
 /// The scan service wrapper.
 /// </param>
 public CancelScanCommand(IScan ssw)
 {
     this.scanServiceWrapper = ssw;
     this.scanServiceWrapper.ScanStared += this.ScanServiceWrapperScanStared;
     this.scanServiceWrapper.ScanCompleted += this.ScanServiceWrapperScanCompleted;
 }
Esempio n. 40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
 /// </summary>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public StaticPreviewViewModel(IScan scanService)
 {
     this.scanService = scanService;
     this.selectedPreviewImage = 1;
     this.Title = Properties.Resources.Preview;
 }
Esempio n. 41
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
            IErrorService errorService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();
            this.SelectedPreset = this.presetService.DefaultPreset;

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 42
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="shellViewModel">
        /// The shell View Model.
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="notificationService">
        /// The notification Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            // Setup Properties
            this.WindowTitle = Resources.HandBrake_Title;
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();
            this.HasSource = false;

            // Setup Events
            this.scanService.ScanStarted += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.Drives = new BindingList<SourceMenuItem>();

            HandBrakeInstanceManager.Init();
        }
Esempio n. 43
0
        /// <summary>
        /// Start the service
        /// </summary>
        public void Start(string port)
        {
            using (host = new ServiceHost(typeof(ServerService), new Uri(string.Format("net.tcp://127.0.0.1:{0}", port))))
            {
                // Setup a listener
                host.AddServiceEndpoint(typeof(IServerService), new NetTcpBinding(), "IHbService");
                host.Open();
                Console.WriteLine("::: HandBrake Isolation Server - Debug Console:::");
                Console.WriteLine("Service Started. Waiting for Clients...");

                // Setup the services we are going to use.
                scanService = new ScanService(new UserSettingService()); // TODO this needs wired up with castle
                encodeService = new Encode(new UserSettingService());

                shutdownFlag = new ManualResetEvent(false);
                shutdownFlag.WaitOne();
            }
        }
Esempio n. 44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        /// <param name="pictureSettingsViewModel">
        /// The picture Settings View Model.
        /// </param>
        /// <param name="videoViewModel">
        /// The video View Model.
        /// </param>
        /// <param name="filtersViewModel">
        /// The filters View Model.
        /// </param>
        /// <param name="audioViewModel">
        /// The audio View Model.
        /// </param>
        /// <param name="subtitlesViewModel">
        /// The subtitles View Model.
        /// </param>
        /// <param name="advancedViewModel">
        /// The advanced View Model.
        /// </param>
        /// <param name="chaptersViewModel">
        /// The chapters View Model.
        /// </param>
        /// <param name="staticPreviewViewModel">
        /// The static Preview View Model.
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, 
            IErrorService errorService, IUpdateService updateService,
            IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel,
            IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel,
            IAdvancedViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.updateService = updateService;
            this.windowManager = windowManager;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            this.PictureSettingsViewModel = pictureSettingsViewModel;
            this.VideoViewModel = videoViewModel;
            this.FiltersViewModel = filtersViewModel;
            this.AudioViewModel = audioViewModel;
            this.SubtitleViewModel = subtitlesViewModel;
            this.ChaptersViewModel = chaptersViewModel;
            this.AdvancedViewModel = advancedViewModel;
            this.StaticPreviewViewModel = staticPreviewViewModel;

            // Setup Properties
            this.WindowTitle = Resources.HandBrake_Title;
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();
            this.HasSource = false;

            // Setup Events
            this.scanService.ScanStarted += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.Drives = new BindingList<SourceMenuItem>();

            HandBrakeInstanceManager.Init();
        }
Esempio n. 45
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmMain"/> class.
        /// </summary>
        /// <param name="args">
        /// The arguments passed in on application startup.
        /// </param>
        public frmMain(string[] args)
        {
            InitializeComponent();
            this.presetsToolStrip.Renderer = new ToolStripRenderOverride();

            // We can use LibHB, if the library hb.dll exists.
            this.SourceScan = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();
            lbl_libhb_warning.Visible = File.Exists("hb.dll") ? true : false;

            // Update the users config file with the CLI version data.
            Main.SetCliVersionData();

            if (userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion).Contains("svn"))
            {
                this.Text += " " + userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion);
            }

            // Check for new versions, if update checking is enabled
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.UpdateStatus))
            {
                if (DateTime.Now.Subtract(userSettingService.GetUserSetting<DateTime>(UserSettingConstants.LastUpdateCheckDate)).TotalDays
                    > userSettingService.GetUserSetting<int>(UserSettingConstants.DaysBetweenUpdateCheck))
                {
                    // Set when the last update was
                    this.userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now);
                    string url = userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakePlatform).Contains("x86_64")
                                                  ? userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_x64)
                                                  : userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_i686);
                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild),
                        userSettingService.GetUserSetting<int>(UserSettingConstants.Skipversion));
                }
            }

            // Clear the log files in the background
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.ClearOldLogs))
            {
                Thread clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
                clearLog.Start();
            }

            // Setup the GUI components
            LoadPresetPanel(); // Load the Preset Panel
            treeView_presets.ExpandAll();
            lbl_encode.Text = string.Empty;
            drop_mode.SelectedIndex = 0;
            queueWindow = new frmQueue(this.queueProcessor, this); // Prepare the Queue
            if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.QueryEditorTab))
                tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.
            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.TooltipEnable))
                ToolTip.Active = true;

            // Load the user's default settings or Normal Preset
            if (this.presetHandler.DefaultPreset != null)
            {
                this.loadPreset(this.presetHandler.DefaultPreset.Name);
            }
            else
                loadPreset("Normal");

            // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)
            GrowlCommunicator.Register();

            // Event Handlers and Queue Recovery
            events();
            Main.RecoverQueue(this.queueProcessor);

            // If have a file passed in via command arguemtents, check it's a file and try scanning it.
            if (args.Length >= 1 && (File.Exists(args[0]) || Directory.Exists(args[0])))
            {
                this.StartScan(args[0], 0);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InstantViewModel"/> class.
        /// </summary>
        /// <param name="userSettingService">
        /// The user setting service.
        /// </param>
        /// <param name="scanService">
        /// The scan service.
        /// </param>
        /// <param name="encodeService">
        /// The encode service.
        /// </param>
        /// <param name="presetService">
        /// The preset service.
        /// </param>
        /// <param name="errorService">
        /// The error service.
        /// </param>
        /// <param name="shellViewModel">
        /// The shell view model.
        /// </param>
        /// <param name="updateService">
        /// The update service.
        /// </param>
        /// <param name="notificationService">
        /// The notification service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when done service.
        /// </param>
        public InstantViewModel(
            IUserSettingService userSettingService,
            IScan scanService,
            IEncodeServiceWrapper encodeService,
            IPresetService presetService,
            IErrorService errorService,
            IShellViewModel shellViewModel,
            IUpdateService updateService,
            INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.userSettingService = userSettingService;
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;

            this.queueProcessor = IoC.Get<IQueueProcessor>();

            // Setup Properties
            this.TitleList = new BindingList<SelectionTitle>();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;

            this.Presets = this.presetService.Presets;
            this.CancelScanCommand = new CancelScanCommand(this.scanService);
        }
Esempio n. 47
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="shellViewModel">
        /// The shell View Model.
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="notificationService">
        /// The notification Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncodeServiceWrapper encodeService, IPresetService presetService,
            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService, INotificationService notificationService,
            IPrePostActionService whenDoneService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            // Setup Properties
            this.WindowTitle = "HandBrake";
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.CancelScanCommand = new CancelScanCommand(this.scanService);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
 /// </summary>
 /// <param name="scanService">
 /// The scan service.
 /// </param>
 public StaticPreviewViewModel(IScan scanService)
 {
     this.scanService = scanService;
     this.selectedPreviewImage = 1;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class.
        /// </summary>
        /// <param name="scanService">
        /// The scan service.
        /// </param>
        /// <param name="userSettingService">
        /// The user Setting Service.
        /// </param>
        public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService)
        {
            this.scanService = scanService;
            this.selectedPreviewImage = 1;
            this.Title = Properties.Resources.Preview;
            this.PreviewNotAvailable = true;

            // Live Preview
            this.userSettingService = userSettingService;
            this.encodeService = new LibEncode(); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point

            this.Title = "Preview";
            this.Percentage = "0.00%";
            this.PercentageValue = 0;
            this.Duration = 30;
            this.CanPlay = true;

            UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer);
            this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration);
        }
Esempio n. 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// The viewmodel for HandBrakes main window.
        /// </summary>
        /// <param name="userSettingService">
        /// The User Setting Service
        /// </param>
        /// <param name="scanService">
        /// The scan Service.
        /// </param>
        /// <param name="encodeService">
        /// The encode Service.
        /// </param>
        /// <param name="presetService">
        /// The preset Service.
        /// </param>
        /// <param name="errorService">
        /// The Error Service
        /// </param>
        /// <param name="updateService">
        /// The update Service.
        /// </param>
        /// <param name="whenDoneService">
        /// The when Done Service.
        /// *** Leave in Constructor. *** 
        /// </param>
        /// <param name="windowManager">
        /// The window Manager.
        /// </param>
        /// <param name="pictureSettingsViewModel">
        /// The picture Settings View Model.
        /// </param>
        /// <param name="videoViewModel">
        /// The video View Model.
        /// </param>
        /// <param name="filtersViewModel">
        /// The filters View Model.
        /// </param>
        /// <param name="audioViewModel">
        /// The audio View Model.
        /// </param>
        /// <param name="subtitlesViewModel">
        /// The subtitles View Model.
        /// </param>
        /// <param name="advancedViewModel">
        /// The advanced View Model.
        /// </param>
        /// <param name="chaptersViewModel">
        /// The chapters View Model.
        /// </param>
        /// <param name="staticPreviewViewModel">
        /// The static Preview View Model.
        /// </param>
        /// <param name="queueViewModel">
        /// The queue View Model.
        /// </param>
        public MainViewModel(IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService, 
            IErrorService errorService, IUpdateService updateService, 
            IPrePostActionService whenDoneService, IWindowManager windowManager, IPictureSettingsViewModel pictureSettingsViewModel, IVideoViewModel videoViewModel, 
            IFiltersViewModel filtersViewModel, IAudioViewModel audioViewModel, ISubtitlesViewModel subtitlesViewModel, 
            IAdvancedViewModel advancedViewModel, IChaptersViewModel chaptersViewModel, IStaticPreviewViewModel staticPreviewViewModel,
            IQueueViewModel queueViewModel)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.updateService = updateService;
            this.windowManager = windowManager;
            this.QueueViewModel = queueViewModel;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>();

            this.PictureSettingsViewModel = pictureSettingsViewModel;
            this.VideoViewModel = videoViewModel;
            this.FiltersViewModel = filtersViewModel;
            this.AudioViewModel = audioViewModel;
            this.SubtitleViewModel = subtitlesViewModel;
            this.ChaptersViewModel = chaptersViewModel;
            this.AdvancedViewModel = advancedViewModel;
            this.StaticPreviewViewModel = staticPreviewViewModel;

            // Setup Properties
            this.WindowTitle = Resources.HandBrake_Title;
            this.CurrentTask = new EncodeTask();
            this.CurrentTask.PropertyChanged += this.CurrentTask_PropertyChanged;
            this.ScannedSource = new Source();
            this.HasSource = false;

            // Setup Events
            this.scanService.ScanStarted += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueueChanged += this.QueueChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
            this.userSettingService.SettingChanged += this.UserSettingServiceSettingChanged;

            this.Presets = this.presetService.Presets;
            this.Drives = new BindingList<SourceMenuItem>();

            // Set Process Priority
            switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))
            {
                case "Realtime":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                    break;
                case "High":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                    break;
                case "Above Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                    break;
                case "Normal":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal;
                    break;
                case "Low":
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;
                    break;
                default:
                    Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;
                    break;
            }

            HandBrakeInstanceManager.Init();
        }
Esempio n. 51
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService)
            : base(windowManager)
        {
            this.userSettingService = userSettingService;
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length);

            // Setup Properties
            this.WindowTitle = "HandBrake WPF Test Application";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;

            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.QueuePaused += this.QueuePaused;
            this.queueProcessor.EncodeService.EncodeStarted += this.EncodeStarted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }
Esempio n. 52
0
        /// <summary>
        /// Initializes a new instance of the <see cref="frmMain"/> class.
        /// </summary>
        /// <param name="args">
        /// The arguments passed in on application startup.
        /// </param>
        public frmMain(string[] args)
        {
            InitializeComponent();
            this.presetsToolStrip.Renderer = new ToolStripRenderOverride();

            // We can use LibHB, if the library hb.dll exists.
            this.SourceScan = File.Exists("hb.dll") ? (IScan)new LibScan() : new ScanService();

            // Update the users config file with the CLI version data.
            Main.SetCliVersionData();

            if (userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn"))
            {
                this.Text += " " + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion);
            }

            // Check for new versions, if update checking is enabled
            if (Settings.Default.updateStatus)
            {
                if (DateTime.Now.Subtract(Settings.Default.lastUpdateCheckDate).TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck)
                {
                    // Set when the last update was
                    Settings.Default.lastUpdateCheckDate = DateTime.Now;
                    Settings.Default.Save();
                    string url = this.userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1")
                                                  ? Settings.Default.appcast_unstable
                                                  : Settings.Default.appcast;
                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion));
                }
            }

            // Clear the log files in the background
            if (Settings.Default.clearOldLogs)
            {
                Thread clearLog = new Thread(() => GeneralUtilities.ClearLogFiles(30));
                clearLog.Start();
            }

            // Setup the GUI components
            LoadPresetPanel(); // Load the Preset Panel
            treeView_presets.ExpandAll();
            lbl_encode.Text = string.Empty;
            drop_mode.SelectedIndex = 0;
            queueWindow = new frmQueue(this.queueProcessor, this); // Prepare the Queue
            if (!Settings.Default.QueryEditorTab)
                tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.
            if (Settings.Default.tooltipEnable)
                ToolTip.Active = true;

            // Load the user's default settings or Normal Preset
            if (Settings.Default.defaultPreset != string.Empty && presetHandler.GetPreset(Properties.Settings.Default.defaultPreset) != null)
            {
                string query = presetHandler.GetPreset(Settings.Default.defaultPreset).Query;
                if (query != null)
                {
                    x264Panel.Reset2Defaults();

                    EncodeTask presetQuery = QueryParserUtility.Parse(query);
                    PresetLoader.LoadPreset(this, presetQuery, Settings.Default.defaultPreset);

                    x264Panel.StandardizeOptString();
                    x264Panel.SetCurrentSettingsInPanel();
                }
            }
            else
                loadNormalPreset();

            // Register with Growl (if not using Growl for the encoding completion action, this wont hurt anything)
            GrowlCommunicator.Register();

            // Event Handlers and Queue Recovery
            events();
            Main.RecoverQueue(this.queueProcessor);

            // If have a file passed in via command arguemtents, check it's a file and try scanning it.
            if (args.Length >= 1 && (File.Exists(args[0]) || Directory.Exists(args[0])))
            {
                this.StartScan(args[0], 0);
            }
        }
Esempio n. 53
0
        public MainViewModel(IWindowManager windowManager, IUserSettingService userSettingService, IScan scanService, IEncode encodeService, IPresetService presetService,
            IErrorService errorService, IShellViewModel shellViewModel, IUpdateService updateService)
        {
            this.scanService = scanService;
            this.encodeService = encodeService;
            this.presetService = presetService;
            this.errorService = errorService;
            this.shellViewModel = shellViewModel;
            this.updateService = updateService;
            this.userSettingService = userSettingService;
            this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!

            // Setup Properties
            this.WindowTitle = "HandBrake";
            this.CurrentTask = new EncodeTask();
            this.ScannedSource = new Source();

            // Setup Events
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;
            this.queueProcessor.QueueCompleted += this.QueueCompleted;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;

            this.Presets = this.presetService.Presets;
        }
Esempio n. 54
0
        /// <summary>
        /// The test isolation services.
        /// Swaps out the implementation of IScan to the IsolatedScanService version.
        /// </summary>
        public void EnableIsolationServices()
        {
            // Unhook the old services
            this.scanService.ScanStared -= this.ScanStared;
            this.scanService.ScanCompleted -= this.ScanCompleted;
            this.scanService.ScanStatusChanged -= this.ScanStatusChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;

            // Replace the Services
            this.scanService = new IsolatedScanService(this.errorService, this.userSettingService);
            this.encodeService = new IsolatedEncodeService(this.errorService, this.userSettingService);
            this.queueProcessor.SwapEncodeService(this.encodeService);

            // Add the new Event Hooks
            this.scanService.ScanStared += this.ScanStared;
            this.scanService.ScanCompleted += this.ScanCompleted;
            this.scanService.ScanStatusChanged += this.ScanStatusChanged;
            this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;
        }