コード例 #1
0
        /// <summary>
        /// Updates the floor normal and sends controller object. Calculates scan ending time; End Time = Now + Duration
        /// </summary>
        /// <param name="sender">Object sending the event</param>
        /// <param name="e">Event arguments</param>
        private void Controller_ReconstructionStarted(object sender, EventArgs e)
        {
            var controller = (ReconstructionController)sender;

            FloorNormal = controller.FloorNormal;

            scanEndTime = DateTime.UtcNow.Add(SCAN_DURATION);

            ScanStarted?.Invoke(this, EventArgs.Empty);
        }
コード例 #2
0
ファイル: Monitor.cs プロジェクト: mediabuff/KodiSharp
        private bool onEvent(KodiEventMessage e)
        {
            switch (e.Sender)
            {
            case "onAbortRequested":
                AbortRequested?.Invoke(e.Sender, new EventArgs());
                break;

            case "onCleanStarted":
                CleanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0]));
                break;

            case "onCleanFinished":
                CleanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0]));
                break;

            case "onDPMSActivated":
                DPMSActivated?.Invoke(e.Sender, new EventArgs());
                break;

            case "onDPMSDeactivated":
                DPMSDeactivated?.Invoke(e.Sender, new EventArgs());
                break;

            case "onDatabaseScanStarted":
                DatabaseScanStarted?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0]));
                break;

            case "onDatabaseUpdated":
                DatabaseUpdated?.Invoke(e.Sender, new DatabaseEventArgs(e.EventArgs[0]));
                break;

            case "onNotification":
                Notification?.Invoke(e.Sender, new NotificationEventArgs(
                                         e.EventArgs[0], e.EventArgs[1], e.EventArgs[2]
                                         ));
                break;

            case "onScanStarted":
                ScanStarted?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0]));
                break;

            case "onScanFinished":
                ScanFinished?.Invoke(e.Sender, new LibraryEventArgs(e.EventArgs[0]));
                break;

            case "onScreensaverActivated":
                ScreensaverActivated?.Invoke(e.Sender, new EventArgs());
                break;

            case "onScreensaverDeactivated":
                ScreensaverDeactivated?.Invoke(e.Sender, new EventArgs());
                break;

            case "onSettingsChanged":
                SettingsChanged?.Invoke(e.Sender, new EventArgs());
                break;

            default:
                PyConsole.WriteLine(string.Format("Unknown event '{0}' not handled", e.Sender));
                return(false);
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Scans the tree to find all images, and all shortcuts to images.
        /// </summary>
        /// <param name="token"></param>
        public void Populate(CancellationToken token)
        {
            ScanStarted?.Invoke(new DirectoryScanInfo {
                Directory = DirectoryInfo
            });

            if (token.IsCancellationRequested)
            {
                return;
            }

            try
            {
                EnsureShortcutUtility();

                List <ImageItem> children = new List <ImageItem>();
                ImageItem        child;

                foreach (var file in DirectoryInfo.EnumerateFilesByExtensions(Constants.IMAGE_FILE_EXTENSIONS_PLUS_LINK))
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    child = new ImageItem(file, ShortcutUtility);

                    if (child.IsImage)
                    {
                        children.Add(child);
                    }
                }

                if (token.IsCancellationRequested)
                {
                    return;
                }

                AddDescendants(children, 0);

                EnsureBlacklist();

                foreach (var subDir in DirectoryInfo.EnumerateDirectories())
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    if (!BlacklistExcludes(subDir.FullName) && !subDir.Attributes.HasFlag(FileAttributes.System))
                    {
                        var subTreeDir = new ImageTreeDirectory(subDir, this)
                        {
                            Blacklist       = Blacklist,
                            ShortcutUtility = ShortcutUtility
                        };

                        subTreeDir.ScanStarted += ScanStarted;
                        subTreeDir.ScanFailed  += ScanFailed;

                        subTreeDir.Populate(token);

                        if (token.IsCancellationRequested)
                        {
                            return;
                        }

                        ChildDirectories.Add(subTreeDir);
                    }
                }

                IsPopulated = true;
            }
            catch (Exception ex)
            {
                ScanFailed?.Invoke(new DirectoryScanInfo {
                    Directory = DirectoryInfo, Exception = ex
                });
            }
        }
コード例 #4
0
 public Task NotifyScanStarted()
 {
     ScanStarted.Invoke();
     return(Task.CompletedTask);
 }