I'd like to be able to customize how lists are rendered by ContainerWidgets. Shape tracing only gives me the following options:
Parts.ContainerWidget.cshtml
Parts.ContainerWidget-url-homepage.cshtml
I'd like to be able to supply an alternate for a specific zone. I think that IShapeTableProvider is the way to go, but I'm just not sure. I've also thought of using a Widget alternate (Widget-MyZone.cshtml) but I can't understand how to get to the underlying list items to render them myself. Also, overriding Widget seems like overkill. Ideally, I'd like to be able to add a Part alternate like Parts.ContainerWidget-MyZone.cshtml.
There seem to be quite a few posts around the web that discuss this problem, but nothing I could find really points to a concrete working example.
Is this the right approach? Something else I should try? Any examples around?
It turns out that Orchard 1.4 has built-in support for zone based container widget alternates. The recommended solution, therefore, is to just upgrade to 1.4.
IShapeTable provider should work. What happens when you try it? Here's a rough example (not tested):
public class Shapes : IShapeTableProvider {
public void Discover(ShapeTableBuilder builder) {
builder.Describe("Content").OnDisplaying(displaying => {
if (displaying.ShapeMetadata.DisplayType == "Detail"
&& (displaying.Shape.ContentItem as ContentItem).ContentType.Equals("MyWidgetType", System.StringComparison.OrdinalIgnoreCase)) {
var metadata = displaying.ShapeMetadata;
ContentItem contentItem = displaying.Shape.ContentItem;
metadata.Alternates.Add("MyWidgetType_MyCUstomAlternate");
}
});
}
Related
For Xamarin.Forms.DatePicker It is not obvious that the date field is "tapable" I want to change the text color of it to blue so the user will think it is clickable?
I see a background color property but not forecolor/text color?
Let me know how I can do that.
I did it just creating a class like that on my Android Project and making no changes on my Forms Pages:
using Xamarin.Forms;
using xxxx.Droid;
[assembly: ExportRenderer(typeof(Xamarin.Forms.DatePicker), typeof(MyDatePickerRederer))]
namespace xxxx.Droid
{
public class MyDatePickerRederer : Xamarin.Forms.Platform.Android.DatePickerRenderer
{
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
{
base.OnElementChanged(e);
this.Control.SetTextColor(Android.Graphics.Color.Black);
}
}
}
I don't think that the forecolor/text color is accessible at this time and I'm not sure if it will be in the future or not. Typically what you would do in this scenario is create a Custom Renderer to get down into the native implementation of the UIDatePicker control for iOS and change it's properties there. The problem with that in this case is that if you look through the iOS SDK documentation as well, I don't believe there is a way to customize the text on the UIDatePicker picker control. This is why you can't do it in Xamarin.Forms either.
At this point you will probably have to create your own custom control/renderer to make such a small change. Frustrating, I know, but unfortunately that this point I don't think you can actually accomplish the simple thing you are looking to do. :-(
I am trying to set up a generic class that deals with menus within Unity3D.
The following code I intend to attach to an empty game object
import System.Collections.Generic;
#pragma strict
public enum MenuType { loadSceneOnMouseDown, enableGameObject, changeValue };
public class MenuClass extends System.Object
{
public var menuObject : GameObject;
public var menuType : MenuType;
}
public var menuItems = List.<MenuClass>();
This results in the following within the editor:
I want each menu type to have its own parameter, so in this example I want the "loadSceneOnMouseDown" to have another public variable as a string defining the name of the scene to be loaded, once loadSceneOnMouseDown is selected from the enum. Whereas I want the "enableGameObject" Type to have a gameobject as a public var. However I dont want both to appear in both fields. For example I could make it like this:
public class MenuClass extends System.Object
{
public var menuObject : GameObject;
public var menuType : MenuType;
public var sceneName : String
public var targetObject : GameObject
}
But that would make it come under each element of the list. I considered doing a further subclass to resolve this, but then with the line "public var menuItems = List.();" that wouldnt work. (or would it? :D)
Apologies if I have been unclear, trying my best here but Im finding it difficult. Theres probably a very simple solution, or im going about thins entirely the wrong way. Any help with this problem would be very much appreciated!
Thanks!
Unity's serialization doesn't really support polymorphism. A list of type MenuClass can technically contain subclassed objects at runtime, but as far as serializing the list Unity is going to assume they are all objects of the base type.
It's a bit inconvenient, sometimes.
There are a few popular workarounds:
Leave all of the possible fields serialized MenuClass, then write a custom inspector which exposes only the relevant fields while you're working. In simple cases like yours, this is often the quickest solution.
Serialize some basic data fields, then use that data to reconstruct your more elaborate objects at runtime. For example, Unity can't serialize a Dictionary, but it can serialize two lists which you stitch back together. Handy, still simple, has some limits.
Build in some custom serialization library, and go nuts with it. Popular choices include JsonFx, MiniJson, Protobufs, and C#'s built-in XML serialization. Lots of work, but very powerful.
Like I said, in your case I'd recommend starting with the custom inspector, if you think that'll cover your needs.
Aside from code that's in most common tutorials, you could switch based on that control value, then call functions like EditorGUILayout.FloatField(), EditorGUILayout.ObjectField() and their cousins to get data.
Custom editor scripting is often overlooked, but it's one of the most powerful features available to Unity developers.
I need to implement a login/logout using MVVMCross, iOS only to start. After the user logs in, I want to close the view and make the "real" first view the root controller. For logout, I want to do the same in reverse. Whenever the LoginViewModel is requested, clear the root and replace it.
This Remove ViewController from stack indicates there is a ClearTop parameter, but it looks like it is gone in v3?
I then found this What is the best way to handle GoBack for the different MvvmCross (v3) platforms and I implemented this Presenter:
public override void Close(IMvxViewModel toClose)
{
if (toClose is LoginViewModel)
{
ClearBackStack();
Show(new MvxViewModelRequest() { ViewModelType = typeof(FirstViewModel)});
return;
}
base.Close(toClose);
}
public override void Show(MvxViewModelRequest request)
{
if (request.ViewModelType == typeof (LoginViewModel))
{
ClearBackStack();
}
base.Show(request);
}
Is this the correct way to handle this? Is there an easier mechanism (pre-v3 like)? Should I be overriding ChangePresentation instead?
Also, is there a mechanism to call ShowViewModel from a View? Do I need to resolve the IMvxViewDispatcher or is there a more straight forward method?
Yes, if you want to do custom presentation techniques then the easiest way is to implement your own view presenter.
For an introduction and some links on this, see How can I implement SplitView in another view in MvvmCross?
You are free to write code directly in your views, including navigation logic using resolved IoC objects. However, mvvmCross tries to encourage you to put this logic in the viewmodels - especially so that the 'logic' is more easily shared between platforms.
I'm trying to put a joypad made with AndEngine on a WebView that will be the view of an ipCamera. How can I do? I've searched a lot about that, but still haven't found the solution. Thank you all very much
You didn't mention what version of AndEngine you are using.
If you are using GLES2 (same technique may work for the GLES1 branch but I have not verified that), look at the AndEngine TextBreakExample.
That example shows how to use the org.andengine.opengl.view.RenderSurfaceView in combination with another layout like a LinearLayout. The "other layout" can contain anything - this example uses an EditText, but you should be able to use a WebView using the same technique.
Be sure and check the res/layout/textbreakexample.xml file. Also note these extra methods in the TextBreakExample.java file
#Override
protected int getLayoutID() {
return R.layout.textbreakexample;
}
#Override
protected int getRenderSurfaceViewID() {
return R.id.textbreakexample_rendersurfaceview;
}
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/src/org/andengine/examples/TextBreakExample.java
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/res/layout/textbreakexample.xml
Also might check out this layout file
https://github.com/nicolasgramlich/AndEngineExamples/blob/GLES2/res/layout/xmllayoutexample.xml
If anyone is having idea how to customize properties in a smartpart. I have created usercontrol and i m wrappin it in a smartpart.I want to upload my xml from Document library.
private string feedXML;
[Browsable(true),
Personalizable(true) ]
public string FeedXML
{
get
{ return feedXML; }
set
{ feedXML = value; }
}
and I am using this like
//
feedXML="\customxml.xml";
XPathDocument doc = new XPathDocument(Server.MapPath(feedXML));
but this thing is not working . When I am clicking on modify shared webpart of sharepoint page is not rendering. Any clue where I m getting wrong.
You might want to verify the result of your server.mappath statement. It will be something like C:\Inetpub...
So your code is trying to retrieve a file from the filesystem that really lives in SharePoint because you have uploaded it to a Document Library.
If you want that file you'll have to retrieve it using the SharePoint object model, have a look at the GetFileAsString method.
I agree with Denni..
Seems like Smartpart is only making it more difficult? What advantages does it have?
I make my own webpart containers for ascx controls.. very little work and all the control you need. No problems with trust settings either.
Are you sure this is correct?
feedXML="\customxml.xml";
Perhaps, what you want is:
feedXML="\\customxml.xml"; //escape the back-slash.
or
feedXML="/customxml.xml"; // use the forward-slash.
Anyway, if you just want to wrap your user control inside a Web part, you don't need the SmartPart. You can write your custom Web part yourself quite easily.