public TimeText(TimeEntry aOwner, DataPart aPart) : base() { XPos = 0.5; part = aPart; owner = aOwner; switch (aPart) { case DataPart.AMPM: SizeText = " <b>AM</b>"; break; case DataPart.HourSeparator: Text = ":"; break; case DataPart.MillisecondSeparator: Text = "."; break; case DataPart.Millisecond: SizeText = "<b>888</b>"; break; default: SizeText = "<b>88</b>"; break; } Refresh(); }
/// <summary> /// Start execution of archiving /// </summary> public void Execute() { int workBlockSize = 1000000; int processorCount = Environment.ProcessorCount; this._provider = new DataProvider(_initialFileName, workBlockSize, workBlockSize * processorCount); DataPart[] initialBuffer = new DataPart[processorCount]; this._writer = new FileWriter(_destinationFileName, processorCount); this._threads = new Thread[processorCount]; _autoResetEvents = new EventWaitHandle[processorCount]; //read data from file while it has unread data while (_provider != null && _provider.GetData(initialBuffer) > 0) { if (!_threadsAreRun) { CreateAndRunThreads(_threads, initialBuffer); } //permit to work lock (_lockObject) _manualResetEvent?.Set(); //Wait all archiving tasks WaitHandle.WaitAll(_autoResetEvents); } }
public void Parse(byte[] bytes) { Bytes = bytes; Hex = ByteHelper.byteToHexStr(bytes); ByteStr = ByteHelper.byteToStr(bytes); for (int i = 0; i < bytes.Length; i++) { if (i < 5) { CmdPart.Add(bytes[i]); } else if (i < bytes.Length - 4) { DataPart.Add(bytes[i]); } else { EndPart.Add(bytes[i]); } } CmdHex = ByteHelper.byteToHexStr(CmdPart.ToArray()); DataHex = ByteHelper.byteToHexStr(DataPart.ToArray()); EndHex = ByteHelper.byteToHexStr(EndPart.ToArray()); }
public void Test() { // Arrange string filePath = AppDomain.CurrentDomain.BaseDirectory.Split("bin")[0] + "/Data/WriteTest.txt"; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } DataPart[] writtenData = new DataPart[1] { new DataPart(new byte[12] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, 0, 11) }; // Act using (Services.FileWriter writer = new Services.FileWriter(filePath)) { writer.Write(writtenData); } FileInfo file = new FileInfo(filePath); // Assert Assert.Equal(file.Length, writtenData[0].Data.Length); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } }
public Form1(string[] argv) { InitializeComponent(); var res = DataPart.doit(argv).First().First(); field = res.Item3; unitQueue = res.Item4; //MessageBox.Show(DataPart.printField(field)); for (var i = 0; i < field.width; ++i) { for (var j = 0; j < field.height; ++j) { var c = DataPart.getCell(i, j, field); cells.Add(new Cell(j, i, c.IsFULL? Color.Red : ((Color?)null))); } } nextUnit(); //var unit = units.First(); //cells.Add(new Cell(unit.pivot.col, unit.pivot.row, Color.Aquamarine)); //foreach(var f in unit.filled) //{ // cells.Add(new Cell(f.row, f.col, Color.BurlyWood)); //} this.Width = field.width * 25 + 75; this.Height = field.height * 18 + 72; updateTimer = new Timer(); updateTimer.Tick += UpdateTimer_Tick; }
/// <summary> /// Handles ButtonPress event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventButton"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { if (CanFocus == true) { if (HasFocus == false) { GrabFocus(); return(true); } } if (Editable == false) { return(base.OnButtonPressEvent(evnt)); } IDrawingCell cell = mainbox.CellAtCoordinates(System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (cell == null) { return(base.OnButtonPressEvent(evnt)); } if (TypeValidator.IsCompatible(cell.GetType(), typeof(TimeText)) == true) { if ((int)(cell as TimeText).Part < 4) { Selected = (cell as TimeText).Part; return(true); } } return(base.OnButtonPressEvent(evnt)); }
public void Import(string filename) { DataPart part = DataPart.none; foreach (var str in File.ReadLines(filename)) { switch (str) { case "$Nodes": { part = DataPart.node; break; } case "$EndNodes": { part = DataPart.none; break; } case "$Elements": { part = DataPart.element; break; } case "$EndElements": { part = DataPart.none; break; } default: { switch (part) { case DataPart.element: { elementline.Add(new ElementLine(str)); break; } case DataPart.node: { nodeline.Add(new NodeLine(str)); break; } default: { break; } } break; } } } }
public MediaData(DataPart part) { ContentType = part.ContentType; using (Stream s = part.GetStream(FileMode.Open, FileAccess.Read)) { Media = new byte[s.Length]; s.Read(Media, 0, (int)s.Length); } }
/// <summary> /// Handles focus in event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusInEvent(Gdk.EventFocus evnt) { if (Editable == false) { return(true); } Selected = DataPart.Hour; return(base.OnFocusInEvent(evnt)); }
/// <summary> /// Handles focus in event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusInEvent(Gdk.EventFocus evnt) { if (Editable == false) { return(true); } Selected = labels[0].Part; return(base.OnFocusInEvent(evnt)); }
/// <summary> /// The Child GuiTreeNode may change and some data is copied, /// so there is need for update. /// </summary> public void UpdateFromGuiTreeNode() { Icon.ToolTip = DataPart.ToString(); if (DataPart.Parent is KmlVessel) { Text.Content = "[" + (DataPart.Parent as KmlVessel).Parts.IndexOf(DataPart) + "]"; } Text.ToolTip = DataPart.ToString(); Text.ContextMenu = Icon.ContextMenu; }
private IpText GetIpPart(DataPart aPart) { foreach (IpText lbl in cells) { if (lbl.Part == aPart) { return(lbl); } } return(null); }
/// <summary> /// Gets label which displays specified part /// </summary> /// <param name="aPart"> /// Part <see cref="DataPart"/> /// </param> /// <returns> /// Label cell <see cref="TimeText"/> /// </returns> private TimeText GetTimePart(DataPart aPart) { foreach (TimeText lbl in labels) { if (lbl.Part == aPart) { return(lbl); } } return(null); }
public IpText (IPv4Entry aEntry, DataPart aPart) : base() { entry = aEntry; part = aPart; if (aPart == DataPart.Separator) Text = "."; else { Text = "255"; SizeText = "<b>255</b>"; } }
private void genFieldCells() { cells.Clear(); for (var i = 0; i < field.width; ++i) { for (var j = 0; j < field.height; ++j) { var c = DataPart.getCell(i, j, field); cells.Add(new Cell(j, i, c.IsFULL ? Color.Red : ((Color?)null))); } } }
/// <summary> /// Get data from source file /// </summary> /// <param name="initialBuffer">The Dictionary will read data from there. Where key is index read data and DataPart <see cref="T:GZipTest.Models.DataPart" /></param> /// <returns>>Sum of bytes filled buffer dictionary</returns> public long GetData(DataPart[] initialBuffer) { int dataIndex = 0; this.ResetCounterProperties(); while (_bufferSize > 0 && _notReadSpace > 0) { int realBufferSize = _workBlockSize; if (_notReadSpace < _workBlockSize) { realBufferSize = (int)_notReadSpace; } DataPart buffer; lock (_lockObject) { if (_reader is null) { break; } buffer = new DataPart(new byte[realBufferSize], _reader.Position, _reader.Position + realBufferSize); _reader?.Read(buffer.Data, 0, realBufferSize); } //buffer.EndPosition = _reader.Position - 1; initialBuffer[dataIndex] = buffer; _notReadSpace -= realBufferSize; _bufferSize -= realBufferSize; _readData += realBufferSize; dataIndex++; } if (dataIndex != initialBuffer.Length) { for (int i = dataIndex; i < initialBuffer.Length; i++) { //initialBuffer[i] = new DataPart(new byte[0], 0, 0); initialBuffer[i] = null; } } return(_readData); }
private int IndexOf(DataPart aIndex) { int sel = -1; for (int i = 0; i < 5; i++) { if (Selected == labels[i].Part) { return(i); } } return(-1); }
public void SelectNext() { atStart = 0; if (CurrentPart != "") { atStart = System.Convert.ToByte(CurrentPart); } int sel = (int)Selected; if ((sel + 2) < 7) { Selected = (DataPart)sel + 2; } }
/// <summary> /// Selects previous part /// </summary> public void SelectPrev() { atStart = 0; if (CurrentPart != "") { atStart = System.Convert.ToInt32(CurrentPart); } int sel = (int)Selected; if ((sel - 1) > -1) { Selected = (DataPart)sel - 1; } }
public static void AreEqual(DataPart expected, DataPart actual) { AreEqual(expected.Headers, actual.Headers); AreEqual(expected.Properties, actual.Properties); using (var expectedStream = new MemoryStream()) using (var actualStream = new MemoryStream()) { expected.CopyToStream(expectedStream); actual.CopyToStream(actualStream); AreEqual(expectedStream, actualStream); } }
private void handleLock() { if (!DataPart.valid_apply(unit, field)) { MessageBox.Show("You lost!"); updateTimer.Stop(); return; } DataPart.apply_unit_mut(unit, field); DataPart.handle_lock(field); genFieldCells(); nextUnit(); }
/// <summary> /// Selects next part /// </summary> public void SelectNext() { atStart = 0; if (CurrentPart != "") { atStart = System.Convert.ToInt32(CurrentPart); } int sel = (int)Selected; if ((sel + 1) < 4) { Selected = (DataPart)sel + 1; } }
public IpText(IPv4Entry aEntry, DataPart aPart) : base() { entry = aEntry; part = aPart; if (aPart == DataPart.Separator) { Text = "."; } else { Text = "255"; SizeText = "<b>255</b>"; } }
/// <summary> /// Selects previous part /// </summary> public void SelectPrev() { atStart = 0; if (CurrentPart != "") { atStart = System.Convert.ToInt32(CurrentPart); } int sel = IndexOf(Selected); if ((sel - 2) > -1) { Selected = labels[sel - 2].Part; } ResetEditing(); }
private byte[] Compress(DataPart dataPart) { if (dataPart == null) { return(new byte[0]); } using (MemoryStream stream = new MemoryStream()) { using (GZipStream compressionStream = new GZipStream(stream, CompressionMode.Compress)) { compressionStream.Write(dataPart.Data); } return(stream.ToArray()); } }
public void Test() { // Arrange int workBlockSize = 1; int processorCount = Environment.ProcessorCount; string dataDirectory = AppDomain.CurrentDomain.BaseDirectory.Split("bin")[0] + "/Data/sample-2mb-text-file.txt"; DataPart[] initialBuffer = new DataPart[processorCount]; // Act using (Services.DataProvider dataProvider = new Services.DataProvider(dataDirectory, workBlockSize, processorCount * workBlockSize)) { long readBytesCount = dataProvider.GetData(initialBuffer); // Assert Assert.Equal(processorCount * workBlockSize, readBytesCount); } }
public static DataPart Create(IDataContainer dataContainer, Headers headers, Properties properties) { var obj = new DataPart(dataContainer); if (headers != null) { foreach (var header in headers) { obj.Headers.Add(header); } } if (properties != null) { foreach (var property in properties.GetPropertiesList()) { obj.Properties.AddOrReplace(property); } } return(obj); }
private void nextUnit() { unit = unitQueue.FirstOrDefault(); if (unit == null) { updateTimer.Stop(); MessageBox.Show("Out of pieces; technically, you won!"); return; } unitQueue = unitQueue.Skip(1); unit = DataPart.unit_start(unit, field); var bm = DataPart.best_move(unit, field); aiMoves = bm.Select(pair => pair.Item2); //MessageBox.Show(DataPart.string_from_units(bm.Select(pair => pair.Item1))); genUnitCells(); }
public DateText(DateEntry aOwner, DataPart aPart) : base() { XPos = 0.5; YPos = 0.5; part = aPart; owner = aOwner; switch (aPart) { case DataPart.Year: SizeText = " <b>8888</b>"; break; case DataPart.Separator: Text = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator; break; default: SizeText = "<b>88</b>"; break; } Refresh(); }
public static void WriteTransportFile( [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString fullFileName, [SqlFacet(MaxSize = 255, IsNullable = false)] SqlString tableName, [SqlFacet(MaxSize = 255, IsNullable = true)] SqlString fields) { if (fullFileName.IsNull) { throw new ArgumentNullException("fullFileName"); } if (tableName.IsNull) { throw new ArgumentNullException("tableName"); } string fieldFilter = "*"; if (!fields.IsNull) { fieldFilter = fields.Value; } var commandText = string.Format("SELECT {0} FROM {1}", fieldFilter, tableName.Value); var streamContainer = new DataStreamContainer(ContextConnectionString, commandText); var dataPart = new DataPart(streamContainer); var dataPack = new DataPack("RRTFv6"); dataPack.Description = "Экспериментальная выгрузка данных"; dataPack.DataParts.Add(dataPart); using (var output = new FileStream(fullFileName.Value, FileMode.Create, FileAccess.Write, FileShare.None)) { TransportSerializer.Serialize(dataPack, output); } }
/// <summary> /// Handles ButtonPress event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventButton"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnButtonPressEvent (Gdk.EventButton evnt) { if (HasFocus == false) return (base.OnButtonPressEvent (evnt)); IDrawingCell cell = mainbox.CellAtCoordinates (System.Convert.ToInt32(evnt.X), System.Convert.ToInt32(evnt.Y)); if (cell == null) return (base.OnButtonPressEvent (evnt)); if (TypeValidator.IsCompatible(cell.GetType(), typeof(DateText)) == true) if ((int) (cell as DateText).Part < 3) { Selected = (cell as DateText).Part; return (true); } return (base.OnButtonPressEvent (evnt)); }
/// <summary> /// Handles focus in event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusInEvent (Gdk.EventFocus evnt) { if (Editable == false) return (true); Selected = DataPart.Hour; return (base.OnFocusInEvent (evnt)); }
/// <summary> /// Selects next part /// </summary> public void SelectNext() { atStart = 0; if (CurrentPart != "") atStart = System.Convert.ToInt32(CurrentPart); int sel = (int) Selected; if ((sel+1) < 4) Selected = (DataPart) sel+1; }
private void WriteProperty(string name, PropertyType type, DataPart part, StringBuilder sb, string comment) { int count = 0; var propertyName = FixName(name); propertyNameCount.TryGetValue(propertyName, out count); count++; propertyNameCount[propertyName] = count; if (count > 1) { propertyName = propertyName + "_" + (count - 1).ToString(); } var forceSingle = (part == DataPart.File) || (part == DataPart.URLTemplate); tabRepeatCount++; var pathString = pathDic[part]; var typeString = part == DataPart.File ? "FileUploadInfo" : "string"; WriteComment(comment, sb); sb .Append(Tabs()) .Append("public ") .Append(type == PropertyType.List && (!forceSingle) ? "List<" : "") .Append(typeString) .Append(type == PropertyType.List && (!forceSingle) ? ">" : "") .Append(" ") .Append(propertyName) .AppendLine() .Append(Tabs()) .Append("{ ") .AppendLine(); tabRepeatCount++; sb .Append(Tabs()) .Append("get { return ") .Append(pathString) .Append(".ContainsKey(\"").Append(name).Append("\")") .Append(" ? ") .Append(pathString) .Append("[\"").Append(name).Append("\"]") .Append((type == PropertyType.List) || (forceSingle) ? "" : ".FirstOrDefault()") .Append(" : ") .Append("null;") .Append(" }") .AppendLine(); sb .Append(Tabs()) .Append("set") .AppendLine() .Append(Tabs()) .Append("{") .AppendLine(); tabRepeatCount++; if (type == PropertyType.Single && !forceSingle) { sb .Append(Tabs()) .Append("var oldv=") .Append(propertyName) .Append(";") .AppendLine() .Append(Tabs()) .Append("var target = ") .Append(pathString) .Append(".ContainsKey(\"").Append(name).Append("\")") .Append(" ? ") .Append(pathString) .Append("[\"").Append(name).Append("\"]") .Append(" : ") .Append("new List<string> ()") .Append(" ;") .AppendLine() .Append(Tabs()) .Append("target.Clear();") .AppendLine() .Append(Tabs()) .Append("target.Add(value);") .AppendLine() .Append(Tabs()) .Append(pathString) .Append("[\"").Append(name).Append("\"]") .Append(" = target;") .AppendLine() .Append(Tabs()) .Append("if") .Append("(").Append(" PropertyChanged !=null && oldv!=value").Append(")") .Append("PropertyChanged(this , new PropertyChangedEventArgs(\"") .Append(propertyName) .Append("\"));") .AppendLine(); } else { sb .Append(Tabs()) .Append(pathString) .Append("[\"").Append(name).Append("\"]") .Append(" = value;") .AppendLine() .Append(Tabs()) .Append("if") .Append("(").Append(" PropertyChanged !=null ").Append(")") .Append("PropertyChanged(this , new PropertyChangedEventArgs(\"") .Append(propertyName) .Append("\"));") .AppendLine(); } tabRepeatCount--; sb .Append(Tabs()) .Append("}") .AppendLine(); tabRepeatCount--; sb .Append(Tabs()) .Append("}") .AppendLine(); tabRepeatCount--; }
public void SelectNext() { atStart = 0; if (CurrentPart != "") atStart = System.Convert.ToByte(CurrentPart); int sel = (int) Selected; if ((sel+2) < 7) Selected = (DataPart) sel+2; }
public void SelectPrev() { atStart = 0; if (CurrentPart != "") atStart = System.Convert.ToByte(CurrentPart); int sel = (int) Selected; if ((sel-2) > -1) Selected = (DataPart) sel-2; }
private IpText GetIpPart (DataPart aPart) { foreach (IpText lbl in cells) if (lbl.Part == aPart) return (lbl); return (null); }
public TimeText (TimeEntry aOwner, DataPart aPart) : base () { XPos = 0.5; part = aPart; owner = aOwner; switch (aPart) { case DataPart.AMPM: SizeText = " <b>AM</b>"; break; case DataPart.HourSeparator: Text = ":"; break; case DataPart.MillisecondSeparator: Text = "."; break; case DataPart.Millisecond: SizeText = "<b>888</b>"; break; default: SizeText = "<b>88</b>"; break; } Refresh(); }
private int IndexOf (DataPart aIndex) { int sel = -1; for (int i=0; i<5; i++) if (Selected == labels[i].Part) return (i); return (-1); }
public DateText (DateEntry aOwner, DataPart aPart) : base () { XPos = 0.5; YPos = 0.5; part = aPart; owner = aOwner; switch (aPart) { case DataPart.Year: SizeText = " <b>8888</b>"; break; case DataPart.Separator: Text = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator; break; default: SizeText = "<b>88</b>"; break; } Refresh(); }
/// <summary> /// Handles focus out event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusOutEvent (Gdk.EventFocus evnt) { ResetEditing(); Selected = DataPart.None; return (base.OnFocusOutEvent (evnt)); }
/// <summary> /// Selects previous part /// </summary> public void SelectPrev() { atStart = 0; if (CurrentPart != "") atStart = System.Convert.ToInt32(CurrentPart); int sel = IndexOf (Selected); if ((sel-2) > -1) Selected = labels[sel-2].Part; ResetEditing(); }
/// <summary> /// Gets label which displays specified part /// </summary> /// <param name="aPart"> /// Part <see cref="DataPart"/> /// </param> /// <returns> /// Label cell <see cref="TimeText"/> /// </returns> private DateText GetDatePart (DataPart aPart) { foreach (DateText lbl in labels) if (lbl.Part == aPart) return (lbl); return (null); }
/// <summary> /// Handles focus out event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusOutEvent(Gdk.EventFocus evnt) { Selected = DataPart.None; return(base.OnFocusOutEvent(evnt)); }
/// <summary> /// Handles focus in event /// </summary> /// <param name="evnt"> /// Arguments <see cref="Gdk.EventFocus"/> /// </param> /// <returns> /// true if handled, false if not <see cref="System.Boolean"/> /// </returns> protected override bool OnFocusInEvent (Gdk.EventFocus evnt) { if (Editable == false) return (true); Selected = labels[0].Part; return (base.OnFocusInEvent (evnt)); }