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(); } } }
private void thisDoubleClick(Object sender, EventArgs e) { if (elvMode == "StandAlone" && FocusedItem != null && File.Exists(FocusedItem.Tag.ToString())) { FileOpened?.Invoke(FocusedItem.Tag.ToString()); } }
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); } }
public Stream Open(FileHandler file, FileMode fileMode, FileAccess fileAccess, FileOpened handler = null) { var fStream = (Stream)file.Open(fileMode, fileAccess); handler?.Invoke(file); return(fStream); }
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 }); } }
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 }); } }
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)); }
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(); } } }
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); }
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); }
/// <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 }); } }
/// <summary> /// The OnFileOpened /// </summary> /// <param name="e">The e<see cref="EventArgs"/></param> protected virtual void OnFileOpened(EventArgs e) { FileOpened?.Invoke(this, e); }
protected virtual void OnFileOpened(Bitmap input) { FileOpened?.Invoke(this, new OpenEventArgs(input)); }
public async Task LoadFileAsync(string path, bool isDirty) { fileContents = await filePersistence.LoadAsync(path); FileOpened?.Invoke(this, new FileOperationEventArgs(path, fileContents, isDirty)); }
private void FileHandler_FileOpened(object sender, EventArgs e) { lineEditingControl.ResetPan(); FileOpened?.Invoke(sender, e); }
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); }
public void InvokeFileOpened(object sender, FileOpenedEventArgs arg) { FileOpened?.Invoke(sender, arg); }
protected virtual void OnFileOpened(FileInfo fileInfo) { FileOpened?.Invoke(this, fileInfo); }
protected virtual void OnFileOpened(string filename, System.Exception error) { FileOpened?.Invoke(this, new FileOpenedEventArgs(filename, error)); }
protected virtual void OnFileOpened(string e) { FileOpened?.Invoke(this, e); }
private void OnFileOpened(EventArgs e) => FileOpened?.Invoke(this, e);