converter

File path to file name String converter not working

孤人 提交于 2019-12-02 10:41:43
Using a wpf ListBox I'm trying to display a list of filename without displaying the full path (more convenient for user). Data comes from an ObservableCollection which is filled using Dialog. private ObservableCollection<string> _VidFileDisplay = new ObservableCollection<string>(new[] {""}); public ObservableCollection<string> VidFileDisplay { get { return _VidFileDisplay; } set { _VidFileDisplay = value; } } In the end I want to select some items and get back the full file path. For this I have a converter : public class PathToFilenameConverter : IValueConverter { public object Convert(object

JSF Convert dates for title attribute

99封情书 提交于 2019-12-02 10:34:39
I need to put a date into the title attribute of an image so that it displays when the user puts the mouse over. Problem is I would like to change the date format. Any ideas? <ice:graphicImage value="bean.image" title="#{bean.date}"/> Either do it directly in a getter method public String getDate() { return new SimpleDateFormat("yyyy-MM-dd").format(this.date); } or grab JSTL's <fmt:formatDate> . <fmt:formatDate value="#{bean.date}" pattern="yyyy-MM-dd" var="date" /> <ice:graphicImage value="bean.image" title="#{date}"/> (which would not work inside repeating components like UIData ) 来源: https:

Negative values returned from file in NXC

家住魔仙堡 提交于 2019-12-02 10:15:18
I am saving values to a .csv file in NXC(Not eXactly C) and then calling on them ata later point in time. The problem I am having is when calling any negative values back from a cell it is displayed as 0123 instead of -123 which is throwing all my additional calculations off. The current code is: OpenFileRead("map.csv", fSize, count); until (eof == true) { ReadLnString(count, val); int lstFwd = StrToNum(val); NumOut(0,LCD_LINE1,lstFwd); } while(true); Can anyone explain how to rectify this issue as it is causing me a great deal of stress now. StrToNum should convert negativ numbers. Its a bit

How do I reverse each word in a string, but in the same sentence order? [duplicate]

我是研究僧i 提交于 2019-12-02 10:15:01
This question already has an answer here: Reverse each word in a string 7 answers I tried doing this while 1: line = input('Line: ') print(line[::-1]) but all that did was reverse the whole sentence, I was wondering if someone could help me with a program that converts 'hello world' to 'olleh dlrow' instead of 'dlrow olleh', and how do I make a loop that stops when the input is nothing, or just a space? Thank you in advanced! You need to split the sentence, reverse the words, then reassemble. The simplest way to split is to do so on whitespace, with str.split() ; reassembly is then just a case

JSF converter for selectOneMenu

十年热恋 提交于 2019-12-02 09:26:15
I want to set a many-to-one relationship in a hibernate entity using selectOneMenu . <h:selectOneMenu value="#{taskBean.instance.currency}" class="form-control" id="currencyList" converter="#{currencyConverterBean}"> <f:selectItems value="#{currencyBean.currencyList}" var="currency" itemLabel="#{currency.name}"/> </h:selectOneMenu> where #{taskBean.instance} returns a hibernate entity Task: @Entity @Table(name="task") public class Task { //... public Currency currency; @ManyToOne @JoinColumn(name = "currencyID") public Currency getCurrency() { return currency; } //... } If one sets value #

C++ LPCTSTR to char*

本小妞迷上赌 提交于 2019-12-02 09:18:55
I am using visual studio 2010 MFC to build a C++ program. My program calls a DLL that is not apart of the project and it accepts a char*. I have a function that gets a string in a format of LPCTSTR. I have been on google for about two hours now, and no solution found. How do I convert form a MFC LPCTSTR to a char*. Everything I have found either does not work, or just does not compile. Roman R. In MFC the easiest is to convert through CStringA (provided that resulting buffer will be a read-only argument): LPCTSTR pszA = ... CStringA sB(pszA); const char* pszC = sB; char* pszD = const_cast<char

C# converting string to int goes wrong

风格不统一 提交于 2019-12-02 08:30:55
I have a string that contains numbers, like so: string keyCode = "1200009990000000000990"; Now I want to get the number on position 2 as integer , which I did like so: int number = Convert.ToInt32(keyCode[1]); But instead of getting 2 , I get 50 . What am I doing wrong? 50 is the ascii code for char '2'. 0->48, 1->49 etc.... You can do int number = keyCode[1]-'0'; You observed that when you do int n = Convert.ToInt32( '2' ); you get 50 . That's correct. Apparently, you did not expect to get 50 , you expected to get 2 . That's what's not correct to expect. It is not correct to expect that

Convert PPT into JPG/PNG on windows

血红的双手。 提交于 2019-12-02 07:43:12
I would like to convert a ppt presentation in a collection of images, one per each slide, programmatically in a windows environment. I tried to modify the following code that transform a ppt to a pdf(perfectly working) but I dind't succed. Can anyone help me? Thanks a lot. Option Explicit Sub WriteLine ( strLine ) WScript.Stdout.WriteLine strLine End Sub ' http://msdn.microsoft.com/en-us/library/office/aa432714(v=office.12).aspx Const msoFalse = 0 ' False. Const msoTrue = -1 ' True. ' http://msdn.microsoft.com/en-us/library/office/bb265636(v=office.12).aspx Const ppFixedFormatIntentScreen = 1

DateTime string format in c#

那年仲夏 提交于 2019-12-02 07:22:11
问题 I have a project that contain 3 string variables. DateFormatStr is the format string I need to use to output dates. DateFormatFrom is the start date a request will apply from FilloutDateTo is the end date the request will apply to. The problem is that I don't want to manually specify the dates. As you can see in my example below (a working example), I need to specify the dates, but is there a way to make it that the from date has time 00:00:00 and the end date has time 23:59:59? string

Convert Image to Base64String

半世苍凉 提交于 2019-12-02 06:28:47
I need some help in convert image to base64string. I had used solution from similar question in stackoverflow but an error occured. Solution used: convert image into base64 in wp8 The problem lies on the Image's Source I used to set as a writeablebitmap but the outcome was a null exception. This is my image source : image123.Source = new BitmapImage(new Uri("/correct1.jpg", UriKind.Relative)); Error occured in this line : WriteableBitmap wbitmp = new WriteableBitmap((BitmapImage)image123.Source); The Error: An exception of type 'System.NullReferenceException' occurred in System.Windows.ni.dll