Esempio n. 1
0
        public void CopyFrom(object original)
        {
            if (original is null)
            {
                throw new ArgumentNullException(nameof(original));
            }

            var src = (Template)original;

            Name        = src.Name;
            Description = src.Description;

            foreach (var t in src.Tags)
            {
                Tags.Add(t);
            }

            foreach (var a in src.Alarms)
            {
                Alarms.Add(a);
            }

            foreach (var z in src.Archives)
            {
                Archives.Add(z);
            }

            foreach (var d in src.DeviceToTemplates)
            {
                DeviceToTemplates.Add(d);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds the provided Archive to the collection.</summary>
        /// <param name="writeToDb">If true, the object will be written to the Database.</param>
        private async Task AddArchiveAsync(Archive archive, bool writeToDb)
        {
            Archives.Add(archive);

            if (writeToDb)
            {
                await Database.InsertArchiveAsync(archive);
            }
        }
Esempio n. 3
0
        private void ReadArchives()
        {
            int i = 0;

            do
            {
                Archives.Add(new Archive(br, i, this));
                i++;
            }while (br.BaseStream.Position != br.BaseStream.Length);
        }
Esempio n. 4
0
        public override bool OnLoad()
        {
            var archive = new ArchiveAddon();

            archive.ArchiveType = typeof(PKGArchive);
            archive.ArchiveName = "Trails of Cold Steel Archive";
            archive.FileExtensions.Add(".pkg");
            Archives.Add(archive);
            return(true);
        }
Esempio n. 5
0
        private void Archives_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (ignoreChanges)
            {
                return;
            }

            ignoreChanges = true;

            // If the collection was reset, then e.OldItems is empty. Just clear and reload.
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
            {
                Archives.Clear();

                foreach (var archive in index.Archives)
                {
                    Archives.Add(new ArchiveViewModel(archive, this));
                }
            }
            else
            {
                // Remove items from collection.
                var toRemove = new List <ArchiveViewModel>();

                if (null != e.OldItems && e.OldItems.Count > 0)
                {
                    foreach (var item in e.OldItems)
                    {
                        foreach (var existingItem in Archives)
                        {
                            if (existingItem.IsViewFor((Archive)item))
                            {
                                toRemove.Add(existingItem);
                            }
                        }
                    }
                }

                foreach (var item in toRemove)
                {
                    Archives.Remove(item);
                }

                // Add new items to the collection.
                if (null != e.NewItems && e.NewItems.Count > 0)
                {
                    foreach (var item in e.NewItems)
                    {
                        Archives.Add(new ArchiveViewModel((Archive)item, this));
                    }
                }
            }
            ignoreChanges = false;
        }
Esempio n. 6
0
 private void AddLocation(string archiveLocation, string offloadLocation)
 {
     if (Archives.All(archive => Path.Combine(archive.Location, archive.Name) != archiveLocation))
     {
         Archives.Add(new Archive()
         {
             Name            = FilePath.GetFileName(archiveLocation),
             Location        = FilePath.GetDirectoryName(archiveLocation),
             OffloadLocation = offloadLocation
         });
     }
 }
Esempio n. 7
0
 private void LoadArchive(List <string> listFiles)
 {
     foreach (string file in listFiles)
     {
         IntPtr hArchive = new IntPtr(0);
         bool   ret      = SFileOpenArchive(file, 0, 0, ref hArchive);
         if (ret)
         {
             Archives.Add(file, hArchive);
             ArchiveList.Add(file, new MPQArchive(hArchive));
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Reload the ArchiveManager from given directory (optional).
        /// </summary>
        /// <param name="indir"></param>
        public void Reload(DirectoryInfo indir = null)
        {
            if (indir != null)
            {
                _parentDirectoryInfo = indir;
            }

            var archives = _parentDirectoryInfo.GetFiles("*.archive").ToList();

            Archives.Clear();
            foreach (var fi in archives)
            {
                Archives.Add(fi.FullName, new Archive(fi.FullName));
            }

            ReloadFiles();
        }
 private void SaveProfile()
 {
     if (listViewEnvVars.Items.Count > 0)
     {
         if (_selectedArchive == null)
         {
             _selectedArchive = new Archive()
             {
                 Name    = _archiveName,
                 Count   = listViewEnvVars.Items.Count,
                 Comment = string.Empty
             };
         }
         _archiveTable = _selectedArchive.Code;
         _archives.Add(_selectedArchive);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Load a single bundle
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="ispatch"></param>
        public override void LoadArchive(string filename, bool ispatch = false)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }
            var bundle = new Archive(filename);

            foreach (KeyValuePair <ulong, ArchiveItem> item in bundle.Files)
            {
                // add new key if the file isn't already in another bundle
                if (!Items.ContainsKey(item.Key.ToString()))
                {
                    Items.Add(item.Key.ToString(), new List <IGameFile>());
                }
                Items[item.Key.ToString()].Add(item.Value);
            }
            Archives.Add(filename, bundle);
        }
Esempio n. 11
0
        private void AddArchive(string archive)
        {
            if (string.IsNullOrWhiteSpace(archive))
            {
                return;
            }

            var parts = archive.Split('|', '=');

            if (parts.Length < 1)
            {
                return;
            }

            var input  = parts[0];
            var output = parts.Length == 1 ? input : parts[1];

            Archives.Add(input, output);
        }
Esempio n. 12
0
    /// <summary>
    /// Fills out the <see cref="Installation.Archives"/> list by parsing Morrowind.ini.
    /// </summary>
    private void BuildArchiveList()
    {
        ArgumentNullException.ThrowIfNull(Configuration);

        // Always start off with Morrowind.
        Archives.Add("Morrowind.bsa");

        // Load the rest from the ini file.
        var configArchives = Configuration["Archives"];

        for (var i = 0; true; ++i)
        {
            var archive = configArchives["Archive " + i];
            if (string.IsNullOrEmpty(archive))
            {
                break;
            }
            Archives.Add(archive);
        }
    }
Esempio n. 13
0
        /// <summary>
        ///     Load a single soundcache
        /// </summary>
        /// <param name="filename"></param>
        private void LoadBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new SoundCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(item.Name))
                {
                    Items.Add(item.Name, new List <IGameFile>());
                }

                Items[item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }
Esempio n. 14
0
        /// <summary>
        ///     Load a single mod bundle
        /// </summary>
        /// <param name="filename">
        ///     file to process
        /// </param>
        public override void LoadModArchive(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new Archive(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(GetModFolder(filename) + "\\" + item.Key))
                {
                    Items.Add(GetModFolder(filename) + "\\" + item.Key, new List <IGameFile>());
                }

                Items[GetModFolder(filename) + "\\" + item.Key].Add(item.Value);
            }

            Archives.Add(filename, bundle);
        }
Esempio n. 15
0
        /// <summary>
        ///     Load a single soundcache
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new TextureCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(item.Name))
                {
                    Items.Add(item.Name, new List <IWitcherFile>());
                }

                Items[item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }
Esempio n. 16
0
        /// <summary>
        ///     Load a single mod soundcache
        /// </summary>
        /// <param name="filename"></param>
        public void LoadModBundle(string filename)
        {
            if (Archives.ContainsKey(filename))
            {
                return;
            }

            var bundle = new SoundCache(filename);

            foreach (var item in bundle.Files)
            {
                if (!Items.ContainsKey(GetModFolder(filename) + "\\" + item.Name))
                {
                    Items.Add(GetModFolder(filename) + "\\" + item.Name, new List <IWitcherFile>());
                }

                Items[GetModFolder(filename) + "\\" + item.Name].Add(item);
            }

            Archives.Add(filename, bundle);
        }
        public void Load()
        {
            XmlReader reader = new XmlTextReader(BasicArchivePath);

            try
            {
                BasicArchives basicArchives = XMLHelper.UnSerializer(reader, typeof(BasicArchives)) as BasicArchives;
                if (basicArchives != null)
                {
                    foreach (var value in basicArchives)
                    {
                        Archives.Add(value);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                reader.Close();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Populates the index with data stored in the database.</summary>
        public async Task LoadDataAsync()
        {
            foreach (var ex in await Database.GetExclusionsAsync())
            {
                await AddFileExclusionAsync(ex, false);
            }

            foreach (var hash in await Database.GetFileHashAsync())
            {
                AddFileHash(hash);
            }

            var loadedArchives = await Database.GetArchiveAsync();

            // Prepare loaded sets before adding them to the index
            foreach (var archive in loadedArchives)
            {
                archive.Index = this;

                archive.Volume = (await Database.GetLogicalVolumeAsync(archive.Guid.ToString())).FirstOrDefault();
                archive.Volume.RefreshStatus();
                archive.Volume = await AddLogicalVolume(archive.Volume, false);

                // rebuild the directory tree of the archive

                // load all nodes of the archive
                var loadedNodes = await Database.GetFileNodeAsync(archive.Guid.ToString());

                loadedNodes.Sort();

                // create a lookup collection by grouping each node by their respective directory name
                var groupedNodes = loadedNodes.GroupBy(x => x.DirectoryName);

                foreach (var node in loadedNodes)
                {
                    node.Archive = archive;

                    if (node is FileNode)
                    {
                        // don't look for further subdirectories if the current item is a file node
                        // instead link it with it's file hash
                        var hash = Hashes.FirstOrDefault(x => x.Checksum.Equals(((FileNode)node).Checksum));
                        if (hash != null)
                        {
                            hash.AddNode((FileNode)node);
                            ((FileNode)node).Hash = hash;
                        }
                    }
                    else
                    {
                        // find all child items from the lookup collection
                        var childNodes = groupedNodes.FirstOrDefault(x => x.Key == (Path.Combine(node.DirectoryName, node.Name)));

                        if (childNodes is null || childNodes.Count() == 0)
                        {
                            continue;
                        }

                        foreach (var childNode in childNodes)
                        {
                            // if the name of directory is "\", it's automatically the root directory
                            // it's not possible for these directories to have a parent, so skipt them
                            if (childNode.DirectoryName == @"\" && childNode.Name == @"\")
                            {
                                continue;
                            }

                            childNode.Parent = node;
                            if (childNode is FileNode)
                            {
                                node.FileNodes.Add((FileNode)childNode);
                            }
                            else
                            {
                                node.SubDirectories.Add(childNode);
                            }
                        }
                    }
                }

                // The only directory left without a parent is the root directory
                archive.RootDirectory = loadedNodes
                                        .OfType <FileDirectory>()
                                        .FirstOrDefault(x => x.Parent == null && x.GetType() == typeof(FileDirectory));
            }

            foreach (var archive in loadedArchives)
            {
                Archives.Add(archive);
            }
        }
Esempio n. 19
0
        void BackupProgramHandler_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Core.settings.IsBackupPathSet || archive_name_override != null)
            {
                if (archive_name_override != null)
                {
                    output_path = Path.GetDirectoryName(archive_name_override);
                }
                else
                {
                    output_path = Core.settings.backup_path;
                }


                IList <GameEntry> games;

                if (back_these_up != null && back_these_up.Count > 0)
                {
                    games = back_these_up;
                }
                else
                {
                    if (Games.detected_games_count == 0)
                    {
                        Games.detectGames();
                    }
                    games = Games.DetectedGames.Items;
                }

                if (games.Count > 0)
                {
                    ProgressHandler.value = 1;
                    ProgressHandler.max   = games.Count;
                    TranslatingProgressHandler.setTranslatedMessage("GamesToBeBackedUpCount", games.Count.ToString());


                    foreach (GameEntry game in games)
                    {
                        if (CancellationPending)
                        {
                            return;
                        }

                        //if(archive_name_override!=null)
                        //all_users_archive = new ArchiveHandler(new FileInfo(archive_name_override),game.id);

                        if (games.Count == 1)
                        {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpSingleGame", game.Title);
                        }
                        else
                        {
                            TranslatingProgressHandler.setTranslatedMessage("BackingUpMultipleGames", game.Title, ProgressHandler.value.ToString(), games.Count.ToString());
                        }

                        List <DetectedFile> files;
                        if (only_these_files != null && only_these_files.Count > 0)
                        {
                            files = only_these_files;
                        }
                        else
                        {
                            files = game.Saves.Flatten();
                            ;
                        }


                        Archive override_archive = null;

                        try {
                            DictionaryList <Archive, DetectedFile> backup_files = new DictionaryList <Archive, DetectedFile>();
                            foreach (DetectedFile file in files)
                            {
                                ArchiveID archive_id;
                                Archive   archive;
                                if (CancellationPending)
                                {
                                    return;
                                }

                                archive_id = new ArchiveID(game.id, file);

                                if (archive_name_override != null)
                                {
                                    if (override_archive == null)
                                    {
                                        file.Type = null;
                                    }
                                    override_archive = new Archive(new FileInfo(archive_name_override), new ArchiveID(game.id, file));
                                    archive          = override_archive;
                                }
                                else
                                {
                                    if (Archives.Get(archive_id) == null)
                                    {
                                        Archives.Add(new Archive(output_path, new ArchiveID(game.id, file)));
                                    }
                                    archive = Archives.Get(archive_id);
                                }

                                backup_files.Add(archive, file);
                            }
                            if (CancellationPending)
                            {
                                return;
                            }

                            foreach (KeyValuePair <Archive, List <DetectedFile> > backup_file in backup_files)
                            {
                                if (override_archive == null)
                                {
                                    backup_file.Key.backup(backup_file.Value, false, false);
                                }
                                else
                                {
                                    backup_file.Key.backup(backup_file.Value, true, false);
                                }
                            }
                        } catch (Exception ex) {
                            TranslatingMessageHandler.SendException(ex);
                        } finally {
                            ProgressHandler.value++;
                        }
                    }
                }
                else
                {
                    TranslatingMessageHandler.SendError("NothingToBackup");
                }
            }
            else
            {
                TranslatingMessageHandler.SendError("BackupPathNotSet");
            }
        }
Esempio n. 20
0
        static OpenTK.Vector3 alpha          = new OpenTK.Vector3(0, 0, 0);    //Class vector



        public static void loadVar()
        {//LOAD VARIABLES FOR PROGRAM
         //alpha = alpha.setXYZ("<(123, 423, 0123)]>");

            path[0] = "C:\\Users\\Micah Richards\\Dropbox\\Programing\\C#\\NextGen\\DTView\\WindowsFormsApplication4";


            //Create Archive
            List <String> SD = File.Read(path[0] + "\\Resources\\Archive.txt");

            for (int i = 0; i < SD.Count; i += 9)
            {
                Archives.Add(new Archive(SD[i + 0], SD[i + 1], SD[i + 2], SD[i + 3], SD[i + 4], SD[i + 5], SD[i + 6], SD[i + 7]));
            }
            //0)Selection
            //1)Empty
            //2)Character
            //3)Dirt
            //4)Grass
            //5)Stone
            //6)Dark_Stone
            //7)Sand
            //8)Log
            //9)Leaves
            //10)Clouds
            //11)Water
            //12)Lava



            // Load textures
            //Textures[0] = new Texture("Wood");
            //Textures[1] = new Texture("Dirt");
            //Textures[2] = new Texture("Grass", "Dirt", "GDirt", "GDirt", "GDirt", "GDirt");
            //Textures[3] = new Texture("Stone");
            //Textures[4] = new Texture("DStone");
            //Textures[5] = new Texture("Sand");
            //Textures[6] = new Texture("Water");
            //Textures[7] = new Texture("Cloud");
            //Textures[8] = new Texture("SSide", "SSide", "Slime", "SSide", "SSide", "SSide");
            //Textures[9] = new Texture("TRings", "TRings", "Trunk", "Trunk", "Trunk", "Trunk");
            //Textures[10] = new Texture("Leaves");
            //Textures[11] = new Texture("Lava");
            //Textures[12] = new Texture("CCube");
            //Textures[13] = new Texture("Select");
            //Hey Micah, don't be stupid. If you add another texture, change that ^^^^^^^^^


            //Set Colors
            Colors[0] = new Scheme(Color.FromArgb(255, 255, 255, 255)); // White
            Colors[1] = new Scheme(Color.FromArgb(255, 0, 255, 255));   // Teal
            Colors[2] = new Scheme(Color.FromArgb(255, 255, 0, 255));   // Purple
            Colors[3] = new Scheme(Color.FromArgb(255, 255, 255, 0));   // Yellow
            Colors[4] = new Scheme(Color.FromArgb(255, 0, 0, 255));     // Blue
            Colors[5] = new Scheme(Color.FromArgb(255, 255, 0, 0));     // Red
            Colors[6] = new Scheme(Color.FromArgb(255, 0, 255, 0));     // Green
            Colors[7] = new Scheme(Color.FromArgb(255, 0, 0, 0));       // Black

            //Set Transparency
            //TransP[0] = new Transparency(0);
            //TransP[1] = new Transparency(.1f);
            //TransP[2] = new Transparency(.2f);
            //TransP[3] = new Transparency(.3f);
            //TransP[4] = new Transparency(.4f);
            //TransP[5] = new Transparency(.5f);
            //TransP[6] = new Transparency(.6f);
            //TransP[7] = new Transparency(.7f);
            //TransP[8] = new Transparency(.8f);
            //TransP[9] = new Transparency(.9f);
            //TransP[10] = new Transparency(1);

            //Rotation Axis
            //rotAxis = rotAxis.setXYZ(0, 1, 0);
            Scene = convertToRoom(File.Read(path[0] + "\\parts\\Tree.ngs"));
            createRoom();
            potato = new Intelligence(alpha.setXYZ(-1, -1, -1), -1, -1, -1, -1, -1, -1, -1, -1);
        }
Esempio n. 21
0
        /// <summary>
        /// Loads the configuration from the specified file.
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            try
            {
                SetToDefault();

                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName));
                }

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);
                XmlElement rootElem = xmlDoc.DocumentElement;

                if (rootElem.SelectSingleNode("GeneralOptions") is XmlNode generalOptionsNode)
                {
                    GeneralOptions.LoadFromXml(generalOptionsNode);
                }

                if (rootElem.SelectSingleNode("ListenerOptions") is XmlNode listenerOptionsNode)
                {
                    ListenerOptions.LoadFromXml(listenerOptionsNode);
                }

                if (rootElem.SelectSingleNode("PathOptions") is XmlNode pathOptionsNode)
                {
                    PathOptions.LoadFromXml(pathOptionsNode);
                }

                HashSet <string> moduleCodes = new HashSet <string>();

                if (rootElem.SelectSingleNode("Modules") is XmlNode modulesNode)
                {
                    foreach (XmlElement moduleElem in modulesNode.SelectNodes("Module"))
                    {
                        string moduleCode = ScadaUtils.RemoveFileNameSuffixes(moduleElem.GetAttribute("code"));

                        if (moduleCodes.Add(moduleCode.ToLowerInvariant())) // check uniqueness
                        {
                            ModuleCodes.Add(moduleCode);
                        }
                    }
                }

                if (rootElem.SelectSingleNode("Archives") is XmlNode archivesNode)
                {
                    foreach (XmlElement archiveElem in archivesNode.SelectNodes("Archive"))
                    {
                        ArchiveConfig archiveConfig = new ArchiveConfig();
                        archiveConfig.LoadFromXml(archiveElem);
                        Archives.Add(archiveConfig);

                        if (archiveConfig.Active && moduleCodes.Add(archiveConfig.Module.ToLowerInvariant()))
                        {
                            ModuleCodes.Add(archiveConfig.Module);
                        }
                    }
                }

                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = CommonPhrases.LoadAppConfigError + ": " + ex.Message;
                return(false);
            }
        }
