How to get the Time format for all the regionals - winapi

In Control Panel-> Regional and language options-> Regional Options-> Standard and formats, there is the list of all the regionals and by clicking the "Customize" button, the user can set the time format
My question is how to get the current and default time format for all the regionals programmelly?

You can list them through C# like this.
foreach(var cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures))
{
Console.WriteLine("{0}: {1}",
cultureInfo.Name,
cultureInfo.IsNeutralCulture ? "-" : cultureInfo.DateTimeFormat.ShortDatePattern);
}

Related

Automate a reoccuring manual task (generate order number based on name) in Visual Studio

I'm currently working on a EpiServer project where we use the ContentType attribute to set the DisplayName and Order of the blocks. The Order is based on the name of the block. Here's an example:
[ContentType(
DisplayName = "My First Block",
Order = 133536,
GUID = "0f02e38a-a6e2-4333-9bd1-c61cf573d8d3",
Description = "Just an example block.",
GroupName = "Blocks.Content"
)]
public class MyFirstBlock : BaseBlock
{
}
Apparently EpiServer can't sort the blocks alphabetically so we generate the order based on the DisplayName as a work around. A formula was invented to determine the order. One colleague has written a JavaScript function that can be used to generate the order number:
function getEPiOrderNumber(value) {
var alphabeticalIndex = function (character) {
return character.toLowerCase().charCodeAt() - 96;
};
var firstSection = alphabeticalIndex(value[0]);
var secondSection = alphabeticalIndex(value[1]) + 10;
var thirdSection = alphabeticalIndex(value[2]) + 100;
return `${firstSection}${secondSection}${thirdSection}`;
}
This function can be executed in the console of a browser. Better than having to calculate the order by hand, but this requires that I switch to a browser, open the console, paste this code and execute it and finally copy the result and paste it in the model I'm working on.
I figured it would be much more convenient to be able to do generate the order number from within VS. I have been looking into using Visual Studio Extensions but can't really find anything that is to my liking.
The most optimal solution would be to be able to select the (part of the) DisplayName, right click and select a new command from the context menu that will generate the order and paste it at the correct location. Or place it on the clip board so I can easily paste it in the right location myself. A pop-up displaying the order would be fine as well.
Is this even possible?
Another option could be a new command in one of the toolbar menu's, say Tools, that would display a small window where I can enter/ paste the text and to have it generate the order that I can then paste in the code.
I have figured out how to add an Custom Command to the Tools menu and how I could generate the code and display it, but how can I enter the text? Or is it maybe possible to retrieve selected text from the editor window? That would solve my problem as well.
If anyone could point me in the right direction, that would be great!
PS. I'm not too happy with the title of this question so I'm open to suggestions if anyone can think of a title that better describes my question.
You could retrieve selected text from Visual Studio editor window with following code.
DTE dte = (DTE)this.ServiceProvider.GetService(typeof(DTE));
string text = "";
if (dte.ActiveDocument != null)
{
var selection = (TextSelection)dte.ActiveDocument.Selection;
text = selection.Text;
}

Change format of Telerik DateTimePicker's TimePicker control

