How can I assign a custom color to a cell in Aspose Cells? - excel-interop

In the legacy (Excel Interop) code, this can be done to assign a custom color to a cell:
contractCell.Interior.Color = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
Using Aspose Cells, I'm trying to find the corresponding way to do it. This code:
styleContractRow2.ForegroundColor = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
styleContractRow2.Pattern = BackgroundType.Solid;
...does not compile, telling me, "Cannot implicitly convert type 'int' to 'System.Drawing.Color'"
So how can I assign a custom color in Aspose Cells?

Please check the reply and sample code in your Aspose.Cells forum thread.
Note: I am working as Developer Evangelist at Aspose

It seems as if the translation is unnecessary; this compiles:
styleContractRow2.ForegroundColor = Color.FromArgb(202, 134, 250);

Related

Pharo Smalltalk: How to create an input field using TextMorph and then get the data off the input field?

I am completely new to Pharo, Smalltalk. I'm developing a small app that will convert temperature from Fahrenheit to Celsius. Can anyone give me any idea on how to create an input field using TextMorph and display it on a window as shown in the screen shot. In addition, being able to get the data back from the input field when the button is clicked. The below code is what I have done so far.
Screenshot
The class TemperatureMorph
BorderedMorph subclass: #TemperatureMorph
instanceVariableNames: 'tempInputField counter'
classVariableNames: ''
package: 'Assignment'
The initialize method: Contains a label, textbox and a button.
initialize
| headingLabel converterButton|
super initialize.
self bounds: (0#0 corner:300#300).
self color: Color gray.
headingLabel := StringMorph contents: 'Converter'.
headingLabel position: 130#20.
self addMorph: headingLabel.
tempInputField := TextMorph new.
tempInputField position: 50#50.
self addMorph: tempInputField.
Thanks
On a side not, if you're doing UI stuff in Pharo for anything other than learning (It looks like OP /is/ learning, so this probably doesn't apply). You should be looking at either Glamour or Spec. Both of which have really easy text input and control systems.
Spec
Glamour
You can already see the necessary code in your screenshot, you only have to replace the construction of a StringMorph with that of a TextMorph. I suggest you take a look at the Pharo by Example book. It has a chapter on Morphic, which is the UI framework in Pharo.
yourTextMorph := TextMorph new.
yourTextMorph contents: 'initial text'.
ownerMorph addMorph: yourTextMorph.
I guess you will also want to read the contents back out of the TextMorph. You can use yourTextMorph contents to achieve that. See also Pharo Smalltalk: Reading from TextMorph

Possible to make a composite symbol?

When editing a vertex I would like to substitute the vertex symbol with SimpleMarkerSymbol and a TextSymbol but that appears to be impossible. Any suggestions on how I could do this? I want the appearance of dragging something like this (text + circle):
After taking some time to look at the API I've come to the conclusion it is impossible. Here is my workaround:
editor.on("vertex-move", args => {
let map = this.options.map;
let g = <Graphic>args.vertexinfo.graphic;
let startPoint = <Point>g.geometry;
let tx = args.transform;
let endPoint = map.toMap(map.toScreen(startPoint).offset(tx.dx, tx.dy));
// draw a 'cursor' as a hack to render text over the active vertex
if (!cursor) {
cursor = new Graphic(endPoint, new TextSymbol({text: "foo"}));
this.layer.add(cursor);
} else {
cursor.setGeometry(endPoint);
cursor.draw();
}
})
You could use a TextSymbol to create a point with font type having numbers inside the circle. Here is one place where you can find such font. http://www.fontspace.com/the-fontsite/combinumerals
Wont be exactly as shown in the image but close enough. Also some limitation it wont work with IE9 or lower (this is as per esri documentation, as I am using halo to get the white border).
Here is the working Jsbin : http://jsbin.com/hayirebiga/edit?html,output use point of multipoint
PS: I have converted the ttf to otf and then added the font as base64, which is optional. I did it as I could not add the ttf or otf to jsbin.
Well, Achieve this seems impossible so far however ArcGIS JS API provides a new Application/platform where you can generate single symbol online for your applications.
We can simply create all kind of symbols(Provide by ESRI) online and it gives you on the fly code which you just need to paste in your application.
This will help us to try different type of suitable symbols for the applications.
Application URL: https://developers.arcgis.com/javascript/3/samples/playground/index.html
Hoping this will help you :)

Swift: Cannot access methods from declared library

