public void ClearEventInvocationList()
        {
            if (ErrorOccured != null)
            {
                foreach (var subscribedDelegate in ErrorOccured.GetInvocationList())
                {
                    ErrorOccured -= (EventHandler <BaseErrorResponseInfo>)subscribedDelegate;
                }
            }

            if (LoadingStarted != null)
            {
                foreach (var subscribedDelegate in LoadingStarted.GetInvocationList())
                {
                    LoadingStarted -= (EventHandler <EventArgs>)subscribedDelegate;
                }
            }

            if (LoadingCompleted != null)
            {
                foreach (var subscribedDelegate in LoadingCompleted.GetInvocationList())
                {
                    LoadingCompleted -= (EventHandler <EventArgs>)subscribedDelegate;
                }
            }
        }
Beispiel #2
0
 public void AddSeansesFromVentursFile(List <string> files)
 {
     LoadingStarted.Invoke(this);
     foreach (string file in files)
     {
         List <Channel> channels = GetChannelsFromVentursFile(file);
         Parallel.ForEach(channels, channelInfo =>
         {
             string pathPartToPaste  = Path.GetDirectoryName(file);
             string pathPartToDelete = channelInfo.Directory.Substring(0, channelInfo.Directory.IndexOf("riClient") + 8);
             string channelDirectory = channelInfo.Directory.Replace(pathPartToDelete, pathPartToPaste).ToLower();
             Seanse currentSeanse    = Seanses.FirstOrDefault(x => x.Directory.FullName.ToLower() == channelDirectory);
             if (currentSeanse == null)
             {
                 lock (Seanses)
                 {
                     LoadSeanse(channelDirectory);
                 }
             }
             if (currentSeanse != null)
             {
                 currentSeanse.ChannelInfo = channelInfo;
             }
         });
     }
     LoadingEnded(this);
 }
 private void OnLoadingStarted()
 {
     this.IsLoading = true;
     if (LoadingStarted != null)
     {
         LoadingStarted.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #4
0
        public bool AddSeanse(string seanseDir)
        {
            bool result = false;

            lock (Seanses)
            {
                LoadingStarted.Invoke(this);
                result = LoadSeanse(seanseDir);
                LoadingEnded.Invoke(this);
            }
            return(result);
        }
Beispiel #5
0
        public void AddAllSeansesFromFolder(string path)
        {
            lock (Seanses)
            {
                DirectoryInfo   di        = new DirectoryInfo(path);
                DirectoryInfo[] childDirs = di.GetDirectories();

                List <string> dirsInStock = Seanses.Select(x => x.Directory.FullName.ToLower()).ToList();
                LoadingStarted.Invoke(this);
                Parallel.ForEach(childDirs, directory =>
                {
                    if (!dirsInStock.Contains(directory.FullName.ToLower()))
                    {
                        LoadSeanse(directory.FullName);
                    }
                });
                LoadingEnded.Invoke(this);
            }
        }
        /// <summary>
        /// Load all modules in the Module Directory
        /// </summary>
        public static void LoadAll()
        {
            ModuleLoadOrder = ModuleLoadOrder ?? new Dictionary <int, UserModule>();
            ModuleLoadOrder?.Clear();

            var sysModule = UserModule.FromType(typeof(SystemCommands));

            ModuleLoadOrder.Add(ModuleLoadOrder.Count, sysModule);

            var directories = Directory.GetDirectories(ModuleDirectory, "*", SearchOption.TopDirectoryOnly);

            LoadingStarted?.Invoke(directories.Length);

            // Search through all directories and add user modules
            directories.ToList().ForEach(dir => {
                var um = GetModuleFromDirectory(dir);

                // If a module is detected, add it to the ModuleLoadOrder dictionary
                if (um != null)
                {
                    var index  = ModuleLoadOrder.Count + 1;
                    var canUse = false;
                    do
                    {
                        if (!ModuleLoadOrder.ContainsKey(index))
                        {
                            canUse = true;
                            ModuleLoadOrder.Add(index, um);
                            ModuleLoaded?.Invoke(um);
                        }
                        else
                        {
                            index++;
                        }
                    } while(canUse == false);
                }
            });

            LoadingEnded?.Invoke();
        }
        public static async Task LoadAllAsync()
        {
            ModuleLoadOrder = ModuleLoadOrder ?? new Dictionary <int, UserModule>();
            ModuleLoadOrder?.Clear();

            var sysModule = await UserModule.FromTypeAsync(typeof(SystemCommands));

            ModuleLoadOrder.Add(ModuleLoadOrder.Count, sysModule);

            var directories = Directory.GetDirectories(ModuleDirectory, "*", SearchOption.TopDirectoryOnly);

            LoadingStarted?.Invoke(directories.Length);

            var foundModules = await GetModulesFromDirectoriesAsync(directories);

            foundModules.ForEach(um => {
                var index  = ModuleLoadOrder.Count + 1;
                var canUse = false;

                do
                {
                    if (!ModuleLoadOrder.ContainsKey(index))
                    {
                        canUse = true;
                        ModuleLoadOrder.Add(index, um);
                        ModuleLoaded?.Invoke(um);
                    }
                    else
                    {
                        index++;
                    }
                } while(canUse == false);
            });

            LoadingEnded?.Invoke();
        }
Beispiel #8
0
 void IImageSourcePartEvents.LoadingStarted()
 {
     IsLoading = true;
     LoadingStarted?.Invoke();
 }
Beispiel #9
0
 void IImageSourcePartEvents.LoadingStarted() =>
 LoadingStarted?.Invoke();
Beispiel #10
0
 public void OnLoadingStarted()
 {
     LoadingStarted?.Invoke(this, new EventArgs());
 }
 protected void Loading()
 {
     LoadingStarted?.Invoke(this, EventArgs.Empty);
 }