Monday, 2 September 2013

WPF: Data Bindining A Slider Value To A ToolTip Content String In XAML

WPF: Data Bindining A Slider Value To A ToolTip Content String In XAML

In a C# based WPF UserControl, I have a set of Sliders to adjust the
Red,Green and Blue values of a Color element; essentially the UserControl
is a color picker. I have a combination of XAML and C# code behind for the
ToolTipOpening Event Handler that allows me to set the individual integer
value representing the Color component property value. So, if I have the
slider positioned for adjusting the amount of Red in the color in the
middle of the Slider, the ToolTip will display "Red: 125", as each Color
component property value can range from 0 to 255. The code fragments below
for both the XAML and C# work as expected:
XAML:
<UserControl x:Class="CustomColorPicker.ColorPickerUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Name="colorPicker">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="175" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Label HorizontalAlignment="Right">Red:</Label>
<Slider Grid.Row="0" Grid.Column="1" Name="sliderRed" Minimum="0"
Maximum="255"
Margin="{Binding ElementName=colorPicker, Path=Padding}"
Value="{Binding ElementName=colorPicker, Path=Red}"
ToolTipOpening="OnColorSliderToolTipOpening"
ToolTip="Red: 0" />
<Label Grid.Row="1" Grid.Column="0"
HorizontalAlignment="Right">Green:</Label>
<Slider Grid.Row="1" Grid.Column="1" Name="sliderGreen"
Minimum="0" Maximum="255"
Margin="{Binding ElementName=colorPicker, Path=Padding}"
Value="{Binding ElementName=colorPicker, Path=Green}"
ToolTipOpening="OnColorSliderToolTipOpening"
ToolTip="Green: 0" />
<Label Grid.Row="2" Grid.Column="0"
HorizontalAlignment="Right">Blue:</Label>
<Slider Grid.Row="2" Grid.Column="1" Name="sliderBlue" Minimum="0"
Maximum="255"
Margin="{Binding ElementName=colorPicker, Path=Padding}"
Value="{Binding ElementName=colorPicker, Path=Blue}"
ToolTipOpening="OnColorSliderToolTipOpening"
ToolTip="Blue: 0" />
<Rectangle Grid.Column="2" Grid.RowSpan="3"
Margin="{Binding ElementName=colorPicker, Path=Padding}"
Width="85" Stroke="Black" StrokeThickness="1">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding ElementName=colorPicker,
Path=Color}" />
</Rectangle.Fill>
</Rectangle>
</Grid>
</UserControl>
C#:
private void OnColorSliderToolTipOpening(object sender,
ToolTipEventArgs e)
{
Slider slider = (Slider) sender;
string colorName = "N/A";
int colorValue = 0;
if (slider.Name == "sliderRed")
{
colorName = "Red";
colorValue = (int) Color.R;
}
else if (slider.Name == "sliderGreen")
{
colorName = "Green";
colorValue = (int) Color.G;
}
else if (slider.Name == "sliderBlue")
{
colorName = "Blue";
colorValue = (int) Color.B;
}
string colorTip =
string.Format("{0}: {1}", colorName, colorValue.ToString());
slider.ToolTip = colorTip;
return;
}
Is there a way to eliminate the code behind and set the ToolTip contents
to display the same string using the ToolTip.Content and
ToolTip.ContentStringFormat properties in XAML only, allowing for the
elimination of the ToolTipOpening event handler in the code behind in C#?
I've tried the following XAML using DataBinding to format the content
string of the Slider's ToolTip:
XAML:
<Slider Grid.Row="2" Grid.Column="1" Name="sliderBlue" Minimum="0"
Maximum="255"
Margin="{Binding ElementName=colorPicker, Path=Padding}"
Value="{Binding ElementName=colorPicker, Path=Blue}">
<Slider.ToolTip>
<ToolTip
Content="{Binding ElementName=colorPicker, Path=Blue}"
ContentStringFormat="{}Blue: {0}" />
</Slider.ToolTip>
</Slider>
and the ToolTip Popup display comes up empty:

Stop a jQueryUI effect

Stop a jQueryUI effect

I'm developing a kind of chat similar the Facebook one. I used the jQuery
UI highlight effect when a new message arrives. Now I want to stop this
effect when the user click on the windows.
This is my code on window click event. The "janela" class is the chat's
windows.
$('.janela').live('click', function(){
var id = $(this).children('.topo').attr('id');
$.post('sys/chat.php',{acao: 'mudar_status', user: id});
$(".topo").effect("none"); //it's just a frustrated try.
});
Thanks.