On a side-note: I would like to apologize if the title is misleading. Couldn't find a better title for this question.
I imported the NDHTMLtoPDF library to my Xcode application.
In the demo of the library, this is how they use the library:
class NDViewController :UIViewController, NDHTMLtoPDFDelegate
{
var PDFCreator:NDHTMLtoPDF?
[...]
#IBAction func generatePDFUsingDelegate( sender:AnyObject ){
self.resultLabel?.text = "loading..."
let tt:NSString = ("~/Documents/delegateDemo.pdf" as NSString).stringByExpandingTildeInPath
self.PDFCreator = NDHTMLtoPDF.createPDFWithURL(NSURL(string:"http://edition.cnn.com/2012/11/12/business/china-consumer-economy/index.html?hpt=hp_c1")!, pathForPDF:tt, delegate: self, pageSize: CGSizeMake(595.2,841.8), margins:UIEdgeInsetsMake(10, 5, 10, 5)) as? NDHTMLtoPDF;
}
}
In my application, I do the same thing: I declare the PDFCreator variable as an NDHTMLtoPDF? type, I added NDHTMLtoPDFDelegate at the class declaration where I use the library instance, and I wrote the following code in my method:
let tt:NSString = ("~/Documents/delegateDemo.pdf" as NSString).stringByExpandingTildeInPath
self.PDFCreator = NDHTMLtoPDF!.createPDFWithHTML("Hello", pathForPDF: tt, pageSize: CGSizeMake(595.2,841.8), margins:UIEdgeInsetsMake(36, 36, 36, 36))
Every time I type self.PDFCreator = NDHTMLtoPDF!., I only get autocompletes for the following methods:
createPDFWithHTML(self:NDHTMLToPDF)
createPDFWithURL(self:NDHTMLToPDF)
If I type self.PDFCreator = NDHTMLtoPDF., Xcode complains that this is an ambiguous reference to member <insert_member_here>.
However, if I do self.PDFCreator., I suddenly get createPDFWithURL( URL:NSURL ,pathForPDF PDFpath:NSString ,delegate:AnyObject ,pageSize:CGSize ,margins pageMargins:UIEdgeInsets ) as an autocomplete option. I attempted to run my code with that only, but it turns out the method is never called (I checked by adding print calls in the methods).
I am seriously at a loss.
Thank you for any help you may provide!
If you need any extra code, let me know.
So after fiddling with it some more, I figured it out. The solution is simple: update the code to the latest Swift 2.0 syntax.
I took the liberty of forking the repository and fixing it myself. I made a pull request, but if you want to get a copy of it before they merge it into the official master branch, go grab it here.

How to add page numbers to the header of a word document using Delphi xe5

I would like to be able to add the page numbers in a word document to the header.
I have found some links that display the code in visual basic, but no matter what i try, i keep getting errors. It keeps telling me the either "sections" or "headers" or "footers" is not a supported automation object.
Any help would realy be great. Thank You.
Links:
http://blogs.technet.com/b/heyscriptingguy/archive/2006/05/10/how-can-i-add-centered-page-numbers-to-the-footer-of-a-word-document.aspx
http://msdn.microsoft.com/en-us/library/office/ff194253(v=office.14).aspx
I Tried addapting the link's code with no success:
wrdDoc.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).PageNumbers.Add
and if possible please how to allign the page number right.
Use [] instead of () for indexes
//Headers[wdHeaderFooterPrimary] = Headers[1]
//Add possible values:
//wdAlignPageNumberCenter = 1
//wdAlignPageNumberInside = 3
//wdAlignPageNumberLeft = 0
//wdAlignPageNumberOutside = 4
//wdAlignPageNumberRight =2
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(1); //example with center alignment
wrdDoc.Sections[1].Headers[1].PageNumbers.Add(2); //example with right alignment

Actionscript 3: Call to undefined method

I am brand new to Actionscript and this is one of my first "scripts" by myself so forgive me if this is obvious.
I have a movieclip with the name "Smiley"
and this is my actionscript in frame 1 of the actions layer
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
var smiley:MovieClip = addChild(new Smiley) as MovieClip; // **ERROR HERE**
stage.addEventListener(MouseEvent.MOUSE_DOWN,toggleSmiley);
stage.addEventListener(MouseEvent.MOUSE_UP,toggleSmiley);
function mousePosition(event:MouseEvent) {
smiley.x = mouseX; smiley.y = mouseY;
}
function toggleSmiley(e:MouseEvent):void
{
smiley.visible = (e.type == MouseEvent.MOUSE_DOWN);
}
See the line marked "ERROR HERE" above, thats where Flash is throwing the error.
I am getting this error:
Scene 1, Layer 'actions', Frame 1, Line 6 1180: Call to a possibly
undefined method Smiley.
Am confused as to where the problem is. Thanks in advance.
Your "Smiley" has not been linked for usage with ActionScript. It doesn't exist, as far as your script knows.
In the library, in "Smiley"'s Symbol Properties, check "Export for ActionScript".
In your library, you'll need to export your Smiley for Actionscript. Open up your library, select the square, and select the "properties" by right-clicking or cmd+clicking. Twirl down the "Advanced" section if it's not open already, then select "Export for Actionscript". In the "Class" field you should likely see the same name as it is in the library, "Smiley". This creates its own class which has the properties of the movie clip you designed in Flash.
Below this field, you'll see "Base Class", and it should have "flash.display.MovieClip". This means that your Smiley is already a movieclip, and it is just extended to be an extra special type now called Smiley, so you won't have to declare it as a MovieClip in your code when you instantiate it, because a Smiley is already a MovieClip.
Now go back to your actions, and you'll change the line you instantiate it with to:
var smiley:Smiley = new Smiley();
addChild(smiley);
In general, you want to call the constructor of a class first, ie: "new Smiley()", and then add it to the display list, rather than trying to do it all at once.

Resources