How to make AppStore-like buttons on iPad - objective-c

I can't seem to figure out how to do subject.
What I would like is to have some buttons which are not round-rect buttons.
The iPad AppStore has e.g. the search controls which mimics a dropdown known from e.g. the web select box or dropdown from Windows.
How do I create a button that looks more like a UIBarButtonItem than a RoundRect UIButton, and still being able to place it anywhere?
I'm working in MonoTouch, but answers can come in any flavour, how to do it through Interface builder or programmatically in objective-c or MonoTouch, or even just a pseudo description - im just hoping to get a hint.
Hope someone out there can lead me in the right direction...
/Anders

Just create a custom button. Here's an example to create a real ugly custom button using some features of UIView and CALayer.
var btn = UIButton.FromType(UIButtonType.Custom);
btn.Frame = new RectangleF(100, 100, 150, 30);
btn.SetTitle("Button", UIControlState.Normal);
// Custom backround image.
btn.SetBackgroundImage(UIImage.FromFile("./images/barbuttonbackground.png"), UIControlState.Normal);
// Custom border color.
btn.Layer.BorderColor = UIColor.Orange.CGColor;
// Custom border width.
btn.Layer.BorderWidth = 2.0f;
// Custom rounded corners (does not really work well together with the background image).
btn.Layer.CornerRadius = 10.0f;
// Transparency.
btn.Alpha = 0.6f;
window.AddSubview(btn);
Adjust it to your needs. If you want to have your buttons look differently, go ahead.

There are some custom controls in the web that you can use for your purpose, e.g. MAConfirmButton which replicates the App Store's "Buy Now" buttons.

Heres my sample of how I do it in MonoTouch at the moment.
Since i'm not using colors I have commented out the section with the colorlayer - but kept it for reference.
public static UIButton GetNewButton(RectangleF frame)
{
var btn = UIButton.FromType(UIButtonType.Custom);
btn.Frame = frame;
btn.Layer.BorderWidth = 1.0f;
btn.Layer.BorderColor = UIColor.FromRGB(200,200,200).CGColor;
btn.Layer.CornerRadius = 4.0f;
btn.SetTitleColor(UIColor.Black, UIControlState.Normal);
btn.TitleLabel.TextAlignment = UITextAlignment.Right;
btn.TitleLabel.BackgroundColor = UIColor.Clear;
btn.Layer.NeedsDisplayOnBoundsChange = true;
SetupLayers(btn);
return btn;
}
private static void SetupLayers(UIButton btn){
CAGradientLayer bevelLayer = new CAGradientLayer();
bevelLayer.Frame = new RectangleF(new PointF(0,0), btn.Frame.Size);
bevelLayer.Colors = new CGColor[]{UIColor.White.CGColor, UIColor.FromRGB(218,218,218).CGColor};
bevelLayer.CornerRadius = 4.0f;
bevelLayer.NeedsDisplayOnBoundsChange = true;
/* CALayer colorLayer = new CALayer();
colorLayer.Frame = new RectangleF(0f,1f, btn.Frame.Width, btn.Frame.Height -2);
colorLayer.BorderColor = UIColor.FromWhiteAlpha(0, 0.1f).CGColor;
colorLayer.BackgroundColor = UIColor.FromRGBA(0.220f, 0.357f, 0.608f, 1).CGColor;
colorLayer.BorderWidth = 1.0f;
colorLayer.CornerRadius = 4.0f;
colorLayer.NeedsDisplayOnBoundsChange = true;
*/
CAGradientLayer colorGradient = new CAGradientLayer();
colorGradient.Frame = new RectangleF(0f,1f, btn.Frame.Width, btn.Frame.Height -2);
colorGradient.Colors = new CGColor[]{UIColor.FromWhiteAlpha(1f, 0.1f).CGColor, UIColor.FromWhiteAlpha(0.2f, 0.1f).CGColor/*, null*/};
colorGradient.Locations = new NSNumber[]{NSNumber.FromFloat(0.0f), NSNumber.FromFloat(1.0f)};
colorGradient.CornerRadius = 4.0f;
colorGradient.NeedsDisplayOnBoundsChange = true;
btn.Layer.AddSublayer(bevelLayer);
// btn.Layer.AddSublayer(colorLayer);
btn.Layer.AddSublayer(colorGradient);
btn.BringSubviewToFront(btn.TitleLabel);
}

