Example #1
0
        // Load the query
        private void QueryClick(object sender, MouseButtonEventArgs e)
        {
            var item = (sender as ListView)?.SelectedItem;

            if (item != null)
            {
                Query q = (Query)item;

                // Expose the query
                _query = q.QueryStr;

                // Substitute tags
                DlQueryBox.Text = q.Tags;
                // Set scores
                MinimumScore_Numeric.Value = q.MinScore;
                MaximumScore_Numeric.Value = q.MaxScore;
                // Set ratings
                Safe_Switch.IsChecked         = q.Ratings[0];
                Questionable_Switch.IsChecked = q.Ratings[1];
                Explicit_Switch.IsChecked     = q.Ratings[2];

                // Clear grid
                if (FilesCollection.Any())
                {
                    FilesCollection.Clear();
                    DlPage.Value = 1;;
                }

                // Populate grid
                PopulateGrid(_query);
            }
        }
Example #2
0
        public void AddFile(string fileName)
        {
            string path = Location + "/" + fileName;

            File.WriteAllText(path, "/* Default text */", Encoding.UTF8);
            FilesCollection.Add(new FileItem(path, FilesCollection, this, null));
        }
Example #3
0
        // метод для загрузки файлов в коллекцию
        private void LoadCollection()
        {
            FilesCollection.Clear();

            // создаем список файлов, находящихся в заданной директории
            var fileList = GetFilesListFrom(CollectionPath);

            if (fileList.Count != 0)
            {
                // заполняем коллекцию объектами
                foreach (var file in fileList)
                {
                    FilesCollection.Add(new MyFile()
                    {
                        FilePath = file,
                        Name     = Path.GetFileName(file),
                        MD5sum   = ComputeMD5Checksum(file),
                        Clone    = false
                    });
                }

                //сортируем по MD5-сумме
                var sortedFileColl = FilesCollection.OrderBy(x => x.MD5sum).ToList();

                //проверяем наличие одинаковых файлов
                var count = 0; //количество дубликатов
                for (var i = 0; i < sortedFileColl.Count - 1; ++i)
                {
                    if (sortedFileColl[i].MD5sum == sortedFileColl[i + 1].MD5sum &&
                        CompareFilesByByte(sortedFileColl[i].FilePath, sortedFileColl[i + 1].FilePath) &&
                        sortedFileColl[i].Name == sortedFileColl[i + 1].Name)
                    {
                        sortedFileColl[i + 1].Clone = true;
                        sortedFileColl[i].Clone     = true;
                        ++count;
                    }
                }

                // передаем обработанный список
                FilesCollection = new ObservableCollection <MyFile>(sortedFileColl);

                //информируем о результате
                if (count == 0)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "Одинаковых файлов не обнаружено.",
                        "Инфо",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Asterisk);
                }
                else
                {
                    System.Windows.MessageBox.Show(
                        string.Format("Обнаружено дубликатов: {0}.", count,
                                      "Инфо",
                                      MessageBoxButtons.OK,
                                      MessageBoxIcon.Asterisk));
                }
            }
        }
Example #4
0
 public void Add(FilePart part)
 {
     if (files == null)
     {
         files = new FilesCollection();
     }
     this.files.Add(part);
 }
Example #5
0
 // Handle cleaning fetched files
 private void ClearFetched_Btn_Click(object sender, RoutedEventArgs e)
 {
     if (FilesCollection.Any())
     {
         FilesCollection.Clear();
         DlPage.Value = 1;
         testBox.Text = "List has been cleared!";
     }
 }
Example #6
0
        private void OnOpenFile()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Log files (*.log)|*.log|All files (*.*)|*.*";
            if (openFileDialog.ShowDialog() == true)
            {
                FilesCollection.Add(openFileDialog.FileName);
                SelectedFile = openFileDialog.FileName;
            }
        }
Example #7
0
        public ProcessManager()           //}
        {
            FileCollectionCurrent  = new FilesCollection <FileCurrent>();
            FileCollectionRevision = new FilesCollection <FileRevision>();
            FileCollectionFinal    = new FilesCollection <FileFinal>();

            history   = SavedFolderManager.GetHistoryManager();
            favorites = SavedFolderManager.GetFavoriteManager();

            Reset();
        }
