Пример #1
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);
 }
Пример #2
0
 private void OnLoadingStarted()
 {
     this.IsLoading = true;
     if (LoadingStarted != null)
     {
         LoadingStarted.Invoke(this, EventArgs.Empty);
     }
 }
Пример #3
0
        public bool AddSeanse(string seanseDir)
        {
            bool result = false;

            lock (Seanses)
            {
                LoadingStarted.Invoke(this);
                result = LoadSeanse(seanseDir);
                LoadingEnded.Invoke(this);
            }
            return(result);
        }
Пример #4
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);
            }
        }
Пример #5
0
        /// <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();
        }
Пример #6
0
        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();
        }
Пример #7
0
 void IImageSourcePartEvents.LoadingStarted()
 {
     IsLoading = true;
     LoadingStarted?.Invoke();
 }
Пример #8
0
 void IImageSourcePartEvents.LoadingStarted() =>
 LoadingStarted?.Invoke();
Пример #9
0
 public void OnLoadingStarted()
 {
     LoadingStarted?.Invoke(this, new EventArgs());
 }
Пример #10
0
 protected void Loading()
 {
     LoadingStarted?.Invoke(this, EventArgs.Empty);
 }