Related

How to make the performance of NSTextField consistent with NSAttributedString?

We have an NSView that uses quartz's related methods to draw pictures and text, and we can control scale and translate.
It is similar to a vector graphics software. After double clicking the text layer, you can input text and display it in real time.
Now we need to add a requirement. Double click the text in the fixed area to freely edit and reuse NSAttributedString to draw on NSView. Therefore, we use NSTextField as a sub view of NSView.
But we don't know how to make NSTextField behave like NSAttributedString, because we want it to overlap with the text on NSView.
The following enables us to generate the component configuration code and result diagram.
/// setup
func setup(){
let rect = tree.convertToRectOnView(rect: node.drawCellRect)
textField.setFrameSize(rect.size)
textField.setFrameOrigin(rect.origin)
textField.isEditable = true
textField.isSelectable = true
let newFont = self.font.withSize(self.font.pointSize * self.zoomScale)
let ps = NSMutableParagraphStyle()
ps.minimumLineHeight = newFont.ascender + abs(newFont.descender) + abs(newFont.leading)
ps.maximumLineHeight = newFont.ascender + abs(newFont.descender) + abs(newFont.leading)
textField.font = newFont
textField.attributedStringValue = NSAttributedString(string: "title", attributes: [.font: newFont, .paragraphStyle: ps])
}

Camera position cause objects to disappear

I'm developing an app with blazor client-side and I need to render a 3D scene.
I have an issue and I guess it is material-related.
I have a composition of parallelepipeds where one of them is fully opaque and the others are transparent.
Depending on the camera angle, the transparent ones completely disappear:
Example where everything is visible:
Example with 2 missing:
Example with all missing:
Code for transparent parallelepipeds
var geometry = new THREE.CubeGeometry(item.xDimension * _scene.normalizer, item.yDimension * _scene.normalizer, item.zDimension * _scene.normalizer);
var material = new THREE.MeshBasicMaterial();
var box = new THREE.Mesh(geometry, material);
box.material.color = new THREE.Color("gray");
box.material.opacity = 0.8;
box.material.transparent = true;
Code for the camera:
var camera = new THREE.PerspectiveCamera(60, width / height, 0.1, 100);
camera.position.set(1.3, 1.3, 1.3);
camera.lookAt(0, 0, 0);
I'm using OrbitControls and every object size is between 0 an 1 (_scene.normalizer is for that purpose)
Do you know why this is happening?
Edit:
I found it being a material depth function issue. Do you know which should I use?
Thanks,
Transparency is tricky with WebGL because a transparent object writes to the depthmap, and then the renderer assumes that subsequent objects behind it are occluded so it skips drawing them. You could avoid this by playing with the material's .depthTest and .depthWrite attributes (see the docs):
box.material.color = new THREE.Color("gray");
box.material.opacity = 0.8;
box.material.transparent = true;
box.material.depthWrite = false;

how to add arcgis button in a windows form