Example #8
0
        // метод для удаления помеченных файлов
        private void DeleteClones()
        {
            int        count      = 0; // количество удалений
            int        inumerator = 0; // номер файла в списке
            List <int> resultList = new List <int>();

            // поиск отмеченных на удаление файлов
            MyFile current = null;

            foreach (var item in FilesCollection)
            {
                current = item as MyFile;
                if (current.Clone == true)
                {
                    resultList.Add(inumerator);
                    ++count;
                }
                ++inumerator;
            }

            //информируем о рузультате
            if (resultList.Count == 0)
            {
                System.Windows.MessageBox.Show(
                    "Нет файлов для удаления.",
                    "Инфо", MessageBoxButton.OK);
            }
            else
            {
                MessageBoxResult result = System.Windows.MessageBox.Show(
                    "Вы уверены, что хотите удалить все выделенные файлы?",
                    "ВНИМАНИЕ!!!",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes) //Если нажал Да
                {
                    var shift = 0;
                    // удаляем выбранные елементы из коллекции
                    foreach (var n in resultList)
                    {
                        File.Delete(FilesCollection[n - shift].FilePath);
                        FilesCollection.RemoveAt(n - shift);
                        ++shift;
                    }
                    System.Windows.MessageBox.Show(
                        string.Format("Файлы успешно удалены.\n" +
                                      "Количество удаленных файлов: {0}.", resultList.Count,
                                      "Готово",
                                      MessageBoxButton.OK,
                                      MessageBoxImage.Asterisk));
                }
            }
        }
Example #9
0
        public static FilesCollection SelectAll()
        {
            FilesCollection List = new FilesCollection();

            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblFiles_Select_SelectAll_linhnx"))
            {
                while (rd.Read())
                {
                    List.Add(getFromReader(rd));
                }
            }
            return(List);
        }
Example #10
0
        // Method used to populate the grid
        public void PopulateGrid(string query)
        {
            // Prepare json
            string json = JsonGetter.GetJson(query);

            Derpi derpi = Derpi.FromJson(json);

            testBox.Text = query + " at " + _settings.DownloadLocation;

            // Go through images in the search
            if (derpi == null)
            {
                testBox.Text = "No results for: " + query;
            }
            else
            {
                foreach (var search in derpi.Search)
                {
                    // Check if artist is given
                    string[] tags    = search.Tags.Split(',').Select(sValue => sValue.Trim()).ToArray();
                    var      artists = tags.Where(it => it.StartsWith("artist:"))
                                       .Select(it => it.Replace("artist:", null));

                    // Format artists
                    string artist = artists.Aggregate("", (current, v) => current + (v.ToString() + ","));
                    artist = artist.TrimEnd(',');

                    // Add to list of downloaded files
                    FilesCollection.Add(new FileDisplay(search.FileName,
                                                        search.MimeType,
                                                        search.SourceUrl,
                                                        artist,
                                                        search.Tags,
                                                        search.Description,
                                                        (int)search.Faves,
                                                        "https:" + search.Representations.Thumb,
                                                        "https:" + search.Image,
                                                        search.Id));

                    // Log the file
                    DownloadLog.Text += search.Image + Environment.NewLine;
                }

                // Up page number
                DlPage.Value = DlPage.Value + 1;

                // Up the file count
                TotalFiles        = FilesCollection.Count();
                FileIndexTxt.Text = CurrentFileNumber + "/" + TotalFiles;
            }
        }
Example #11
0
        public static FilesCollection SelectByTinnhanID(SqlConnection con, Guid PH_ID)
        {
            FilesCollection List = new FilesCollection();

            SqlParameter[] obj = new SqlParameter[1];
            obj[0] = new SqlParameter("PH_ID", PH_ID);
            using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "sp_tblFiles_Select_SelectByTinnhan_ductt", obj))
            {
                while (rd.Read())
                {
                    List.Add(new Files(rd));
                }
            }
            return(List);
        }
Example #12
0
        public static FilesCollection SelectByPRowId(Guid F_PID)
        {
            FilesCollection List = new FilesCollection();

            SqlParameter[] obj = new SqlParameter[1];
            obj[0] = new SqlParameter("F_PID", F_PID);
            using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblFiles_Select_SelectByPRowId_hoangda", obj))
            {
                while (rd.Read())
                {
                    List.Add(new Files(rd));
                }
            }
            return(List);
        }
Example #13
0
        public FilesCollection <FileFinal> Process()
        {
            if (FileCollectionRevision == null || FileCollectionCurrent == null)
            {
                return(null);
            }

            FinalFileColl = new FilesCollection <FileFinal>();

            // step one - Match adjusted sheet numbers
            if (!MatchSheetsNumbers())
            {
                return(null);
            }

            return(FinalFileColl);
        }
