Get local file while in Fullscreen mode - file

I have swf that expands to fullscreen:
stage.displayState = StageDisplayState.FULL_SCREEN;
The second I try to select local file, it's collapsing to NORMAL_SCREEN
file_mask = new FileFilter("Images: (*.jpeg, *.jpg, *.png, *.JPG)","*.jpeg; *.jpg; *.png; *.JPG");
local_file.browse([file_mask]);
Is it bug, or feature, or the way it used to be ???
import flash.net.*;
import flash.events.*;
import flash.display.*;
expand_btn.addEventListener(MouseEvent.CLICK, openApp)
function openApp(e:MouseEvent) {
stage.displayState = StageDisplayState.FULL_SCREEN;
}
file_btn.addEventListener(MouseEvent.CLICK, openApp2)
function openApp2(e:MouseEvent) {
var local_file:FileReference = new FileReference();
var file_mask:FileFilter = new FileFilter("Images: (*.jpeg, *.jpg, *.png, *.JPG)","*.jpeg; *.jpg; *.png; *.JPG");
local_file.browse([file_mask]);
}

Use fullscreen interactive.
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
//Align top left of the stage.
stage.align = StageAlign.TOP_LEFT;
//align swf contents without scale.
stage.scaleMode = StageScaleMode.NO_SCALE;
and if you are embeding in browser add the below parameters.
<param name="allowFullScreenInteractive" value="true" />
Ref

Related

React - when document open in new tab change the name of this new tab

I need to open document in a new tab in the browser and change the name of this tab
I wrote this code:
const blobUrlDocs = URL.createObjectURL(blob);
var newWindow = window.open(blobUrlDocs, "_blank");
newWindow.document.title = data.D_NAME;
return newWindow;
but the namews tab has not changed
I try wrote it in onload function :
newWindow.onload = function () {
newWindow.document.title = data.D_NAME;
return newWindow;
};
But the name of the tab only changed when the document was loaded.
What should I do so that the name of the document remains even after loading the document?

How to create a pop-up with a Picker where the picker is immediately active and with a 'Skip' option?

I have a couple of places in my UI where the user clicks an action and then I'd like to show a pop-up with (something like) a Dialog to invite him/her to add optional information, e.g. use a Picker to enter a date.
The idea is that this popup should be as little intrusive as possible and require as few clicks as possible, so I was thinking something like a Dialog with an explanation text and a Picker already activated so the user can directly swipe to the right date and push Done, and also a [Skip] button to directly close the Dialog without entering anything.
However, I've tried many different solutions and the picker (even in Light mode) appears outside the Dialog and I can't get the Dialog to close when clicking Done in the Picker.
Does anyone have a suggestion on how this could be achieved?
Here's how I finally implemented it, using the non-public components used by the Spinners (so the class must be placed in com.codename1.ui.spinner). I also noticed an issue in DateSpinner3D which sets the time of day randomly (to the time of activation), which means it may alter a Date even if not edited, but I'll do a PR for that.
I've only implemented support for the Picker elements I currently use.
So not fully reusable/generic solution, but hopefully it can help show how it can be done if anyone runs into the same need.
I've added a screenshot (only test colors): [![enter image description here][1]][1]
package com.codename1.ui.spinner;
import com.codename1.components.SpanLabel;
import com.codename1.components.Switch;
import com.codename1.io.Log;
import com.codename1.ui.Button;
import com.codename1.ui.Command;
import com.codename1.ui.Container;
import com.codename1.ui.Dialog;
import com.codename1.ui.Display;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.layouts.BoxLayout;
import com.parse4cn1.operation.SetFieldOperation;
import java.util.Date;
public class PickerDialog {
Dialog dlg;
Command doneCmd;
int type;
DateTimeSpinner3D dateTimeSpinner;
DateSpinner3D dateSpinner;
DurationSpinner3D durationSpinner3D;
public static String DONE_BUTTON_TEXT = "Done";
public static String CANCEL_BUTTON_TEXT = "Cancel";
public PickerDialog(String title, String text, Object value, String cancelText, String doneText, int type) {
this.type = type;
dlg = new Dialog();
dlg.setDialogUIID("PickerDialog");
dlg.setTitle(title);
dlg.setLayout(BorderLayout.center());
Container cont = new Container(BoxLayout.y());
SpanLabel textSpanLabel = new SpanLabel(text);
textSpanLabel.setTextUIID("PickerDialogText");
cont.add(textSpanLabel);
switch (this.type) {
case Display.PICKER_TYPE_DATE_AND_TIME:
dateTimeSpinner = new DateTimeSpinner3D();
dateTimeSpinner.setValue(value);
cont.add(dateTimeSpinner);
break;
case Display.PICKER_TYPE_DATE:
dateSpinner = new DateSpinner3D();
dateSpinner.setValue(value);
cont.add(dateSpinner);
break;
case Display.PICKER_TYPE_DURATION:
durationSpinner3D = new DurationSpinner3D(DurationSpinner3D.FIELD_HOUR | DurationSpinner3D.FIELD_HOUR);
durationSpinner3D.setValue(value);
cont.add(durationSpinner3D);
break;
}
doneCmd = Command.create(doneText, null, (e) -> {
dlg.dispose();
});
Button doneButton = new Button(doneCmd);
Container buttonBar;
if (cancelText != null && !cancelText.isEmpty()) {
Button cancelButton = new Button(Command.create(cancelText, null, (e) -> {
dlg.dispose();
}));
buttonBar = BorderLayout.centerEastWest(null, doneButton, cancelButton);
} else {
buttonBar = BorderLayout.centerEastWest(doneButton, null, null);
}
dlg.getContentPane().add(BorderLayout.SOUTH, buttonBar);
dlg.getContentPane().add(BorderLayout.CENTER, cont);
}
/**
* return the value of the picker of the defined type (Date or
*
* #return
*/
public Object show() {
Command cmd = dlg.showDialog();
if (cmd == doneCmd) {
switch (type) {
case Display.PICKER_TYPE_DATE_AND_TIME:
return dateTimeSpinner.getValue();
case Display.PICKER_TYPE_DATE:
return dateSpinner.getValue();
case Display.PICKER_TYPE_DURATION:
return durationSpinner3D.getValue();
}
}
return null;
}
}
[1]: https://i.stack.imgur.com/ByvFK.png

