Example #1
0
 private void lblFile_Click(object sender, EventArgs e)
 {
     if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             _bytes = File.ReadAllBytes(ofd.FileName);
             var ext = Path.GetExtension(ofd.FileName);
             if (ext == ".ppm" || ext == ".pgm")
             {
                 _ci = new CustomImage(_bytes);
             }
             if (ext == ".wav")
             {
                 _wd = Lab4.GetWaveData(ofd.FileName);
             }
             ofd.FileName = ofd.SafeFileName;
             lblFile.Text = ofd.SafeFileName;
         }
         catch
         {
             MessageBox.Show(string.Format("Открыть файл {0} не удалось",
                                           ofd.FileName),
                             "Ошибка",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
         if (_ci != null || _wd != null)
         {
             FileOpened?.Invoke();
         }
     }
 }
Example #2
0
 internal void InternalOpen(string filename)
 {
     info.Logger.Info("Öffne Datei " + filename);
     Timetable = open.Import(filename, info);
     if (Timetable == null)
     {
         info.Logger.Error("Fehler beim Öffnen der Datei!");
     }
     else
     {
         info.Logger.Info("Datei erfolgeich geöffnet!");
     }
     if (Timetable?.UpgradeMessage != null)
     {
         info.Logger.Warning(Timetable.UpgradeMessage);
     }
     FileState.Opened   = Timetable != null;
     FileState.Saved    = Timetable != null;
     FileState.FileName = Timetable != null ? filename : null;
     undo.ClearHistory();
     if (Timetable != null)
     {
         FileOpened?.Invoke(this, null);
     }
 }
 private void thisDoubleClick(Object sender, EventArgs e)
 {
     if (elvMode == "StandAlone" && FocusedItem != null && File.Exists(FocusedItem.Tag.ToString()))
     {
         FileOpened?.Invoke(FocusedItem.Tag.ToString());
     }
 }
Example #4
0
        private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "JPG files (*.jpg)|*.jpg| All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.Stream FileOpened;
                if ((FileOpened = openFileDialog1.OpenFile()) != null)
                {
                    byte[] FileData = new byte[FileOpened.Length];
                    FileOpened.Read(FileData, 0, FileData.Length);
                    FileOpened.Close();

                    if (EventAddImage.Target != null)
                    {
                        EventAddImage.Invoke(FileData, null);
                    }
                }
                ;
            }
            ;
        }
        public void Handle(FileOpened message)
        {
            var uploadFileViewModel = _container.Resolve <UploadFileViewModel>();

            _windowManager.ShowWindow(uploadFileViewModel);

            ICommand command = _uploadFileFactory(SelectedContactsNumbers.First(), message.FileInfo);

            CommandInvoker.InvokeBusy(command, uploadFileViewModel, e => uploadFileViewModel.TryClose());
        }
Example #6
0
 internal void New(TimetableType type)
 {
     if (!NotifyIfUnsaved())
     {
         return;
     }
     Timetable          = new Timetable(type);
     FileState.Opened   = true;
     FileState.Saved    = false;
     FileState.FileName = null;
     undo.ClearHistory();
     info.Logger.Info("Neue Datei erstellt");
     FileOpened?.Invoke(this, null);
 }
        private void FileBrowser_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = GetSelectedItem((FrameworkElement)e.OriginalSource);

            if (!(item.DataContext is FileItem file))
            {
                return;
            }

            if (!file.IsDirectory)
            {
                FileOpened?.Invoke(file.Path);
            }
        }
        /// <summary>
        /// Opens a file from the given filename.
        /// </summary>
        /// <param name="filename">Full path of the file to open.</param>
        /// <param name="modelType">Type of the model of the file.</param>
        /// <remarks>This overload is intended to open files on disk, using a specific file type, that are not associated with a project.
        /// To open a project file, use <see cref="OpenFile(Object, Project)"/>.
        /// To open a file that is not necessarily on disk, use <see cref="OpenFile(Object, Boolean)"/>.
        /// To open a file, auto-detecting the file type, use <see cref="OpenFile(String)"/>.
        ///
        /// When the file is closed, the underlying model will be disposed.</remarks>
        public virtual async Task OpenFile(string filename, TypeInfo modelType)
        {
            var model = await IOHelper.OpenFile(filename, modelType, CurrentPluginManager);

            if (!OpenFiles.Any(x => ReferenceEquals(x.Model, model)))
            {
                var wrapper = CreateViewModel(model);
                wrapper.Filename       = filename;
                wrapper.DisposeOnClose = true;
                OpenFiles.Add(wrapper);
                FileOpened?.Invoke(this, new FileOpenedEventArguments {
                    File = model, FileViewModel = wrapper, DisposeOnExit = true
                });
            }
        }
