How to use LowprofileImageLoader and Image Place holder together in wp7? - c#

How can we use LowprofileImageLoader and Image Place holder together in wp7 app?
I have gone through this and this link but unable to use together.
But people have said in comments that they are able to use both by changing the following code in PlaceImage.cs:
if (null != _frontImage)
{
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
{
Delay.LowProfileImageLoader.SetUriSource(this, ((BitmapImage)this.Source).UriSource);
}
}
But when I do so, I got invalid arguments error. Can somebody suggest me how to solve this problem?

It should be:
if (null != _frontImage)
{
if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
{
Delay.LowProfileImageLoader.SetUriSource(_frontImage, ((BitmapImage) this.Source).UriSource);
}
}
It's the _frontImage's UriSource that you want to set.

Related

In acumatica, how can I grab the value of a selector and use it to fill another field?

As seen in the image below, I want to try and pass the value of the Selector to the Attention field. I'm trying to make it so that whenever I choose a new selector value, the Attention field will be updated with the selector's value.
The Contact Selector in the image above is a Custom Field, so I was trying to access it through it's extension. However, I couldn't seem to get it working.
Here is the Data Access screen showing how the field is set up:
Here is the code so you can grab it if needed:
[PXDBString(50)]
[PXUIField(DisplayName="Contact")]
[PXSelector(typeof(Search2<Contact.displayName,
LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,
Where<Contact.contactType, Equal<ContactTypesAttribute.person>>>))]
[PXRestrictor(typeof(
Where<Current<PMContact.customerID>,
Like<Contact.bAccountID>>), "")]
Below are my two attempts of trying to grab the extension. I've tried using these pieces of code in various events; RowSelected, RowUpdated, FieldUpdated. Nothing seemed to work, which obviously means I'm not grabbing the extension properly, but I'm not sure what else to try.
Attempt 1
protected void PMContact_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (PMContact)e.Row;
if (row == null) return;
PMContactExt rowExt = row.GetExtension<PMContactExt>();
if (rowExt != null) {
row.Attention = rowExt.UsrContactSelect;
}
}
Attempt 2
protected void PMContact_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (PMContact)e.Row;
if (row == null) return;
PMContact items = (PMContact)Base.ItemSettings.Current;
var itemExt = PXCache<PMContact>.GetExtension<PMContactExt>(items);
row.Attention = itemExt.UsrContactSelect;
}
This attempt was giving me an error about the ItemSettings part:
\App_Code\Caches\ProjectEntry.cs(43): error CS1061: 'ProjectEntry' does not contain a definition for 'ItemSettings' and no accessible extension method 'ItemSettings' accepting a first argument of type 'ProjectEntry' could be found (are you missing a using directive or an assembly reference?)
I'm a bit stuck on what else I can try to make this happen.
Do you have any other suggestions? :)
Thanks so much for your help #Hugues and #Robert!
As Hugues mentioned, my custom field had CommitChanges=False so I changed it to true and voila, it worked!
It worked fine using the RowSelected event, but I took Robert's advice and changed it to FieldUpdated to ensure I'm doing things more suitably.
This is the code I used when the event was triggered:
protected void PMContact_UsrContactSelect_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (PMContact)e.Row;
if (row == null) return;
PMContactExt rowExt = row.GetExtension<PMContactExt>();
if (rowExt != null) {
row.Attention = rowExt.UsrContactSelect;
}
}
Thanks so much again! This issue has been a really stubborn one :D
Try using a Field updated event on your selector field. The row_selected is geared more for driving the behavior of the UI.
https://help-2021r1.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=9048a6d5-41a0-a5bd-9b78-7ce9833114b2
ItemSettings dataview is in InventoryItemMaint graph, are you extending InventoryItemMaint?
Also it does not contain PMContact DAC, it is selecting InventoryItem DAC.
I would not expect this line of code to work for this reason:
PMContact items = (PMContact)Base.ItemSettings.Current;
I've tried using these pieces of code in various events; RowSelected, RowUpdated, FieldUpdated. Nothing seemed to work, which obviously means I'm not grabbing the extension properly,
I'm not sure about the conclusion here. Did you debug the code to make sure the PMContactExt extension is null?
Did you debug to make sure the events called? If events aren't called you need to add CommitChanges=True property on the ASPX control.
RowUpdated event should be used instead of RowSelected because RowSelected is not recommended to set DAC field values.
Is PMContact DAC a Projection? If it's a projection you will need to extend both the projection and the base DAC.
EDIT it is not a projection:

Highlighting a particular control while capturing screenshot of a dialog in web page in c#

