public async Task ExecuteThreeFileDifferenceWebResources(SelectedFile selectedFile, ConnectionData connectionData1, ConnectionData connectionData2, ShowDifferenceThreeFileType differenceType, CommonConfiguration commonConfig) { string operation = string.Format(Properties.OperationNames.DifferenceLocalFileAndTwoWebResourcesFormat3, differenceType, connectionData1?.Name, connectionData2?.Name); this._iWriteToOutput.WriteToOutputStartOperation(null, operation); try { this._iWriteToOutput.WriteToOutput(null, Properties.OperationNames.CheckingFilesEncoding); CheckController.CheckingFilesEncoding(this._iWriteToOutput, null, new List <SelectedFile>() { selectedFile }, out List <SelectedFile> filesWithoutUTF8Encoding); this._iWriteToOutput.WriteToOutput(null, string.Empty); this._iWriteToOutput.WriteToOutput(null, string.Empty); this._iWriteToOutput.WriteToOutput(null, string.Empty); await ThreeFileDifferenceWebResources(selectedFile, connectionData1, connectionData2, differenceType, commonConfig); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(null, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(null, operation); } }
public void HandleOpenWebResourceInExplorer(ConnectionData connectionData, SelectedFile selectedFile, ActionOnComponent actionOnComponent) { CommonConfiguration commonConfig = CommonConfiguration.Get(); if (connectionData == null) { if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig)) { return; } connectionData = crmConfig.CurrentConnectionData; } if (connectionData != null && commonConfig != null) { ActivateOutputWindow(connectionData); WriteToOutputEmptyLines(connectionData, commonConfig); CheckWishToChangeCurrentConnection(connectionData); try { Controller.StartOpeningWebResourceInExplorer(connectionData, commonConfig, selectedFile, actionOnComponent); } catch (Exception ex) { WriteErrorToOutput(connectionData, ex); } } }
public async Task ExecuteCreatingLastLinkReport(SelectedFile selectedFile, ConnectionData connectionData) { string operation = string.Format(Properties.OperationNames.CreatingLastLinkForReportFormat1, connectionData?.Name); this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation); try { { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OperationNames.CheckingFilesEncoding); CheckController.CheckingFilesEncoding(this._iWriteToOutput, connectionData, new List <SelectedFile>() { selectedFile }, out List <SelectedFile> filesWithoutUTF8Encoding); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); } await CreatingLastLinkReport(selectedFile, connectionData); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation); } }
public async Task <FilesResult> LoadSelectedFile() { FilesResult result = new FilesResult(); ExternalStorageDevice sdCard = (await ExternalStorage.GetExternalStorageDevicesAsync()).FirstOrDefault(); if (sdCard != null) { IEnumerable <ExternalStorageFile> files = await sdCard.RootFolder.GetFilesAsync(); if (SelectedFile.Name.EndsWith(".txt")) { System.IO.Stream fileStream = await SelectedFile.OpenForReadAsync(); //Read the entire file into the FileText property using (StreamReader streamReader = new StreamReader(fileStream)) { FileText = streamReader.ReadToEnd(); } fileStream.Close(); result.Success = true; } else { result.Success = false; result.Message = "Invalid file type. Can only open text files with a '.txt' extension"; } } return(result); }
void _selectButton_Action(object sender, EventArgs e) { if (fileName.Text != string.Empty) { var rootDir = System.IO.Path.GetDirectoryName(AppContext.BaseDirectory); var folder = directoryListBox.CurrentFolder.Remove(0, rootDir.Length); SelectedFile = System.IO.Path.Combine(folder, fileName.Text); var extensions = fileFilterString.Replace("*", "").Trim(';').Split(';'); bool foundExtension = false; foreach (var item in extensions) { if (SelectedFile.ToLower().EndsWith(item)) { foundExtension = true; break; } } if (!foundExtension) { SelectedFile += extensions[0]; } DialogResult = true; Hide(); } }
private void ItemSettingsComponent_Load(object sender, System.EventArgs e) { txtFileIdentifier.Text = SelectedFile.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Last(); txtStructureIdentifier.Text = StructureIdentifier; comboBox1.SelectedIndex = 0; }
public async Task ExecuteDifferenceWebResources(SelectedFile selectedFile, bool isCustom, ConnectionData connectionData, CommonConfiguration commonConfig) { string operation = string.Format(Properties.OperationNames.DifferenceWebResourceFormat1, connectionData?.Name); this._iWriteToOutput.WriteToOutputStartOperation(connectionData, operation); try { { this._iWriteToOutput.WriteToOutput(connectionData, Properties.OperationNames.CheckingFilesEncoding); CheckController.CheckingFilesEncoding(this._iWriteToOutput, connectionData, new List <SelectedFile>() { selectedFile }, out List <SelectedFile> filesWithoutUTF8Encoding); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); this._iWriteToOutput.WriteToOutput(connectionData, string.Empty); } await DifferenceWebResources(selectedFile, isCustom, connectionData, commonConfig); } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(connectionData, ex); } finally { this._iWriteToOutput.WriteToOutputEndOperation(connectionData, operation); } }
/// <summary> /// Deletes the file. /// </summary> /// <param name="fileName">Name of the file.</param> private void DeleteFile(string fileName) { if (!string.IsNullOrEmpty(SelectedFile) && SelectedFile.EqualsIgnoreCase(fileName)) { SelectedFile = null; } }
public void Decompress() { FileStream stream = File.OpenRead(SelectedFile); byte[] byte_tab = new byte[stream.Length]; stream.Read(byte_tab, 0, byte_tab.Length); List <KeyValuePair <int, List <byte> > > dictionary = new List <KeyValuePair <int, List <byte> > >(); List <byte> decommpressed = new List <byte>(); for (int i = 0; i < byte_tab.Length; i += 3) { OnShowProgress(new ShowProgressArgs(byte_tab.Length, i)); if ((byte_tab[i] == byte.MinValue) && (byte_tab[i + 1] == byte.MinValue)) { List <byte> tmp = new List <byte>(); decommpressed.Add(byte_tab[i + 2]); tmp.Add(byte_tab[i + 2]); dictionary.Add(KeyValuePair.Create(dictionary.Count() + 1, tmp)); } else { byte[] tmp_b = new byte [2]; tmp_b[0] = byte_tab[i + 1]; tmp_b[1] = byte_tab[i]; int x = BitConverter.ToInt16(tmp_b, 0); try { List <byte> listFromIndex = (from f in dictionary where f.Key.Equals(x) select f.Value).First(); foreach (var s in listFromIndex) { decommpressed.Add(s); } decommpressed.Add(byte_tab[i + 2]); List <byte> tmp_list = new List <byte>(listFromIndex); tmp_list.Add(byte_tab[i + 2]); dictionary.Add(KeyValuePair.Create(dictionary.Count() + 1, tmp_list)); } catch (Exception e) { Console.WriteLine("Error during decompression.You sure that file is commpressed in LZ78?"); Console.ReadKey(); Environment.Exit(0); } //dictionary.Where(l => l.Key == byte_tab[i]); } } byte[] decommpress_tab = decommpressed.ToArray(); string output_name = SelectedFile.Remove(SelectedFile.Length - 4) + "decomp" + FileExtension; File.WriteAllBytes(output_name, decommpress_tab); }
private void RecentFilesToolStripMenuItem_ChildClick(object sender, EventArgs e) { var file = sender?.ToString(); if (!string.IsNullOrWhiteSpace(file)) { SelectedFile?.Invoke(file); } }
public void HandleAddPluginStep(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => HandleAddPluginStepInternal(conn, commonConfig, selectedFile)); }
public void HandleFetchXmlExecuting(ConnectionData connectionData, SelectedFile selectedFile, bool strictConnection) { if (selectedFile == null || !File.Exists(selectedFile.FilePath)) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => CrmDeveloperHelperPackage.Singleton?.ExecuteFetchXmlQueryAsync(selectedFile.FilePath, conn, this, strictConnection)); }
public void HandleSystemFormOpenInWebCommand(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartSystemFormOpenInWeb(conn, commonConfig, selectedFile)); }
public void HandleReportCreateLaskLinkCommand(SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(null, (conn, commonConfig) => Controller.StartReportCreatingLastLink(conn, selectedFile)); }
public void HandleRibbonDifferenceCommand(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartRibbonDifference(conn, commonConfig, selectedFile)); }
public void HandleEntityRibbonOpenInWeb(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartEntityRibbonOpenInWeb(conn, commonConfig, selectedFile)); }
public void HandleSavedQueryGetCurrentCommand(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } GetConnectionConfigAndExecute(connectionData, (conn, commonConfig) => Controller.StartSavedQueryGetCurrent(conn, commonConfig, selectedFile)); }
public HomeViewModel(string selectedSection) { _selectedSection = selectedSection; if (GpfTools.GpfUtil.ProfilesList().Count < 1) { if (String.IsNullOrEmpty(GpfTools.GpfUtil.FindGarminDeviceDirectory())) { var cancelButton = new Button { Content = "OK", IsDefault = true, IsCancel = true, MinHeight = 21, MinWidth = 65, Margin = new Thickness(4, 0, 0, 0) }; var v = new ModernDialog() { Title = "Connect Device", Content = "Please connect your device and try again.", Buttons = new Button[] { cancelButton } }; cancelButton.Click += (sender, args) => App.Current.MainWindow.Close(); v.ShowDialog(); } else { GpfTools.GpfUtil.BackupDeviceToRepository(); } } var fileList = GpfTools.GpfUtil.ProfilesList().Select(s => Path.GetFileName(s.Item1).Replace(".gpf", string.Empty)); foreach (var file in fileList) { items.Add(new Link() { DisplayName = file, Source = new Uri("/Content/" + _selectedSection + ".xaml?file=" + file, UriKind.Relative) }); } SelectedFile = items.First().Source; SetNewCommand(); DeleteCommand = new RelayCommand(g => { GpfTools.GpfUtil.DeleteProfile( SelectedFile.ToString().Split('=').Last()); items.Remove(Files.First(s => s.Source == SelectedFile)); }); }
/// <summary> /// Processes and reroutes events when the list box selection changes. /// The three types of events are when selection count is 0, 1 or many. /// </summary> void listMain_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ignoreSelectionChanges.IsBlocked) { return; } foreach (ListPageItem added in e.AddedItems) { added.Selected = true; } foreach (ListPageItem added in e.RemovedItems) { added.Selected = false; } var count = listMain.SelectedItems.Count; if (count == 0) { SelectedNothing.Invoke(this, directory); } else if (count == 1) { var item = (ListPageItem)listMain.SelectedItem; if (item.Reference is File) { SelectedFile.Invoke(this, directory, (File)item.Reference); } else if (item.Reference is Directory) { SelectedDirectory.Invoke(this, directory, (Directory)item.Reference); } else if (item.Reference is Jump) { SelectedJump.Invoke(this, directory, (Jump)item.Reference); } else if (item.Reference is Link) { SelectedLink.Invoke(this, directory, (Link)item.Reference); } } else { var items = new List <FileSystemItem>(); foreach (ListPageItem item in listMain.SelectedItems) { items.Add(item.Reference); } SelectedMultiple.Invoke(this, directory, items.ToArray()); } }
private void RemoveFile() { if (SelectedFile == null) { return; } SelectedFile.Dispose(); FileMonitors.Remove(SelectedFile); }
private void toolStripButtonOpenFile_Click(object sender, EventArgs e) { var file = OpenFile("Open"); if (file != null) { textBoxFile.Text = file; SelectedFile?.Invoke(file); } }
protected async Task OnInputFileChange(InputFileChangeEventArgs e) { SelectedFile = e.File; using (Stream stream = SelectedFile.OpenReadStream(long.MaxValue)) { await ContentService.UploadAsync(Entity.Id, SelectedFile.ContentType, stream); } await RefreshAsync(); }
public void Export_Clicked(object parameter) { var dlg = new SaveFileDialog(); dlg.Title = "Export file"; dlg.FileName = SelectedFile.GetFile().Name; if (dlg.ShowDialog() == true) { model.Export(SelectedFile.GetFile(), dlg.FileName); } }
private void tbSearch_KeyPress(object sender, KeyPressEventArgs e) { if ((int)e.KeyChar != 13) { return; } if (tbSearch.Text == "" && _currentMusic != null) { if (ltbSongs.Items.IndexOf(_currentMusic) < ltbSongs.Items.Count - 2) { ltbSongs.SelectedIndex = ltbSongs.Items.IndexOf(_currentMusic) + 2; } ltbSongs.SelectedIndex = ltbSongs.Items.IndexOf(_currentMusic); } else { int startIndex; bool found = false; if (ltbSongs.SelectedIndices.Count == 0 || !SelectedFile.Searcher(tbSearch.Text)) { startIndex = 0; } else { startIndex = ltbSongs.SelectedIndex + 1; } for (int i = startIndex; i < ltbSongs.Items.Count; i++) { if (((MusicFile)ltbSongs.Items[i]).Searcher(tbSearch.Text)) { ltbSongs.SelectedIndex = i; found = true; break; } } if (startIndex != 0 && !found) { for (int i = 0; i <= startIndex; i++) { if (((MusicFile)ltbSongs.Items[i]).Searcher(tbSearch.Text)) { ltbSongs.SelectedIndex = i; found = true; break; } } } if (!found) { ltbSongs.SelectedItem = null; } } }
public void HandleRibbonDiffXmlUpdateCommand(ConnectionData connectionData, SelectedFile selectedFile) { if (selectedFile == null) { return; } Func <ConnectionData, string> message = (conn) => string.Format(Properties.MessageBoxStrings.PublishRibbonDiffXmlFormat2, selectedFile.FileName, conn.GetDescription()); string title = Properties.MessageBoxStrings.ConfirmPublishRibbonDiffXml; GetConnectionConfigConfirmActionAndExecute(connectionData, message, title, (conn, commonConfig) => Controller.StartRibbonDiffXmlUpdate(conn, commonConfig, selectedFile)); }
public void HandleOpenReportCommand(ConnectionData connectionData, SelectedFile selectedFile, ActionOnComponent actionOnComponent) { if (selectedFile == null) { return; } CommonConfiguration commonConfig = CommonConfiguration.Get(); if (connectionData == null) { if (!HasCurrentCrmConnection(out ConnectionConfiguration crmConfig)) { return; } connectionData = crmConfig.CurrentConnectionData; } if (connectionData != null && commonConfig != null) { CheckWishToChangeCurrentConnection(connectionData); var objectId = connectionData.GetLastLinkForFile(selectedFile.FriendlyFilePath); if (objectId.HasValue) { switch (actionOnComponent) { case ActionOnComponent.OpenInWeb: connectionData.OpenEntityInstanceInWeb(Entities.Report.EntityLogicalName, objectId.Value); return; case ActionOnComponent.OpenDependentComponentsInWeb: connectionData.OpenSolutionComponentDependentComponentsInWeb(Entities.ComponentType.Report, objectId.Value); return; } } ActivateOutputWindow(connectionData); WriteToOutputEmptyLines(connectionData, commonConfig); try { Controller.StartOpeningReport(connectionData, commonConfig, selectedFile, actionOnComponent); } catch (Exception ex) { WriteErrorToOutput(connectionData, ex); } } }
private void Open() { if (SelectedFile.GetType() == typeof(Folder)) { InFolder = SelectedFile; _openedFolders.Add(InFolder); _inFolderIndex++; Refresh(); OnPropertyChanged("Path"); } else if (SelectedFile.GetType() == typeof(Shell.Models.File)) { SelectedFile.Open(); } }
public void HandleShowDifferenceWithDefaultSiteMap(SelectedFile selectedFile, string selectedSiteMap) { if (selectedFile == null || !File.Exists(selectedFile.FilePath)) { return; } CommonConfiguration commonConfig = CommonConfiguration.Get(); if (commonConfig == null) { return; } ActivateOutputWindow(null); WriteToOutputEmptyLines(null, commonConfig); try { Uri uri = FileOperations.GetSiteMapResourceUri(selectedSiteMap); StreamResourceInfo info = Application.GetResourceStream(uri); var doc = XDocument.Load(info.Stream); info.Stream.Dispose(); string fileName = string.Format("SiteMap.{0}.xml", selectedSiteMap); var filePath = Path.Combine(FileOperations.GetTempFileFolder(), fileName); doc.Save(filePath, SaveOptions.OmitDuplicateNamespaces); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, string.Empty); this.WriteToOutput(null, "{0} exported.", fileName); this.WriteToOutput(null, string.Empty); this.WriteToOutputFilePathUri(null, filePath); var task = this.ProcessStartProgramComparerAsync(null, selectedFile.FilePath, filePath, selectedFile.FileName, fileName); } catch (Exception ex) { WriteErrorToOutput(null, ex); } }
private void SaveFileAs() { //Initialize SaveFileDialog saveDlg = new SaveFileDialog() { Filter = SelectedFile.FileFilter, FileName = SelectedFile.DisplayName }; //Show if (saveDlg.ShowDialog() ?? false) { SelectedFile.FileName = saveDlg.FileName; SelectedFile.SaveToFile(); } }
private void OnShowFilePropertiesCmdExecute() { Dictionary <string, string> properties = null; Dictionary <string, string> security = null; Dictionary <string, string> info = null; if (SelectedFile.GetProperties(out properties, out info, out security) == Define.Success) { FilePropertiesViewModel filePropertiesViewModel = new FilePropertiesViewModel(SelectedFile.Info.FullName, properties, info, security); FilePropertiesView propertiesView = new FilePropertiesView(); propertiesView.DataContext = filePropertiesViewModel; propertiesView.Owner = App.Current.MainWindow; propertiesView.Show(); } }
private void buttonOK_Click(object sender, EventArgs e) { string path; if (radioAccountShare.Checked) { this.Result = new SelectedFile(((Settings.IAccount)gridAccounts.SelectedRows[0].Tag).DatFile); this.DialogResult = DialogResult.OK; return; } else if (radioAccountCopy.Checked) { path = ((Settings.IAccount)gridAccounts.SelectedRows[0].Tag).DatFile.Path; } else if (radioCreateNew.Checked) { this.Result = new SelectedFile(null, null); this.DialogResult = DialogResult.OK; return; } else { path = textBrowse.Text; } if (!File.Exists(path)) { MessageBox.Show(this, "The selected file does not exist", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string temp; try { temp = Path.GetTempFileName(); } catch { temp = Util.FileUtil.GetTemporaryFileName(Path.GetDirectoryName(path)); } if (radioFileMove.Checked) { try { try { File.Delete(temp); } catch { } File.Move(path, temp); this.Result = new SelectedFile(temp, path); } catch (Exception ex) { MessageBox.Show(this, "An error occured while trying to move the file.\n\n" + ex.Message, "Failed to move file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { try { File.Copy(path, temp, true); this.Result = new SelectedFile(temp); } catch (Exception ex) { try { File.Delete(temp); } catch { } MessageBox.Show(this, "An error occured while trying to copy the file.\n\n" + ex.Message, "Failed to copy file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Util.FileUtil.AllowFileAccess(temp, System.Security.AccessControl.FileSystemRights.Modify); this.DialogResult = DialogResult.OK; }