Example #9
0
        private async Task OpenInnerAsync(string fileName, Func <TDocument> ifNotExists = null)
        {
            string ext = Path.GetExtension(fileName);

            string openFile = fileName;

            if (FileHandlers.ContainsKey(ext))
            {
                openFile = FileHandlers[ext].Invoke(fileName);
            }

            Document = await JsonFile.LoadAsync(openFile, ifNotExists);

            Filename = openFile;
            FileOpened?.Invoke(this, new EventArgs());
        }
        /// <summary>
        /// Opens the given file
        /// </summary>
        /// <param name="model">The model to open</param>
        /// <param name="disposeOnClose">True to call the file's dispose method (if IDisposable) when closed.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> is null.</exception>
        public virtual void OpenFile(object model, bool disposeOnClose)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (!OpenFiles.Any(x => ReferenceEquals(x.Model, model)))
            {
                var wrapper = CreateViewModel(model);
                wrapper.DisposeOnClose = disposeOnClose;
                OpenFiles.Add(wrapper);
                FileOpened?.Invoke(this, new FileOpenedEventArguments {
                    File = model, FileViewModel = wrapper, DisposeOnExit = disposeOnClose
                });
            }
        }
Example #11
0
        public void OpenFile(string filePath)
        {
            if (IsFileOpen)
            {
                CloseFile();
            }

            FileOpening?.Invoke(this, new FileOpeningEventArgs(filePath));

            this.filePath = filePath;

            using (var stream = File.OpenRead(filePath))
            {
                this.memory = Memory.CreateFromStream(stream);
            }

            FileOpened?.Invoke(this, new FileOpenedEventArgs(filePath));
        }
Example #12
0
        private void updateFile(IndexingTask task)
        {
            task.BeginScan();

            SetFilePropertiesOf(task);

            if (task.FileAccessException != null)
            {
                return;
            }

            if (task.Path == null)
            {
                return;
            }

            if (task.FileLength >= MaxFileLength)
            {
                _indexEngine.Remove(task.ContentId, task.CancellationToken);
                task.EndScan();
                return;
            }

            var textReader = openFile(task);

            if (textReader == null)
            {
                return;
            }

            using (textReader)
            {
                FileOpened?.Invoke(this, task);
                _indexEngine.Update(task.ContentId, textReader, task.CancellationToken);

                if (!task.CancellationToken.IsCancellationRequested)
                {
                    task.EndScan();
                }
            }
        }
Example #13
0
        public static FileOpened GetFileOpenedReport(DebuggerThread Context, DataProcessor Data)
        {
            FileOpened Report = new FileOpened();

            Report.Handle = new IntPtr(Data.Pop());

            var Type = (StringType)Data.Pop();

            if (Type != StringType.WCHAR)
            {
                throw new Exception("GetFileOpenedReport expects a widestring message");
            }

            var Length     = Data.Pop();
            var MessagePtr = new IntPtr(Data.Pop());

            Report.FileName  = Context.OwningProcess.ReadWString(MessagePtr, Length);
            Report.Succeeded = Data.Pop() != 0;

            return(Report);
        }
        private void OnFileOpened()
        {
            if (!ActiveFile.FileFormat.IsMobile)
            {
                ActiveFile.Name = Path.GetFileNameWithoutExtension(TheSettings.MostRecentFile);
            }
            if (!ActiveFile.FileFormat.IsPS2)
            {
                ActiveFile.TimeStamp = File.GetLastWriteTime(TheSettings.MostRecentFile);
            }

            OnPropertyChanged(nameof(IsFileOpen));
            Log.Info("File opened successfully.");
            Log.Info("File Info:");
            Log.Info($"        Type = {ActiveFile.FileFormat}");
            Log.Info($"  Time Stamp = {ActiveFile.TimeStamp}");
            Log.Info($"    Progress = {(ActiveFile.Stats.ProgressMade / ActiveFile.Stats.TotalProgressInGame):P2}");
            Log.Info($"Last Mission = {ActiveFile.Stats.LastMissionPassedName}");
            Log.Info($" Script Size = {ActiveFile.Scripts.MainScriptSize}");

            FileOpened?.Invoke(this, EventArgs.Empty);
        }