I have a requirement to capture the screen shot of the opened dialog with a particular html control highlighted ( whose static id is given ). currently I Implemented the code following manner :
public void Snapshot()
{
Image currentImage = null;
currentImage = GetOpenedDialogFrame().CaptureImage();
}
public UITestControl GetOpenedDialogFrame()
{
var dialogsFrames = new HtmlDiv(this.BrowserMainWindow.UiMobiControlDocument);
dialogsFrames.SearchProperties.Add(new PropertyExpression(HtmlControl.PropertyNames.Class, "mcw-dialog", PropertyExpressionOperator.Contains));
var dialogs = dialogsFrames.FindMatchingControls();
if (dialogs.Count == 0)
{
return null;
}
return dialogs[dialogs.Count - 1];
}
Now I have to write the code to highlight the particular html control while taking a screenshot. The DrawHighlight() method of Microsoft.VisualStudio.TestTools.UITesting.dll does not take any parameter so how can I highlight a particular html control in the screenshot.
DrawHighlight() is a method of a UI Control. It could be used in this style:
public void Snapshot()
{
Image currentImage = null;
var control = GetOpenedDialogFrame();
// TODO: protect the code below against control==null.
control.DrawHighlight();
currentImage = control.CaptureImage();
}
Whilst that answers your question about DrawHighlight, I am not sure it will achieve what you want. Please see this question the Microsoft forums where they are trying to do a similar screen capture.
Why not simply user the playback settings:
Playback.PlaybackSettings.LoggerOverrideState = HtmlLoggerState.AllActionSnapshot;
This will produce the html log file with all the screenshots that your codedui test went threw.
After searching for the matching controls you can try to highlight each one of them.
something like:
foreach( var control in controls)
{
control.drawhighlight();
}
that way you'll be able to which controls are located by the playback(qtagent to be more precise). furthermore this will help you decide which instance to refer to. (run and wait to see which controls are highlighted, pick the one you need and hard code it to be part of the test).
so after the test run you'll end up with something like:
var dialogs = dialogsFrames.FindMatchingControls();
dialogs[desiredLocation].drawhighlight();
hope this helps.

Exist control in current form?

I need to find out if component with some name exist in current form.
I have name of the component in string variable and if it doesnt exist, i need create it.
I use this code
Control c = Controls.Find(New, true)[0]; //najiti komponenty
if (c == null) {}
But it gives me error that the index was outside the bounds of the array.
I know this code is bad, but i dont know to write it good and google dont help me.
Find method return an array of controls, i.e. Control[]. You are trying to access the first element of the empty array, thus resulting in IndexOutOfRangeException
You should try:
Control[] controls = Controls.Find(New, true);
if (controls.Length > 0)
{
//logic goes here
}
else
{
//no components where found
}
Try using the Control.ContainsKey() Method, (pass a string variable containg the control name instead of the quoted text in my example):
if (!this.Controls.ContainsKey("MyControlName"))
{
// Do Something
}

How do I check the display styling of an element with Watin?

I'd like to do the following with watin. Maybe you guys know the best ways to go about doing this. I've been unable to find any thorough documentation on watin's power, I've even checked the homesite with little luck.
I'd like to...
Check the visibility/display value of a div.
Check the class name of an element.
eg:
Span this_span = Span(Find.ByText("Loading..."));
if (this_span.Visibility=="True")
{
}
and
if (this_span.Class.Value=="classname")
{
}
I appreciate any help!
if (this_span.Style.Display != "none")
{
}
Check the class name of an element.
if (this_span.ClassName=="classname")
{
}
Check the class name of an element.
if (this_span.Style.GetAttributeValue("display")!="none")
{
}

How to handle possibility of null variables in Razor code?

I have some Razor code that has conditional logic based on whether a certain array variable is set. I'm having a heck of a time figuring out the best way to handle when it's null and I'm not happy with my kludgy solution.
Here's a simple example of what's happening:
#{
if (ViewBag.Foo != null)
{
double[] bar = new double[ViewBag.Foo.Length];
}
}
Later on in the code, I'll have something like this:
#if (ViewBag.Foo != null)
{
...some code that uses `bar` goes here ...
}
With that code, I get errors when ViewBag.Foo actually is null. I get an exception thrown complaining about the second section of code that uses bar and it not being in scope . However, in the execution, that second section will always be skipped.
After messing with it for awhile, I just did this instead:
double[] bar;
#{
if (ViewBag.Foo != null)
{
bar = new double[ViewBag.Foo.Length];
}
}
else
{
bar = new double[1];
}
With this change, the code works when ViewBag.Foo is null and non-null. There's gotta be a better way to handle this... anyone?
This sort of work does not belong in a view:
#{
if (ViewBag.Foo != null)
{
double[] bar = new double[ViewBag.Foo.Length];
}
}
The sort of problem you had is exactly why this is the case. Your problem came down to the fact that bar was not correctly scoped. If instead this work was happing within a ViewModel, a similar mistake would have immediately given you a compiler error. Instead you don't find out until you compile and use the application, and the error you are given can often be cryptic and difficult to track down.
You solved your own problem.
The bar variable was not in scope because you declared it within an if block. Your change broadened it.

Categories