How to get current LayoutAwarePage? - windows-runtime

I'm not asking about the Type of the current LayoutAwarePage
Type type = ((Frame)Window.Current.Content).CurrentSourcePageType;
but about instance of current Page, I need an access to its properties

var frame = (Frame)Window.Current.Content;
var page = (LayoutAwarePage)frame.Content;

Related

Getting selected elements properties in forge viewer when more then one model loaded

I have have a viewer app with 8 models loaded
I have a plugin looking for the "AGGREGATE_SELECTION_CHANGED_EVENT" event
this.viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, this.onSelectionBinded);
I need to be able to get access to the selected elements properties
this.viewer.getProperties(_dbId, (result) => { })
but it seams the viewer is only looking at the last loaded model not all of them.
do i have to load/switch to the other models ? and if so how.
The viewer.model is always pointed to the first loaded model with my experience. If you want to access other loaded models, you can obtain them via calling viewer.impl.modelQueue().getModels(). Afterward, call Viewer properties APIs in this way:
var allModels = viewer.impl.modelQueue().getModels();
var model = allModels[1];
model.getProperties( dbId, onSuccessCallback, onErrorCallback );
Besides, you can obtain the model instance in the function argument event of your onSelectionBinded callback. So, your onSelectionBinded can be modified to this based on the above logic:
this.onSelectionBinded = function( event ) {
var selSet = event.selections;
var firstSel = selSet[0];
var model = firstSel.model;
var dbIds = firstSel.dbIdArray;
var firstDbId = dbIds[0];
model.getProperties( firstDbId, onSuccessCallback, onErrorCallback );
}
Hope it helps!
I know this is a little late...
Another way to get properties for multi-model, is to use the aggregated method.
var DBids = viewer.impl.selector.getAggregateSelection();
I have a blog post and sample website that goes through the details:
https://forge.autodesk.com/blog/highlighting-clashes-multi-model

Swift Class is not constructible

I'm following along with the iBook for swift programming, but I am getting an error when I try to contruct a class with var. Here is a stuct and a class:
struct Resolution {
var width = 0
var height = 0
}
class VideoMode {
var resolution = Resolution()
var interlaced = false
var frameRate = 0.0
var name: String?
}
I can create an instance of the Resolution struct just fine, but I can't seem to make one for VideoMode Class.
var r = Resolution()
println("Width:\(r.width) Height:\(r.height)")
r.height = 1234
r.width = 9877
println("Width:\(r.width) Height:\(r.height)")
var vm = VideoMode() //Says that 'VideoMode' is not constructible with ()
let vm = VideoMode() //Apparently this works though.... why?
vm.resolution.width = 22222
vm.resolution.height = 1234
vm.name = "Calimari"
print(vm)
I find this strange can anyone explain?
Update:
Apparently it works ok in playground. I am not running this in playground. I am running it using the master detail template using swift code. I added the "var vm = VideoMode()" in the viewDidLoad method and I get an error. But it seems to be ok if I change it to "let". No clue why that makes a difference.
If you don't define default values for all stored properties then you must define init().
var name: String? // There's no default value here. Either set name to `nil` or define init()
Exerpt from the Swift Documentation:
Classes and structures must set all of their stored properties to an appropriate initial value by the time an instance of that class or structure is created. Stored properties cannot be left in an indeterminate state.
You can set an initial value for a stored property within an initializer, or by assigning a default property value as part of the property’s definition. These actions are described in the following sections.
Addendum:
As stressed by user #valfer, I've found the following:
Optional Property Types
[...] Properties of optional type are automatically initialized with a value of nil, indicating that the property is deliberately intended to have “no value yet” during initialization.
I ignore if the above was present from the get-go or if it was added after the fact as the language is in beta at the time of this writing and is still in flux.
Apparently the Question mark at the end of the "name" variable declaration was preventing this from constructing.
//Implementation file of VideoMode
class VideoMode {
var resolution = Resolution()
var interlaced = false
var frameRate = 0.0
var name: String = "" //removed the question mark
}
//.....in another class
var vm = VideoMode(); //seems to work after making the above changes to the class declaration
I guess you forget to put : NSObject
like this:
class VideoMode: NSObject {
var resolution = Resolution()
var interlaced = false
var frameRate = 0.0
var name: String?
}

Using web audio api live input to control stuff

I would like to use my microphone input to control an image i have. I managed to edit this code by far and get my image affected. There was javascriptNode.onaudioprocess = function() and for some reason it disabled my microphone input checking.
You shouldn't need a Javascript node at all. You should just use a requestAnimationFrame handler to do the section of your code that does:
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
var average = getAverageVolume(array);
var array2 = new Uint8Array(analyser2.frequencyBinCount);
analyser2.getByteFrequencyData(array2);
var average2 = getAverageVolume2(array2);
element.style.opacity = average/100;
element2.style.opacity = average2/100;

programatically creating a folder in ssrs using SOAP

I am using the SSRS 2008r API to create and manage SSRS from a webform application. When creating a folder I see where I can add a folder name as well as specify additional meta data (custom properties) that can be a part of the folder. My question is how do I populate additional fields in the catalog database via the api. When I look at the CreateFolder method the only properties I can add at the insert are folder name, path, and custom properties:
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form
However I would also like to set at this time the description, and hidden value.
I'd appreciate any suggestions on how this is accomplished. Every example I have seen within MSDN only shows setting the folder name, path, and custom properties.
thanks in advance
Set the item properties (Description and Hidden) by initializing a Property class for each. Never done it before, but I'm guessing it would look something like this (assuming C#):
...
// description property
Property description = new Property();
description.Name = "Description";
description.Value = "Your description here.";
// hidden property
Property hidden = new Property();
hidden.Name = "Hidden";
hidden.Value = "True"; // not sure on value here, may be True/False, Yes/No
// build properties array
props[0] = description;
props[1] = hidden;
// create folder
rs.CreateFolder(folderName, "/", props); // foldername is a string passed in from the form

Store IList selected data to a variable

I'am working with Adobe AIR application and i have a registration form which contains a combobox which consist of 2 values...i want to store the selected value to a variable..
here is the code..
var a:IList = new ArrayCollection(['Nurse','Patient']).list;
selectbox.dataProvider =a;
suppose if it was a textbox,we can store the value like this:-
var lastname:String = textbox2.text;
in the same way how can i store the selected value from combobox...?
Thanks
You'll use the selectedItem property:
var role:String = selectbox.selectedItem;
P.S. Welcome to StackOverflow! If you find my answer helpful, please be sure to 'accept' it by clicking the green checkmark to the left.