Example #15
0
        public Bootstrapper(LastFileHandler lfh)
        {
            timetableBackup = new Dictionary <object, Timetable>();

            var configPath = Path.Combine(PathManager.Instance.SettingsDirectory, "fpledit.conf");

#pragma warning disable CA2000
            settings = new Settings(GetConfigStream(configPath));
#pragma warning restore CA2000

            var lang = settings.Get("lang", "de-DE");
            T.SetLocale(Path.Combine(PathManager.Instance.AppDirectory, "Languages"), lang);

            registry         = new RegisterStore();
            Update           = new UpdateManager(settings);
            undo             = new UndoManager();
            ExtensionManager = new ExtensionManager(this);
            FileHandler      = new FileHandler(this, lfh, undo);

            FileHandler.FileOpened       += (o, args) => FileOpened?.Invoke(o, args);
            FileHandler.FileStateChanged += (o, args) => FileStateChanged?.Invoke(o, args);
        }
        public static FileOpened GetFileOpenedReport(DebuggerThread Context, uint[] Data)
        {
            FileOpened Report = new FileOpened();

            Report.Handle = new IntPtr(Data[0]);

            StringType Type = (StringType)Data[1];

            if (Type != StringType.WCHAR)
            {
                throw new Exception("GetFileOpenedReport expects a widestring message");
            }

            uint   Length     = Data[2];
            IntPtr MessagePtr = new IntPtr(Data[3]);

            Report.FileName = Context.OwningProcess.ReadWString(MessagePtr, Length);

            Report.Succeeded = Data[4] != 0;

            return(Report);
        }
        /// <summary>
        /// Opens the given file
        /// </summary>
        /// <param name="model">File to open</param>
        /// <param name="parentProject">Project the file belongs to.  If the file does not belong to a project, don't use this overload.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> or <paramref name="parentProject"/> is null.</exception>
        public virtual void OpenFile(object model, Project parentProject)
        {
            if (ReferenceEquals(model, null))
            {
                throw (new ArgumentNullException(nameof(model)));
            }
            if (ReferenceEquals(parentProject, null))
            {
                throw (new ArgumentNullException(nameof(parentProject)));
            }

            if (!OpenFiles.Any(x => ReferenceEquals(x.Model, model)))
            {
                var wrapper = CreateViewModel(model);
                wrapper.DisposeOnClose = false;
                wrapper.ParentProject  = parentProject;
                OpenFiles.Add(wrapper);
                FileOpened?.Invoke(this, new FileOpenedEventArguments {
                    File = model, FileViewModel = wrapper, DisposeOnExit = false, ParentProject = parentProject
                });
            }
        }
Example #18
0
        public string OpenDBDialog(string defaultPath)
        {
            Stream FileOpened;

            System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
            openFileDialog1.Title            = "Укажите путь к файлу Базы Данных";
            openFileDialog1.InitialDirectory = defaultPath;
            openFileDialog1.Filter           = "DataBase files (*.mdb)|*.mdb| All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                CloseDB();
                if ((FileOpened = openFileDialog1.OpenFile()) != null)
                {
                    FileOpened.Close();
                    try
                    {
                        if (!OpenDB(openFileDialog1.FileName))
                        {
                            throw new Exception("Не удалось подключится к базе данных " + openFileDialog1.FileName);
                        }
                        return(openFileDialog1.FileName);
                    }
                    catch (Exception ex)
                    {
                        ErrorWork.ErrorProcess(ex);
                    };
                }
                ;
            }
            ;

            return("");
        }
Example #19
0
        private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog SaveFileDialog1 = new SaveFileDialog();

            SaveFileDialog1.Filter           = "JPG files (*.jpg)|*.jpg| All files (*.*)|*.*";
            SaveFileDialog1.FilterIndex      = 1;
            SaveFileDialog1.RestoreDirectory = true;
            if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.Stream FileOpened;
                if ((FileOpened = SaveFileDialog1.OpenFile()) != null)
                {
                    FileOpened.Close();
                    if (EventGetImage.Target != null)
                    {
                        EventGetImage.Invoke(new string[] { listViewImages.SelectedItems[0].ImageKey, SaveFileDialog1.FileName }, EventArgs.Empty);
                    }
                    else
                    {
                        listViewImages.LargeImageList.Images[listViewImages.LargeImageList.Images.IndexOfKey(listViewImages.SelectedItems[0].ImageKey)].Save(SaveFileDialog1.FileName);
                    }
                }
            }
        }
