'Slider' does not contain a definition for 'value' - slider

I want to make some project when I slide the UI slider will appear some text. But after I finish my coding, the error appears.
error CS1061: 'Slider' does not contain a definition for 'value' and no accessible extension method 'value' accepting a first argument of type 'Slider' could be found (are you missing a using directive or an assembly reference?)
But if I put in a new project, the error did not come out. When I import asset the error comes again.
Here is my code:
public class TextControl : MonoBehaviour {
public Slider Food;
public Slider Calories;
public Text States;
public Text Question;
public void Update()
{
wordShown();
}
public void wordShown()
{
if (Food.value >= 0.5f)
{
if (Calories.value >= 0.5f)
{
States.text = "INACTIVE, UNHEALTHY";
Question.text = "What changes can make him be active and healthy?";
}
else if (Calories.value < 0.5f)
{
States.text = "ACTIVE, HEALTHY";
Question.text = "What should he do to maintaian his fitness?";
}
}
else if (Food.value < 0.5f)
{
if (Calories.value >= 0.5f)
{
States.text = "INACTIVE,UNHEALTHY";
Question.text = "What classes of food should have consume by this person?";
}
else if (Calories.value < 0.5f)
{
States.text = "ACTIVE, HEALTHY";
Question.text = "High calorie associated with what type of food?";
}
}
}
}

Ok i got the solution.
there is actually a script named slider.cs. So I changed it to sliderscript.cs. Slider is the name for the property of unity. we cannot use the property as our script name.

I got another solution.
use UnityEngine.UI.Slider instead of Slider because as Kamil Digital said the property slider and script slider somehow conflict.
Example:
Slider MusicSlider; //DOESNT WORK
MusicSlider = musicObj.GetComponent<Slider>();//DOESNT WORK
UnityEngine.UI.Slider MusicSlider;//SHOULD WORK
MusicSlider = musicObj.GetComponent<UnityEngine.UI.Slider>();//SHOULD WORK

Related

How to attach pdf from trigger to an object?

I'm a bit lost trying to attach a pdf with populated values from an opportunity record
Here is the code:
Trigger:
trigger OpportunityTrigger on Opportunity (after insert)
if(trigger.isAfter && trigger.isUpdate) {
opportunityTriggerHelper.attachFileToOpportunityRecord(trigger.new);
}
Helper Class:
private void attachFileToOpportunityRecord(List<Opportunity> lstOpp) {
List<Id> oppListIdsForAttach = new List<Id>();
for(Opportunity opp : lstOpp) {
oppListIdsForAttach .add(opp.Id);
}
attachFileToOpportunities(oppListIdsForAttach);
}
#future(callout=true)
private static void attachFileToOppotunities(List<Id> OpportunityIds) {
List<Attachment> attachList = new List<Attachment>();
for(Id oppId : opportunityIds) {
OpportunityPdfController file = new OpportunityPdfController();
file.getData(oppId);
PageReference pdfPage = Page.PdfAttachmentForOpp;
blob pdfBody;
pdfBody = pdfPage.getContent();
Attachment attach = new Attachment();
attach.Body = pdfBody;
attach.Name = 'Pdf file';
attach.IsPrivate = false;
attach.ParenId = oppId;
attachList.add(attach);
}
insert attachList;
}
VF Page:
<apex:page controller="OpportunityPdfController" renderAs="pdf">
<apex:repeat value="{!pricingDetails}" var="pd">
<apex:outputText>{!pd.basePrice}</apex:outputText>
</apex:repeat>
</apex:page>
VF Page Controller:
public with sharing class OpportunityPdfController {
public List<PricingDetailWrapper> pricingDetails {get;set;}
public void getData(Id opportunityId) {
List<Pricing_Detail__c> pdList = [
SELECT basePrice
FROM Pricing_Detail__c
WHERE OpportunityId =: opportunityId
];
for(Pricing_Detail__c pd : pdList) {
PricingDetailWrapper pdw = new PricingDetailWrapper();
pdw.basePrice = pd.basePrice;
pricingDetails.add(pdw);
}
}
public class PricingDetailWrapper {
public String basePrice {get;set;}
}
}
The result is whenever I update an opportunity it attaches the corresponding pdf file but it is blank and if I add for example the following to vf page body: "<h1> hello World!</h1>" this works and shows as expected, but this is not happening to what I required above.
You didn't really pass the opportunity id to the VF page. And I doubt this actually works at all? If you manually access the VF page as /apex/PdfAttachmentForOpp?id=006... does it render the content ok? I'm assuming it doesn't.
Fixing the page
You didn't specify constructor so SF generates one for you, fine. I think you need to add something like
public OpportunityPdfController(){
if(ApexPages.currentPage() != null){
Id oppId = ApexPages.currentPage().getParameters().get('id');
System.debug(oppId);
getData(oppId);
}
}
Add this, try to access the page passing valid opp id and see if it renders ok, if right stuff shows in debug log. /apex/PdfAttachmentForOpp?id=006...
(VF page constructors are bigger topic, this might be simpler with standardController + extension class)
Fixing the callout
VF page (especially accessed as callout) will not share memory with the OpportunityPdfController controller you've created in the code. New object of this class will be created to support the page and your file will be ignored. You might try to make-do with some static variable holding current opportunity's id but it feels bit yucky.
In normal execute anonymous try if this returns correct pdf:
PageReference pdfPage = Page.PdfAttachmentForOpp;
pdfPage.getParameters().put('id', '006...');
Blob pdfBody = pdfPage.getContent();
System.debug(pdfBody.toString());
If it works - use similar trick in the actual code, pass the id as url parameter.

