private void OnChanged(object source, FileSystemEventArgs e) { string FileFlag, FileFlagR, StatusFlag, FileFlagRZ, FileFlagZ, ExchangeDir; int cureventcount = statusWatchers.Length; foreach (DataGridViewRow Row in GlobalVars.CurrentSettingsBase.DGV.Rows) { if (!(cureventcount == statusWatchers.Length)) { return; } if (Row.Cells["Code"].Value == null) { continue; } if (Row.Cells["Code"].Value.ToString().Trim() == "") { continue; } ExchangeDir = Row.Cells["Dir"].Value.ToString().Trim(); if (ExchangeDir == "") { ExchangeDir = GlobalVars.CurrentSettingsBase.Settings.ExchangeDir; } FileFlag = ExchangeDir + GlobalVars.CurrentSettingsBase.Settings.ThisNodeCode + "-" + Row.Cells["Code"].Value.ToString() + ".txt"; FileFlagZ = FileFlag.Replace(".txt", ".zip"); FileFlagR = ExchangeDir + Row.Cells["Code"].Value.ToString() + "-" + GlobalVars.CurrentSettingsBase.Settings.ThisNodeCode + ".txt"; FileFlagRZ = FileFlagR.Replace(".txt", ".zip"); StatusFlag = ""; if (File.Exists(FileFlag)) { if (File.Exists(FileFlagZ)) { StatusFlag = "Выгружено"; } else { StatusFlag = "Загрузка в приемнике"; } } if (File.Exists(FileFlagR)) { if (StatusFlag != "") { StatusFlag = "куча мала"; } else { StatusFlag = "Можно загружать"; } } //EditDGV(Row.Index, "StatusFlag", StatusFlag, GlobalVars.CurrentSettingsBase.DGV, GlobalVars.CurrentSettingsBase); EditDGV(Row.Index, "StatusFlag", StatusFlag, GlobalVars.CurrentSettingsBase.DGV, GlobalVars.CurrentSettingsBase); } }
protected FileSpec( ushort recordLength, ushort pageSize, byte keyCount, FileFlag flag) { this.RecordLength = recordLength; this.PageSize = pageSize; this.KeyCount = keyCount; this.Flag = flag; }
public FileEntry(string fullName, FileFlag flag, string alias = null, string pathSource = null) { Fullname = fullName; Alias = alias; Flag = flag; if (string.IsNullOrEmpty(pathSource)) { PathSource = CommandNode.DefaultFromSource; } else { PathSource = pathSource; } }
public CreateFileSpec( ushort recordLength, ushort pageSize = DefaultPageSize, FileFlag flag = DefaultFlag, byte duplicatedPointerCount = 0, ushort allocation = 0) : base( recordLength, pageSize, 0, flag) { if (recordLength == 0) { throw new ArgumentException(); } this.DuplicatedPointerCount = duplicatedPointerCount; this.Allocation = allocation; }
internal StatFileSpec( ushort recordLength, ushort pageSize, byte keyCount, byte fileVersion, uint recordCount, FileFlag flag, byte unusedDuplicatedPointerCount, ushort unusedPage) : base( recordLength, pageSize, keyCount, flag) { this.FileVersion = fileVersion; this.RecordCount = recordCount; this.UnusedDuplicatedPointerCount = unusedDuplicatedPointerCount; this.UnusedPage = unusedPage; }
/// <summary> /// Loads a precompiled program from disk. /// </summary> /// <remarks> /// NOTE: We should employ some sort of checksum to verify bytecode integrity. /// </remarks> /// <param name="path"></param> public void Load(string path) { int i, count; Reset(); try { using BinaryReader reader = new(File.Open(path, FileMode.Open)); // Check signature i = reader.ReadInt32(); if (i != FileSignature) { throw new Exception(InvalidFileFormat); } // Read reserved int i = reader.ReadInt32(); if (i != 0) { throw new Exception(InvalidFileFormat); } // Read flags FileFlag flags = (FileFlag)reader.ReadInt32(); // Read bytecodes count = reader.ReadInt32(); ByteCodes = new int[count]; for (i = 0; i < count; i++) { ByteCodes[i] = reader.ReadInt32(); } // Read functions count = reader.ReadInt32(); List <Function> functions = new(count); for (i = 0; i < count; i++) { string name = reader.ReadString(); FunctionType type = (FunctionType)reader.ReadInt32(); if (type == FunctionType.Internal) { // Temporarily set non-nullable action to null // We will correct further down var function = new InternalFunction(name, null !); functions.Add(function); } else if (type == FunctionType.Intrinsic) { var function = new IntrinsicFunction(name); functions.Add(function); } else // FunctionType.User { var function = new UserFunction(name, 0) { IP = reader.ReadInt32(), NumVariables = reader.ReadInt32(), NumParameters = reader.ReadInt32(), }; functions.Add(function); } } // Read global variables count = reader.ReadInt32(); Variables = new Variable[count]; for (i = 0; i < count; i++) { Variables[i] = ReadVariable(reader); } // Read literals count = reader.ReadInt32(); Literals = new Variable[count]; for (i = 0; i < count; i++) { Literals[i] = ReadVariable(reader); } // Read line numbers if (flags.HasFlag(FileFlag.HasLineNumbers)) { count = reader.ReadInt32(); LineNumbers = new int[count]; for (i = 0; i < count; i++) { LineNumbers[i] = reader.ReadInt32(); } Debug.Assert(LineNumbers.Length == ByteCodes.Length); } // Fixup internal functions foreach (var function in functions.OfType <InternalFunction>()) { if (InternalFunctions.InternalFunctionLookup.TryGetValue(function.Name, out InternalFunctionInfo? info)) { function.Action = info.Action; function.MinParameters = info.MinParameters; function.MaxParameters = info.MaxParameters; } else { throw new Exception($"Internal intrinsic function \"{function.Name}\" not found"); } } Functions = functions.ToArray(); } catch (Exception) { // Clear to known state if error Reset(); throw; } }
/// <summary> /// Event on format cell /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private static void FastOlvOnFormatCell(object sender, FormatCellEventArgs args) { FileListItem obj = (FileListItem)args.Model; if (obj == null) { return; } // currently document if (obj.FullPath.Equals(Plug.CurrentFilePath)) { RowBorderDecoration rbd = new RowBorderDecoration { FillBrush = new SolidBrush(Color.FromArgb(50, ThemeManager.Current.MenuFocusedBack)), BorderPen = new Pen(Color.FromArgb(128, ThemeManager.Current.MenuFocusedBack.IsColorDark() ? ControlPaint.Light(ThemeManager.Current.MenuFocusedBack, 0.10f) : ControlPaint.Dark(ThemeManager.Current.MenuFocusedBack, 0.10f)), 1), BoundsPadding = new Size(-2, 0), CornerRounding = 6.0f }; args.SubItem.Decoration = rbd; } // display the flags int offset = -5; foreach (var name in Enum.GetNames(typeof(FileFlag))) { FileFlag flag = (FileFlag)Enum.Parse(typeof(FileFlag), name); if (flag == 0) { continue; } if (!obj.Flags.HasFlag(flag)) { continue; } Image tryImg = (Image)ImageResources.ResourceManager.GetObject(name); if (tryImg == null) { continue; } ImageDecoration decoration = new ImageDecoration(tryImg, 100, ContentAlignment.MiddleRight) { Offset = new Size(offset, 0) }; if (args.SubItem.Decoration == null) { args.SubItem.Decoration = decoration; } else { args.SubItem.Decorations.Add(decoration); } offset -= 20; } // display the sub string if (offset < -5) { offset -= 5; } if (!string.IsNullOrEmpty(obj.SubString)) { TextDecoration decoration = new TextDecoration(obj.SubString, 100) { Alignment = ContentAlignment.MiddleRight, Offset = new Size(offset, 0), Font = FontManager.GetFont(FontStyle.Bold, 11), TextColor = ThemeManager.Current.SubTextFore, CornerRounding = 1f, Rotation = 0, BorderWidth = 1, BorderColor = ThemeManager.Current.SubTextFore }; args.SubItem.Decorations.Add(decoration); } }
protected static extern SafeFileHandle CreateFile(string FileName, [MarshalAs(UnmanagedType.U4)] FileAccess DesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare ShareMode, uint SecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode CreationDisposition, FileFlag FlagsAndAttributes, int hTemplateFile);
public GrfEntry(string path, uint fileOffset, uint compressedSize, uint compressedFileSizeAligned, uint uncompressedSize, FileFlag flags, Grf owner) { Path = path; Header = new GrfEntryHeader { FileOffset = fileOffset, CompressedSize = compressedSize, CompressedSizeAligned = compressedFileSizeAligned, UncompressedSize = uncompressedSize, Flags = flags }; _owner = owner; }
protected static extern IntPtr CreateFile(string FileName, [MarshalAs(UnmanagedType.U4)] FileAccess DesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare ShareMode, uint SecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode CreationDisposition, FileFlag FlagsAndAttributes, int hTemplateFile);
void StatusWatch(GlobalVars.SettingsBaseListClass CurrentSettingsBase) { //return; foreach (FileSystemWatcher FSW in statusWatchers) { FSW.EnableRaisingEvents = false; FSW.Changed -= OnChanged; FSW.Created -= OnChanged; FSW.Deleted -= OnChanged; FSW.Renamed -= OnChanged; } Array.Resize(ref statusWatchers, 0); Array.Resize(ref statusWatchersDir, 0); string FileFlag, FileFlagR, StatusFlag, FileFlagRZ, FileFlagZ, ExchangeDir; if (CurrentSettingsBase == null) { return; } foreach (DataGridViewRow Row in CurrentSettingsBase.DGV.Rows) { if (Row.Cells["Code"].Value == null) { continue; } if (Row.Cells["Code"].Value.ToString().Trim() == "") { continue; } ExchangeDir = Row.Cells["Dir"].Value.ToString().Trim(); if (ExchangeDir == "") { ExchangeDir = CurrentSettingsBase.Settings.ExchangeDir; } FileFlag = ExchangeDir + CurrentSettingsBase.Settings.ThisNodeCode + "-" + Row.Cells["Code"].Value.ToString() + ".txt"; FileFlagZ = FileFlag.Replace(".txt", ".zip"); FileFlagR = ExchangeDir + Row.Cells["Code"].Value.ToString() + "-" + CurrentSettingsBase.Settings.ThisNodeCode + ".txt"; FileFlagRZ = FileFlagR.Replace(".txt", ".zip"); StatusFlag = ""; if (File.Exists(FileFlag)) { if (File.Exists(FileFlagZ)) { StatusFlag = "Выгружено"; } else { StatusFlag = "Загрузка в приемнике"; } } if (File.Exists(FileFlagR)) { if (StatusFlag != "") { StatusFlag = "куча мала"; } else { StatusFlag = "Можно загружать"; } } //EditDGV(Row.Index, "Status", StatusFlag, SettingsBase.DGV); //Row.Cells["StatusFlag"].Value = StatusFlag; EditDGV(Row.Index, "StatusFlag", StatusFlag, CurrentSettingsBase.DGV, CurrentSettingsBase); bool NoFSW = true; foreach (string FSWD in statusWatchersDir) { if (FSWD == ExchangeDir) { NoFSW = false; break; } } if (NoFSW) { try { FileSystemWatcher StatusWatcher = new FileSystemWatcher(); StatusWatcher.Path = ExchangeDir; /* Watch for changes in LastAccess and LastWrite times, and * the renaming of files or directories. */ StatusWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; //// Only watch text files. //StatusWatcher.Filter = "*.txt"; // Add event handlers. StatusWatcher.Changed += new FileSystemEventHandler(OnChanged); StatusWatcher.Created += new FileSystemEventHandler(OnChanged); StatusWatcher.Deleted += new FileSystemEventHandler(OnChanged); StatusWatcher.Renamed += new RenamedEventHandler(OnChanged); Array.Resize(ref statusWatchers, statusWatchers.Length + 1); Array.Resize(ref statusWatchersDir, statusWatchersDir.Length + 1); statusWatchersDir[statusWatchersDir.Length - 1] = ExchangeDir; statusWatchers[statusWatchers.Length - 1] = StatusWatcher; } catch (Exception ee) { } } } foreach (FileSystemWatcher FSW in statusWatchers) { FSW.EnableRaisingEvents = true; } }
internal static extern SafeFileHandle CreateFileW([In] string lpFileName, FileAccess dwDesiredAccess, FileShare dwShareMode, IntPtr lpSecurityAttributes, FileMode dwCreationDisposition, FileFlag dwFlagsAndAttributes, IntPtr hTemplateFile);