I have an alert and I am reading the string text. However sometimes the alert has a bell icon at the start.
It displays as "?? This is the alert info" I have tried int replaceIcon = StringReplace(result[1],"?? ",""); which does not work. No error.
I have also tried result[1] = StringTrimLeft(result[1]);
It works for both string and array, not clear why it does not work for you. Maybe you expect something different. Please show the full MCVE code with a problem.
string msg="?? This is the alert info";
StringReplace(msg,"?? ","");
printf("%i %s: msg=%s.",__LINE__,__FILE__,msg);
//32 tmp2.mq4: msg=This is the alert info.
string array[2];
array[0]="?? This is the alert info";
array[1]="?? This is the alert info!!!";
for(int i=0;i<2;i++)
{
StringReplace(array[i],"?? ","");
printf("%i %s: msg=%s.",__LINE__,__FILE__,array[i]);
// 0: 41 tmp2.mq4: msg=This is the alert info.
// 1: 41 tmp2.mq4: msg=This is the alert info!!!.
}
Related
With the help of this question I was able to figure out how I can display a link inside a StyledText widget in SwT. The color is correct and even the cursor changes shape when hovering over the link.
So far so good, but the link is not actually clickable. Although the cursor changes its shape, nothing happens if clicking on the link. Therefore I am asking how I can make clicking the link to actually open it in the browser.
I thought of using a MouseListener, tracking the click-location back to the respective text the click has been performed on and then deciding whether to open the link or not. However that seems way too complicated given that there already is some routine going on for changing the cursor accordingly. I believe that there is some easy way to do this (and assuring that the clicking-behavior is actually consistent to when the cursor changes its shape).
Does anyone have any suggestions?
Here's an MWE demonstrating what I have done so far:
public static void main(String[] args) throws MalformedURLException {
final URL testURL = new URL("https://stackoverflow.com/questions/1494337/can-html-style-links-be-added-to-swt-styledtext");
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, true));
StyledText sTextWidget = new StyledText(shell, SWT.READ_ONLY);
final String firstPart = "Some text before ";
String msg = firstPart + testURL.toString() + " some text after";
sTextWidget.setText(msg);
sTextWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
StyleRange linkStyleRange = new StyleRange(firstPart.length(), testURL.toString().length(), null, null);
linkStyleRange.underline = true;
linkStyleRange.underlineStyle = SWT.UNDERLINE_LINK;
linkStyleRange.data = testURL.toString();
sTextWidget.setStyleRange(linkStyleRange);
shell.open();
while(!shell.isDisposed()) {
display.readAndDispatch();
}
}
Okay I was being a little too fast on posting this question... There's a snippet that deals with exactly this problem and it shows, that one indeed has to use an extra MouseListener in order to get things working.
The snippet can be found here and this is the relevant part setting up the listener:
styledText.addListener(SWT.MouseDown, event -> {
// It is up to the application to determine when and how a link should be activated.
// In this snippet links are activated on mouse down when the control key is held down
if ((event.stateMask & SWT.MOD1) != 0) {
int offset = styledText.getOffsetAtLocation(new Point (event.x, event.y));
if (offset != -1) {
StyleRange style1 = null;
try {
style1 = styledText.getStyleRangeAtOffset(offset);
} catch (IllegalArgumentException e) {
// no character under event.x, event.y
}
if (style1 != null && style1.underline && style1.underlineStyle == SWT.UNDERLINE_LINK) {
System.out.println("Click on a Link");
}
}
}
});
I have generated my barcode image through code 39 when i going to scan image on my desktop then its not getting scanned.And Also not working when i print that Barcode image and scan after.
public Byte[] getBarcodeImage(string barcode, string file)
{
try
{
BarCode39 _barcode = new BarCode39(); int barSize =25;
string fontFile = HttpContext.Current.Server.MapPath("~/fonts/FREE3OF9.TTF");
return (_barcode.Code39(barcode, barSize, true, file, fontFile));
}
catch (Exception ex) { }
return null;
}
According to this article and the comments within you first need to increase the bar size. I set mine at 64. Then you need to add * character to beginning and end of barcode image like this: return (_barcode.Code39($"*{barcode}*", barSize, true, file, fontFile)); This should work and when you scan you get your barcode without the * characters.
So I'm new to Dart and WebStorm and I'm having trouble with the print statements. I have several print statements in my code, but when I run it, none of them appear.
Here's my code:
import 'dart:io';
void main() {
int choice = 0;
String line;
String firstName, lastName, contact;
do {
print("Please choose a number: /n");
print("1 - Add a contact /n");
print("2 - Edit a contact /n");
print("3 - Look for a contact /n");
print("0 - Exit application /n");
line = stdin.readLineSync();
choice = int.parse(line);
switch (choice) {
case 1:
{
print("Enter contact's first name: ");
firstName = stdin.readLineSync();
print("Enter contact's last name: ");
lastName = stdin.readLineSync();
print("Enter a contact number: ");
contact = stdin.readByteSync();
print("Is this an office or home contact?");
print("Is this an office or home contact?");
}
case 0:
{
return 0;
}
}
} while (choice > 3 || choice < 0);
}
The console shows this when I try to run it:
C:\dart-sdk\bin\dart.exe --ignore-unrecognized-flags --checked --enable-vm-service:51901 --trace_service_pause_events "C:\Users\myname\WebstormProjects\untitled\Test.dart"
Process finished with exit code 254
How are attempting to run the dart file? I just created a new Project and pasted your code in and right clicked on file and pressed run "filename".
Then, I recieved this
Please choose a number: /n
1 - Add a contact /n
2 - Edit a contact /n
3 - Look for a contact /n
0 - Exit application /n
I am using coding4fun message prompt in my app to display message box with customized buttons to the user. It works fine when the app is in the foreground and there is a message to be displayed. But, When I exit the app and re-launch it there are a set of things happening when after app's splash screen is displayed and before the main screen of the app is shown. During this process the app checks if any upgrade is available, if there are upgrades then on the splash screen the message box must be displayed to the user. When i was previously using xna framework message box this worked well, but due to marketplace submission process I replaced xna framework message box with coding4fun message prompt and the message prompt doesn't show when splash screen is displayed. Is this how Coding4Fun message prompt works or am i doing something wrong?
here is how i have implemented the message prompt in my code..
public MainPage()
{
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
{
DataManager.getInstance().setUIListener(this);
if (checkUpgradeStatus())
{
return;
}
});
}
private bool checkUpgradeStatus()
{
try
{
string flag = "1";
if (!Utils.isNullString(flag))
{
DataManager.getInstance().CheckForUpgrade();
if (flag.Equals(CacheManager.MAJOR_UPGRADE))
{
customizedMessageBox(Utils.APP_UPGRADE_CONFIRM, CustomizedMessageBox.APP_UPGRADE_CONFIRM_TITLE, AppResources.APP_UPGRADE_CONFIRM);
DataManager.getInstance().UpdateBadge(true);
return true;
}
else if (flag.Equals(CacheManager.MINOR_UPGRADE))
{
CacheManager.getInstance().writeDataToConfigFile(CacheManager.APP_UPGRADE_STATUS, "0");
customizedMessageBox(Utils.APP_MINOR_UPGRADE_CONFIRM, CustomizedMessageBox.APP_MINOR_UPGRADE_CONFIRM_TITLE, AppResources.APP_UPGRADE_MINOR_CONFIRM);
DataManager.getInstance().UpdateBadge(true);
return false;
}
}
CacheManager.getInstance().writeDataToConfigFile(CacheManager.APP_UPGRADE_STATUS, "0");
return false;
}
catch (Exception ex)
{
Logger.log(TAG, ":checkUpgradeStatus():" + ex.Message);
return false;
}
}
public void customizedMessageBox(int messageboxtype, string title, string text)
{
try
{
switch (messageboxtype)
{
Case 6:
messageBox = new MessagePrompt();
Button btnMinorUpgrade = new Button();
btnMinorUpgrade.Content = "Upgrade";
messageBox.ActionPopUpButtons.Add(btnMinorUpgrade);
btnMinorUpgrade.Click += new RoutedEventHandler(btnMinorUpgrade_Click);
Button btnMinorUpgradeCancel = new Button();
btnMinorUpgradeCancel.Content = "Cancel";
messageBox.ActionPopUpButtons.Add(btnMinorUpgradeCancel);
btnMinorUpgradeCancel.Click += new RoutedEventHandler(btnMinorUpgradeCancel_Click);
messageBox.Show();
break;
}
}
catch (Exception ex)
{
Logger.log(TAG, ":customizedMessageBox():" + ex.Message);
}
}
NOTE*:- For testing purpose I have hard-coded flag's value to "1".
All the answers and suggestions appreciated.
Thank you
I have a text box where the user can enter details up to 140 characters after that a dialog box pop up which showing maximum limit reached .My problem is that after the message box is shown the cursor is blinking at the beginning of the text.and also further typing is possible.I have to do two things one is the cursor should blinking at the end of text after message box shown.and next is when the user hit characters more than 140 it should not be entered in the text box.?Please give me a solution for this
Here is my code.
private void tbMessage_TextChanged(object sender, TextChangedEventArgs e)
{
string txt = tbMessage.Text;
Regex regx = new Regex("\\(?\\b(http|https)://([-A-Za-z0-9+&##/%?=~_()|!:,.;\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]*[-A-Za-z0-9+&##/%=~_()|])");
regx.Matches(txt);
MatchCollection mactches = regx.Matches(txt);
foreach (Match match in mactches)
{
txt = txt.Replace(match.Value, "<--------------------->");
}
textBlockNumberLimit.Text = txt.Length.ToString() + "/140";
if (txt.Length > 140)
{
try
{
MessageBox.Show("Maximum limit reached", "SPRINKLR", MessageBoxButton.OK);
tbMessage.Text = tbMessage.Text.Substring(0, tbMessage.Text.Length - 1);
}
catch
{
}
}
}