Per the instructions here, I have changed the format of my DateTimePicker to use HH for the date format. And yet, the little clock icon to the right of the textbox still displays the choices in terms of AM and PM. Does anyone know if there is a way to force that to use the same time format?
My current code:
#( Html.Telerik().DateTimePicker()
.Name("DateTimePicker")
.Value(DateTime.Now)
.Format("MM/dd/yyyy HH:mm:ss")
.HtmlAttributes(new { #class = "ui-widget" })
)
From what I have been able to test, the AM/PM display relies more on kendo.culture than on the DateTimePicker format.
If I am using the format you provide : ("MM/dd/yyyy HH:mm:ss") with the default culture, I am getting the same display as you get.
But for example if I specify french culture using this simple line :
" kendo.culture('fr') "
and I specify this same format, I get rid of the AM/PM thing. I do not know what is your whole goal, but I hope this helps.

Input mask on an Ajax combobox

I'm using ASP.Net 4.0 to create a web project, and I have two Ajax ComboBoxes on one of my pages. The users have requested input masks on the two ComboBoxes. I can't use the Ajax MaskedEditExtender, since it won't work with a ComboBox. Has anyone ever implemented input masks on an Ajax ComboBox?
DevExpress editors allow you to use masks during editing. Masks are useful when a string entered by an end-user should match a specific format. For instance, you may require a text editor to only accept date/time values in a 24-hour format, only accept numeric values, or only accept numbers that are automatically inserted into the placeholders of a telephone number.
Masked input is supported by the following editor types:
Text box editors (ASPxTextBox and ASPxButtonEdit).
Text box mask settings can be accessed via the MaskSettings property. The editor’s mask can be specified via the MaskSettings.Mask property.
Date editors (ASPxDateEdit).
To enable masked input within a date editor, the UseMaskBehavior property should be set to true. The mask can be defined via the EditFormatString property if the EditFormat property is set to 'Custom'.
In this demo, see how masked input behavior is implemented by entering data into the various types of editors.
learn more here
using System;
using System.Web.UI;
public partial class Features_MaskedInput : Page {
protected void Page_Load(object sender, EventArgs e) {
txtZip.MaskSettings.PromptChar = cmbPromtChar.SelectedItem.Value.ToString()[0];
dateEdit.EditFormatString = cmbDateType.SelectedItem.Value.ToString();
dateEdit.Value = DateTime.Now;
}
}

Make a click event based on a control's name value property

I'm using TestComplete for the automation of QA process.
TestComplete detects click events based on the postion of the mouse on the screen. But when I run the same test on a different machine (a larger/smaller screen) the mouse button won't click on the correct position.
Therefore I want to know is there a method which I can search a control based on its name (i.e. name of a button) and then run a script to click on that particular word (or position).
Any help is appreciated :)
Additional Details
This is a sample script generated by TestComplete for clicking the search button on a web page.
Sub Test6()
'Opens the specified URL in a running instance of the specified browser.
Call Browsers.Item(btIExplorer).Navigate("http://www.simplyrecipes.com/search/?cx=003084314295129404805%3Ai2-mkfc4cai&cof=FORID%3A11&q=&sa.x=48&sa.y=16")
'Clicks at point (173, 10) of the 'textboxQ' object.
Call Aliases.browser.pageHttpWwwSimplyrecipesComSearc.panelPage.headerMasthead.group.panelSiteSearch.formSearchbox0030843142951294048.textboxQ.Click(173, 10)
'Sets the text 'asd' in the 'textboxQ' text editor.
Call Aliases.browser.pageHttpWwwSimplyrecipesComSearc.panelPage.headerMasthead.group.panelSiteSearch.formSearchbox0030843142951294048.textboxQ.SetText("asd")
'Clicks at point (57, 12) of the 'imagebuttonSa' object.
Call Aliases.browser.pageHttpWwwSimplyrecipesComSearc.panelPage.headerMasthead.group.panelSiteSearch.formSearchbox0030843142951294048.imagebuttonSa.Click(57, 12)
End Sub
Here is the button click event captured in the RecordTest window
What I want to know is, is there a way I can specify the control name (i.e 'Search' or 'imagebuttonSa'), so the TestComplete will search for the name in the given GUI and then once it's found, make a click event on the word.
I'm using Windows 7 64bit OS, TestComplete 9 trial version and VBScript as the scripting language.
As far as I can see, TestComplete already works in your case with specific controls/objects: textboxQ and imagebuttonSa. These two names are given to objects by the Name Mapping functionality and you are free to change them as you like.
As for the coordinates, these coordinates are related to the top left corner of the corresponding control (textboxQ or imagebuttonSa). If you want, you can remove the coordinates from the action parameters (e.g. ...imagebuttonSa.Click()) and TestComplete will click the central point of the control.
In case you have any problems with playing back your tests and you cannot find out what the cause of these problems is, the best option for you will be contacting the SmartBear support team with detailed explanation of what happens. Send them your project with failed results logs.
Whenever I have a problem with not finding an object with TC I use one of this functions or a combination of them.
In case you have the table object (parent of the cell you want to click):
function clickCellByText(text,tablePath)
{
var table = tablePath;
if (!table.Exists)
{
Log.Error("A table with the following text cannot be found: " + table);
}
clickCell1(table, "*Cell*", "*Cell*");
function clickCell1(table, idText, linkText)
{
var propArray = new Array("innerText", "ObjectType");
var valArray = new Array(text,"Cell*");
var idCell = table.FindChild(propArray, valArray, 20000);
if (idCell.Exists)
{
// Row found, find the link in the same row
idCell.Click();
}
else
{
Log.Error("A cell with the following text cannot be found: " + text);
}
}
}
If you want to find the object or the parent of the object by any property:
function clickComponent(property,text)
{
// Using the Find method
var myObj = Sys.Browser("iexplore").Page("*").NativeWebObject.Find(property,text);
// Checks if the button exists
if (myObj.Exists)
{
myObj.Click();
}
else
Log.Error("Can't find the object","");
}
If you don't specify co-ordinate, it will click at the center of the object.
You can try doing FindChild or Find with the Object Name Mapping where the button resides, with Properties like (Eg:ObjectType as Button and Button Caption with your required button caption), once the FindChild finds the button with above specified properties you can use that object to click on it:
var button = ParentObj.FindChild(["ObjectType","Caption"],["Button","OK"],10);
if(button.Exists)
button.Click()

Birt - How to format default date parameter as yyyy-MM-dd

I want my parameter default to be the first day of this year so I put in the formula:
BirtDateTime.firstDayOfYear(BirtDateTime.today())
And I'd like the default to be displayed in yyyy-MM-dd format so the users know what format to enter.
However when I run the preview it shows the default as "Jan 1, 2012".
Here is a screen shot of my parameter settings, and a screen shot of the report:
You can use Formatter which is a birt function
var now = new Date();
Formatter.format(now, "yyyy-MM-dd");
Another answer is here:
http://eclipse.org/birt/documentation/tutorial/tutorial-12.php
basically all you have to do is add a new data field. Make it a DateTime and add new Date( ) as the function. In the properties there is a tab called "Format DateTime". You can choose your format there.
I know there's been struggle with this issue across the web so I wanted to give as much info as possible.

Resources