protected void OnButtonInsertFromBufferClicked(object sender, EventArgs e) { bool error = true; string booferCoordinates = clipboard.WaitForText(); string[] coordinates = booferCoordinates?.Split(','); if (coordinates?.Length == 2) { bool goodLat = decimal.TryParse(coordinates[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out decimal lat); bool goodLon = decimal.TryParse(coordinates[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out decimal lng); SetCoordinates(lat, lng); if (goodLat && goodLon) { deliverypriceview.DeliveryPrice = DeliveryPriceCalculator.Calculate(latitude, longitude, yspinBottles.ValueAsInt); error = false; } } if (error) { MessageDialogHelper.RunErrorDialog( "Буфер обмена не содержит координат или содержит неправильные координаты"); } }
public void PerformPaste(Gtk.Clipboard clipboard) { string txt = string.Empty; txt = clipboard.WaitForText(); if (String.IsNullOrEmpty(txt)) { return; } string[] ins_lines = txt.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.None); string endline = lines [linePos].Substring(textPos); lines [linePos] = lines [linePos].Substring(0, textPos); bool first = true; foreach (string ins_txt in ins_lines) { if (!first) { linePos++; lines.Insert(linePos, ins_txt); textPos = ins_txt.Length; } else { first = false; lines[linePos] += ins_txt; textPos += ins_txt.Length; } } lines [linePos] += endline; Recalculate(); }
/// <summary> /// Pastes text from the clipboard. /// </summary> /// <returns> /// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise. /// </returns> public bool PerformPaste (Gtk.Clipboard clipboard) { string txt = string.Empty; txt = clipboard.WaitForText (); if (String.IsNullOrEmpty (txt)) return false; if (HasSelection ()) DeleteSelection (); string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.RemoveEmptyEntries); string endline = lines [currentPos.Line].Substring (currentPos.Offset); lines [currentPos.Line] = lines [currentPos.Line].Substring (0, currentPos.Offset); bool first = true; foreach (string ins_txt in ins_lines) { if (!first) { currentPos.Line++; lines.Insert (currentPos.Line, ins_txt); currentPos.Offset = ins_txt.Length; } else { first = false; lines[currentPos.Line] += ins_txt; currentPos.Offset += ins_txt.Length; } } lines [currentPos.Line] += endline; selectionStart = currentPos; State = TextMode.Uncommitted; OnModified (); return true; }
protected void OnButtonInsertFromBufferClicked(object sender, EventArgs e) { bool error = true; string booferCoordinates = clipboard.WaitForText(); string[] coordinates = booferCoordinates?.Split(','); if (coordinates?.Length == 2) { coordinates[0] = coordinates[0].Replace('.', ','); coordinates[1] = coordinates[1].Replace('.', ','); decimal latitude, longitude; bool goodLat = decimal.TryParse(coordinates[0].Trim(), out latitude); bool goodLon = decimal.TryParse(coordinates[1].Trim(), out longitude); if (goodLat && goodLon) { Entity.Latitude = latitude; Entity.Longitude = longitude; error = false; } } if (error) { MessageDialogWorks.RunErrorDialog( "Буфер обмена не содержит координат или содержит неправильные координаты"); } }
void OnPasteEvent(EventKey evnt) { Gtk.Clipboard clip = Gtk.Clipboard.Get(Selection.Clipboard); if (!clip.WaitIsTextAvailable()) { return; } string str = clip.WaitForText(); SearchController.SetString(SearchController.Query + str); }
public object GetData(TransferDataType type) { if (type == TransferDataType.Text) { return(clipboard.WaitForText()); } if (type == TransferDataType.Text) { return(clipboard.WaitForImage()); } TransferDataStore store = new TransferDataStore(); foreach (var at in GetAtomsForType(type)) { var data = clipboard.WaitForContents(at); Util.GetSelectionData(data, store); } return(((ITransferData)store).GetValue(type)); }
public override object GetData(TransferDataType type) { if (type == TransferDataType.Text) { return(clipboard.WaitForText()); } if (type == TransferDataType.Image) { return(ApplicationContext.Toolkit.WrapImage(new GtkImage(clipboard.WaitForImage()))); } TransferDataStore store = new TransferDataStore(); foreach (var at in GetAtomsForType(type)) { var data = clipboard.WaitForContents(at); Util.GetSelectionData(ApplicationContext, data, store); } return(((ITransferData)store).GetValue(type)); }
bool PastePrimaryClipboard() { Gtk.Clipboard clip = GetClipboard(Gdk.Selection.Primary); string text = clip.WaitForText(); if (text == null || text.Trim() == string.Empty) { return(false); } Note link_note = manager.FindByUri(NoteManager.StartNoteUri); if (link_note == null) { return(false); } link_note.Window.Present(); PrependTimestampedText(link_note, DateTime.Now, text); return(true); }
protected void OnButtonPasteClicked(object sender, EventArgs e) { entryAccessCode.Text = _clipBoard.WaitForText(); }