Example #14
0
        // Handle opening the file
        private void OpenFile_Btn_Click(object sender, RoutedEventArgs e)
        {
            FileDisplay fd = ((FrameworkElement)sender).DataContext as FileDisplay;

            CurrentFile       = fd;
            CurrentFileId     = FilesCollection.IndexOf(fd);
            FileIndexTxt.Text = CurrentFileId + 1 + "/" + TotalFiles;

            //Set infogrid
            SetImage(fd);

            CloseImageView.Visibility    = Visibility.Visible;
            ToggleInfogridBtn.Visibility = Visibility.Visible;
            FileIndexTxt.Visibility      = Visibility.Visible;

            Display_Flyout.IsOpen = true;
        }
Example #15
0
        private async void GetFilesFromDir()
        {
            //FilesCollection.;
            StorageFolder localFolder = ApplicationData.Current.LocalFolder;

            //retrieve folder
            string        level1FolderName = "UserDataStore";
            StorageFolder UserDataStore    = await localFolder.GetFolderAsync(level1FolderName);

            //retrieve files from selected folder
            IReadOnlyList <StorageFile> items = await UserDataStore.GetFilesAsync();

            foreach (StorageFile file in items)
            {
                FilesCollection.Add(file.Name);
            }
            //FilesList.ItemsSource = FilesCollection;
            FilesList.ItemsSource = FilesCollection;
        }
Example #16
0
        // Fetch
        private void FetchBtn_Click(object sender, RoutedEventArgs e)
        {
            // Empty collection if query was changed
            if (_wasQueryChanged)
            {
                FilesCollection.Clear();
                _wasQueryChanged = false;
            }

            string query = BuildQuery();

            if (query != "")
            {
                _query = query;

                // Populate grid
                PopulateGrid(_query);
            }
        }
Example #17
0
        // Button event handlers

        // Upload button event handler
        private void UploadButton_Click(object sender, RoutedEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                if (FilesCollection.Where(f => f.Name == _shortUploadFilename).Count() > 0)
                {
                    var result = MessageBox.Show($"A file with the name '{_shortUploadFilename}' already exists. Would you like to replace it?",
                                                 "Replace file", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                    if (result == MessageBoxResult.OK)
                    {
                        DeleteFile(_shortUploadFilename);
                        InitProgress(out ProgressModel progModel, out Progress <ProgressModel> progress, _shortUploadFilename,
                                     ActionType.Upload);
                        MakeListViewVisibleOnUI(UploadProgressListView);
                        UploadFile(UploadFilename, _shortUploadFilename, progress);
                        lock (this)
                        {
                            RemoveOnUI(UploadProgressList, progModel);
                        }
                        if (UploadProgressList.Count < 1)
                        {
                            MakeListViewHiddenOnUI(UploadProgressListView);
                        }
                    }
                }
                else
                {
                    InitProgress(out ProgressModel progModel, out Progress <ProgressModel> progress, _shortUploadFilename,
                                 ActionType.Upload);
                    UploadFile(UploadFilename, _shortUploadFilename, progress);
                    lock (this)
                    {
                        RemoveOnUI(UploadProgressList, progModel);
                    }
                }
            });
            UploadFileTextBox.Clear();
        }
Example #18
0
 public ProcessFiles(FilesCollection <FileCurrent> fileCollectionCurrent,
                     FilesCollection <FileRevision> fileCollectionRevision)
 {
     FileCollectionRevision = fileCollectionRevision;
     FileCollectionCurrent  = fileCollectionCurrent;
 }
