public FindDifferencesDialog(Graph graph, IList <ListView.Item> items, double start, double end) { InitializeComponent(); TxWinForms.Bind(this); this.graph = graph; mainInstructionLabel.Font = new Font(mainInstructionLabel.Font, FontStyle.Bold); listView.EmptyText = Tx.T("main.list is empty"); Font monospacedFont = new Font("Consolas", 8f); startTextBox.Font = monospacedFont; endTextBox.Font = monospacedFont; startTextBox.Text = start.ToExactString(); endTextBox.Text = end.ToExactString(); startTextBox.SelectionStart = 0; endTextBox.SelectionStart = 0; foreach (var item in items) { listView.Items.Add(item); } EstimateTime(true); refreshTimer = new Timer(); refreshTimer.Tick += OnRefreshTimer; refreshTimer.Interval = 4000; }
private static void OnTxDictionaryChanged(object sender, EventArgs args) { context.Post(delegate { lock (controlBindings) { foreach (var binding in controlBindings) { switch (binding.Key.Target) { case Control control: { switch (binding.Key.Type) { case BindingType.Text: control.Text = Tx.T(binding.Value); break; } break; } case ToolStripItem item: { switch (binding.Key.Type) { case BindingType.Text: item.Text = Tx.T(binding.Value); break; case BindingType.ToolTip: item.ToolTipText = Tx.T(binding.Value); break; } break; } } } } }, null);
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Size clientSize = ClientSize; UI.PaintDirtGradient(e.Graphics, 1, 1, clientSize.Width - 1, 360, 360, 255); int y = 9; Color back = SystemColors.Window; Color fore = SystemColors.WindowText; Color foreAnimated = Color.FromArgb( back.R + (fore.R - back.R) * animationValue / 255, back.G + (fore.G - back.G) * animationValue / 255, back.B + (fore.B - back.B) * animationValue / 255 ); using (GdiGraphics g = GdiGraphics.FromGraphics(e.Graphics)) { y += DrawString(g, App.AssemblyTitle, mainInstructionFont, foreAnimated, new Point(23, y)) + 4; y += DrawString(g, Tx.T("main.about.description"), subtitleFont, foreAnimated, new Point(23, y)) + 18; y += DrawString(g, App.AssemblyCopyright, Font, fore, new Point(23, y)) + 3; y += DrawString(g, "This project is licensed under the terms of the GNU General Public License v3.0.", Font, fore, new Point(23, y)) + 10; } Point linkPos = new Point(21, y); if (linkLabel.Location != linkPos) { linkLabel.Location = linkPos; } }
public void Initalize() { var tasksSection = new MenuSection <ItemCommand <ClientViewModel> >(); var tasksSubMenu = new NavigationalEntry <ItemCommand <ClientViewModel> > { Header = Tx.T("TasksInfrastructure:CreateTask.Commands", 2), IsOrdered = true, Icon = _icons.SelectCommandColumn }; InitializeCommands(tasksSubMenu); tasksSection.Add(tasksSubMenu); var createTaskCommand = new ItemCommand <ClientViewModel> { Header = Tx.T("TasksInfrastructure:CreateTask"), Icon = _icons.NewCatalog, Command = new DelegateCommand <ClientViewModel>(client => CreateTaskCommand(new List <ClientViewModel> { client })), MultipleCommand = new DelegateCommand <IList <ClientViewModel> >(CreateTaskCommand) }; tasksSection.Add(createTaskCommand); _clientsContextMenu.Add(tasksSection); }
private void TransportWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs args) { if (args.Cancelled) { RemainingTimeLabel.Text = Tx.T("msg.cancelled"); progressBar1.Value = 0; } else if (args.Error != null) { RemainingTimeLabel.Text = Tx.T("msg.title.error"); ErrorLabel.Text = args.Error.Message; ErrorPanel.Show(); FinishedInfoLabel.Text = Tx.T("transport progress view.select another transport"); FinishedInfoLabel.Show(); } else { RemainingTimeLabel.Text = Tx.T("msg.completed"); finished = true; SuccessPanel.Show(); if (SharedData.Instance.FromShortcut) { FinishedInfoLabel.Text = Tx.T("transport progress view.delete shortcut"); FinishedInfoLabel.Show(); } UpdateButtons(); } }
public LogSelectionView() { InitializeComponent(); TxDictionaryBinding.AddTextBindings(this); LogBasePathHeader.Text = Tx.T("log selection view.list.log base path"); LastUpdateHeader.Text = Tx.T("log selection view.list.last update"); SizeHeader.Text = Tx.T("log selection view.list.size"); Dock = DockStyle.Fill; // Set up and initialise column sorting logDirsColumnSorter = new ListViewColumnSorter(LogDirsListView); logDirsColumnSorter.SortColumn = 0; logDirsColumnSorter.Order = SortOrder.Ascending; logDirsColumnSorter.Update(); LogDirsListView.ListViewItemSorter = logDirsColumnSorter; // Force-enable double buffering in the ListView to prevent flickering var prop = LogDirsListView.GetType().GetProperty( "DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); if (prop != null) { prop.SetValue(LogDirsListView, true, null); } }
public void CallContractOnLocalNodeTest() { Account account = nativeClient.GetAccount(baseKeyPair.PublicKey); ulong nonce = account.Nonce + 1; Calldata callData = nativeClient.EncodeCalldata(logger, TestConstants.TestContractSourceCode, TestConstants.TestContractFunction, TestConstants.TestContractFunctionParams); UnsignedTx unsignedTxNative = CreateUnsignedContractCallTx(nonce, callData.CallData, null); Tx signedTxNative = nativeClient.SignTransaction(unsignedTxNative, baseKeyPair.PrivateKey); // post the signed contract call tx PostTxResponse postTxResponse = nativeClient.PostTx(logger, signedTxNative); Assert.AreEqual(postTxResponse.TXHash, Encoding.ComputeTxHash(signedTxNative.TX)); logger.LogInformation("CreateContractTx hash: " + postTxResponse.TXHash); // get the tx info object to resolve the result TxInfoObject txInfoObject = nativeClient.WaitForTxInfoObject(logger, postTxResponse.TXHash); // decode the result to json JToken json = nativeClient.DecodeCallResult(TestConstants.TestContractSourceCode, TestConstants.TestContractFunction, txInfoObject.CallInfo.ReturnType, txInfoObject.CallInfo.ReturnValue, CompileOptsBackend.Fate); Assert.AreEqual(TestConstants.TestContractFunctionParam, json.Value <string>()); }
private void CompressWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs args) { if (args.Cancelled) { RemainingTimeLabel.Text = Tx.T("msg.cancelled"); RemainingTimeLabel.ForeColor = SystemColors.ControlText; progressBar1.Value = 0; DiscardArchive(); } else if (args.Error != null) { RemainingTimeLabel.Text = Tx.TC("msg.title.error") + " " + args.Error.Message; RemainingTimeLabel.ForeColor = Color.FromArgb(240, 0, 0); DiscardArchive(); } else { RemainingTimeLabel.Text = Tx.T("msg.completed"); RemainingTimeLabel.ForeColor = Color.FromArgb(0, 160, 0); CompressedSizeLabel.Text = Tx.DataSize(SharedData.Instance.ArchiveFileSize); dataReady = true; UpdateButtons(); MainForm.Instance.FocusNextButton(); } }
public void Tx_Out_Address() { //single output tests var tests = new string[][] { //P2PK new string[] { "12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX", "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000" }, //P2PKH new string[] { "18xRrVE5SGdD3QYgszxYyEjuCeHnfqMTqH", "0100000002144e211274abfee1ea9d63bb40002f36d6a0955d051649d460ac43c2631b6cae010000006b483045022100f0762d76613f2775445d6bd0e944c93e213d8b61aa314f56641c6692dc620a0f022077b6cec522f57ce3e21be954c3b0d24883fd946623a0fecfa44eceb5a6f14e9301210328582a9204abf0ee920f54c64adf5359b720fc44019b518ed214c997c531aac1ffffffff3dc9ace14aaf623bab12ea6ff7e8010954282654ab9042b18b913b621328726f000000006a473044022041d81ae917b556ab903e6a2d65af896de49e5ebc48ea4aba5a60dfae6b077d8d02202bddb8b3be71753c4fa9c22d418982566a80a657d8fccf46ab78b293bd615f8f012103184f0018baae12bf2499c4a868bfb9f05d94093596cfcc1dd505b366038da642ffffffff01f6537b0b000000001976a9145744813aff6759cc19595547e9947c21fc7c07f088ac00000000" }, //P2SH new string[] { "3AZdx7cGMU1prFer7gzsmeNzERzo7pPSAP", "010000000162220eace15cc50893da8ec40a0aa8a4f890b60405f0d8ffcce3ceae1f65eda2030000006a4730440220516b1584bc1fcae77a6a04aada82b5663864e0f734a75d2a5bd643dbb271703802205cf4e92e9bb47bbd78484956a96b68f15701fface600182760a382e0a1afddb801210320d6ff1346469239bf7f147fcb8154b1dd22329d6409757c290a6762f8d6162cffffffff01e4f8a8000000000017a9146153e0d56d97dbbe56a5214a1289f6221ea6249a8700000000" }, //P2SH_P2WPKH new string[] { "bc1qc8jgyt0wc4tv3nym274gn4fwe58tlswe5uhdjz", "010000000001019b5d5dfeff3f451a456b5bab1d2930f34ce940bb3bbf5c0794ddf8fd98f7c9f004000000171600147826fe22125ae742c3b91e7e6e41a7d743c25de1ffffffff02eb68000000000000160014c1e4822deec556c8cc9b57aa89d52ecd0ebfc1d99e790900000000001976a914153e989ec362cfdf14f46e8f3a986735dfc11cdd88ac02483045022100a0b07e0e0aa8a44f17b43bbd02045efa52224ac5aaac4db6ec08899dfc460c7d02200be3181a13dbc72a92777941c991cac0f01322563d34343404e4d0a2cedb9aec012103424b3498226467f8b015fe5c7d5f2e002c265242d0b3c3533f74a38b019580d200000000" }, //P2WSH new string[] { "bc1qpapzchprzhnhg5kcamfm3vmfjlx49hzqjh5s2vrp38yst6fm9rkqmnhq3a", "0200000000010130c62a0fa62608f378b13645b89ef15ffce557414a35a251727dc3cf8a12aa050100000000a70d9980010e8a0700000000002200200f422c5c2315e77452d8eed3b8b36997cd52dc4095e905306189c905e93b28ec0400483045022100ac56ad14a790e0677ebceafc64d29a95eb9d6aa503bec173cdb57087d25f690302204b2e8dfd9e89f0d7917e423f50a49c86a786275cad320514ffefc4602723d8750147304402206e6b06e66a17d40674b93e47e11100c90ed8625231c1591ba66d92a958b8b9f00220734d487437d0084cd9fb5e7d15b2e5a87ab0bd25e495711c1bb69519fac3130c0147522102e6c7484ed0dd6b3632644c20b070dd64f1034fbb601206b6eaca08da8806bb81210365213c3d159cb62fe849f5ff2760d9bdb1784fdf362cb6d0eae1cdd4fe31369b52ae86125d20" } }; foreach (var t in tests) { var tx = new Tx(); #if NETCOREAPP2_1 tx.ReadFromPayload(t[1].FromHex()); #else tx.ReadFromPayload(t[1].FromHex(), 0); #endif Assert.Equal(t[0], tx.TxOut[0].GetAddress().ToString()); } }
private string ReadClipboard() { string str = null; int retryCount = 20; while (true) { try { str = Clipboard.GetText(); break; } catch (COMException ex) { retryCount--; if (retryCount > 0) { System.Threading.Thread.Sleep(50); continue; } else { App.ErrorMessage(Tx.T("window.wizard.error reading clipboard"), ex, "Reading from clipboard"); return(null); } } } #if DEBUG if (retryCount < 20) { App.WarningMessage("Tried reading the clipboard " + (20 - retryCount) + " times!"); } #endif return(str); }
// General TX File downgrading or upgrading public static void UpdatePendingTXFile(Block b) // delete all TX in pending if they are include in the block ( just with verifying pkey & tou) { uint byteOffset = 0; FileInfo f = new FileInfo(_folderPath + "ptx"); int fl = (int)f.Length; while (byteOffset < fl) { Tx TX = BytesToTx(GetBytesFromFile(byteOffset, 1100, _folderPath + "ptx")); if (TX == null) { FatalErrorHandler(0, "no tx found in data during update pending tx file"); return; } // FATAL ERROR foreach (Tx BTX in b.Data) { if (BTX == null) { FatalErrorHandler(0, "no tx found in builder during update pending tx file"); return; } // FATAL ERROR if (TX.sPKey.SequenceEqual(BTX.sPKey) && TX.TokenOfUniqueness == BTX.TokenOfUniqueness) { // flip bytes then truncate byte[] lastTX = GetBytesFromFile((uint)fl - 1100, 1100, _folderPath + "ptx"); OverWriteBytesInFile(byteOffset, _folderPath + "ptx", lastTX); TruncateFile(_folderPath + "ptx", 1100); f = new FileInfo(_folderPath + "ptx"); fl = (int)f.Length; break; } } byteOffset += 1100; } }
public IBitcoinBasedTransaction Clone() { return(new BitcoinBasedTransaction( currency: (BitcoinBasedCurrency)Currency, tx: Tx.Clone(), blockInfo: (BlockInfo)BlockInfo?.Clone())); }
private async Task RefetchPageAsync(bool fetchContent, bool replaceContent = false) { Status = Tx.T("editor.fetching page", "title", WikiPage.Title); IsBusy = true; try { await WikiPage.RefreshAsync(fetchContent?PageQueryOptions.FetchContent : PageQueryOptions.None); lastRefreshTime = DateTime.Now; UpdateRelativeDates(); ReloadPageInformation(); if (fetchContent && replaceContent) { ReloadPageContent(); } Status = null; } catch (Exception ex) { Status = Utility.GetExceptionMessage(ex); } finally { IsBusy = false; } }
//public int NewNo { get; set; } // Display Info of the RFEM Objects on Panels // Parameters are separated by ";". The component split text can be used to break the string down into a list. public override string ToString() { return(string.Format($"RFEM-LineHinge;No:{No};Ux:{Tx.DOF("kN/m")};Uy:{Ty.DOF("kN/m")};Uz:{Tz.DOF("kN/m")};" + $"φx:{Rx.DOF("kNm/rad")};φy:{Ry.DOF("kNm/rad")};φz:{Rz.DOF("kNm/rad")};Tag:{((Tag == "") ? "-" : Tag)};" + $"LineNo:{LineNo};SfcNo:{SfcNo}IsValid:{IsValid};ID:{((ID == "") ? "-" : ID)};Side:{Side.ToString()};" + $"ToModify:{ToModify};ToDelete:{ToDelete};Comment:{((Comment == "") ? "-" : Comment)};")); }
private void OpenDirectoryProperties(DirectoryViewModel directory, FileExplorerViewModel context) { context.Window.Show <PropertiesViewModel>(null, window => { window.Title = Tx.T("FileExplorer:Properties.Title", "name", directory.Name); }, viewModel => viewModel.Initialize(directory), out _); }
//public int NewNo { get; set; } // Display Info of the RFEM Objects on Panels // Parameters are separated by ";". The component split text can be used to break the string down into a list. public override string ToString() { return(string.Format($"RFEM-SrfcSupport;No:{No};Ux:{Tx.DOF("kN/m")};Uy:{Ty.DOF("kN/m")};Uz:{Tz.DOF("kN/m")};" + $"Vxz:{Vxz.DOF("kNm/rad")};Vyz:{Vyz.DOF("kNm/rad")};Tag:{((Tag == "") ? "-" : Tag)};" + $"SurfaceList:{((SurfaceList == "") ? "-" : SurfaceList)};IsValid:{IsValid};ID:{((ID == "") ? "-" : ID)};" + $"ToModify:{ToModify};ToDelete:{ToDelete};Comment:{((Comment == "") ? "-" : Comment)};")); }
/// <summary> /// Sets the revisions to diff. /// </summary> public void SetRevisions(Revision revision1, Revision revision2) { if (revision1 == null) { throw new ArgumentNullException(nameof(revision1)); } if (revision2 == null) { throw new ArgumentNullException(nameof(revision2)); } Debug.Assert(revision1.Page.Site == SiteContext.GetSiteAsync().Result); Debug.Assert(revision1.Page.Site == revision2.Page.Site); RevisionId1 = revision1.Id; RevisionId2 = revision2.Id; DeltaContentLength = revision2.ContentLength - revision1.ContentLength; if (revision1.Page.Title == revision2.Page.Title) { Title = Tx.T("page diff.title", "name", revision1.Page.Title); } else { Title = Tx.T("page diff.general title", "name1", revision1.Page.Title, "name2", revision2.Page.Title); } Revision1 = revision1; Revision2 = revision2; // Just throw the rest of the job to TextDiffViewer… }
public static string[] AffectedAccounts(Tx tx, Meta meta) { var accounts = new List <string>(); accounts.Add(tx.Account); if (tx.Destination != null) { accounts.Add(tx.Destination); } if (tx.LimitAmount != null) { accounts.Add(tx.LimitAmount.Issuer); } if (meta != null && meta.TransactionResult == "tesSUCCESS") { foreach (var an in meta.AffectedNodes) { var node = an.CreatedNode ?? an.DeletedNode ?? an.ModifiedNode; if (node == null) { continue; } var fieldsSet = new FieldsSet(node.FinalFields, node.NewFields, node.PreviousFields); switch (node.LedgerEntryType) { case "AccountRoot": case "Offer": var account = fieldsSet.Account; if (account != null) { accounts.Add(account); } break; case "SkywellState": var highLimit = fieldsSet.HighLimit; if (highLimit != null && highLimit.Issuer != null) { accounts.Add(highLimit.Issuer); } var lowLimit = fieldsSet.LowLimit; if (lowLimit != null && lowLimit.Issuer != null) { accounts.Add(lowLimit.Issuer); } break; } } } return(accounts.ToArray()); }
/// <summary> /// Performs the dictionary lookup and translates the text key based on the selected /// configuration. /// </summary> /// <returns>Text value for the builder's text key.</returns> public string Make() { var result = Tx.T(text, count, arguments.ToDictionary(p => p.Key, p => p.Value)); if (upperCase) { result = Tx.UpperCase(result); } if (colon) { result += Tx.Colon(); } if (quoteNested) { result = Tx.QuoteNested(result); } if (quote) { result = Tx.Quote(result); } if (parentheses) { result = Tx.Parentheses(result); } return(result); }
public static string[] AffectBooks(Tx tx, Meta meta) { if (tx == null || meta == null) { return(null); } var isSell = ((long)LedgerOfferFlags.Sell & tx.Flags) != 0; var books = new List <string>(); foreach (var an in meta.AffectedNodes) { var node = an.CreatedNode ?? an.ModifiedNode ?? an.DeletedNode; if (node == null || node.LedgerEntryType != "Offer") { continue; } var fielsSet = new FieldsSet(node.FinalFields, node.NewFields, node.PreviousFields); var gets = fielsSet.TakerGets; var pays = fielsSet.TakerPays; var getsKey = GetAmountString(gets); var paysKey = GetAmountString(pays); var key = isSell ? GetAmoutPairKey(pays, gets) : GetAmoutPairKey(gets, pays); books.Add(key); } return(books.ToArray()); }
public TimeSelectionView() { timeEntries.Add(new TimeEntry(TimeSpan.FromMinutes(5))); timeEntries.Add(new TimeEntry(TimeSpan.FromMinutes(15))); timeEntries.Add(new TimeEntry(TimeSpan.FromMinutes(30))); timeEntries.Add(new TimeEntry(TimeSpan.FromHours(1))); timeEntries.Add(new TimeEntry(TimeSpan.FromHours(3))); timeEntries.Add(new TimeEntry(TimeSpan.FromHours(6))); timeEntries.Add(new TimeEntry(TimeSpan.FromHours(12))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(1))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(2))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(3))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(7))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(10))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(14))); timeEntries.Add(new TimeEntry(TimeSpan.FromDays(30))); timeEntries.Add(new TimeEntry { Text = Tx.T("time selection.everything"), TimeSpan = TimeSpan.MaxValue }); InitializeComponent(); TxDictionaryBinding.AddTextBindings(this); Dock = DockStyle.Fill; TimeTrackBar.Value = (timeEntries.Count - 1) - 4; }
public DateTimeStopEventViewModel() { this.RegisterProperty(() => DateTime, Tx.T("TasksCommon:StopEvents.DateTime.Properties.DateTime"), Tx.T("TasksCommon:StopEvents.DateTime.Properties.DateTime.Description"), Tx.T("TasksCommon:Categories.Common")); DateTime = DateTime.Now.AddDays(1); }
public Form1() { // Setup translation data Tx.UseFileSystemWatcher = true; Tx.LoadDirectory("lang"); Tx.PrimaryCulture = "de"; InitializeComponent(); // Adopt UI font Font = SystemFonts.MessageBoxFont; // Statically set a control's text once //IntroLabel.Text = Tx.T("intro"); // Add a custom control property binding to a text key //TxDictionaryBinding.AddBinding(IntroLabel, "Text", "intro"); // Add translation dictionary bindings for all controls TxDictionaryBinding.AddTextBindings(this); // Fill the languages drop-down and select the current language string currentCulture = Tx.GetCultureName(); foreach (CultureInfo ci in Tx.AvailableCultures) { CultureLabel cl = new CultureLabel(ci.Name, Tx.U(ci.NativeName)); LanguageCombo.Items.Add(cl); if (ci.Name == currentCulture) { LanguageCombo.SelectedItem = cl; } } isLoading = false; }
public TransportView() { InitializeComponent(); TxDictionaryBinding.AddTextBindings(this); Dock = DockStyle.Fill; if (httpTransportView.Transport.CanExecute()) { TransportComboBox.Items.Add(new TransportMethod { Text = Tx.T("transport.http"), View = httpTransportView, Transport = httpTransportView.Transport }); } if (mailTransportView.Transport.CanExecute()) { TransportComboBox.Items.Add(new TransportMethod { Text = Tx.T("transport.mail"), View = mailTransportView, Transport = mailTransportView.Transport }); } TransportComboBox.Items.Add(new TransportMethod { Text = Tx.T("transport.file"), View = fileTransportView, Transport = fileTransportView.Transport }); TransportComboBox.SelectedIndex = 0; }
public static void ReflectionTest10() { Tx obj = new Tx { FloatField = 21, IntField = 21 }; Type t = obj.GetType(); var fields = t.GetProperties(BindingFlags.Public | BindingFlags.Instance); var info = fields[0]; //FloatField object value = info.GetGetMethod().Invoke(obj, null); Console.WriteLine(string.Format("{0} = {1}", info.Name, value)); if (value == null) { throw new Exception("null obj - FloatField"); // 不应该走到这里来,但走到了这里 } info = fields[1]; value = info.GetGetMethod().Invoke(obj, null); Console.WriteLine(string.Format("{0} = {1}", info.Name, value)); if (value == null) { throw new Exception("null obj - IntField"); } else { Console.WriteLine("not null obj - IntField"); // 对于int是正确的,走到了这里 } }
public static void LoadBlocks() { using (StreamReader reader = new StreamReader("../../../block.txt")) { string line; int count = 0; while (null != (line = reader.ReadLine())) { JSONBack jsonBack = ConvertToJSONBack(line); List <In> ins = new List <In>(); foreach (Input _in in jsonBack.ins) { In __in = new In(_in.addr, _in.tx_index); ins.Add(__in); } try { Tx tx = new Tx(jsonBack.CellID, jsonBack.time, jsonBack.hash, ins, jsonBack.outs, jsonBack.amount, Convert.ToBoolean(jsonBack.isAmount), Convert.ToBoolean(jsonBack.isFreq), Convert.ToBoolean(jsonBack.isCycle)); Global.LocalStorage.SaveTx(tx); } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } count++; } Console.WriteLine(count); } }
public static bool CheckPunctuationConsistency(string a, string b, out string message) { if (a == null) { a = ""; } if (b == null) { b = ""; } string pattern; Match m1, m2; pattern = "^([ \t\r\n]*)"; m1 = Regex.Match(a, pattern); m2 = Regex.Match(b, pattern); if (!m1.Success || !m2.Success || m1.Groups[1].Value != m2.Groups[1].Value) { message = Tx.T("validation.content.inconsistent punctuation"); return(false); } pattern = "([ \t\r\n!%,.:;?…]*)$"; m1 = Regex.Match(a, pattern); m2 = Regex.Match(b, pattern); if (!m1.Success || !m2.Success || m1.Groups[1].Value != m2.Groups[1].Value) { message = Tx.T("validation.content.inconsistent punctuation"); return(false); } message = null; return(true); }
public static CellarSize EstimateSize(Tx tx) { var chunkCount = 0; var diskSize = 0L; var byteSize = 0L; var records = 0L; foreach (var pair in Lmdb.ListChunks(tx)) { chunkCount += 1; var dto = pair.Value; diskSize += dto.GetCompressedDiskSize(); byteSize += dto.GetUncompressedByteSize(); records += dto.GetChunkRecords(); } var buffer = Lmdb.GetBuffer(tx, 0); if (buffer != null) { diskSize += buffer.GetBufferMaxBytes(); byteSize += buffer.GetBufferPos(); records += buffer.GetBufferRecords(); } return(new CellarSize(chunkCount, diskSize, byteSize, records)); }
public DirectoryViewModel(DirectoryEntry directoryEntry, IFileSystem fileSystem, IUiTools uiTools, bool isNode) { _fileSystem = fileSystem; _uiTools = uiTools; _source = directoryEntry; if (directoryEntry is DriveDirectoryEntry driveDirectory) { Size = driveDirectory.UsedSpace; Description = Tx.T($"FileExplorer:DriveTypes.{driveDirectory.DriveType}"); } else { Description = Tx.T("FileExplorer:Directory"); } UpdateName(); if (isNode) { fileSystem.EntryAdded += FileSystemOnEntryAdded; fileSystem.EntryRemoved += FileSystemOnEntryRemoved; fileSystem.DirectoryEntriesUpdated += FileSystemOnDirectoryEntriesUpdated; } fileSystem.EntryUpdated += FileSystemOnEntryUpdated; _isNodeViewModel = isNode; }
//public int NewNo { get; set; } // Display Info of the RFEM Objects on Panels // Parameters are separated by ";". The component split text can be used to break the string down into a list. public override string ToString() { return(string.Format($"RFEM-LineSupport;No:{No};Ux:{Tx.DOF("kN/m")};Uy:{Ty.DOF("kN/m")};Uz:{Tz.DOF("kN/m")};" + $"φx:{Rx.DOF("kNm/rad")};φy:{Ry.DOF("kNm/rad")};φz:{Rz.DOF("kNm/rad")};Tag:{((Tag == "") ? "-" : Tag)};" + $"LineList:{((LineList == "") ? "-" : LineList)};IsValid:{IsValid};ID:{((ID == "") ? "-" : ID)};ReferenceSystemType:{RSType.ToString()};" + $"ToModify:{ToModify};ToDelete:{ToDelete};Comment:{((Comment == "") ? "-" : Comment)};")); }
static void _Main(string[] args) { TcpClient tcpClient = new TcpClient("10.1.1.40", 8333); NetworkStream ns = tcpClient.GetStream(); NetAddr localaddr = new NetAddr(Services.NODE_NETWORK, ((IPEndPoint)tcpClient.Client.LocalEndPoint).Address, (UInt16)((IPEndPoint)tcpClient.Client.LocalEndPoint).Port); NetAddr remaddr = new NetAddr(Services.NODE_NETWORK, ((IPEndPoint)tcpClient.Client.RemoteEndPoint).Address, (UInt16)((IPEndPoint)tcpClient.Client.RemoteEndPoint).Port); new Message("version", Version.Default(remaddr, localaddr, 0)).Write(ns); Tx tx = new Tx(HexString.ToByteArray("0100000001b924de36d37e9b46171036c2380dd3f86c33de7868b95f295c79d057abb876c9000000006c493046022100d35d290d515b2310a81850b14522f3965982ad059b08b7d6646372c9f6f98642022100d2d0fa06f8afa2a9df7bf7e06f901f08fc40882f486b292c217c96706912f23a012103b5091600a12d971b056170a682ea596b6680dd8a784f2960b1bfdc891155db44ffffffff0100ae4c2d000000001976a91443e86640aa84e2a53597e79109e912f8f9ebda1188ac00000000")); Message mtx = new Message("tx", tx); mtx.Write(ns); while (tcpClient.Client.Connected) { Message msg = Message.FromStream(ns); ISerialize p = msg.payload; Console.WriteLine(msg.payload); switch (msg.strcmd) { case "addr": break; case "alert": break; case "block": break; case "getaddr": { // Message m = new Message("addr", new Addr()); break; } case "getblocks": break; case "getdata": break; case "getheaders": break; case "headers": break; case "inv": { Inv inv = (Inv)msg.payload; new Message("getdata", new GetData(inv.inventory)).Write(ns); break; } case "ping": break; case "tx": break; case "verack": break; case "version": { Message m = new Message("verack", new VerAck()); m.Write(ns); break; } default: break; } } /* string line; Transaction txUnspent = new Transaction(HexString.ToByteArray("0100000001f165b1179cb8ed7057540375884214287cf1592f2325080364f0bd8ef51d638b010000006a47304402207cf76bb48434e70ff0ea86a949ec4191fff0c31fdbbf6441c28293a09cb6841d022039906ff8b98761aa0d113e975c7af277d091a3cb9aaceae07dffe91f13fd65830121031adaac125ad58a48d1289bd44624d569b3ace8f9c59e02557e8ad00787dc7e06ffffffff0100ae4c2d00000000232102004066b81e658b2535b951c309edc4807a5260d9f1387e5dfda2d91355e562efac00000000")); Address addr = new Address("1QJqE3KiyFBSCP12kTybW1ZRSeuJZTUwBY"); TxIn txIn = new TxIn(txUnspent.hash, 0, new Byte[0]); TxOut txOut = new TxOut(760000000, ScriptTemplate.PayToAddress(addr).ToBytes()); Transaction tx = new Transaction(1, new TxIn[] { txIn }, new TxOut[] { txOut }, 0); PrivateKey pk = PrivateKey.FromWIF("L1F95LNfoyGozceafTC1Pex8296YeF3EbsfETs22E83uhqVF5PBy"); tx.inputs[0].Sign(tx, txUnspent.outputs[0], pk); Console.WriteLine(HexString.FromByteArray(tx.ToBytes())); Script t = new Script(tx.inputs[0].scriptSig, txUnspent.outputs[0].scriptPubKey); Console.WriteLine(t.Evaluate(tx, 0)); /****/ /* int blockFileNum = 0; FileStream fs = new FileStream(@"C:\Users\Administrator\AppData\Roaming\Bitcoin\blocks\blk" + blockFileNum.ToString("D5") + ".dat", FileMode.Open); List<Block_Disk> blocks = new List<Block_Disk>(); List<Byte[]> blockHashes = new List<byte[]>(); List<Address> addrs = new List<Address>(); while (fs.Position < fs.Length) { Block_Disk b; b = Block_Disk.FromStream(fs); if (b.blockSize == 0) { blockFileNum++; try { fs = new FileStream(@"C:\Users\Administrator\AppData\Roaming\Bitcoin\blocks\blk" + blockFileNum.ToString("D5") + ".dat", FileMode.Open); } catch (FileNotFoundException) { break; } continue; } foreach (Transaction t in b.txns) foreach (TxOut txo in t.outputs) { addrs.Add(Address.FromScript(txo.script)); //Console.WriteLine(Address.FromScript(txo.script)); //Console.ReadLine(); } //blockHashes.Add(b.prev_block); //Console.WriteLine(HexString.FromByteArray(b.hash)); //blocks.Add(b); } Console.WriteLine(HexString.FromByteArray(blockHashes[blockHashes.Count() - 1])); /**/ Console.ReadLine(); }
/// <summary> /// Initializes the transaction with values /// </summary> /// <param name="transaction">JSON transaction deserialized</param> /// <param name="transactionType">IN or OUT transaction</param> /// <param name="rawData">The JSON raw data (serialized) for extracting missing values</param> /// <param name="value">Transaction value/amount</param> /// <param name="balance">The balance of the address after the transaction</param> /// <param name="itemOrder">The order/index of the transaction according to BlockChain</param> /// <returns>Initialized extended transaction</returns> private Transaction InitializeTrx(Tx transaction, TransactionType transactionType, string rawData, long value, long balance, int itemOrder) { Transaction trxEntry = new Transaction(); trxEntry.TimeEpoch = GetEpochTimeFromJSON(transaction.time, rawData, transaction.tx_index); // convert epoch time to regular date time System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0); trxEntry.Time = dtDateTime.AddSeconds(trxEntry.TimeEpoch).ToLocalTime(); trxEntry.TransactionType = transactionType; trxEntry.Value = value; trxEntry.Hash = transaction.hash; trxEntry.Index = transaction.tx_index; trxEntry.Balance = balance; trxEntry.ItemOrder = itemOrder; return trxEntry; }
public void RegisterUpdateToReverse(Guid txId, MessageBookmark bookmark, MessageStatus statusToRestore, string subQueue) { if (!Directory.Exists(_txsPath)) Directory.CreateDirectory(_txsPath); var path = Path.Combine(_txsPath, FileUtil.FromTransactionId(txId, null)); if (File.Exists(path)) File.Delete(path); var obj = new Tx { txId = txId, bookmark = bookmark.Bookmark, valueToRestore = (int)statusToRestore, queue = bookmark.QueueName, subQueue = subQueue, }; File.WriteAllText(path, JsonConvert.SerializeObject(obj)); }