Working with checkboxes - unable to check if checkboxes are disabled

Looking for some review on this to let me know if this is the right approach to check for disabled checkboxes.
Part of my page model here:
class eligibleAccountType {
constructor (text) {
this.label = label.withText(text);
this.checkbox = this.label.find('input[type=checkbox]');
}
}
class ProgramOptionsSubscriptionRulesPage{
constructor(){
this.contractsatAccountLevel = Selector("#program_option_allow_participant_account_contracts")
this.eligibleAccountTypesList = [
new eligibleAccountType("Residential"),
new eligibleAccountType("Commercial"),
new eligibleAccountType("Industrial")
];
Part of my test here
if (userdata.userrole == "Read Only") {
for (const eligibleAccountType of programOptionsSubscriptionRulesPage.eligibleAccountTypeList) {
await t.expect(eligibleAccountType.hasAttribute('disabled')).ok()
}
}
Getting error such as:
ReferenceError: label is not defined
I think I found out the problem, I had not defined the
const label = Selector('label');
I see no label definition in your example. You can try to rewrite your eligibleAccountType constructor by using Selector:
class eligibleAccountType {
constructor (text) {
this.label = Selector(...).withText(text);
this.checkbox = Selector(...).find('input[type=checkbox]');
}
}
In this situation it may be useful to check the markup of required elements. Please refer to the "TestCafe Examples" repository: https://github.com/DevExpress/testcafe-examples/blob/master/examples/element-properties/check-element-markup.js
Update:
and now I see that my list is actually not even building and I get this error " 1) TypeError: programOptionsSubscriptionRulesPage.eligibleAccountTypeList is not iterable"
It seems like you have a naming mistake in your loop:
for (const eligibleAccountType of programOptionsSubscriptionRulesPage.eligibleAccountTypeList) {
According to your ProgramOptionsSubscriptionRulesPage class definition, the list name should be eligibleAccountTypesList (with the "s" character).

UWP - Saving Settings does not work all the time

I've got the following code just copied from here. I want to bind a double value to a xaml slider, get this value from the localsetting every time I navigate to the SettingsPage and everytime the slidervalue gets changed by the user I want it to be saved to localsettings. Here is my code so far:
SettingsPage.xaml.cpp:
Windows::Storage::ApplicationDataContainer^ localSettings = Windows::Storage::ApplicationData::Current->LocalSettings;
SettingsPage::SettingsPage()
{
InitializeComponent();
this->viewModel = ref new SettingsViewModel();
this->DataContext = this->viewModel;
}
void SettingsPage::QSlider_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e)
{
Windows::Storage::ApplicationDataCompositeValue^ composite =ref new Windows::Storage::ApplicationDataCompositeValue();
bool a = composite->Insert(SETTINGS_TAG_SLIDER_Q, dynamic_cast<PropertyValue^>(PropertyValue::CreateDouble((double)sldQ->Value)));
auto values = localSettings->Values;
bool b = values->Insert(SETTINGS_TAG_SETTINGS_PAGE, composite);
}
SettingsPage.xaml:
<Slider x:Name="sldQ" Margin="15,5,15,0" Value="{Binding SliderQValue}" ValueChanged="Slider_ValueChanged" MaxWidth="300" HorizontalContentAlignment="Left" ></Slider>
SettingsViewModel.cpp:
double SettingsViewModel::SliderQValue::get()
{
Windows::Storage::ApplicationDataContainer^ localSettings = Windows::Storage::ApplicationData::Current->LocalSettings;
ApplicationDataCompositeValue^ composite = safe_cast<ApplicationDataCompositeValue^>(localSettings->Values->Lookup(SETTINGS_TAG_SETTINGS_PAGE));
if (composite != nullptr)
{
if (composite->HasKey(SETTINGS_TAG_SLIDER_Q)) {
double value = safe_cast<IPropertyValue^>(composite->Lookup(SETTINGS_TAG_SLIDER_Q))->GetDouble();
return value;
}
}
return 99;
}
My Problem is that this works exactly once! If I navigate from other pages to SettingsPage, I get slidervalue=99. Then I set it by dragging to e.g. 50. Then I navigat back to other page. From the other page I navigate again to SettingsPage and get slidervalue=50. But doing it once again I get 99 again. So it only works for 1 page navigation-cycle but it should work even if the app is rebooted. What is the problem in my code? Am I understanding something wrong?
I actually solved the problem with the help of this. In my code above I was initializing a new 'ApplicationDateCompositeValue' each time I wanted to write/read it. So with the new method it works like it was planned to do:
OnValueChanged:
Windows::Storage::ApplicationDataContainer^ localSettings = Windows::Storage::ApplicationData::Current->LocalSettings;
auto values = localSettings->Values;
values->Insert(TAG_SLIDER, dynamic_cast<PropertyValue^>(PropertyValue::CreateDouble((double)sldQuality->Value)));
Property::get():
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
auto values = localSettings->Values;
if (localSettings->Values->HasKey(TAG_SLIDER)) {
double value = safe_cast<double>(localSettings->Values->Lookup(TAG_SLIDER));
return value;
}
else
return default_value;

Aurelia validation errors not displayed when validation initialized on attached

I want to show invalid input fields when the view is shown.
I have validation rules setup in a separate class (UserValidation) with one function (initValidatorOn).
export class UserValidation {
public _validation: Validation;
constructor(validation: Validation) {
this._validation = validation;
}
initValidatorOn(user: UserDto): ValidationGroup {
return this._validation.on(user, null)
.ensure('name').isNotEmpty();
}
}
Everything works for this setup.
export class User {
public validationGroup : ValidationGroup;
public userValidation : UserValidation;
public user : UserDto;
constructor(uv: UserValidation) {
this.userValidation = uv;
//this code works here and in activate method
this.validationGroup = this.userValidation.initValidatorOn(this.user);
}
attached() {
this.validationGroup.validate();
}
}
As I said before, the above works. But sometimes the object that I need to validate I not available in constructor or in activate function so I need to initialize validation in attached function. When I do that, my view no longer shows validation errors until I update the value in input.
So, this doesn't work
attached() {
this.validationGroup = this.userValidation.initValidatorOn(this.user);
//no validation errors displayed on the view
this.validationGroup.validate();
}
Can someone explain why errors aren't displayed on the view after I call validate when I initialize validationGroup in attached function?
Thank you.

GXT TextField or TextArea not decode html entites

i use grid cell renderer... and form bindig...
grid cell renderer valus is good
form bindig value is bad (
i tested: ff9 and last chrome
this bug ? or browser error ? or something else ?
sorry i little speak english.... (i use gtranslate)
error picture => http://test.eggproject.hu/gxt/textfieldentitesbugg.PNG
about json(gxt model)
{"ID":1,"user_email":"xxxx#xxxx.com","display_name":"XXX YYYY","user_cegnev":"","user_jogosultsag":"administrator","user_kedvezmeny":0,"user_city":0,"user_irsz":-1,"user_district":3,"user_street":241,"user_hazszam":"2813","user_emelet":"10","user_ajto":"588","user_kapucsengo":"58","user_comment":"óüöú\u0151\u0171áí","first_name":"Harangozo","last_name":"Gabor","user_telephone":"06111111","user_street2":""}
user_comment error displaying just textarea or textfield why ?
This is due to the components each section is using. A grid is essentially a tag which means any HTML encoded data loaded into this table is rendered correctly. Conversely A TextBox is a tag which only displays exactly what can be seen.
A solution is a custom field binding which processes the data in and out.
public class HTMLParserBinding extends FieldBinding {
protected Field<?> field;`
public HTMLParserBinding( Field<?> field, String property ) {
super(field, property);
this.field = field;
}
protected Object onConvertFieldValue( Object value ) {
if (value == null) {
return null;
}
return Format.htmlDecode(value.toString());
}
protected Object onConvertModelValue( Object value ) {
if( value == null ) {
return null;
}
return Format.htmlEncode(value.toString());
}
}