I was trying out doing a manual instantiation of a view and all I get is a black screen.
Here's the core of my FinishedLoading
currentController = new ChoicesScreen(this.window.Handle);
window.AddSubview (currentController.View);
window.MakeKeyAndVisible();
note: CurrentController is a protected UIViewController currentController
ChoicesScreen is defined in IB, has the proper outlets, actions, etc. in other words its a valid view.
I tried the default constructor for ChoicesScreen and got the same thing. Obviously I'm missing something in how to get my own screen up.
Driss,
You need to set the frame for the new view, to define where it'll show in the view:
currentController = new ChoicesScreen(this.window.Handle);
currentController.View.Frame = new System.Drawing.RectangleF(0, 0, 320, 480);
window.AddSubview (currentController.View);
window.MakeKeyAndVisible();
Related
I'm currently trying to create an interop layer to render my render target texture into a Skia SkImage. This is being done to facilitate rendering from my graphics API into Avalonia.
I've managed to piece together enough code to get everything running without any errors (at least, none that I can see), but when I draw the SkImage I see nothing but a black image.
Of course, these things are easier to describe with code:
private EglPlatformOpenGlInterface _platform;
private AngleWin32EglDisplay _angleDisplay;
private readonly int[] _glTexHandle = new int[1];
IDrawingContextImpl context // <-- From Avalonia
_platform = (EglPlatformOpenGlInterface)platform;
_angleDisplay = (AngleWin32EglDisplay)_platform.Display;
IntPtr d3dDevicePtr = _angleDisplay.GetDirect3DDevice();
// Device5 is from SharpDX.
_d3dDevice = new Device5(d3dDevicePtr);
// Texture.GetSharedHandle() is the shared handle of my render target.
_eglTarget = _d3dDevice.OpenSharedResource<Texture2D>(_target.Texture.GetSharedHandle());
// WrapDirect3D11Texture calls eglCreatePbufferFromClientBuffer.
_glSurface = _angleDisplay.WrapDirect3D11Texture(_platform, _eglTarget.NativePointer);
using (_platform.PrimaryEglContext.MakeCurrent())
{
_platform.PrimaryEglContext.GlInterface.GenTextures(1, _glTexHandle);
}
var fbInfo = new GRGlTextureInfo(GlConsts.GL_TEXTURE_2D, (uint)_glTexHandle[0], GlConsts.GL_RGBA8);
_backendTarget = new GRBackendTexture(_target.Width, _target.Height, false, fbInfo);
using (_platform.PrimaryEglContext.MakeCurrent())
{
// Here's where we find the gl surface to our texture object apparently.
_platform.PrimaryEglContext.GlInterface.BindTexture(GlConsts.GL_TEXTURE_2D, _glTexHandle[0]);
EglBindTexImage(_angleDisplay.Handle, _glSurface.DangerousGetHandle(), EglConsts.EGL_BACK_BUFFER);
_platform.PrimaryEglContext.GlInterface.BindTexture(GlConsts.GL_TEXTURE_2D, 0);
}
// context is a GRContext
_skiaSurface = SKImage.FromTexture(context, _backendTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888, SKAlphaType.Premul);
// This clears my render target (obviously). I should be seeing this when I draw the image right?
_target.Clear(GorgonColor.CornFlowerBlue);
canvas.DrawImage(_skiaSurface, new SKPoint(320, 240));
So, as far as I can tell, this should be working. But as I said before, it's only showing me a black image. It's supposed to be cornflower blue. I've tried calling Flush on the ID3D11DeviceContext, but I'm still getting the black image.
Anyone have any idea what I could be doing wrong?
I am making an image gallery using javafx, i wish to have the feature which allow the user to add some tag(for human faces) to the imageview when the user is onclick at the imageview, it should grab the position of the mouse pointed and prompt a dialog for user to enter the name for the face and save it to database.
Is this achievable by using javafx?
If yes, how should i do that?
Your help is appreciated.
Sample output of my application below:
Sure it's possible. I created this simple example for a single Image that adds a button to the scene which adds a circle where the image was clicked. This should demonstrate the approach.
#Override
public void start(Stage primaryStage) {
ImageView imageView = new ImageView(...);
imageView.setPreserveRatio(true);
imageView.setFitHeight(200);
StackPane pane = new StackPane();
StackPane.setAlignment(imageView, Pos.TOP_LEFT);
pane.getChildren().add(imageView);
VBox box = new VBox(pane);
pane.setOnMouseClicked(evt -> {
if (evt.getButton() == MouseButton.PRIMARY) {
// create node(s) that uses the click data
Button button = new Button("Show point");
button.setOnAction(e -> {
// do something with the data on user interaction
box.getChildren().remove(button);
Circle circle = new Circle(evt.getX(), evt.getY(), 5, Color.RED);
Pane circlePane = new Pane(circle);
StackPane.setAlignment(circlePane, Pos.TOP_LEFT);
pane.getChildren().add(circlePane);
});
box.getChildren().add(button);
}
});
Scene scene = new Scene(box, 200, 300);
primaryStage.setScene(scene);
primaryStage.show();
}
For your application you would:
Create a different event handler that creates and/or initializes the UI according to your needs or shows a dialog. You also would register the listener to the ImageView directly (unless you need to add some elements on top of it, like I do)
Calculate the real click position in image coordinates using evt.getX() * imageView.getImage().getWidth() / imageView.getLayoutBounds().getWidth() (absolute position) or evt.getX() / imageView.getLayoutBounds().getWidth() (relative position); procede accordingly for y position. Do this calculation directly in the click handler, not when the user submits the entered information, since you may want the user to be able to resize the image. Also if you use the viewport property, you need to modify the calculations accordingly.
Create a different thread that sends the information to the database, when the user submits his/her edits. Of course you also need to store some information about the image currently shown in the ImageView somewhere.
I'm a noob to monotouch and can't manage to add table views to flyoutnavigation controller. Does anyone have an example?
** update
My setup is a bit complicated and after much hacking managed to get the static table cells displayed on my storyboard with the below config.
tab bar controller
|
-tab 1
|
-tab 2 - nav controller
|
uiview controller A - flyout nav A --> uiview controller A1...A3
|
uiview controller B - flyout nav B --> tableview controller B1 (static cells)
I've cast the tableview controllers as uiview controllers on the flyout navs' setup thus allowing the tableviewcontroller to be displayed correctly and navigated to main uiview controllers via sergues. For example in the flyouts setup:
NavigationRoot = new RootElement ("FlyoutNavigationB") {
new Section ("Pages") {
new StringElement ("A Table View with static cells")
}
},
ViewControllers = new [] {
TableViewControllerB1 as UIViewController,
},
This hack seems to work but cleaner solutions are warmly invited (as I'm only 2weeks dev experience with monotouch) and feel a little saddened that I have uiview controllers sitting unattached on the storyboard without ability to do sergues via the flyout nav. It almost behaves like old school xib development.
Anyway I'm experimenting with tying this upto monotouch dialog now but not yet sure how. Comments most welcome to aid my learning :P
* update
Ok I think I got it working by creating a subclassed dialogviewcontroller. Then passing this subclass instance into the ViewControllers array in flyoutnavigationcontroller like so:
public partial class MyDvcController : DialogViewController
{
public MyDvcController (UINavigationController nav): base (UITableViewStyle.Grouped, null)
{
navigation = nav;
Root = new RootElement ("Demos"){
new Section ("Element API"){
new StringElement ("iPhone Settings Sample", DemoElementApi),
}
};
}
}
In my calling flyoutnav controller:
// Supply view controllers corresponding to menu items:
ViewControllers = new [] {
new UIViewController { View = new UILabel { Text = "Address txt" }, Title = "Address" },
new MyDvcController(NavigationController) as UIViewController
}
My wish list is almost complete...now how to add custom upickerviews with lovely transparent input accessory views wired to inputviews so they show automatically from calling monotouch dialog elements...hmmmm...another quest awaits...
Are you trying to push a second list over inside the flyout? I couldn't get it to work either.
I got it to work by modifying the source and redoing how the selection list is setup--but those changes are on my machine at work. I'll try to push those when I have a chance.
i want to change the Identifier of my UIBarButton when the value from my slider has changed. I tried it that way:
var button = new UIBarButtonItem(UIBarButtonSystemItem.Save);
this.Pad_btnClose = null;
this.Pad_btnClose = button;
But it doesnt work. I also tried it that way:
this.Pad_btnClose = new UIBarButtonItem(UIBarButtonSystemItem.Save);
doesn´t work too.
Setting that variable (or outlet, you don't say which) isn't going to remove the UIBarButtonItem from the screen.
In order to do that, you must create an outlet for the UIToolbar, then call:
yourToolbar.Items = new UIBarButtonItem[] { yourNewButtonItem };
Or if you want it to animate:
yourToolbar.SetItems(new UIBarButtonItem[] { yourNewButtonItem }, true);
This will overwrite the list of button items in the toolbar on the screen.
I have a function, which creates layout with widgets. The problem is what one of the widget is virtual tree (on left side of layout) and the second widget on the right side depends on clicked row on left side. Virtual tree works like menu, which should return value of row name to the right widget and recreate it on right side with provided data. However currently it is not recreating, but adding a new widget to the old one. How to recreate widget on the right side not adding it to the existing one (interface is similar to qooxdoo demobrowser view with tests)?
_createLayout : function()
{
// Create main layout
var dockLayout = new qx.ui.layout.Dock();
var dockLayoutComposite = new qx.ui.container.Composite(dockLayout);
this.getRoot().add(dockLayoutComposite, {edge:0});
// Create header
this.__header = new bank.view.Header();
dockLayoutComposite.add(this.__header, {edge: "north"});
// Create toolbar
this.__toolBarView = new bank.view.ToolBar(this);
dockLayoutComposite.add(this.__toolBarView, {edge: "north"});
// Create the tree view, which should create dockLayout below, when user clicks with Row value
dockLayoutComposite.add(this.getTreeView(), {edge: "west"});
// This layout should be created and recreated with clicked row value
dockLayoutComposite.add(bank.InvoiceListBuilder.createList("Tree_returned_value"), {edge: "center"});
},
getTreeView : function()
{
var hBox = new qx.ui.container.Composite(new qx.ui.layout.HBox(20));
var tree = new qx.ui.treevirtual.TreeVirtual("Tree");
tree.setColumnWidth(0, 170);
tree.setAlwaysShowOpenCloseSymbol(true);
var dataModel = tree.getDataModel();
var te2 = dataModel.addBranch(null, "Folders", true);
dataModel.addBranch(te2, "Incoming", false);
dataModel.addBranch(te2, "Outgoing", false);
dataModel.addBranch(te2, "Drafts", false);
dataModel.setData();
hBox.add(tree);
var foldercontent = bank.InvoiceListBuilder.createList("incoming");
tree.addListener("changeSelection",
function(e)
{
// this function should return row value to function: bank.InvoiceListBuilder.createList("Tree_returned_value") and create/recreate dockLayout with newly created widget from bank.InvoiceListBuilder.createList function
});
return hBox;
},
you are using a old virtual tree implementation (qx.ui.treevirtual.TreeVirtual), I would suggest to use the qx.ui.tree.VirtualTree implementation.
The next step is to use something like a controller for your view, which listen to the selection and creates widgets when the selection changed. The controller should know the container for adding widgets.
When your left side is just a list. You can also use the virtual list (qx.ui.list.List) and use a set of the tree model.
Cheers,
Chris