Example #19
0
        private void Initialize()
        {
            if (!IsFastCgiInstalled())
            {
                // If FastCGI is not installed on IIS then bail out as there is no point to continue
                _registrationType = PHPRegistrationType.NoneNoFastCgi;
                return;
            }

            // Get the handlers collection
            var handlersSection = _configurationWrapper.GetHandlersSection();
            _handlersCollection = handlersSection.Handlers;

            // Get the Default document collection
            var defaultDocumentSection = _configurationWrapper.GetDefaultDocumentSection();
            _defaultDocumentCollection = defaultDocumentSection.Files;

            // Get the FastCgi application collection
            var appHostConfig = _configurationWrapper.GetAppHostConfiguration();
            var fastCgiSection = (FastCgiSection)appHostConfig.GetSection("system.webServer/fastCgi", typeof(FastCgiSection));
            _fastCgiApplicationCollection = fastCgiSection.Applications;

            // Assume by default that PHP is not registered
            _registrationType = PHPRegistrationType.None;

            // Find the currently active PHP handler and FastCGI application
            var handler = _handlersCollection.GetActiveHandler("*.php");
            if (handler != null)
            {
                if (String.Equals(handler.Modules, "FastCgiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.FastCgi;
                }
                else if (String.Equals(handler.Modules, "CgiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.Cgi;
                }
                else if (String.Equals(handler.Modules, "IsapiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.Isapi;
                }

                if (_registrationType == PHPRegistrationType.FastCgi)
                {
                    ApplicationElement fastCgiApplication = _fastCgiApplicationCollection.GetApplication(handler.Executable, handler.Arguments);
                    if (fastCgiApplication != null)
                    {
                        _currentPhpHandler = handler;
                        _currentFastCgiApplication = fastCgiApplication;
                        _phpIniFilePath = GetPHPIniFilePath();
                        if (String.IsNullOrEmpty(_phpIniFilePath))
                        {
                            throw new FileNotFoundException(String.Format(Resources.CannotFindPhpIniForExecutableError, handler.Executable));
                        }
                        _phpDirectory = GetPHPDirectory();
                    }
                    else
                    {
                        _registrationType = PHPRegistrationType.None;
                    }
                }
            }
        }
Example #20
0
 protected void InitFiles()
 {
     files         = new FilesCollection(this);
     filesReadonly = new ReadOnlyCollection <OpenedFile>(files);
 }
Example #21
0
        private void Initialize()
        {
            // Get the handlers collection
            ManagementConfiguration config = _managementUnit.Configuration;
            HandlersSection handlersSection = (HandlersSection)config.GetSection("system.webServer/handlers", typeof(HandlersSection));
            _handlersCollection = handlersSection.Handlers;

            // Get the Default document collection
            DefaultDocumentSection defaultDocumentSection = (DefaultDocumentSection)config.GetSection("system.webServer/defaultDocument", typeof(DefaultDocumentSection));
            _defaultDocumentCollection = defaultDocumentSection.Files;

            // Get the FastCgi application collection
            Configuration appHostConfig = _managementUnit.ServerManager.GetApplicationHostConfiguration();
            FastCgiSection fastCgiSection = (FastCgiSection)appHostConfig.GetSection("system.webServer/fastCgi", typeof(FastCgiSection));
            _fastCgiApplicationCollection = fastCgiSection.Applications;

            // Assume by default that PHP is not registered
            _registrationType = PHPRegistrationType.None;

            // Find the currently active PHP handler and FastCGI application
            HandlerElement handler = _handlersCollection.GetActiveHandler("*.php");
            if (handler != null)
            {
                if (String.Equals(handler.Modules, "FastCgiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.FastCgi;
                }
                else if (String.Equals(handler.Modules, "CgiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.Cgi;
                }
                else if (String.Equals(handler.Modules, "IsapiModule", StringComparison.OrdinalIgnoreCase))
                {
                    _registrationType = PHPRegistrationType.Isapi;
                }

                if (_registrationType == PHPRegistrationType.FastCgi)
                {
                    ApplicationElement fastCgiApplication = _fastCgiApplicationCollection.GetApplication(handler.Executable, handler.Arguments);
                    if (fastCgiApplication != null)
                    {
                        _currentPHPHandler = handler;
                        _currentFastCgiApplication = fastCgiApplication;
                        _phpIniFilePath = GetPHPIniFilePath();
                        _phpDirectory = GetPHPDirectory();
                    }
                    else
                    {
                        _registrationType = PHPRegistrationType.None;
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="address">Сетевой адрес устройсва</param>
        public Device(Byte address)
        {
            _Status = Status.Stopped;
            Address = address;
            _Description = String.Empty;

            _Coils = new CoilsCollection();
            _Coils.SetOwner(this);
            _Coils.ListWasChanged +=
                new EventHandler(EventHandler_Coils_ListWasChanged);
            _DiscretesInputs = new DiscretesInputsCollection();
            _DiscretesInputs.SetOwner(this);
            _DiscretesInputs.ListWasChanged +=
                new EventHandler(EventHandler_DiscretesInputs_ListWasChanged);
            _InputRegisters = new InputRegistersCollection();
            _InputRegisters.SetOwner(this);
            _InputRegisters.ListWasChanged +=
                new EventHandler(EventHandler_InputRegisters_ListWasChanged);
            _HoldingRegisters = new HoldingRegistersCollection();
            _HoldingRegisters.SetOwner(this);
            _HoldingRegisters.ListWasChanged +=
                new EventHandler(EventHandler_HoldingRegisters_ListWasChanged);
            _Files = new FilesCollection();
            _Files.SetOwner(this);
            _Files.ListWasChanged +=
                new EventHandler(EventHandler_Files_ListWasChanged);
        }