Esempio n. 22
0
        void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MonitorFile file;

            while (!worker.CancellationPending)
            {
                NotifyPropertyChanged("Active");
                NotifyPropertyChanged("Status");
                if (QueueCount == 0)
                {
                    // No new files? Take a nap.
                    try {
                        Thread.Sleep(100);
                    } catch (Exception ex) {
                        TranslatingMessageHandler.SendException(ex);
                    }
                    continue;
                }

                lock (FileQueue) {
                    file = FileQueue.Dequeue();
                }

                if (!file.Path.Game.IsMonitored)
                {
                    continue;
                }

                FileInfo fi   = new FileInfo(Path.Combine(file.root, file.path));
                GameID   game = file.Path.Game.id;
                switch (file.change_type)
                {
                case System.IO.WatcherChangeTypes.Changed:
                case System.IO.WatcherChangeTypes.Created:
                case System.IO.WatcherChangeTypes.Renamed:
                    if (!fi.Exists)
                    {
                        continue;
                    }
                    List <DetectedFile> these_files = file.Path.Game.GetSavesMatching(file.full_path);
                    if (these_files.Count == 0)
                    {
                        continue;
                    }
                    foreach (DetectedFile this_file in these_files)
                    {
                        _status = game.Name + " updating " + Path.Combine(this_file.Path, this_file.Name);
                        NotifyPropertyChanged("Status");

                        if (this_file.FullDirPath == null)
                        {
                            continue;
                        }

                        Archive archive = Archives.GetArchive(game, this_file);

                        try {
                            if (archive == null)
                            {
                                if (this_file.owner == null)
                                {
                                    archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                }
                                else
                                {
                                    archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                }
                                Archives.Add(archive);
                            }
                            //monitorNotifier.ShowBalloonTip(10, "Safety Will Robinson", "Trying to archive " + file.path, ToolTipIcon.Info);
                            MessageHandler.suppress_messages = true;
                            List <DetectedFile> temp_list = new List <DetectedFile>();
                            temp_list.Add(this_file);
                            archive.backup(temp_list, false, true);
                        } catch {
                            //monitorNotifier.ShowBalloonTip(10,"Danger Will Robinson","Error while trying to archive " + file.path,ToolTipIcon.Error);
                            // If something goes wrong during backup, it's probable the file copy.
                            // Reinsert the file to the end of the queue, then move on to the next one.
                            if (!FileQueue.Contains(file))
                            {
                                FileQueue.Enqueue(file);
                            }
                        } finally {
                            MessageHandler.suppress_messages = false;
                        }
                    }
                    break;
                }
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                }

                _status = null;
            }
            NotifyPropertyChanged("Status");
            NotifyPropertyChanged("Active");
        }