I am new in ArcGis. I came across a requirement that I need a command on the ArcGis Toolbar. On click the command, a Windows Form will open and there one region selector button is there. upon clicking on the button, the current Form UI must be minimized and the user will be allowed to draw a polygon. Can you please help on how to do that. Here is the code. I took normal windows button and wrote the below code in the click event.
_application = ((IApplication)_hookHelper.Hook);
IMxDocument pMxDoc = (IMxDocument)_application.Document;
IMap pMap = (IMap)pMxDoc.FocusMap;
IActiveView pActiveView = (IActiveView)pMap;
if (pActiveView == null)
{
return;
}
//// Changing the state of the Window.
if (this.WindowState == FormWindowState.Normal || this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Minimized;
// this.Hide();
}
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = pActiveView.ScreenDisplay;
// Constant
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
rgbColor.Blue = 111;
ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast
ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
simpleFillSymbol.Color = color;
ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberRectangularPolygonClass();
// ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass();
ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol);
screenDisplay.SetSymbol(symbol);
screenDisplay.DrawPolygon(geometry);
screenDisplay.FinishDrawing();
I am also not getting any mouse event and the UI is not minimized while starting drawing the polygon. Can anyone please help.
Have we check the white paper for ArcGIS runtime SDK for .Net?
http://resources.arcgis.com/en/help/runtime-wpf/concepts/index.html#/Essential_vocabulary/01700000004z000000/

How to draw outer and inner border in kendo donut chart

I wanted to draw border around Kendo donut chart. is there any options available to achieve the same. For detail please refer attached image.
Thanks
I got the solution and I am posting the answer if someone wants the same functionalities.
we can override default series visual
this.$('.chartview').kendoChart({
series.visual = this.overrideSeries.bind(this),
...
});
funtion overrideSeries(e){
let origin = e.center;
let radius = e.radius;
var draw = kendo.drawing;
var geom = kendo.geometry;
var circleGeometryOuter = new geom.Circle(origin, radius + 5);
var circleOuter = new draw.Circle(circleGeometryOuter).stroke(CssConst.DONUT_BORDER_COLOR, .5);
var circleGeometryInner = new geom.Circle(origin, radius - 5);
var circleInner = new draw.Circle(circleGeometryInner).stroke('#cdcdcd', .5);
var visual = new draw.Group();
visual.append(circleOuter, e.createVisual(), circleInner);
return visual
}

controlling X and Y of spark.components.Window

I am building an air app in Flex 4. I am creating windows as I need them in a chromeless application.
Here is what I have in my main app creation complete
protected function creationCompleteHandler(event:FlexEvent):void
{
facade.sendNotification(AppFacade.APP_INIT, this);
var buttons:NavigatorWindow = new NavigatorWindow();
var workingSets:WorkingSets = new WorkingSets();
buttons.addElement( workingSets );
buttons.width = 115;
buttons.height =200;
buttons.maximizable = false;
buttons.resizable = false;
buttons.addEventListener(AIREvent.WINDOW_COMPLETE, onWindowComplete);
buttons.open();
}
private function onWindowComplete(event:AIREvent):void
{
event.currentTarget.x = 100;
event.currentTarget.y = 100;
}
for some reason the application adds the window in the middle of the screen and if I set the x and y of the Window it does not put it where I expect in the upper left of my screen. How do I position the window where I would like when it is opened?
thanks,
The spark.components.Window exists inside a NativeWindow you'll need to position the NativeWindow if you want to move it around on the screen. It is a bit confusing because you can position the Window inside the native window as well. You'll have to do the positioning after creation complete, otherwise you'll get null reference errors.
You could invoke the window like this if you created a component based on spark.components.Window:
var win:MyWindow = new MyWindow(); //MXML component
win.height = 150;
win.width = 300;
win.systemChrome = NativeWindowSystemChrome.NONE;
win.type = NativeWindowType.LIGHTWEIGHT;
win.showStatusBar = false;
win.transparent = true;
win.alwaysInFront = true;
win.open(true);
Then in that mxml component, you set an creationComplete event handler to do this:
var padding:int = 25;
this.nativeWindow.x = Screen.mainScreen.visibleBounds.right - this.width - padding;
this.nativeWindow.y = Screen.mainScreen.visibleBounds.top + padding;
This should put your new window in the top right hand corner with 25px of padding on the top and right.