Java not adding classes on IE9/8

Java not adding classes on IE9/8

I'm working on this website
The problem is that on IE9/8 the classes that are added/removed are not
working.
For example, after the page is loaded the body get's the .open class on
chrome/mozilla but on IE9/8 it still has the .close class, that happens
with all the animations so the page basically doesn't work on those
browsers.
This is the code of the body load:
/****************
* GLOBAL BINDS *
****************/
$(window).bind({
'load' : init,
'resize' : resizing,
'resizeEnd' : resize_end
})
function init(){
var open_time = false;
var open_load = false;
$('#home_img img').each(function(){
$(this).bind({
'load' : function(){
if(open_time){
this.open_stage()
}
open_load = true;
}
}).each(function(){
if(this.complete) jQuery(this).trigger("load");
});
})
var first_open = setTimeout(function(){
open_time = true;
if(open_load){
this.open_stage()
}
}, 2000);
this.open_stage = function(){
$('body').removeClass('close');
$('body').addClass('open');
$('#menu').addClass('active');
}
background_positions();
center_image($('#home_img > img'));
remove_blinder();
}
function resizing(){
center_image($('#home_img > img'));
background_positions()
position_section_items()
position_section_paginate();
if(this.resizeTO) clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function() {
$(this).trigger('resizeEnd');
}, 500);
}
function resize_end(){
position_section_items()
position_section_paginate();
}
Any idea what is the problem, it has never happened to me before, maybe on
IE8 but not on IE9. Also the page gives no errors... so I have no clue.

Start debug at any point

Start debug at any point

Is it possible to enter debug mode at any point without setting a break
point since the location of the code is unknown to me?
The code I'm looking at was written by a genius in a hurry and as such,
I'm struggling - the code (and project) is vast and I'd rather not step
through the entire thing especially since events are being trigged on new
threads, others are polling on other threads, API's are being executed etc
and as such debugging is difficult.
When the application is running, code is being executed at any point. So,
is there a way to tell Visual Studio (2010 or 2012) "add a break point to
where ever you currently are (or if you're in an API or something
unmanaged, wait until you're back in the solution)?". At least I can then
get an idea what project/files are being executed and start debugging from
that point. Or is there already an 'approach' for this?

Sunday, 1 September 2013

Required attribute ”title“ was not provided.”

Required attribute "title" was not provided."

After integrating facebook SDK for both Android and iOS, when setting the
campaign and clicked on "place order" we get the error "Required attribute
"title" was not provided." I didn't understand what the error mean. I
would like to know what could be the cause of this error so that I can try
to find a way to fix it. Is this related to the sdk integration or how we
set the ad? For iOS this is the first time I run the campaign with
Facebook SDK but I've run the Android campaign earlier and it worked fine.
After I stopped the first campaign to change the banners and place the
order again, I found this error. Thanks
pls answer me or Recommend

execute asynctask on View Pager only page selected

execute asynctask on View Pager only page selected

How to make execute asynctask on View Pager only page selected / opened?
like friendcaster for android execute asynctask when page opened. Or like
tabhost method only execute when page opened, but when move to other tabs
and back again not reload again. thanks before. :D

How to preventing inheritance in Objective-C?

How to preventing inheritance in Objective-C?

I came up with the following, which I am not sure if works in all scenarios.
main
#import <Foundation/Foundation.h>
#import "Child.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
Child *c = [[Child alloc] init];
}
return TRUE;
}
Parent Class
.h
#import <Foundation/Foundation.h>
@interface Parent : NSObject
@end
.m
#import "Parent.h"
@implementation Parent
+ (id)allocWithZone:(NSZone *)zone {
NSString *callingClass = NSStringFromClass([self class]);
if ([callingClass compare:@"Parent"] != NSOrderedSame) {
[NSException raise:@"Disallowed Inheritance." format:@"%@ tried to
inherit Parent.", callingClass];
}
return [super allocWithZone:zone];
}
@end
Child Class
.h
#import <Foundation/Foundation.h>
#import "Parent.h"
@interface Child : Parent
@end
.m
#import "Child.h"
@implementation Child
@end