I am trying to figure out how to calculate dewpoint from temperature and humidity. The formula is ridiculously long, but there is a simple formula that gives an approximation, which is good enough for my purposes.
Td = T - ((100 - RH)/5).
Td = Dewpoint in degrees Celcius
T = Temperature in degrees Celcius
RH = Humidity
Since my phone is in degrees F. I had to convert to degrees C. This is what I did, but it doesn't work, I think because of the % symbol attached to the humidity variable: $int((#WCTEMP#-32)*5/9))-(100-#WCHUM#)/5)$. The problem is, it just displays exactly what I typed, it doesn't do the math. Can anyone point a noob in the right direction? It is probably obvious, but I am still trying to figure out zooper.
I have seen other requests for a dewpoint variable on the forums, so there is a demand out there. Any help would be appreciated, thanks!
Do you own Tasker?
You could do an https get on yahoo weather api and get all the info from there.
Its not to terribly difficult. Probably on the intermediate level.
Sent from my Nexus 5 using Tapatalk
I was just considering purchasing that tonight. I will give that a shot! Thanks Mr Biggzz
MrBiggzz said:
Do you own Tasker?
You could do an https get on yahoo weather api and get all the info from there.
Its not to terribly difficult. Probably on the intermediate level.
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Its a great app!
Sent from my Nexus 5 using Tapatalk
@robgross how are you making out?
MrBiggzz said:
@robgross how are you making out?
Click to expand...
Click to collapse
I downloaded Tasker but haven't had time to learn it yet...but I will! I do know that ZW sees #WCHUM# as text, so it will not formulate it. I tried using #WCHUMN# to see if it would dispay the value as a number, as #WCTEMPN# does...but that didnt work. Thanks for following up!
Christmas in May!
Dave Handler shares a file with you, please click the link to download: http://dl.dropboxusercontent.com/1/view/qqiv1skjchq7ifu/Tasker Projects/Yahoo_Weather.prj.xml
In it are two tasks Input Zip code which uses a scene to well, get the zip!
The other task is Get Yahoo Weather. That uses a variable that gets set when you set the zip code.
Set your zip and the run the weather task and then check the variables tabs. You'll see every thing that is supplied including the five day forecast.
You'll have to figure what you want and pass it on to Zooper. Every variable for weather is global!
Enjoy!
p.s. everything is in standard units. Fahrenheit, mph and inches. This only thing I didn't do is give you an indicator if the barometric pressure is falling, stable or rising. If you need it I can put it in there!
Sent from my Nexus 5 using Tapatalk
Mr. Biggs, thanks for this, but I can't seem to open this link, it says it's not valid both in Tasker and a browser.
MrBiggzz said:
@robgross how are you making out?
Click to expand...
Click to collapse
MrBiggzz, I figured out how to use Tasker! It's a lot easier to use than I thought, and the possibilities are endless. Thanks for the tip!
I know its an old thread and i was seaching in this thread too; and now i solved by myself. I post here the solution for tasker if someone needs it:
You need to set up or read out from web 2 variables (%temp = temperature and %hum = humidity), once you have set the 2 variables you need to add a code java scriplet to the task to calculate dewpoint and absolute humidity:
function taupunkt() {
if ( (temp == null || temp == 0) ||
(hum == null || hum == 0) ) {
return;
}
var a1=7.45;
var b1=235;
tp=temp;
fw=hum;
tp=tp*1;
fw=fw*1;
x1=(a1*tp)/(b1+tp);
e1=6.1*Math.exp(x1*2.3025851);
e2=e1*fw/100;
x2=e2/6.1;
x3=0.434292289*Math.log(x2);
taux=(235*x3)/(7.45-x3)*100;
taux=Math.floor(taux)/100;
feux=(216.7*e2)/(273.15+tp)*100;
feux=Math.round(feux)/100;
var TAUX = taux;
setGlobal("TAUX", TAUX );
var FEUX = feux;
setGlobal("FEUX", FEUX );
exit ();
}
taupunkt()
The java scriplet calculate the dewpoint and the absolute humdity and stores it in the variable %TAUX (dewpoint) and %FEUX (absolute humidity). Now you can make a popup alert or whatever you want and display the dewpoint calling %TAUX and the absolute humidity %FEUX
Related
Hi gents.
I want to ask you,how can I use external font loaded from ttf file in my app,developed under Embedded Visual C++?
I need to easily change color and size of the font and using the DrawText() function make an output into current DC.
Can someone make an example for me please?
Thank you.
Here's the bare bones of it ,you'll have to flesh it out to suit. It might not be perfect but it works.
Global Variable
Code:
HFONT g_hfont;
Forward declaration of EnumFontProc()
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData);
In WM_PAINT print it out. I'll use Wingdings. The name in the EnumFonts must match the actual name of the font as declared in the TTF file.
Code:
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
EnumFonts(hdc,TEXT("Wingdings"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
DrawText(hdc,TEXT("12345"),5, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
DeleteObject(g_hfont);
EndPaint(hWnd, &ps);
break;
In EnumFontsProc set the font to the first font given. Returning 0, ends the enumeration, non zero, give me the next.
To change the size do it here by changing lplf->lfHeight and lplf->lfWidth
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
To load and release your font add the code below to the message handling sections.
Code:
WM_CREATE:
AddFontResource(TEXT("\\Storage Card\\myfont.TTF"));
WM_DESTROY:
RemoveFontResource(TEXT("\\Storage Card\\myfont.TTF"));
Here's the proof it works, (with Wingdings anyway!)
Thanks man,I will try it ASAP.
Well,is it possible to read the ttf file directly from exe resource also?
I am still learning C++,so some things are a bit unclear for me. Can you please post this source?
This stuff is explained fully at:
http://msdn.microsoft.com/en-us/library/aa911455.aspx
I've just taken a few shortcuts with it.
The zip file contains the main .cpp file of the above project. It does not include the AddFontResource or RemoveFontResource statements.
Create a shell WinMo application and replace the main program .cpp file with it.
AddFontResource can only accept the path to a True Type font TTF file as an argument.
The thing you have got to get your head around are CALLBACK routines, they are used during most enumeration routines, and are widely used in Win32 for all sorts of things. A Win32 app's WndProc it itself a callback routine. In the case of EnumFonts, you pass the address of the callback routine to the enumerating function, which will call your function once for every instance it finds that matches your request. You terminate the sequence by returning 0 or it will carry on until there are no instances left. You have to decide what to do with the results. In my case I take the first Wingding font I'm offered, then quit.
Be aware that there is little, or no error handling in this code. I cobbled it together pretty quickly to prove the point.
I remember reading somewhere that if you drop the .TTF file in the Windows directory, and do a soft reset, then Windows will pick it up as a resident font, so the AddFontResource and RemoveFontResource functions are not required. EnumFonts() should know about it, and present it accordingly.
Well,thank you very much for that,but can you please provide me full project source,including all the files? With working project,I can better understand the font loading principle.
Unfortunately,I am too busy nowadays to discover something,that I don't understand well,so every time save is a big plus for me. Thank you very much again.
Attached,
But, it is a VS 2008 Smart Device project. EVC won't read it.
You will have to create a shell hello world project in EVC and copy the modified code in the panels above from TestFont.CPP.
Hello.
Actually i've got it working,but I still cannot discover,how to resize the font.
Where should I exactly put the lfWidth and lfHeight?
I am now a bit confused of that.
This is my code:
Functions and declarations of HFONT,CALLBACK,WM_CREATE,WM_DESTROY are present as you described.
void ShowNumber(HDC hdc, int Value,int xrect,int yrect,int wrect,int hrect,HBITMAP source)
{
EnumFonts(hdc,TEXT("Sam's Town"),(FONTENUMPROC) EnumFontsProc,NULL);
SelectObject(hdc,g_hfont);
TCHAR szText[MAX_LOADSTRING];
int width,height;
rtText.right=wrect;rtText.bottom=hrect;width=wrect-xrect;height=hrect-yrect;
TransparentImage(hdc,xrect,yrect,width,height,source,xrect,yrect,width,height,RGB(255,0,255));
SetBkMode(hdc,TRANSPARENT);
if(Value<10) wsprintf (szText, TEXT ("0%d"),Value);else wsprintf (szText, TEXT ("%d"),Value);
rtText.left=xrect ;rtText.top=yrect ;SetTextColor(hdc,RGB(0,0,0)); DrawText(hdc,szText,2,&rtText,DT_SINGLELINE | DT_LEFT | DT_TOP);
DeleteObject(g_hfont);
}
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Click to expand...
Click to collapse
This doesn't work:
lplf.lfWidth=0;
g_hfont = CreateFontIndirect(lplf);
Click to expand...
Click to collapse
Actually I want to put one more parameter into ShowNumber() function,which will tell the function the size of the font.
You are nearly there...........
The code to set the font size will have to go in here.......
Code:
int CALLBACK EnumFontsProc(LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData)
{
lplf->lfHeight=14;
lplf->lfWidth=8;
g_hfont = CreateFontIndirect(lplf);
return 0;
}
Or whatever your values are, I just picked 8 and 14 as examples. If these values are passed as variables to another function above, store them as global variables, and use them here.
As lplf is passed to this function as a pointer to a LOGFONT structure, you have to use the -> operator to access its members. lplf.lfHeight won't work as you mentioned, that is for predeclared or static structures.
These values have to be changed here in the EnumFontsProc() routine before the font is created, as we are passing that pointer to create the font.
Good Luck!!
P.S. While we are here, let's tidy it up a bit.
Replace:
Code:
if(Value<10) wsprintf(szText,TEXT ("0%d"),Value);else wsprintf (szText,TEXT("%d"),Value);
with
Code:
wsprintf(szText, TEXT ("02%d"),Value);
A very big thanks for that.
I am still beginner in C++,so something can look very comic for others.
My beloved programming language is Pascal.
I really didn't think,that -> is an operator,I've just mentioned,you wrote it as something else(something like "to")
You are more than welcome.
Some features in C/C++ are not immediately obvious, but the real battle is fighting your way through the Win32 programming model, trying to get it to do what you want. Sometimes the simplest of things become maddeningly complicated, but the effort to do it properly is usually worth the effort.
Glad you got it working, best wishes, stephj.
Hello a bit later.
First of all,thank your for your explanation and now I am using this method successfuly.
I want to ask you now,if there is a way to get fixed pitch of the font,that is truetype. With standart font I can achieve with this...
lf.lfPitchAndFamily = (tm.tmPitchAndFamily & 0xf0) | TMPF_FIXED_PITCH;
I am using font,that displays numbers in "digital" mode(7-segment display) and I get the number "1" very narrow in comparison with others(actually it is narrow on any kind display,but is displayed on right segments,so "01" has adequate spacing on hard display). Now I get "0l_" instead of "0_l",that's not preferable.
Thanks in advance for reactions.
I don't think there the above method will work as each character has it own width associated with it.
A simpler approach, a bit of a pain, but which should work, is to draw/print the numeric value out one character at a time using DrawText(). Set a RECT structure up to hold the coordinates of the top left and bottom right of the area for each character.
Setting uFormat to DT_RIGHT will force the character to right align in the RECT area, so the '1' should appear correctly. Move the left and right values along a fixed amount for each character. A bit of trial and error will be involved first until you get the values just right.
Good luck, stephj.
Hi there,
Does anyone out there how to preserve/restore the transient state of a CheckBox and/or Radio button?
So far, I'm using the following code, working for textbox
Code:
Public Sub PreserveState_TextBox(ByVal TB As TextBox)
Dim buffer As String = String.Empty
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
buffer = TryCast(PhoneApplicationService.Current.State(TB.Name), String)
If Not String.IsNullOrEmpty(buffer) Then
TB.Text = buffer
End If
End If
End Sub
Public Sub RestoreState_TextBox(ByVal TB As TextBox)
If True = PhoneApplicationService.Current.State.ContainsKey(TB.Name) Then
PhoneApplicationService.Current.State.Remove(TB.Name)
End If
PhoneApplicationService.Current.State.Add(TB.Name, TB.Text)
End Sub
it possible to modify the above code to work for Checkbox and/or Radiobutton?
If not, any ideas?
So far, I've been trying the sample "Tombstoning" sample code from Microsoft without any luck...
Thanks in advance!
Hi,
I'm not a VB developer, but storing the state of a checkbox is not much different from storing any other primitive type. What you could do is have a bool variable "isCbChecked" and store that bool state in your PhoneApplicationService.State.
Code:
PhoneApplicationService.Current.State.Add("isCbChecked", myCheckbox.IsChecked)
Then, when you're restoring your app, simply do
Code:
myCheckbox.IsChecked = (bool)PhoneApplicationService.Current.State.ContainsKey("isCbChecked");
keyboardP said:
Hi,
I'm not a VB developer, but storing the state of a checkbox is not much different from storing any other primitive type. What you could do is have a bool variable "isCbChecked" and store that bool state in your PhoneApplicationService.State.
Code:
PhoneApplicationService.Current.State.Add("isCbChecked", myCheckbox.IsChecked)
Then, when you're restoring your app, simply do
Code:
myCheckbox.IsChecked = (bool)PhoneApplicationService.Current.State.ContainsKey("isCbChecked");
Click to expand...
Click to collapse
Thanks a lot for your fast reply.
Can I ask for additional help on how to make your statements into generic procedures, at least to take them to something similar to what I posted?
Don't care if it's in C#
Thanks in advance!
GFR_2009 said:
Thanks a lot for your fast reply.
Can I ask for additional help on how to make your statements into generic procedures, at least to take them to something similar to what I posted?
Don't care if it's in C#
Thanks in advance!
Click to expand...
Click to collapse
Off the top of my head, something like this should work (C# code).
Code:
public static T RestoreState<T>(string key)
{
if (PhoneApplicationService.Current.State.ContainsKey(key))
{
return (T)PhoneApplicationService.Current.State[key];
}
return null;
}
'T' is the type that will be used. In C# 'T' is a special character denoting the generic type, not something I just used
So in the code above, the return type is 'T' and when using RestoreState, it will be 'RestoreState<Textbox>("TB.Name");'. The value of 'TB.Name' will be searched within the dictionary and, if it's found, it will cast that object as 'T' (Textbox) and return it, otherwise it will return null.
Hi,
So far, I did the following and while no error is raised, nothing happens...
Code:
Public Function Backup(ByVal token As String, ByVal value As Object) As Boolean
If Nothing Is value Then
Return False
End If
Dim store = PhoneApplicationService.Current.State
If store.ContainsKey(token) Then
store(token) = value
Else
store.Add(token, value)
End If
Return True
End Function
Public Function Restore(Of T)(ByVal token As String) As T
Dim store = PhoneApplicationService.Current.State
If Not store.ContainsKey(token) Then
Return Nothing
End If
Return CType(store(token), T)
End Function
I call them as follows
Code:
Backup(Me.CheckBox_1.Name, Me.CheckBox_1)
Restore(Of CheckBox)(Me.CheckBox_1.Name)
Don't where is the error, maybe you could take a look and help me out.
Any help is much appreciated!
Where are you calling the Backup and Restore functions? Since your doing page specific things, you could do it in the OnNavigatedFrom and OnNavigatedTo methods, respectively.
keyboardP said:
Where are you calling the Backup and Restore functions? Since your doing page specific things, you could do it in the OnNavigatedFrom and OnNavigatedTo methods, respectively.
Click to expand...
Click to collapse
Hi,
I'm calling them in the OnNavigatedTo and OnNavigatedFrom methods, as you pointed out
Unfortunately, nothing happens at all!
Thanks!
Hi,
As far as I can tell, there's nothing wrong with your saving/loading code. When you call
"Restore(Of CheckBox)(Me.CheckBox_1.Name)", is that returning a bool? You need to assign that bool to the checkbox:
Code:
myCheckbox.IsChecked = Restore(Of CheckBox)(Me.CheckBox_1.Name);
Also, all variables are reset when the page loads, so make sure you have set "myCheckbox.IsChecked" anywhere else on the page that could be called when the page loads.
Please, check the converted code of the above functions, to C#
Code:
public bool Backup(string token, object value)
{
if (null == value)
{
return false;
}
var store = PhoneApplicationService.Current.State;
if (store.ContainsKey(token))
{
store(token) = value;
}
else
{
store.Add(token, value);
}
return true;
}
public T Restore<T>(string token)
{
var store = PhoneApplicationService.Current.State;
if (! (store.ContainsKey(token)))
{
return default(T);
}
return (T)(store(token));
}
Do you think they are OK?
How should I call them ?
Clearly, the restore does not returns a boolean...
Honestly, I'm lost now!
Hope this helps to find the culprit.
It seems okay to me. You'll have to do some debugging. Set a breakpoint inside the Backup and Restore methods. Step through each line and make sure it's going to the line you expect it to and that the value being set is the correct one.
I haven't seen the tombstoning sample from MSDN, but can you get that to work? If so, is the generic method causing the problem? Or can you not get it to work at all?
Hi,
Sorry for the delay in getting back, but I was trying different codes and at least I found the cause.
Code:
Me.NavigationService.Navigate(New Uri("/PivotPage1.xaml?Name=" & "John", UriKind.Relative))
[B]Me.NavigationService.GoBack[/B]()
Me.NavigationService.Navigate(New Uri("/PivotPage1.xaml", UriKind.Relative))
Everything works fine, and the Checkbox state is saved/restored (in the Pivot Page) if I GO BACK using the GoBack hardware button or Me.NavigationService.GoBack
But, the state's dictionary entry is lost or ignored if I go back with the Navigate service (lines 1 and 3)...
Problem is that I need to get back with the query string...
The query string contains a value taken in the SelectedItem event of PAGE2's ListBox, and automatically once retrieved must go back.
I didn't know until know, that NavigationService.Navigate creates a new page instance or something like that in the backstack...
Any sugestions are welcomed!
Hi,
There are various methods you can use depending on the app's architecture. For example, you could have a 'shared' class that contains a shared field that holds the SelectedItem value. When the user selects the item, set the shared field's value and then when you go back, you can get the value from the shared field.
keyboardP said:
Hi,
There are various methods you can use depending on the app's architecture. For example, you could have a 'shared' class that contains a shared field that holds the SelectedItem value. When the user selects the item, set the shared field's value and then when you go back, you can get the value from the shared field.
Click to expand...
Click to collapse
So, no other way to cope with the navigation service?
It's a strange behaviour for sure...
Will try your ideas.
Thanks a lot for your reply!
GFR_2009 said:
So, no other way to cope with the navigation service?
It's a strange behaviour for sure...
Will try your ideas.
Thanks a lot for your reply!
Click to expand...
Click to collapse
There are other ways. For example, instead of using the PhoneApplicationService to store the tombstoning information, you could put it in a querystring for page 2. Then, in page 2, you could add the information from the previous page to a querystring AND the information of the selected item to the querystring. Navigate to page 1, with the querystring that contains information on what was there before and what the user selected. Tombstoning is there for when the user presses the hardware search button, home button, a phone call arrives etc.. It's not there for the navigation of the app. That's where querystrings, shared variables, binary serialization etc... come into play.
The concept of the navigation service is similar to a website. For example, when you submit something and then go back, it might still be there in the page state. However, if you submit something and then reload the previous page by typing it in the address bar, it becomes a completely new page as no state is stored.
keyboardP said:
There are other ways. For example, instead of using the PhoneApplicationService to store the tombstoning information, you could put it in a querystring for page 2. Then, in page 2, you could add the information from the previous page to a querystring AND the information of the selected item to the querystring. Navigate to page 1, with the querystring that contains information on what was there before and what the user selected. Tombstoning is there for when the user presses the hardware search button, home button, a phone call arrives etc.. It's not there for the navigation of the app. That's where querystrings, shared variables, binary serialization etc... come into play.
The concept of the navigation service is similar to a website. For example, when you submit something and then go back, it might still be there in the page state. However, if you submit something and then reload the previous page by typing it in the address bar, it becomes a completely new page as no state is stored.
Click to expand...
Click to collapse
Hi,
Will try your suggested approach, and thanks a lot for the last explanation on how the darn thing works.
Thanks again!
GFR_2009 said:
Hi,
Will try your suggested approach, and thanks a lot for the last explanation on how the darn thing works.
Thanks again!
Click to expand...
Click to collapse
You're welcome . It's one of those things that take a bit of time to understand, but starts to make sense. You might be interested in a free WP7 development ebook by Charles Petzold.
keyboardP said:
You're welcome . It's one of those things that take a bit of time to understand, but starts to make sense. You might be interested in a free WP7 development ebook by Charles Petzold.
Click to expand...
Click to collapse
I already have the book, but will need a deeper reading
So far, I've been testing your idea of using global classes and works ok.
Thanks a lot for being so cooperative, it's much appreciated!
GFR_2009 said:
I already have the book, but will need a deeper reading
So far, I've been testing your idea of using global classes and works ok.
Thanks a lot for being so cooperative, it's much appreciated!
Click to expand...
Click to collapse
No worries! If programming was super easy everyone would be doing it
keyboardP said:
No worries! If programming was super easy everyone would be doing it
Click to expand...
Click to collapse
Never said better!
I've been banging my head against this one all morning and now i have a head ache so i decided to stick it out to you lot.
I want to make all my user controls (labels, checkbox's etc) transparent - well the text at least. I found this thread on MSDN but i'll be honest and say i'm not entirely sure what i'm supposed to do with it.
Thanks for your thoughts.
Works a treat. Lifted the code from the site and dropped it straight into the form class.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsCE.Forms;
namespace TestDevApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
forum.xda-developers.com/search.php?searchid=90851847
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
DrawLabel(label1,e.Graphics);
DrawLabel(label2, e.Graphics);
DrawLabel(label3, e.Graphics);
DrawLabel(label4, e.Graphics);
}
private void DrawLabel(Label label, Graphics gfx)
{
if (label.TextAlign == ContentAlignment.TopLeft)
{
gfx.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), label.Bounds);
}
else if (label.TextAlign == ContentAlignment.TopCenter)
{
SizeF size = gfx.MeasureString(label.Text, label.Font);
float left = ((float)this.Width + label.Left) / 2 - size.Width / 2;
RectangleF rect = new RectangleF(left, (float)label.Top, size.Width, label.Height);
gfx.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), rect);
}
else //is aligned at TopRight
{
SizeF size = gfx.MeasureString(label.Text, label.Font);
float left = (float)label.Width - size.Width + label.Left;
RectangleF rect = new RectangleF(left, (float)label.Top, size.Width, label.Height);
gfx.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), rect);
}
}
}
}
Devtrans is the view in VS
Transparent is the actual running code.
Cool thanks.
I did try using DrawString but the drawn text doesn't scroll with the form when you... well.... scroll the form.
I'm gonna have the afternoon off but i will check it out properly later. Would this also work for check boxes? If so what are the changes that would need to be made?
Checkboxes might be a different matter. The above method does not work, it only deals with the text caption. There is is an article on The Code Project at
http://www.codeproject.com/KB/dotnet/TransparentControl.aspx
It appears like they have almost created a control from scratch. You may have to take control/override that much of the object, to get it to work, that you have almost created a new control.
stephj said:
Checkboxes might be a different matter. The above method does not work, it only deals with the text caption. There is is an article on The Code Project at
http://www.codeproject.com/KB/dotnet/TransparentControl.aspx
It appears like they have almost created a control from scratch. You may have to take control/override that much of the object, to get it to work, that you have almost created a new control.
Click to expand...
Click to collapse
I did see that page but i couldn't figure out how the hell to use it
Ok, so now you have found one of the BIGGEST challenges to WM development.
I spent 4+ months trying to get the same thing you are looking for (well, what I assume you are looking for), that is: A transparent label that you can use your finger to scroll.
If that is what you are looking for, I can tell you right now that you need to either look into custom controls that already do this or decide how much time you are willing to invest into something as simple as that.
Here is the basic components that you will need to code to get DrawString to properly scroll with your finger:
You will need to code up some kind of container or panel that holds the current virtual x,y coordinates.
You will need to code up some kind of custom control that can be added to the previously made container
Create logic in the container to take the current virtual x,y coords and determine which custom controls are visible and should be drawn on the screen, pass them their offset coords, and draw the control
Override the OnMouse*ACTION* events on the container to manipulate the virtual x,y coords and then refresh the screen
You also will need to know about double buffering so you don't get any flickering.
It's a very very hard thing to do on WinMo, something that other platforms take for granted. This is one of the reasons that some custom WinMo programs have UIs that are either really terrible, or take tons of resources.
If you want to give it a go (and I would highly recommend doing it, I can't tell you how much I learned about software development by creating my own custom controls) I can help point you in the right directions. Feel free to take a look at the code I've written for my Facebook app (specifically the XFControls and SenseUI projects). I'm not on XDA as often as I'd like, but send me a PM with your questions and I'll respond when I log in.
Good Luck!
Hi guys,
We are currently developing an app which stores the users contacts for a quick search.
Any tip on which DB to use (SQL CE, WP7DB, Ninja DB, Rapid Repository and so on)?
My primary and most important requirement is that the database should be quick to load and search on application startup.
We are currently using IsolatedStorageFile together with ObservableCollection which is taking too long to load (~6 seconds to load and search 600 contacts from startup).
Any tip would be much appreciated!!
take a look on CodePlex, this is an example:
http://winphone7db.codeplex.com/
or in general...
http://www.codeplex.com/site/search?query=windows phone database&ac=8
namiran said:
We are currently using IsolatedStorageFile together with ObservableCollection which is taking too long to load (~6 seconds to load and search 600 contacts from startup).
Any tip would be much appreciated!!
Click to expand...
Click to collapse
I believe you have serious problems in design or implementation (or both ). What is the total size of your contact collection? How you serializing that collection? 600 contacts - it's just nothing for ISF file operations...
andreacorti said:
take a look on CodePlex, this is an example:
http://winphone7db.codeplex.com/
or in general...
http://www.codeplex.com/site/search?query=windows phone database&ac=8
Click to expand...
Click to collapse
Thanks!
Do you have any experience with winphone7db performance?
I know there are several solutions out there, I guess i would need the one with the fastest loading time. Don't need any advanced performance or query operations though.
sensboston said:
I believe you have serious problems in design or implementation (or both ). What is the total size of your contact collection? How you serializing that collection? 600 contacts - it's just nothing for ISF file operations...
Click to expand...
Click to collapse
I think you are more advanced developer than I am since I really don't even know how to check the size of the collection.
However this is basically the operation I am performing
on application firststart:
this.contactListOld = new ObservableCollection<Person>();
contacts.SearchAsync(string.Empty, FilterKind.None, "");
foreach contact
contactListOld.Add(b);
when application exits:
save contactListOld
on application load:
load contactListOld
[DataContract]
public class Person
{
...
}
public class IsoStoreHelper
{
public static void SaveList<T>(string folderName, string dataName, ObservableCollection<T> dataList) where T : class
{
if (!IsoStore.DirectoryExists(folderName))
{
IsoStore.CreateDirectory(folderName);
}
string fileStreamName = string.Format("{0}\\{1}.dat", folderName, dataName);
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileStreamName, FileMode.Create, IsoStore))
{
DataContractSerializer dcs = new DataContractSerializer(typeof(ObservableCollection<T>));
dcs.WriteObject(stream, dataList);
}
}
public static ObservableCollection<T> LoadList<T>(string folderName, string dataName) where T : class
{
ObservableCollection<T> retval = new ObservableCollection<T>();
string fileStreamName = string.Format("{0}\\{1}.dat", folderName, dataName);
try
{
using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(fileStreamName, FileMode.OpenOrCreate, IsoStore))
{
if (stream.Length > 0)
{
DataContractSerializer dcs = new DataContractSerializer(typeof(ObservableCollection<T>));
retval = dcs.ReadObject(stream) as ObservableCollection<T>;
}
}
}
catch (Exception es)
{
es.ToString();
}
return retval;
}
}
Personally I've made the switch to the built in Mango SQL CE database, seams performant enough and it's much more pleasant to work with than dealing with serializing data directly to isolated storage. Not to mention u can use LINQ to SQL.
Nudua said:
Personally I've made the switch to the built in Mango SQL CE database, seams performant enough and it's much more pleasant to work with than dealing with serializing data directly to isolated storage. Not to mention u can use LINQ to SQL.
Click to expand...
Click to collapse
But doesn't the loading of the database take a lot of time? How many objects/rows do you store in your database?
Thanks for your input!
namiran said:
I think you are more advanced developer than I am since I really don't even know how to check the size of the collection.
Click to expand...
Click to collapse
I created small project for you to demonstrate simple binary serialization to ISF. I hope you will be happy with timing
P.S. You may also reduce serialization time by using MemoryStream.
sensboston said:
I created small project for you to demonstrate simple binary serialization to ISF. I hope you will be happy with timing
P.S. You may also reduce serialization time by using MemoryStream.
Click to expand...
Click to collapse
Just tried it and it was Really quick!
Gonna see if I can transfer this to my code, thanks so far!
namiran said:
Gonna see if I can transfer this to my code, thanks so far!
Click to expand...
Click to collapse
You are welcome!
P.S. You may also press "thanks" button on my post
Hey all
I have a vertical progress bar,placed at y=-264,min value 900 (9.00 AM),max value 1850 (6.50 PM). It's current value is defined by progressbarcurrentvalue = $#Dm#)>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$ That is,if minutes<50 it displays current hour and minute without spaces or any chars,but if minutes>50 it displays next hour for 10 mins (like if its 16.55 it displays 1700 ). So far so good.
I want to have a horizontal line to follow my progress bar's current value. I came up with the solution that if I use the parameter [oy](ceil((progressbarcurrentvalue-900)*11/19)-264)[\oy] in my horizontal line it should do the trick. But the problem is I can't get to calculate progressbarcurrentvalue-900 it just does not do the calculation. How can i solve this?
TL;DR
I want to do the calculation $#Dm#)>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$-900 but i can't. Why?
Many thanks!
djbaha said:
Hey all
I have a vertical progress bar,placed at y=-264,min value 900 (9.00 AM),max value 1850 (6.50 PM). Its current value is defined by progressbarcurrentvalue = $#Dm#)>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$ That is,if minutes<50 it displays current hour and minute without spaces or any chars,but if minutes>50 it displays next hour for 10 mins (like if its 16.55 it displays 1700 ). So far so good.
I want to have a horizontal line to follow my progress bars current value. I came up with the solution that if I use the parameter [oy](ceil((progressbarcurrentvalue-900)*11/19)-264)[\oy] in my horizontal line it should do the trick. But the problem is I cant get to calculate progressbarcurrentvalue-900 it just does not do the calculation. How can i solve this?
TL;DR
I want to do the calculation $#Dm#)>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$-900 but i cant. Why?
Many thanks!
Click to expand...
Click to collapse
You need to enclose mathematical expressions in $'s in order for it to be evaluated as a mathematical expression. But this is not going to work:
Code:
[oy]$(ceil(($#Dm#>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$-900)*11/19)-264)$[\oy]
because you can't embed conditionals. What you need to do is condense all calculations into a single conditional.
First you can condense these 2 conditionals
Code:
$#Dm#>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$
into 1
Code:
$#Dm#>50?(#DHH#00+100):#DHmm#$
Then this
Code:
[oy]$(ceil(($#Dm#>50?(#DHH#00+100):#DHmm#$-900)*11/19)-264)$[/oy]
can be condensed by just incuding the additional calculations within the conditional
Code:
[oy]$#Dm#>50?(ceil(((#DHH#00+100)-900)*11/19)-264):(ceil((#DHHmm#-900)*11/19)-264)$[/oy]
You need to double check the above. I got a little confused with all the parentheses.
jr67 said:
You need to enclose mathematical expressions in $'s in order for it to be evaluated as a mathematical expression. But this is not going to work:
Code:
[oy]$(ceil(($#Dm#>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$-900)*11/19)-264)$[\oy]
because you can't embed conditionals. What you need to do is condense all calculations into a single conditional.
First you can condense these 2 conditionals
Code:
$#Dm#>50?(#DHH#+1):#DH#$$#Dm#<50?#Dmm#:00$
into 1
Code:
$#Dm#>50?(#DHH#00+100):#DHmm#$
Then this
Code:
[oy]$(ceil(($#Dm#>50?(#DHH#00+100):#DHmm#$-900)*11/19)-264)$[/oy]
can be condensed by just incuding the additional calculations within the conditional
Code:
[oy]$#Dm#>50?(ceil(((#DHH#00+100)-900)*11/19)-264):(ceil((#DHHmm#-900)*11/19)-264)$[/oy]
You need to double check the above. I got a little confused with all the parentheses.
Click to expand...
Click to collapse
Thank you so much !
The last formula worked flawlessly. Now im studying it to understand how it works..
Thanks!