private async void darkButtonAttach_Click(object sender, EventArgs e) { try { this.darkButtonAttach.Enabled = false; bool result = await this.devkits.AttachProcessAsync(); if (result) { DarkMessageBox.ShowInformation("Current game process is attached successfully !", Application.ProductName, DarkDialogButton.Ok); } else { DarkMessageBox.ShowWarning($"No game process found", Application.ProductName, DarkDialogButton.Ok); } } catch (DevKitAttachProcessFailedException ex) { DarkMessageBox.ShowWarning($"No game process found\r\n{ex.Message}", Application.ProductName, DarkDialogButton.Ok); } catch (Exception ex) { DarkMessageBox.ShowError(ex.Message, $"Error - {Application.ProductName}", DarkDialogButton.Ok); } finally { this.darkButtonAttach.Enabled = true; } }
private async void darkButtonConnect_Click(object sender, EventArgs e) { this.darkButtonConnect.Enabled = false; this.darkComboBoxDevkit.Enabled = false; try { ConnectionStatus status = await this.devkits.ConnectTargetAsync(); switch (status) { case ConnectionStatus.Connected: if (this.devkits.DevkitTarget == DevkitTarget.PS3) { this.darkButtonAttach.Enabled = true; } this.darkButtonConnect.Enabled = false; this.darkButtonConnect.Text = "Connected"; DarkMessageBox.ShowInformation($"Connected to Target", "Devkit", DarkDialogButton.Ok); break; default: this.darkButtonConnect.Enabled = true; DarkMessageBox.ShowWarning("Connection error", "Devkit", DarkDialogButton.Ok); break; } } catch (Exception ex) { DarkMessageBox.ShowError(ex.Message, $"Error - {Application.ProductName}", DarkDialogButton.Ok); this.darkButtonConnect.Enabled = true; } finally { this.darkComboBoxDevkit.Enabled = true; } }
/// <summary> /// /// </summary> /// <param name="backupFile"></param> public void RestoreGameFile(BackupFile backupFile) { try { if (!File.Exists(backupFile.LocalPath)) { _ = XtraMessageBox.Show( "This file backup doesn't exist on your computer. If your game doesn't have mods installed, then I would suggest you backup the original files.", "No File Found"); return; } FtpExtensions.UploadFile(backupFile.LocalPath, backupFile.InstallPath); _ = XtraMessageBox.Show( $"Successfully restored file: {backupFile.FileName} to path: {backupFile.InstallPath}", "Success"); } catch (Exception ex) { Program.Log.Error(ex, "There was an issue attempting to restore file."); _ = DarkMessageBox.ShowError( "There was an issue restoring file. Make sure the local file exists on your computer.", "Error"); } }
private void InitializeDatabase() { // carrega o arquivo de configuração Configuration.ParseConfigFile("config.txt"); MySQL.LoginDB = new CommonDB(); MySQL.LoginDB.Server = Configuration.GetString("login_ip"); MySQL.LoginDB.Port = Configuration.GetInt32("login_port"); MySQL.LoginDB.Username = Configuration.GetString("login_user"); MySQL.LoginDB.Password = Configuration.GetString("login_password"); MySQL.LoginDB.Database = Configuration.GetString("login_database"); MySQL.GameDB = new CommonDB(); MySQL.GameDB.Server = Configuration.GetString("game_ip"); MySQL.GameDB.Port = Configuration.GetInt32("game_port"); MySQL.GameDB.Username = Configuration.GetString("game_user"); MySQL.GameDB.Password = Configuration.GetString("game_password"); MySQL.GameDB.Database = Configuration.GetString("game_database"); var error = string.Empty; if (!MySQL.LoginDB.Open(out error)) { DarkMessageBox.ShowError(error, "Ocorreu um erro ao conectar ao MySQL."); return; } if (!MySQL.GameDB.Open(out error)) { DarkMessageBox.ShowError(error, "Ocorreu um erro ao conectar ao MySQL."); return; } }
public void CreateLocalFolder() { try { var newName = DialogExtensions.ShowTextInputDialog(this, "Add New Folder", "Folder name: ", ""); if (newName != null) { string folderPath = TextBoxLocalPath.Text + @"\" + newName; if (Directory.Exists(folderPath)) { XtraMessageBox.Show($"A folder with this name already exists.", "Error"); return; } else { _ = Directory.CreateDirectory(folderPath); LoadLocalDirectory(LocalDirectoryPath); } } } catch (FtpException ex) { DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error"); } catch (Exception ex) { DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error"); } }
private void MenuStrip_Reload_Click(object sender, EventArgs e) { try { Int32 selectedCellCount = ModuleList.GetCellCount(DataGridViewElementStates.Selected); if (selectedCellCount > 0) { int index = ModuleList.SelectedRows[0].Index; int ModuleHandle = Convert.ToInt32(ModuleList.Rows[index].Cells["mHandle"].Value); string ModuleName = Convert.ToString(ModuleList.Rows[index].Cells["ModuleName"].Value); SetStatus("Reloading Module " + ModuleName + "..."); Int32 Handle = PS4.SelectedTarget.Process.ReloadSPRX(ModuleHandle, 0); if (Handle == 0) { DarkMessageBox.ShowError("Handle returned 0.", "Module Failed to Reload."); } else { Thread.Sleep(100); } UpdateModuleList(); SetStatus("Ready"); } } catch { } }
private void btnAddFolder_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Select folder containing PS4 PKG"; fbd.RootFolder = System.Environment.SpecialFolder.MyComputer; fbd.SelectedPath = Properties.Settings.Default.RootFolder; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } foreach (var item in darkListBox1.Items) { if (item.ToString() == fbd.SelectedPath) { DarkMessageBox.ShowError("Path already added.", "PS4 PKG Tool"); return; } } string selectedFolder = fbd.SelectedPath; Properties.Settings.Default.RootFolder = fbd.SelectedPath; Properties.Settings.Default.Save(); darkListBox1.Items.Add(selectedFolder); }
private void FTPStrip_LoadModule_Click(object sender, EventArgs e) { try { DarkTreeNode SelectedNode = FTPDataTree.SelectedNodes.FirstOrDefault(); string FilePath = "/mnt/" + SelectedNode.FullPath; if (!Path.GetExtension(FilePath).Equals(".sprx")) { DarkMessageBox.ShowError("This file is not an sprx module and can not be loaded...", "File not sprx module!"); } else { SetStatus("Loading Module " + Path.GetFileName(FilePath) + "..."); Int32 Handle = PS4.SelectedTarget.Process.LoadSPRX(FilePath, 0); if (Handle == 0) { DarkMessageBox.ShowError("Handle returned 0.", "Module Failed to load."); } else { Thread.Sleep(100); } UpdateModuleList(); SetStatus("Ready"); } } catch { } }
public OrbisLib(bool NoInstance = false) { try { OrbisLib_Dir = (Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Orbis Suite\\"); if (!Directory.Exists(OrbisLib_Dir)) { DarkMessageBox.ShowError("In order to use the functionality of the OrbisLib.dll you need to first install Orbis Suite on this machine.", "Orbis Suite not Installed."); throw new System.Exception("Orbis Suite not Installed."); } Utilities.SetDllDirectory(OrbisLib_Dir); //Set up our instance of the OrbisLibCPP.dll. Imports.SetupCPP(NoInstance); //Set up selected target as default target initially. internal_SelectedTarget = new Target(this); SelectedTarget.Info = DefaultTarget.Info; //Set up classes Internal_Events = new Events(this); } catch { } }
private void UpdateTargetList() { try { if (PS4.TargetManagement.TargetList.Count <= 0) { DarkMessageBox.ShowError("Target list is empty nothing to show.", "Target List Empty", DarkDialogButton.Ok, FormStartPosition.CenterScreen); Environment.Exit(0); } SelectedTarget.Items.Clear(); foreach (TargetInfo Target in PS4.TargetManagement.TargetList) { SelectedTarget.Items.Add(Target.Name); } if (PS4.TargetManagement.TargetList.Find(x => x.Name == SelectedTarget.Text) == null) { SelectTarget(PS4.TargetManagement.TargetList[0].Name); } } catch { } }
public void CreateConsoleFolder() { try { var folderName = DialogExtensions.ShowTextInputDialog(this, "Add New Folder", "Folder Name: ", ""); if (folderName != null) { string folderPath = FtpDirectoryPath + "/" + folderName; if (FtpClient.DirectoryExists(folderPath)) { XtraMessageBox.Show($"A folder with this name already exists.", "Error"); return; } else { _ = FtpExtensions.CreateDirectory(folderPath); LoadConsoleDirectory(FtpDirectoryPath); } } } catch (FtpException ex) { DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error"); } catch (Exception ex) { DarkMessageBox.ShowError($"Unable to create new folder. Error: {ex.Message}", "Error"); } }
private void timer_Visu_Tick(object sender, EventArgs e) { try { ushort size = 1; ushort startAddress = Convert.ToUInt16(ucTextBoxEx_VisuAddress.InputText); if (MBmaster != null) { if (startAddress == 0) { startAddress = 1; } MBmaster.ReadHoldingRegister(5, 0, (ushort)(startAddress - 1), size, ref newdataVisu); if (dataVisu.SequenceEqual <byte>(newdataVisu) == false || addressChangedVisu) { ucMeter_Visu.Value = (int)Convert.ToUInt32(newdataVisu[0] * 256 + newdataVisu[1]); dataVisu = newdataVisu; } addressChangedVisu = false; } } catch (Exception ex) { DarkMessageBox.ShowError(ex.Message.ToString(), "Error!"); } }
private void MenuStrip_Dump_Click(object sender, EventArgs e) { try { Int32 selectedCellCount = ModuleList.GetCellCount(DataGridViewElementStates.Selected); if (selectedCellCount > 0) { int index = ModuleList.SelectedRows[0].Index; int ModuleHandle = Convert.ToInt32(ModuleList.Rows[index].Cells["mHandle"].Value); string ModuleName = Convert.ToString(ModuleList.Rows[index].Cells["ModuleName"].Value); SetStatus("Dumping Module " + ModuleName + "..."); ModuleInfo Info = PS4.SelectedTarget.Process.ModuleList.Find(x => x.Name == ModuleName); int Length = (int)(Info.TextSegmentLen + Info.DataSegmentLen); byte[] Buffer = new byte[Length]; string FilePath = string.Empty; //If its module 0 thats the process so we want to dump the process else we dump a module. if (ModuleHandle == 0) { API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer); //API_ERRORS Result = PS4.SelectedTarget.DumpProcess(ModuleName, Length, Buffer); ModuleName = $"{PS4.SelectedTarget.Process.Current.TitleID}-{ModuleName}"; if (Result != API_ERRORS.API_OK) { DarkMessageBox.ShowError(string.Format("Failed to Dump Process \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module."); return; } } else { API_ERRORS Result = PS4.SelectedTarget.Process.DumpModule(ModuleName, Length, Buffer); if (Result != API_ERRORS.API_OK) { DarkMessageBox.ShowError(string.Format("Failed to Dump Module \"{0}\".\n{1}", ModuleName, OrbisDef.API_ERROR_STR[(int)Result]), "Error dumping module."); return; } } //Create the Orbis Suite Directory in Documents. Directory.CreateDirectory($"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\\Orbis Suite\\"); //Write the file some where. FilePath = string.Format(@"{0}\Orbis Suite\{1}", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Utilities.IndexedFilename(Path.GetFileNameWithoutExtension(ModuleName) + "-Dump", Path.GetExtension(ModuleName))); using (FileStream fs = File.OpenWrite(FilePath)) fs.Write(Buffer, 0, (int)Length); SetStatus("Ready"); } } catch { } }
// // Target Context Menu // private void SendPayload_Click(object sender, EventArgs e) { try { string PayloadPath = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Title = "Open BIN File..."; openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.InitialDirectory = Properties.Settings.Default.BINDirectory; openFileDialog.Filter = "BIN files (*.BIN)|*.BIN"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { PayloadPath = openFileDialog.FileName; Properties.Settings.Default.BINDirectory = Path.GetDirectoryName(openFileDialog.FileName); Properties.Settings.Default.Save(); } else { return; } } FileStream fPayload = File.Open(PayloadPath, FileMode.Open); if (fPayload.CanRead) { byte[] PayloadBuffer = new byte[fPayload.Length]; if (fPayload.Read(PayloadBuffer, 0, (int)fPayload.Length) == fPayload.Length) { Int32 selectedCellCount = TargetList.GetCellCount(DataGridViewElementStates.Selected); if (selectedCellCount > 0) { int index = TargetList.SelectedRows[0].Index; string TargetName = Convert.ToString(TargetList.Rows[index].Cells["mTargetName"].Value); if (!PS4.Target[TargetName].Payload.InjectPayload(PayloadBuffer)) { DarkMessageBox.ShowError("Failed to send payload to target please try again.", "Error: Failed to inject payload."); } } } else { DarkMessageBox.ShowError("Failed read payload from disc to target please try again.", "Error: Failed to inject payload."); } } fPayload.Close(); } catch { } }
public bool Open(String file) { try { BinaryReader br = new BinaryReader(File.Open(file, FileMode.Open)); VaultFileHeader header; if (br != null) { header.magic = br.ReadUInt32(); if (header.magic != VAULT_MAGIC) { return(false); } header.version = br.ReadUInt16(); if (header.version != VAULT_VERSION) { return(false); } header.entries = br.ReadUInt32(); UInt32 temp; Byte keyLen; UInt16 valueLen; for (int i = 0; i < header.entries; i++) { //timestamp //C++ time_t temp = br.ReadUInt32(); keyLen = br.ReadByte(); valueLen = br.ReadUInt16(); char[] key = br.ReadChars(keyLen); char[] value = br.ReadChars(valueLen); VaultEntry entry = new VaultEntry(); entry.key = new string( key ); entry.timestamp = temp; keyValues.Add(entry, new string( value )); } br.Close(); return(true); } } catch (Exception e) { DarkMessageBox.ShowError("Failed to parse vault file\n" + e.Message, "Error"); return(false); } return(false); }
private void darkButton1_Click(object sender, EventArgs e) { FolderBrowserDialog savepath = new FolderBrowserDialog(); if (savepath.ShowDialog() == DialogResult.OK) { try { var numbersAndWords = idEntryList.Zip(nameEntryList, (n, w) => new { id = n, name = w }); foreach (var nw in numbersAndWords) { var pkgPath = filenames; var idx = int.Parse(nw.id); var name = nw.name; var outPath = savepath.SelectedPath + "\\" + name.Replace("_SHA", ".SHA").Replace("_DAT", ".DAT").Replace("_SFO", ".SFO").Replace("_XML", ".XML").Replace("_SIG", ".SIG").Replace("_PNG", ".PNG").Replace("_JSON", ".JSON").Replace("_DDS", ".DDS").Replace("_TRP", ".TRP").Replace("_AT9", ".AT9");; using (var pkgFile = File.OpenRead(pkgPath)) { var pkg = new PkgReader(pkgFile).ReadPkg(); if (idx < 0 || idx >= pkg.Metas.Metas.Count) { DarkMessageBox.ShowError("Error: entry number out of range", "PS4 PKG Tool"); return; } using (var outFile = File.Create(outPath)) { var meta = pkg.Metas.Metas[idx]; outFile.SetLength(meta.DataSize); if (meta.Encrypted) { if (passcode == null) { DarkMessageBox.ShowWarning("Warning: Entry is encrypted but no passcode was provided! Saving encrypted bytes.", "PS4 PKG Tool"); } else { var entry = new SubStream(pkgFile, meta.DataOffset, (meta.DataSize + 15) & ~15); var tmp = new byte[entry.Length]; entry.Read(tmp, 0, tmp.Length); tmp = LibOrbisPkg.PKG.Entry.Decrypt(tmp, pkg.Header.content_id, passcode, meta); outFile.Write(tmp, 0, (int)meta.DataSize); return; } } new SubStream(pkgFile, meta.DataOffset, meta.DataSize).CopyTo(outFile); } } } DarkMessageBox.ShowInformation("All entry item extracted", "PS4 PKG Tool"); } catch (Exception a) { DarkMessageBox.ShowError(a.Message, "PS4 PKG Tool"); } } }
private void AsyncConnect_DoWork(object sender, DoWorkEventArgs e) { try { redis = ConnectionMultiplexer.Connect(txtConnectionEndpoint.Text); } catch (Exception ex) { DarkMessageBox.ShowError(ex.Message, "Fehler"); } }
private void darkButton2_Click_1(object sender, EventArgs e) { if (CheckForPS4Connection() == true) { DarkMessageBox.ShowInformation("PS4 detected.", "PS4 PKG Tool"); } else { DarkMessageBox.ShowError("PS4 not detected.", "PS4 PKG Tool"); } }
public void Initalize(Project project, TextureLoader textureLoader) { foreach (var tilesetPath in this.Descriptor.TilesetPaths) { if (File.Exists(project.ClientRootDirectory + "/" + tilesetPath)) { var texture = textureLoader.LoadFromFile(project.ClientRootDirectory + "/" + tilesetPath); texture.Tag = tilesetPath; this.AddTileset(texture); } else { DarkMessageBox.ShowError($"Could not load tileset {tilesetPath}!", "Error loading tileset!", DarkDialogButton.Ok); } } foreach (var layerDesc in this.Descriptor.Layers.Values) { var layer = new Layer(layerDesc); for (int x = 0; x < layerDesc.Tiles.GetLength(0); x++) { for (int y = 0; y < layerDesc.Tiles.GetLength(1); y++) { var tileDesc = layerDesc.Tiles[x, y]; if (tileDesc != null) { Tile tile = new Tile(tileDesc); if (tileDesc.SpriteInfo != null) { tile.Sprite = new Sprite(_tilesets[Path.GetFileName(tileDesc.SpriteInfo.TextureName)]) { LayerDepth = tileDesc.SpriteInfo.Transform.LayerDepth, SourceRectangle = new Rectangle(tileDesc.SpriteInfo.Transform.Rect.Left, tileDesc.SpriteInfo.Transform.Rect.Top, tileDesc.SpriteInfo.Transform.Rect.Width, tileDesc.SpriteInfo.Transform.Rect.Height), Position = new Vector2(tileDesc.Position.X, tileDesc.Position.Y) }; } layer.SetTile(x, y, tile); } else { layer.SetTile(x, y, new Tile()); } } } this.Layers.Add(layer.Descriptor.Name, layer); } }
private void ToolStrip_SendOrbisPayload_Click(object sender, EventArgs e) { try { if (!PS4.DefaultTarget.Payload.InjectPayload()) { DarkMessageBox.ShowError("Failed to send payload to target please try again.", "Error: Failed to inject payload.", DarkDialogButton.Ok, FormStartPosition.CenterScreen); } } catch { } }
/// <summary> /// </summary> /// <param name="backupFile"></param> public void BackupGameFile(BackupFile backupFile) { try { FtpExtensions.DownloadFile(backupFile.LocalPath, backupFile.InstallPath); _ = XtraMessageBox.Show($"Successfully backed up file {backupFile.FileName} from {backupFile.InstallPath}.", "Success"); } catch (Exception ex) { Program.Log.Error(ex, $"Unable to backup game file. Error: {ex.Message}"); _ = DarkMessageBox.ShowError("There was a problem downloading the file. Make sure the file exists on your console.", "Error"); } }
private void darkButton_WriteSingleCoil_Click(object sender, EventArgs e) { try { ushort ID = 5; UInt16 address = (ushort)(Convert.ToUInt16(ucTextBoxEx_CoilAddress.InputText) - 1); MBmaster.WriteSingleCoils(ID, 0, address, ucSwitch_CoilValue.Checked); }catch (Exception ex) { DarkMessageBox.ShowError(ex.Message.ToString(), "Error!"); } }
private void ToolStrip_SendPayload_Click(object sender, EventArgs e) { try { string PayloadPath = string.Empty; using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Title = "Open BIN File..."; openFileDialog.CheckFileExists = true; openFileDialog.CheckPathExists = true; openFileDialog.InitialDirectory = Properties.Settings.Default.BINDirectory; openFileDialog.Filter = "BIN files (*.BIN)|*.BIN"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { PayloadPath = openFileDialog.FileName; Properties.Settings.Default.BINDirectory = Path.GetDirectoryName(openFileDialog.FileName); Properties.Settings.Default.Save(); } else { return; } } FileStream fPayload = File.Open(PayloadPath, FileMode.Open); if (fPayload.CanRead) { byte[] PayloadBuffer = new byte[fPayload.Length]; if (fPayload.Read(PayloadBuffer, 0, (int)fPayload.Length) == fPayload.Length) { if (!PS4.DefaultTarget.Payload.InjectPayload(PayloadBuffer)) { DarkMessageBox.ShowError("Failed to send payload to target please try again.", "Error: Failed to inject payload.", DarkDialogButton.Ok, FormStartPosition.CenterScreen); } } else { DarkMessageBox.ShowError("Failed read payload from disc to target please try again.", "Error: Failed to inject payload.", DarkDialogButton.Ok, FormStartPosition.CenterScreen); } } fPayload.Close(); } catch { } }
private void btnRename_Click(object sender, EventArgs e) { if (mapTreeList.list.SelectedNode == null) { DarkMessageBox.ShowError( Strings.MapList.selecttorename, Strings.MapList.rename, DarkDialogButton.Ok, Properties.Resources.Icon ); } else { mapTreeList.list.SelectedNode.BeginEdit(); } }
private void EmergencyStopClick(object sender, EventArgs e) { try { Packet EmergencyStopPacket = new Packet(PacketType.EMERGENCY_STOP, false, Scarlet.Science.Constants.CLIENT_NAME); EmergencyStopPacket.AppendData(UtilData.ToBytes("Homura")); Server.SendNow(EmergencyStopPacket); } catch (Exception Exc) { Log.Output(Log.Severity.FATAL, Log.Source.GUI, "FAILED TO SEND EMERGENCY STOP!"); Log.Exception(Log.Source.GUI, Exc); DarkMessageBox.ShowError("Failed to send emergency stop!\n\n" + Exc.ToString(), "Science"); } }
private void ucTextBoxEx_StartAddress_Leave(object sender, EventArgs e) { try { ushort newAddress = Convert.ToUInt16(ucTextBoxEx_StartAddress.InputText); if (startAddress != newAddress || startAddress == 0) { addressChanged = true; } }catch (Exception ex) { DarkMessageBox.ShowError(ex.Message.ToString(), "Error"); ucTextBoxEx_StartAddress.InputText = "0"; } }
private void darkButton_WriteSingleRegister_Click(object sender, EventArgs e) { try { ushort ID = 7; UInt16 address = (ushort)(Convert.ToUInt16(ucTextBoxEx_RegisterAddress.InputText) - 1); int data = Convert.ToInt32(ucTextBoxEx_RegisterValue.InputText); byte[] databyte = BitConverter.GetBytes(data); MBmaster.WriteSingleRegister(ID, 0, address, new byte[] { databyte[1], databyte[0] }); } catch (Exception ex) { DarkMessageBox.ShowError(ex.Message.ToString(), "Error!"); } }
protected virtual bool CanMoveNodes(List <DarkTreeNode> dragNodes, DarkTreeNode dropNode, bool isMoving = false) { if (dropNode == null) { return(false); } foreach (var node in dragNodes) { if (node == dropNode) { if (isMoving) { DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is the same as the source folder.", Application.ProductName); } return(false); } if (node.ParentNode != null && node.ParentNode == dropNode) { if (isMoving) { DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is the same as the source folder.", Application.ProductName); } return(false); } var parentNode = dropNode.ParentNode; while (parentNode != null) { if (node == parentNode) { if (isMoving) { DarkMessageBox.ShowError($"Cannot move {node.Text}. The destination folder is a subfolder of the source folder.", Application.ProductName); } return(false); } parentNode = parentNode.ParentNode; } } return(true); }
private void BtnEntrySave_Click(object sender, EventArgs e) { if (selectedFileName.Length == 0) { return; } if (vaultFile.Save(selectedFileName)) { sndSuccess.Play(); } else { sndFailed.Play(); DarkMessageBox.ShowError("Failed to save vault file", "Error"); } }
public bool Save(String file) { try { // make a backup... if (File.Exists(file)) { File.Copy(file, file + ".bak", true); } // TODO: // check for a .journal file and notify user...?? if (File.Exists(file)) { File.Delete(file); } BinaryWriter bw = new BinaryWriter(File.Open(file, FileMode.OpenOrCreate)); // Header bw.Write((uint)VAULT_MAGIC); bw.Write((ushort)VAULT_VERSION); bw.Write((uint)keyValues.Count); foreach (KeyValuePair <VaultEntry, String> entry in keyValues) { bw.Write((UInt32)entry.Key.timestamp); bw.Write((byte)entry.Key.key.Length); bw.Write((UInt16)entry.Value.Length); bw.Write((char[])entry.Key.key.ToCharArray()); bw.Write((char[])entry.Value.ToCharArray()); } bw.Flush(); bw.Close(); return(true); } catch (Exception e) { DarkMessageBox.ShowError("Failed to save vault file\n" + e.Message, "Error"); return(false); } }