DirectX10/ShapDX Custom control - directx

I am trying to create custom control with directx10/direct2D output (panel, not a form). I do all rendering in the overriding OnPaint method, however I have read somewhere that it is wrong and RenderLoop should be used instead. But where should I insert RenderLoop.Run if I can write code only inside of the control? Thank you.

You would create a thread, and have RenderLoop.Run inside the thread. When you do this you have to make sure that events sent back and forth between the components are invoked in a safe manner.

Related

How to call Method of one UI from Another UI without initializing and without making method static. - Vaadin 14

How can we call FirstUI.Java method from SecondUI.java without initializing the FirstUI.java class and without making FirstUI's method static?
FirstUI.Java has multiple tabs buttons that need to hide and show depending on what method (defined in FirstUI.java) SecondUI.java.
SecondUI.java gets loads in the VerticalLayout present in FirstUI.Java. And is added to the Vertical layout by calling the constructor of the SecondUI.java.
If I make FirstUI.Java's method static which making buttons of tabs enable/disable we have to make the tab also static (This is what happening in my case). And the whole application starts to create an issue.
Any Solution?
My code can be accessed from here, all the static methods in this classes needed to be accessed by other classes
Any Idea of how these methods can be called from different UI without making them static?
what your app needs is an event bus mechanism for between UI communication. You're trying to implement things the wrong way with Vaadin. Your original question is just a side effect of the wrong implementation.
Replied to you over email with additional info to resolve the current issues in your app.
-A

Defining a method to be used with view

I am working on ROR app. The thing i need is a simple slider for view and whenever user change slider i want a method to be call with argument as the value in the slider.
My question:
1) How to call a method every time user change slider.
2) Which is the best place to define method i.e in which file controller class or somewhere else.
A slider would be a JavaScript thing. So you'd have JavaScript events listening for slider changes, and then pulling out whatever attributes you need from that event. Hopefully you could reuse a slider plugin which would almost certainly provide such an event hook for you. Check out: http://vandelaydesign.com/blog/tools/awesome-jquery-sliders/.
If you're saying that after the JavaScript event you'd like to pass the slider state back to your server... then you'd need to make an AJAX call. For this, create a controller that makes sense for receiving this call and point the AJAX code to an action in this controller. The controller can then do whatever you want with the value: store it in the database or whatever.

Custom TControl doesn't paint at design time until cut and pasted

I have an odd issue with TChromeTabs. I know it must be something simple, but I can't figure out what needs to be done to fix it.
When I initially drop the TChromeTabs control on a form it is completely transparent. If I cut the control then paste it back to the form the contents are displayed correctly. The contents also appear if I close, then re-open the form.
As I have no idea why this is happening I can't really give you any code samples. However, you can download the source code here: http://code.google.com/p/delphi-chrome-tabs/downloads/list.
Your control doesn't paint itself because you disable painting. You call BeginUpdate in the constructor, and you don't call EndUpdate until the Loaded method is called. But Loaded is only called when loading a control from a persisted state. Usually, we think of that as being when the control is loaded from a DFM file, but the IDE uses the same technique to allow putting controls on the clipboard.
You haven't noticed this before because, apparently, you only test your control by opening a pre-made demo project. The demo project has a control in its DFM file, so the only code path you exercise is the DFM case. You don't exercise the path where the constructor is called directly — when the control is first dropped on a form, or when the control is created "dynamically" in code.
To fix this, begin by getting rid of the BeginUpdate call in your constructor. Instead, to check whether your control is still in the process of being constructed, check csCreating in ControlState.
You can also get rid of your stsLoading state. Delphi already gives you that with the csLoading bit of ComponentState. Besides, your use of stsLoading is wrong since you set it in the constructor, just like you do with BeginUpdate.
Instead of relying on Loaded being called, you might wish to move certain code into the AfterConstruction method. Put code there that needs to run after your component is created but that has nothing to do with loading properties from a DFM (or other persistence source). I'm not sure I see anything in your Loaded method that really belongs there. Nearly all of it should be able to occur in the constructor.
You should also be aware of the CreateWnd method. It's called when your control's window handle gets allocated. That's where you should start allowing paint operations to occur. When you don't have a window handle, you have nothing to paint to.

In UIView layout, what is an "update cycle"?

According to the documentation for -[UIView setNeedsLayout]:
Because this method does not force an immediate update, but instead waits for the next update cycle, you can use it to invalidate the layout of multiple views before any of those views are updated. This behavior allows you to consolidate all of your layout updates to one update cycle, which is usually better for performance.
Sounds great - but when I use setNeedsLayout without then calling layoutIfNeeded, I find that my control doesn't lay itself out. I had hoped that an "update cycle" would happen before the control was next shown, but I guess that isn't how it works. So what is an "update cycle"? When does one happen?
The 'update cycle' happens at the end of the current run loop cycle.
setNeedsLayout must be called on the main thread (main runloop).
That's strange, I use a lot of custom drawn stuff that I change and call "[self setNeedsLayout]" a lot and I never had to call "layoutIfNeeded"...
Are you sure your "drawRect" is fine and not having some problem? Maybe its data isn't ready before you call "setNeedsLayout".
The first answer to the following thread could help you further.
I don't think there is such an evident bug in UIKit. Being you, I would check if my code calls all base methods I overrided. Especially, in hierarchy parents of the problematic object. If this doesn't help, I would replace custom parent view with some standard views to see if the problem persists. This would help to isolate the problem.
Use layoutIfNeeded instead, which triggers immediate layout update.
setNeedsLayout just schedules layout to the handler, being executed until the next update cycle.
refer to: http://www.iosinsight.com/setneedslayout-vs-layoutifneeded-explained

MOSS 2007 EditModelPanel

I am writing a web control where I'm overriding the CreateChildControls method. In this method I create an EditModelPanel, add a button to it and then add the EditModePanel to my web control's Controls collection (this.Controls.Add(xxx)). The problem is that the button shows up in both Display mode and Edit mode. I've tried setting EditModelPanel's PageDisplayMode property and SuppressTag property and nothing works.
Why does the EditModePanel fail when adding it programatically?
I've googled this issue and someone else had the exact same problem but he got no response.
Firstly, You can detect from within your control if you are in edit mode and not create the child controls. This way you will not need the editmodepanel.
I have refactored the editmodepanel class, and it does things a bit differently. It implements IParserAccessor and the logic is in AddParsedSubObject() method of the interface. I think by manually adding the controls, you are bypassing the IParserAccessor. Hope this helps.

Resources