Windows 10 sharing app settings between devices with same account - windows-10

Is there any possibility to do this ?
I'd like to identify the user and one easy way is to save GUID that is automatically visible on other devices with same MS Account.

You can use roaming settings for this
var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
// Create a simple setting
roamingSettings.Values["exampleSetting"] = "Hello World";
// Read data from a simple setting
Object value = roamingSettings.Values["exampleSetting"];
if (value == null)
{
// No data
}
else
{
// Access data in value
}
// Delete a simple setting
roamingSettings.Values.Remove("exampleSetting");
https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.roamingsettings.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2

Oh my...
I spent half a day reading forums and suddenly found an answer, right after posting SO Queston :( Sorry.
Microsoft has good buch of Win10 samples, and one of them describes ApplicationData.Roaming -
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/ApplicationData
Any file that is put to this folder is synced to other devices automatically.

Related

Fluid clients get out of sync when server is rebooted

I got the HelloWorld example to run fine. But once I stopped & restarted the server the clients got out of sync--even when I set a consistent document (i.e. location.hash = "12345").
Setting createNew=false broke the app (no dice--literally).
And I get a lot of repeating errors:
[start:server] error: Connect Document error: {} {"messageMetaData":{"documentId":"1608237690408","tenantId":"tinylicious"},"label":"winston","timestamp":"2020-12-17T20:45:13.160Z"}
[start:server] info: Disconnect of 60c72737-3e05-4bc7-bf9b-f7ca6439a431 from room {"messageMetaData":{"documentId":"1608237690408","tenantId":"tinylicious"},"label":"winston","timestamp":"2020-12-17T20:45:13.161Z"}
Does Fluid support this scenario? Or am I doing something wrong?
The tinylicious service could support turning off & on with durable data, but it's really meant to be a test service. When you restart the service, you'll probably want to pick a new documentID.
createNew is a more interesting story. The Hello World application is somewhat contrived example. In general, the app developer will get a signal from the user that a new document should be created. Think about Google Docs.
"Create New Google Doc" -> createNew === true
"Open existing Google Doc" -> createNew === false
However, for the Hello World scenario, we want to have as little code as possible. We certainly don't want to write out a whole document management schema. So we rely on a nifty little trick: If you paste in a URL with a specific documentID we assume you are loading an existing document, otherwise we will make a new one for you.
That's what the below is doing!
You'll see the effects in the URLs, which look something like this: http://localhost:8080/#1608592296522
let createNew = false;
if (location.hash.length === 0) {
createNew = true;
location.hash = Date.now().toString();
}
const documentId = location.hash.substring(1);
document.title = documentId;

How to detect that iOS App was launched for first time by specific user (not on specific device)?

I am using in my App cloudKit + Core Data in my App (iOS 13+) (swift).
I cannot figure out how to detect very first run of the app regardless of device to initialize some default data.
There are many posts how to detect first launch of a iOS app on specific device - that's easy. I cannot find solution for detecting the first run of app for specific user or in other words - if in user's iCloud does exist initialized container with specific containerIdentifier.
If user had already used the app on another device before, so during first launch on new device, there will be sync with iCloud and app will use user's data. But if the user has never used the app before I need to initialize some data.
I am searching for clue how to deal with it for hours, cannot find nothing relevant.
Any idea?
Thanks for help in advance.
A bit more information on your cloudkit schema would help, but assuming you are using a publicDB to store information, a unique record will be create for the user when they first take an action that saves data to cloudkit.
So you could check and look at the createDate timestamp of the User object in cloudkit and compare to the current time (a bit clunky, but possible).
Example code to fetch the user:
iCloudUserIDAsync { (recordID: CKRecord.ID?, error: NSError?) in
if let userID = recordID?.recordName {
self.loggedInUserID = userID
self.loggedInWithiCloud = true
} else {
self.loggedInWithiCloud = false
print("Fetched iCloudID was nil")
}
}
Alternatively, and more elegantly, you could write a boolean flag to the user object CloudKit (or locally in CoreData) on first launch. Then on any launch get the entire user object for the logged in iCloud user, you can then initialize it and then act on your Boolean variable from there.
Example code to get the full user and initialize it locally:
CKContainer.default().publicCloudDatabase.fetch(withRecordID: userRecordID) { (results, error ) in
if results != nil {
//now that you have the user, you can perform your checks
self.currentUser = MyUser(record: results!)
}
if let error = error {
print("couldn't set user reference")
}
DispatchQueue.main.async {
completion(nil)
}
}

Can I trigger the Hololens Calibration sequence from inside my application?

I have a hololens app I am creating that requires the best accuracy possible for hologram placement. This application will be used by numerous individuals. Whenever I try to show the application progress, I have to have the user go through the calibration process, otherwise the holograms appear to have way too much drift.
I would like to be able to call the hololens calibration process automatically when the application opens. Later, after I set up user authentication and id management, I will call the calibration process when a new user is found.
https://learn.microsoft.com/en-us/windows/mixed-reality/calibration
I have looked into the calibration (via the above documentation and elsewhere) and it seems that all it is setting is IPD. However the alternative solutions I have found that allow for dynamic ipd adjustment appear to be invalid for UWP Store apps. This makes them unusable for me.
I am looking for any help or direction, or if this is even possible. Thank you.
Yes, it is possible to to this, you need to use the LaunchUriAsync protocol to launch the following URI: ms-hololenssetup://EyeTracking
Here is an example implementation, obtained from the LaunchUri example in MRTK
public void LaunchEyeTracking()
{
#if WINDOWS_UWP
UnityEngine.WSA.Application.InvokeOnUIThread(async () =>
{
bool result = await global::Windows.System.Launcher.LaunchUriAsync(new System.Uri("ms-hololenssetup://EyeTracking"));
if (!result)
{
Debug.LogError("Launching URI failed to launch.");
}
}, false);
#else
Debug.LogError("Launching eye tracking not supported Windows UWP");
#endif
}

How do I see everything stored in Office.context.document.settings?

Looking through the docs, I wasn't able to find a way to view everything currently stored in settings. I'm trying to debug some memory issues, and I'm worried that giant objects have been stored in the document settings (potentially from other add-ins that have worked on this same workbook).
Is there a way to see everything stored in Office.context.document.settings without using the .get method (which requires you to know the name of the property you want)?
Thanks for your help
Which host are you looking for? For Word and Excel, there is an API to get all settings. For Word, document.settings and for Excel use workbook.settings. Other hosts don't support this API.
await Excel.run(async (context) => {
const settings = context.workbook.settings.load();
settings.load("items");
await context.sync();
for (let i = 0; i < settings.items.length; i++) {
console.log(JSON.stringify(settings.items[i])) + "\n";
}
});
For Word, just replace context.workbook with context.document.
It also wouldn't help you here since it also only surfaces settings from the current add-in. Any settings created by other add-ins are inaccessible from yours.
Your best bet is to decompress the .docx file (it's just a Zip file) and inspect the contents directly. The settings are stored as XML in the \xl\webextensions folder.

Print multiple jobs without interruption c#

Is there a way to print multiple jobs in a row, without letting another user send a print job in between? (sort of "don't give the token to another user as long as my print jobs haven't finished")
It's a shared printer and many users have access to it, and what I'm printig is a big document so it takes some time;
I'm using more then one job because its pages are not to be printed from the same paper tray, so I have to switch the paper source in my code.
Help please! and thanks in advance.
P.S. I'm using the PrintDocument object of .Net
Instead of using multiple jobs, I can just change the settings for each page when printing (modify the PrintPageEventHandler), here's a link, and a sample of my code:
private void PrintPage(object sender, PrintPageEventArgs ev)
{
using (Metafile pageImage = new Metafile(streamList[currentPageIndex]))
{
// If it's the first page
if (currentPageIndex == 0)
{
// Use a certain tray
ev.PageSettings.PaperSource = PaperTrayPage1;
}
// For the rest of the document
else
{
// Use another tray
ev.PageSettings.PaperSource = PaperTrayRest;
}
currentPageIndex++;
ev.Graphics.DrawImage(pageImage, ev.PageBounds);
ev.HasMorePages = (currentPageIndex < streamList.Count);
}
}
Combining multiple jobs (PrintDocument objects) is possible, here's an example.
There isn't, as far are I know, you'd need to either keep the printer busy by keeping the job open and sending PJL or other commands that don't eject a page. The other option is to concatenate your jobs together into one large job. I guess you could also programatically pause the shared print queue and send the data directly using a direct IP print port or something. In the end there isn't an elegant solution to this.

Resources