How to resize a Keynote slideshow? - resize

I'm an absolute newbie with Applescript but I need to know, first of all, if is it possible to launch a Keynote Slideshow and then how to resize that slideshow to a particular dimension and rect on the desktop.
I know you to start a slideshow.
I Know how to resize a window with
set the bounds of the window 1 to {0, 0, 200, 400}
but don't know how to pass this command to the Keynote slideshow, if it is possible..
Any hints??

You can resize the windows of any application by using a 'tell' statement or block. In your case, you would use:
tell application "Keynote" to set the bounds of window 1 to {0, 0, 200, 400}

Related

VB.NET Transparent Image Border

I am working with Microsoft Visual Basic 2010 Express and I have ran into an issue with transparent images and picture boxes. When I set the size mode to StretchImage it seems to add a white border around my images. If I leave it set to Normal it displays properly with no added border.
In this picture you can see what I am talking about. The left side is how it's suppose to look. The right side is what happens when I resize the picturebox.
Here is the image I am using
For my program I need to scale these images based on the size input by the user. The input size will never exceed 100x100px. The images are transparent .gif's that are 160x160px and stored in the program resources. These images will only be displayed on screen and never output by the program. I was wondering if there is anyway to scale transparent images without getting a white border around them.
Try manually drawing the image and setting the interpolation mode. You may need to play with different values to get the look you want:
Dim destination = New Bitmap(100, 100)
Dim original = Image.FromFile("gear-256.gif")
Using g = Graphics.FromImage(destination)
g.InterpolationMode = InterpolationMode.HighQualityBilinear
g.DrawImage(original, New Rectangle(0, 0, destination.Width, destination.Height), New Rectangle(0, 0, original.Width, original.Height), GraphicsUnit.Pixel)
End Using
PictureBox1.Image = destination

How to create a small button with a large tappable area

I want to create a close button which will look like a circle with an x in the middle. In x code I set the button's size and width to be large so that the touchable area is larger (50 x 50 with a font of just 22).
I create a button, change the title to X and then set the following:
[self.closeButton.layer setBorderWidth:2.0f];
[self.closeButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[self.closeButton.layer setCornerRadius:self.closeButton.bounds.size.width/2];
The circle border is too far from the X. How would I bring the borders in tighter to the X but not decrease the size of the clickable area?
assign image to a button. and make tappable area as you want. then set image location in button by setting inset value of that button as top, bottom, left, right. change the value of this according to your requirements. You can set inset value from interface builder as shown in image here. change the value and see the difference to place your image in button at exact location you want.
exactly like this image
I'd suggest exactly what Max has done. He has shown how to do this via IB, this is how you do it through code:
myButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 25, 25);// UIButton
myBarButtonItem.imageInsets = UIEdgeInsetsMake(0, 0, 25, 25);// UIBarButtonItem
EDIT:
Sorry for not reading your question properly the first time. I think you will run into the same issue with this approach : the border/cornerRadius of the button will not respect any insets. It will be drawn according to the frame of the button. Only (easy) workaround at the top of my head, is to create an image with the border and corners in it, and then set it as the image. The image will respect the insets, and you will have your desired tappable area, with the borders exactly where you want them.
There might be a more elegant workaround through subclassing, but unless you change the border width/color, or corner radius of your button at any stage, I'd suggest sticking with custom image.
EDIT 2:
Instead of using an image you might want to use this unicode character.

UITextView Text cut off when using setContentInset

I'm trying to shift the text in my UITextView right by 20 pixels to create a text indent using the code below
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0,-20)];
But this is cutting off the right hand side of my text as shown in the screenshot. Can any help me stop this happening please
I think your edge insets are a bit off. Edge insets work towards the middle of the rectangle. For the right inset you should try 20 rather than -20.
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0, 20)];
I couldn't find a solution to your problem even by subclassing UITextView and blocking setContentSize which seemed to be the problem.
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0, rightInset)];
No matter what is the value of the rightInset the text is always clipped. Something is always redrawing text so that it fits the frame width of the text view.
But I am wondering why do you need to set the inset? Can't you just set the background of the UITextView object to clear color and position it properly on your background view to get the illusion of indentation?

How Can I use Graphics.CopyFromScreen to enable alpha transparent controls?

