/// <summary>
        /// Инициализация экземпляра окна с pgorgess bar
        /// </summary>
        /// <returns></returns>
        public static ProgressWindow InitializeProgressWindow()
        {
            ProgressWindow progressWindow = new ProgressWindow();
            progressWindow.capitalText.Background = (System.Windows.Media.Brush)Application.Current.MainWindow.FindResource("Brush8B4789");
            progressWindow.capitalText.Padding = new Thickness(PROGRESS_WINDOW_HEADER_TEXT_PADDING_DEFAULT,
                                                                PROGRESS_WINDOW_HEADER_TEXT_PADDING_DEFAULT,
                                                                PROGRESS_WINDOW_HEADER_TEXT_PADDING_DEFAULT,
                                                                PROGRESS_WINDOW_HEADER_TEXT_PADDING_DEFAULT);
            progressWindow.pbStatus.Value = 0;
            progressWindow.pbStatus.SmallChange = PROGRESS_BAR_STEP_DEFAULT;
            progressWindow.textInformation.Text = INFO_TEXT_DEFAULT;

            return progressWindow;
        }
        /// <summary>
        /// Загрузка видео
        /// </summary>
        private async void LoadVideoFileFunction()
        {
            try
            {
                this.video = new GreyVideo();

                progressWindow = ProgressWindow.InitializeProgressWindow();
                OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow();

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "MP4 Image (.mp4)|*.mp4|3gp (.3gp)|*.3gp|Avi (.avi)|*.avi";
                dialog.ShowDialog();

                FrameSizeWindow frameSizeWindow = FrameSizeWindow.InitializeFrameSizeWindow();
                frameSizeWindow.capitalText.Text = PARAMETERS_SETTING_STRING;
                frameSizeWindow.ShowDialog();

                FrameSizeViewModel frameSizeViewModel = (FrameSizeViewModel)frameSizeWindow.DataContext;

                progressWindow.capitalText.Text = LOAD_VIDEO_STRING;
                progressWindow.textInformation.Text = VIDEO_INITIALIZATION_STRING;
                progressWindow.Show();

                string videoFilePath = System.IO.Path.GetDirectoryName(dialog.FileName);
                string videoFileName = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
                string keyFramesInormatyionFilePath = System.IO.Path.Combine(videoFilePath, videoFileName + ".txt");

                IOData ioData = new IOData() { FileName = dialog.FileName, FrameHeight = frameSizeViewModel.FrameHeight, FrameWidth = frameSizeViewModel.FrameWidth };

                VideoLoader videoLoader = new VideoLoader();
                int framesNumber = await videoLoader.CountFramesNumberAsync(ioData);            
                progressWindow.pbStatus.SmallChange = (double)progressWindow.pbStatus.Maximum / (double)framesNumber;

                /// Если существует файл с информацией о ключевых кадрах
                if (System.IO.File.Exists(keyFramesInormatyionFilePath))
                {
                    FileReader fileReader = new FileReader();
                    FileReader.ExceptionOccuredEvent += this.ExceptionOccuredEventHandler;
                    keyFrameIOInformation = await fileReader.ReadKeyFramesInformationAsync(keyFramesInormatyionFilePath, frameSizeViewModel.FrameWidth, frameSizeViewModel.FrameHeight);
                    ioData.KeyFrameIOInformation = keyFrameIOInformation;                    

                   // EdgeBasedKeyFrameExtractor.keyFrameExtractedEvent += this.KeyFramesExtractionProcessing;
                   // EdgeBasedKeyFrameExtractor edgeBasedKeyFrameExtractor = new EdgeBasedKeyFrameExtractor();
                  //  this.video.Frames = await edgeBasedKeyFrameExtractor.ExtractKeyFramesByListNumberAsync(ioData);
                }
                else   /// Если нет, то выделяем кадры алгоритмически
                {
                    EdgeBasedKeyFrameExtractor.keyFrameExtractedEvent += this.KeyFramesExtractionProcessing;
                    EdgeBasedKeyFrameExtractor.framesDifferenceEvent += this.FramesDifferenceCalculateProcessing;
                    EdgeBasedKeyFrameExtractor edgeBasedKeyFrameExtractor = new EdgeBasedKeyFrameExtractor();
                    this.video.Frames = await edgeBasedKeyFrameExtractor.ExtractKeyFramesTwoPassAsync(ioData);
                }
                okButtonWindow = OkButtonWindow.InitializeOkButtonWindow();
                okButtonWindow.capitalText.Text = LOAD_VIDEO_STRING;
                okButtonWindow.textInformation.Text = LOAD_VIDEO_SUCCESS_STRING;
                okButtonWindow.ShowDialog();

                progressWindow.Close();                
                this.VideoFileName = new Uri(dialog.FileName);
                this.videoFileNameString = dialog.FileName;
                this.MediaPlayerNavigationVisibility = Visibility.Visible;
                this.VideoWasNotLoaded = Visibility.Hidden;

                this.IsVideoFrameTabSelected = false;
                this.IsProcessedVideoFramesTabSelected = false;
                this.IsProcessedVideoFrameTabSelected = false;
                this.IsVideoTabSelected = true;
            }
            catch (Exception exception)
            {
                progressWindow.Hide();
                ShowExceptionMessage(exception.Message);             
            }
        }
        /// <summary>
        /// Сохранение обработанного видео в виде набора ключевых кадров
        /// </summary>
        private async void SaveVideoFileFunction()
        {
            try
            {
                progressWindow = ProgressWindow.InitializeProgressWindow();
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.ShowDialog();

                string XMLFileName = System.IO.Path.Combine(dialog.FileName, System.IO.Path.GetFileNameWithoutExtension(dialog.FileName) + ".xml");
                
                VideoSaver videoSaver = new VideoSaver();
                VideoSaver.videoFrameSavedEvent += this.VideoFrameSavedProcessing;
                System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Red, 2);

                progressWindow.pbStatus.Value = 0.0;
                if (this.video != null && this.video.Frames != null)
                    progressWindow.pbStatus.SmallChange = (double)progressWindow.pbStatus.Maximum / (double)this.video.Frames.Count;
                progressWindow.capitalText.Text = SAVE_PROCESSED_VIDEO_FRAMES_STRING;
                progressWindow.textInformation.Text = "";

                progressWindow.Show();
                if (this.video != null && this.video.Frames != null)
                {
                    await videoSaver.SaveVideoAsync(this.video, pen, dialog.FileName, "ProcessedFrames", ".jpg");
                    await DigitalVideoProcessingLib.IO.XMLWriter.WriteTextBlocksInformation(video, XMLFileName);
                }
                else
                {
                    await videoSaver.SaveVideoAsync(this.processedVideoFramesBitmapForSave, dialog.FileName, "ProcessedFrames", ".jpg");
                    await DigitalVideoProcessingLib.IO.XMLWriter.WriteTextBlocksInformation(this.textRegionsDictionary, XMLFileName);
                }           

                OkButtonWindow okButtonWindow = OkButtonWindow.InitializeOkButtonWindow();
                okButtonWindow.capitalText.Text = SAVE_PROCESSED_VIDEO_FRAMES_STRING;
                okButtonWindow.textInformation.Text = SAVE_PROCESSED_VIDEO_FRAMES_SUCCESS_STRING;

                progressWindow.Hide();    
                okButtonWindow.ShowDialog();                    
            }
            catch (Exception exception)
            {
                progressWindow.Hide();   
                ShowExceptionMessage(exception.Message);
            }
        }