Example #20
0
 protected virtual void OnFileOpened(string e)
 {
     FileOpened?.Invoke(this, e);
 }
Example #21
0
        public override void PerformLayout()
        {
            base.PerformLayout();
            Action <object, string, string> fileOpenAction = (jsBlob, textContent, dataUrl) =>
            {
                var eventArgs = new FileUploadEventArgs(jsBlob, textContent, dataUrl);
                FileOpened?.Invoke(this, eventArgs);
                Command?.Execute(new ICommandParameter(eventArgs));
            };

            Action <object> changeAction = evt =>
            {
                var input = Verbatim.Expression("evt.target");
                var file  = Verbatim.Expression("$0.files[0]", input);
                FileName = (string)Verbatim.Expression("$0.name", file);
                var    reader       = Verbatim.Expression("new FileReader()");
                Action onLoadAction = () =>
                {
                    var jsBlob = Verbatim.Expression("$0.result", reader);
                    //string fileMimeType = (string)Verbatim.Expression("$0.type", file);
                    string textContent = null;
                    string dataUrl     = null;
                    switch (UploadType)
                    {
                    case FileUploadType.TextFile:
                        switch (FileEncoding)
                        {
                        case FileReaderEncoding.ASCII:
                            textContent = jsBlob as string;
                            break;

                        case FileReaderEncoding.UTF8:
                            textContent = BufferConverter.ArrayBufferToStringUTF8(jsBlob);
                            break;

                        case FileReaderEncoding.UTF16:
                            textContent = BufferConverter.ArrayBufferToStringUTF16(jsBlob);
                            break;
                        }
                        break;

                    case FileUploadType.ImageFile:
                        dataUrl = jsBlob as string;
                        break;
                    }
                    fileOpenAction(jsBlob, textContent, dataUrl);
                };
                Verbatim.Expression("$0.onload = $1", reader, onLoadAction);
                switch (UploadType)
                {
                case FileUploadType.TextFile:
                case FileUploadType.BinaryFile:
                    if (FileEncoding == FileReaderEncoding.ASCII)
                    {
                        Verbatim.Expression("$0.readAsText($1);", reader, file);
                    }
                    else
                    {
                        Verbatim.Expression("$0.readAsArrayBuffer($1);", reader, file);
                    }
                    break;

                case FileUploadType.ImageFile:
                    Verbatim.Expression("$0.readAsDataURL($1);", reader, file);
                    break;
                }
            };

            InternalJQElement.BindEventListener("change", changeAction);
        }
Example #22
0
 protected virtual void OnFileOpened(FileInfo fileInfo)
 {
     FileOpened?.Invoke(this, fileInfo);
 }
Example #23
0
 public void InvokeFileOpened(object sender, FileOpenedEventArgs arg)
 {
     FileOpened?.Invoke(sender, arg);
 }
Example #24
0
 /// <summary>
 /// The OnFileOpened
 /// </summary>
 /// <param name="e">The e<see cref="EventArgs"/></param>
 protected virtual void OnFileOpened(EventArgs e)
 {
     FileOpened?.Invoke(this, e);
 }
Example #25
0
        public Stream Open(FileHandler file, FileMode fileMode, FileAccess fileAccess, FileOpened handler = null)
        {
            var fStream = (Stream)file.Open(fileMode, fileAccess);

            handler?.Invoke(file);

            return(fStream);
        }
Example #26
0
        public async Task LoadFileAsync(string path, bool isDirty)
        {
            fileContents = await filePersistence.LoadAsync(path);

            FileOpened?.Invoke(this, new FileOperationEventArgs(path, fileContents, isDirty));
        }
Example #27
0
        private void FileHandler_FileOpened(object sender, EventArgs e)
        {
            lineEditingControl.ResetPan();

            FileOpened?.Invoke(sender, e);
        }
Example #28
0
 protected virtual void OnFileSelected(string file)
 {
     FileOpened.Raise(this, new FileEventArgs(file));
 }
Example #29
0
 protected virtual void OnFileOpened(string filename, System.Exception error)
 {
     FileOpened?.Invoke(this, new FileOpenedEventArgs(filename, error));
 }
Example #30
0
 private void OnFileOpened(EventArgs e) => FileOpened?.Invoke(this, e);