Import image in reactjs

import mainSampleImg from 'images/my_img.jpg';
class ImageCard extends Component {
imgDiv = React.createRef();
componentDidMount() {
if (this.props.bgImgPath) {
const image = new Image();
var test={mainSampleImg}; # the value of test is {"mainSampleImg": "my_img.jpg?1ecdc36e"}
image.src = {mainSampleImg};# the value of image.src is http://localhost:8080/proxy/[object%20Object]
}
}
...
Since img.src has value http://localhost:8080/proxy/[object%20Object], it becomes images not found, what is the right way to specify the images from images/my_img.jpg? (just for info, I am using webpack)
You assign an object to image.src instead of a string:
// not { mainSampleImg }
image.src = mainSampleImg;
if you put images in your public folder then you can just import like so:
<img src={'/path/under/public/route/filename.jpg} />
so if you have public folder with images directory and file is football.jpg you would do:
<img src={'/images/football.jpg'} />
no need to import images at the top of the file

Responsive flat panel in react-360

I would like to make responsive flat panel - on a mobile device should be in full screen like there
https://tour.croptrust.org/
Is there a possibility to achieve that in react-360.
Here is my example https://gstuczynski.com/tour/plaszow/ - try to hit loupe -> on the desktop looks good but how to make it responsive?
Here is my code
https://github.com/gstuczynski/plaszow-cc-virtual-tour
If you're looking to set your surface size based on whether user is on mobile or desktop, I'd approach this by building a NativeModule to check if the device is mobile on componentDidMount() and using the built in resize() function to adjust your surface sizes.
First add a module in client.js
function init(bundle, parent, options = {}) {
const r360 = new ReactInstance(bundle, parent, {
nativeModules: [
//new module added here
ctx => new SurfaceModule(ctx),
],
fullScreen: true,
...options,
});
}
In your case you already have vars for the surfaces - but remove const to expose them to your NativeModule:
infoPanel = new Surface(1440, 850, Surface.SurfaceShape.Flat);
mapPanel = new Surface(850, 800, Surface.SurfaceShape.Flat);
cylinderSurface = new Surface(4096, 720, Surface.SurfaceShape.Cylinder);
Next, create your class SurfaceModule and include a function to check for mobile and include a ref for the surface namecheckMobile(surfaceName)
import {Module} from 'react-360-web';
export default class SurfaceModule extends Module {
constructor(ctx) {
super('SurfaceModule');
this._ctx = ctx;
}
checkMobile(surfaceName, id) {
if (navigator.userAgent.match('add your match criteria here'))
{
let swidth = screen.width
let sheight = screen.height
surfaceName.resize(swidth, sheight);
this._ctx.invokeCallback(
id,
[swidth, sheight]
);
}
}
}
Finally in index.js run the function to check and adjust surface sizes.
With this setup you'll need to call the function for each Surface you want to check or you could rework to send multiple refs and perform an if/switch
You could also move the call out of componentDidMount() into another func
import {
NativeModules
} from 'react-360';
const SurfaceModule = NativeModules.SurfaceModule;
componentDidMount() {
SurfaceModule.checkMobile((swidth, sheight) => {
console.log(swidth);
console.log(sheight);
});
}
EDIT: Updated checkMobile() func & index.js to include callback

WPF FlowDocument Displays *Some* Images But Not Others

This is the code I'm using to create the Image that I'm inserting into a FlowDocument.
private static Image GetImage(string url)
{
if (url == null) throw new ArgumentNullException("url");
if (!(url.StartsWith("http://") || url.StartsWith("https://") || url.StartsWith("ftp://")))
return null;
var uri = new Uri(url, UriKind.Absolute);
var bmpImg = new BitmapImage(uri)
{
CacheOption = BitmapCacheOption.OnDemand,
};
if (bmpImg.CanFreeze) bmpImg.Freeze();
var img = new Image
{
Source = bmpImg,
Stretch = Stretch.Uniform,
Height = 120,
Width = 120,
};
return img;
}
When I create a document and insert an image from my server with
Designer.CaretPosition.Paragraph.Inlines.Add(image);
everything works fine - image displays as expected. Also, the main Google Logo image works fine, but the HackaDay Logo and others just display a blank image.
What could be the reason for this?
I think that some websites have hotlink protection. For example in my website I can link a photo in every page that it is in my domain and it works well, however if you try to link a photo in other domain, the photo doesn't load.

Resources