I am trying to use (and this may be my problem already) e.Graphics.CopyFromScreen() in the OnPaint() method of my control to prepare a background onto which I can draw the content of the control. The goal is a tool-tip with rounded corners and other specific features to replace the default Windows tool tip.
Ideally the tool tip could be antialiased and blended into the backdrop, however at a pinch I could tolerate an aliased boundary. This may also be necessary as the control will often be covering a control with an OpenGL overlay and the whole blending procedure may end up a nightmare.
I have created a custom user control, a persistent instance of which belonds to my applications's main form, overriding the OnPaint and OnPaintBackground methods. The application of transparency however is challenging. As I understand, the graphics object passed to the paint method starts with a copy of the current VisibleClipBounds, where generally the first move is to clear the control with a solid colour and start drawing the main features. My first thought was to bypass the fill and start drawing on the captured background. For the first redraw this works fine, but subsequent redraws keep the previous content instead of re-capturing the backdrop. I hoped that CopyFromScreen would specifically eliminate the currently drawing control from its capture so as to start from a clean base but this is not the case, it captures the rectangle of the new location including the image of the previous location if it is in the bounds.
Other solutions and permutations thereof such as
SetStyle(ControlStyles.SupportsTransparentBackColor, True)
Me.BackColor = Color.Transparent
e.Graphics.Clear(Color.FromArgb(0,0,0,0))
have to-date yielded no appropriate results.
I started with a transparent form using the transparent key colour. This worked with aliasing but using a form as a tool tip seemed excessive and caused annoying artifacts (some of which could be overcome) such as the temporary presence of the taskbar button, focus loss of underlying form with subsequent visual feedback in the host form's title bar colour. The control is much lighter weight but I am struggling to make it work even as well as the form.
At this point I simply ask how to achieve the desired result and whether CopyFromScreen is a part of that solution.
That's a lot of text to read - but addressing transparency to achieve a custom-shaped form/control... Control.Region can do the same thing:
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
private void CreateRegion()
{
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 40, 40));
}
If your control is set as a top-level window and you're running it on Windows 7 or 8, check into DwmEnableBlurBehindWindow. In the parameter structure, I set enable to true and I create a region 1x1 pixels for the blur. With BackColor and TransparencyKey set to Black, this gives me a entirely transparent window (complete with mouse pass-through) that I can paint 32-bit images to with full alpha transparency (using Graphics.FromHwnd). A bonus to this method is that if the window moves or the background changes, Windows DWM does all the work--I don't have to update a thing.

Text drawn to CGContextRef Not Always complete

I am new to the Mac world and am seeing some behavior that is puzzling to me. I am working on a basic full screen utility that will capture the main display of the Mac and display some text. The problem I am having is that if I capture the display multiple times, after the first time the text that I am writing the the contextRef begins to degrade at the beginning of the line each time it is written. The first time it might be that the fill doesn't get drawn in the first letter, after that whole sections of the text at the beginning of the line disappear. The code I am using is as follows:
CGDisplayCapture(kCGDirectMainDisplay);
CGDirectDisplayID display = kCGDirectMainDisplay;
CGContextRef ctx = CGDisplayGetDrawingContext (display);
CGContextSelectFont (ctx, "Times-Roman", 48, kCGEncodingMacRoman);
CGContextSetTextDrawingMode (ctx, kCGTextFillStroke);
CGContextSetRGBFillColor (ctx, 1, 1, 1, 0.75);
CGContextSetRGBStrokeColor (ctx, 1, 1, 1, 0.75);
CGContextShowTextAtPoint (ctx, 400, 400, text, strlen(text));
I have found that if I put a '[NSThread sleepForTimeInterval:0.25]' before the CGContextShowTextAtPoint that the text would always display properly but that is what I would consider a hack.
My question for those who are smarter then I is, what is going on to cause the problem and is there something different that I should be doing to try and resolve it?
TIA,
JT
To make a basic full screen app, do not get the CGDisplay and associated CGContextRef and directly draw on it. I guess you're drawing to the context without being notified by the system to do so at all. That's not what you are supposed to do.
Unless absolutely necessary, create a big view which covers the entire screen, (i.e. keeping windows of other applications behind,) and draw on it just as you would do to a normal view. I.e. never get the context manually and write it actively. Rather, implement a subclass of NSView, implement drawRect, and perform the drawing inside. Finally, use enterFullScreenMode:withOptions:
to make the view full screen.