Join a Line and Ellipse - join

I did find how to bind a line to an ellipse through XAML, but I'm not very familiar with binding, and though I've researched it, I still don't understand how to get binding to work with user input.
Is there a way, programmatically to have an ellipse joined to the end of a line so when the line rotates on a diameter, the ellipse rotates with it? Everything I wrote for this is done in the code, not XAML.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public void geo()
{
freeCanvas.Children.Clear();
double one, two, three, four, ang;
if(double.TryParse(txtOne.Text, out one))
if(double.TryParse(txtTwo.Text, out two))
if(double.TryParse(txtThree.Text, out three))
if (double.TryParse(txtFour.Text, out four))
if(double.TryParse(txtAngle.Text, out ang))
{
RotateTransform ans = new RotateTransform();
ans.Angle = ang;
ans.CenterX = 75;
ans.CenterY = 150;
Line lineA = new Line();
lineA.Stroke = Brushes.Black;
lineA.StrokeThickness = 2;
lineA.X1 = 75;
lineA.Y1 = 150;
lineA.X2 = 75;
lineA.Y2 = 250;
lineA.HorizontalAlignment = HorizontalAlignment.Center;
lineA.VerticalAlignment = VerticalAlignment.Top;
freeCanvas.Children.Add(lineA);
Line lineB = new Line();
lineB.Stroke = Brushes.Black;
lineB.StrokeThickness = 2;
lineB.X1 = 75;
lineB.Y1 = 50;
lineB.X2 = 75;
lineB.Y2 = 150;
//lineB.HorizontalAlignment = HorizontalAlignment.Center;
//lineB.VerticalAlignment = VerticalAlignment.Top;
lineB.RenderTransform = ans;
freeCanvas.Children.Add(lineB);
Line lineC = new Line();
lineC.Stroke = Brushes.Black;
lineC.StrokeThickness = 2;
lineC.X1 = -25;
lineC.Y1 = 150;
lineC.X2 = 175;
lineC.Y2 = 150;
lineC.HorizontalAlignment = HorizontalAlignment.Center;
lineC.VerticalAlignment = VerticalAlignment.Top;
freeCanvas.Children.Add(lineC);
PathFigure pthFigure = new PathFigure();
pthFigure.StartPoint = new Point(-25, 150);
ArcSegment arcSeg = new ArcSegment();
arcSeg.Point = new Point(175, 150);
arcSeg.Size = new Size(100, 100);
arcSeg.IsLargeArc = true;
arcSeg.SweepDirection = SweepDirection.Clockwise;
arcSeg.RotationAngle = 90;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(arcSeg);
pthFigure.Segments = myPathSegmentCollection;
PathFigureCollection pthFigureCollection = new PathFigureCollection();
pthFigureCollection.Add(pthFigure);
PathGeometry pthGeometry = new PathGeometry();
pthGeometry.Figures = pthFigureCollection;
Path arcPath = new Path();
arcPath.Stroke = new SolidColorBrush(Colors.Black);
arcPath.StrokeThickness = 1.5;
arcPath.Data = pthGeometry;
//arcPath.Fill = new SolidColorBrush(Colors.Yellow);
freeCanvas.Children.Add(arcPath);
Ellipse ellA = new Ellipse();
ellA.Width = 10;
ellA.Height = 10;
ellA.Stroke = Brushes.Black;
ellA.Fill = Brushes.Lime;
TranslateTransform ella1 = new TranslateTransform(70, 145);
ellA.RenderTransform = ella1;
freeCanvas.Children.Add(ellA);
Ellipse ellB = new Ellipse();
ellB.Width = 10;
ellB.Height = 10;
ellB.Stroke = Brushes.Black;
ellB.Fill = Brushes.Yellow;
TranslateTransform ellb1 = new TranslateTransform(70, 45);
ellB.RenderTransform = ellb1;
freeCanvas.Children.Add(ellB);
}
}
private void btnTest_Click(object sender, RoutedEventArgs e)
{
geo();
}
}
}

Never mind, I figured it out. I posted the segment of code that provided the answer.
Rads = Math.PI * ang / 180;
x1 = Math.Sin(Rads) * 80;
y1 = Math.Cos(Rads) * 80;
x2 = Math.Sin(Rads) * 30;
y2 = Math.Cos(Rads) * 30;
Ellipse ellA = new Ellipse();
ellA.Width = 10;
ellA.Height = 10;
ellA.Stroke = Brushes.Black;
ellA.Fill = Brushes.Lime;
TranslateTransform ella1 = new TranslateTransform(70 + x1, 145 - y1);
ellA.RenderTransform = ella1;
freeCanvas.Children.Add(ellA);
Ellipse ellB = new Ellipse();
ellB.Width = 10;
ellB.Height = 10;
ellB.Stroke = Brushes.Black;
ellB.Fill = Brushes.Yellow;
TranslateTransform ellb1 = new TranslateTransform(70 + x2, 145 - y2);
ellB.RenderTransform = ellb1;
freeCanvas.Children.Add(ellB);

Related

i am new in action script. trying to split a sentence into words and show them in sprite.and also need which sprite i clicked

I am trying to split a sentence in to words and show them into sprite()
var sentence:String = "My name is Subhadip.";
var txt:Array = new Array();
var splittedSentence:Array = sentence.split(" ");
var myArraySprites:Array = new Array();
var myTextImage:Array = new Array();
var div = 40;
for (var i:int = 0; i < splittedSentence.length; i++)
{
var v = 300 - (div * i);
//...
txt[i] = new TextField();
txt[i].autoSize = TextFieldAutoSize.CENTER;
txt[i].text = splittedSentence[i];
var format1:TextFormat = new TextFormat();
format1.size = 24;
txt[i].setTextFormat(format1);
trace(txt[i]);
myArraySprites[i] = new Sprite();
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill( 0xfffffff );
myArraySprites[i].graphics.drawRect(50, v, 150, div);
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
myTextImage[i].draw(txt[i]);
trace(myTextImage[i]);
//myArraySprites[i].graphics.beginBitmapFill(myTextImage[i]);
//myArraySprites[i].graphics.endFill();
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
}
function removeThis(e:MouseEvent):void
{
var clickTarget:int = myArraySprites.indexOf(e.currentTarget);
trace("Clicked sprite (id): " + clickTarget);
}
[enter image description here][1]
trying to split a sentence into words and show them in sprite.and also need which sprite i clicked
[1]: https://i.stack.imgur.com/RzHUQ.png
The problem is that you're dealing with screen positions in two different places:
myArraySprites[i].graphics.drawRect(50, v, 150, div);
and
myTextImage[i] = new BitmapData(100,v,true,0xffffff);
Think of it in a more object-oriented way. Each Sprite instance you want to be clickable is a single object. As such it also holds the main properties e.g. the on-screen position determined by it's x and y properties.
Each of those sprites have equal width & height, so make this a global property.
var wid:Number = 150;
var hei:Number = 40;
If we look at your .png, we can see that you want to have a single word centered inside such a sprite. To make things easier, we can use the .align property of the TextFormat class, set it to "center" and make each TextField 150 x 40 by using the wid and hei properties.
Finally each sprite's vertical screen position is shifted up by hei == 40 pixels. So let's determine a start position:
var yPos:Number = 300;
assign it to a sprite instance:
myArraySprites[i].x=50;
myArraySprites[i].y=yPos;
and decrement it by hei inside the for-loop.
Everything put together:
var yPos:Number = 300;
var wid:Number = 150;
var hei:Number = 40;
var sentence:String = "My name is Subhadip.";
var txt:TextField = new TextField();
txt.width = wid;
txt.height = hei;
var format1:TextFormat = new TextFormat();
format1.size = 24;
format1.align = "center";
var splittedSentence:Array = sentence.split(" ");
var myTextImage:Array = new Array();
for (var i:int = 0; i<splittedSentence.length; i++)
{
txt.text = splittedSentence[i];
txt.setTextFormat(format1);
myArraySprites[i] = new Sprite();
myArraySprites[i].x = 50;
myArraySprites[i].y = yPos;
myArraySprites[i].graphics.lineStyle(1, 0x000000, 1);
myArraySprites[i].buttonMode = true;
myArraySprites[i].graphics.beginFill(0xfffffff);
myArraySprites[i].graphics.drawRect(0, 0, wid, hei);
myTextImage[i] = new BitmapData(wid, hei, true, 0xffffff);
myTextImage[i].draw(txt);
myArraySprites[i].addChild(new Bitmap(myTextImage[i]));
addChild(myArraySprites[i]);
myArraySprites[i].addEventListener(MouseEvent.CLICK, removeThis);
yPos -= hei;
}

How to update List View Model in Asp.net MVC

Hi I am facing issue in update records in MVC. I have created one list view model and in that i want to update some of the records but i am getting error. Please help me.
Here is my code:
public async Task<bool> AddPurchase(PurchaseOrderViewModel objModel, List<TableViewModel> tableListDto)
{
using (var txn = context.Database.BeginTransaction())
{
bool success = true;
try
{
PurchaseOrder purchase1 = new PurchaseOrder();
purchase1.LoginID = objModel.LoginID;
purchase1.SupplierID = objModel.SupplierID;
purchase1.SupplierName = objModel.SupplierName;
purchase1.LocationID = objModel.LocationID;
purchase1.Notes = objModel.Notes;
purchase1.Currency = objModel.Currency;
purchase1.TotalQuantity = objModel.TotalQuantity;
purchase1.TotalAmount = objModel.TotalAmount;
purchase1.TotalVolume = objModel.TotalVolume;
purchase1.TotalWeight = objModel.TotalWeight;
purchase1.TotalLandedCost = Convert.ToDecimal(objModel.TotalCost);
purchase1.TotalOtherCost = objModel.TotalOtherCost;
purchase1.Date_Of_Purchase = objModel.Date_Of_Purchase;
purchase1.Due_Date = objModel.Due_Date;
purchase1.Date_Arrived = objModel.Date_Arrived;
purchase1.Date_Departed = objModel.Date_Departed;
purchase1.CreatedBy = objModel.LoginID;
purchase1.CreatedOn = objModel.CreatedOn;
purchase1.UpdatedBy = objModel.LoginID;
purchase1.UpdatedOn = objModel.UpdatedOn;
purchase1.Status = StatusConstant.Active;
context.PurchaseOrders.Add(purchase1);
await context.SaveChangesAsync();
success = true;
int latest = purchase1.PurchaseID;
PO_Landed_Cost cost = new PO_Landed_Cost();
cost.LoginID = objModel.LoginID;
cost.PurchaseID = latest;
cost.Packaging_Costs = objModel.Packaging_Cost;
cost.Packaging_Costs_Date_Paid = objModel.Packaging_Costs_Date_Paid;
cost.Inspection_Costs = objModel.Inspection_Cost;
cost.Inspection_Costs_Date_Paid = objModel.Inspection_Costs_Date_Paid;
cost.Freight_And_Duty_Tax = objModel.Freight_Cost;
cost.Freight_And_Duty_Tax_Date_Paid = objModel.Freight_And_Duty_Tax_Date_Paid;
cost.Other_Costs = objModel.Other_Cost;
cost.Total_Landed_Cost = objModel.TotalOtherCost;
context.PO_Landed_Costs.Add(cost);
context.SaveChanges();
OrderDetail order = new OrderDetail();
PO_Landed_Cost_Spread spread1 = new PO_Landed_Cost_Spread();
List<DataDisplayViewModel> data = new List<DataDisplayViewModel>();
if (tableListDto != null)
{
foreach (var item in tableListDto)
{
//First we take all the basic things
var a = Convert.ToDecimal(item.Qty); //Quantity
var b = Convert.ToDecimal(purchase1.TotalQuantity); //Total Quantity
var e = Convert.ToDecimal(objModel.TotalOtherCost); //TotalOtherCost
var g = Convert.ToDecimal(item.Price); //Price
var j = Convert.ToDecimal(item.Volume); //Volume
var l = Convert.ToDecimal(item.Weight); //Weight
var c = Math.Round(Convert.ToDecimal((a / b) * 100), 2); //Total Percent(Quantity)
var f = Math.Round(Convert.ToDecimal(((c * e) / a) / 100), 2); // Quantity Unit Price(Indirect Cost)
var h = Math.Round(Convert.ToDecimal(f + g), 2); //Landed Cost Unit Price (Quantity)
var i = Math.Round(Convert.ToDecimal(h * a), 2); //New Total (Quantity)
var k = Math.Round(Convert.ToDecimal(a * j), 2); //Total Volume
var m = Math.Round(Convert.ToDecimal(a * l), 2); //Total Weight
DataDisplayViewModel datalist = new DataDisplayViewModel();
datalist.LoginID = objModel.LoginID;
datalist.PurchaseID = latest;
datalist.Stock_ID = item.Pid;
datalist.Stock_Name = item.ProductName;
datalist.Quantity = Convert.ToInt32(item.Qty);
datalist.Price = Convert.ToDecimal(item.Price);
datalist.Amount = Convert.ToDecimal(item.Amount);
datalist.Volume = Convert.ToInt32(item.Volume);
datalist.Total_Volume = Convert.ToInt32(k);
datalist.Weight = Convert.ToInt32(item.Weight);
datalist.Total_Weight = Convert.ToInt32(m);
datalist.Total_Percent = Convert.ToString(c);
datalist.Indirect_Cost_UnitPrice = Convert.ToString(f);
datalist.Landed_Cost_UnitPrice = Convert.ToString(h);
datalist.New_Amount = i;
data.Add(datalist);
}
var totalweight = data.Where(x => x.PurchaseID == latest).Select(x => x.Total_Weight).Sum();
var totalvolume = data.Where(x => x.PurchaseID == latest).Select(x => x.Total_Volume).Sum();
foreach (var item in tableListDto)
{
var z = Convert.ToInt32(item.Price);
var a = Convert.ToInt32(item.Qty); //Qty
var l = Convert.ToDecimal(item.Weight); //Weight
var j = Convert.ToDecimal(item.Volume); //Volume
var d = Math.Round(Convert.ToDecimal(((a * l) / totalweight) * 100), 2); //Total Percent Of Weight
var e = Convert.ToInt32(objModel.TotalOtherCost); //Total Other Cost
var f = Math.Round(Convert.ToDecimal(((d * e) / a) / 100), 2);
var h = Convert.ToDecimal(a + f); // Landed Cost Unit Price Of Weight
var i = Convert.ToString(h * a); // New Total Of Weight
var m = (a * j / totalvolume) * 100; //Total Percent Of Volume
var o = Math.Round(Convert.ToDecimal(((m * e) / a) / 100), 2); //Unit Price Of Volume
var q = Math.Round(Convert.ToDecimal(z + o), 2); // Landed Cost Unit Price Of Volume
var r = Convert.ToInt32(q * a); //New Total Of Volume
data.Where(x => x.PurchaseID == latest).FirstOrDefault();
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Indirect_Cost_WeightUnitPrice = Convert.ToString(f);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Landed_Cost_WeightUnitPrice = Convert.ToString(h);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().New_WeightAmount = Convert.ToDecimal(i);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Total_Percent_Volume = Convert.ToString(m);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Indirect_Cost_VolumeUnitPrice = Convert.ToString(o);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Landed_Cost_VolumeUnitPrice = Convert.ToString(q);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().New_VolumeAmount = Convert.ToDecimal(r);
context.Entry(data).State = EntityState.Added;
context.SaveChanges();
}
foreach (var item in data)
{
order.LoginID = objModel.LoginID;
order.PurchaseID = item.PurchaseID;
order.Stock_ID = item.Stock_ID;
order.Quantity = item.Quantity;
order.Price = item.Price;
order.Amount = item.Amount;
order.CreatedBy = objModel.LoginID;
order.CreatedOn = objModel.CreatedOn;
order.UpdatedBy = objModel.LoginID;
order.UpdatedOn = objModel.UpdatedOn;
order.Status = StatusConstant.Active;
order.Stock_Name = item.Stock_Name;
order.Volume = item.Volume;
order.Total_Volume = item.Total_Volume;
order.Weight = item.Weight;
order.Total_Weight = item.Total_Weight;
context.OrderDetails.Add(order);
context.SaveChanges();
spread1.PurchaseID = item.PurchaseID;
spread1.OrderID = order.OrderID;
spread1.LoginID = item.LoginID;
spread1.Total_Percent = item.Total_Percent;
spread1.Indirect_Cost_UnitPrice = item.Indirect_Cost_UnitPrice;
spread1.Landed_Cost_UnitPrice = item.Landed_Cost_UnitPrice;
spread1.New_Amount = item.New_Amount;
spread1.Total_Percent_Volume = item.Total_Percent_Volume;
spread1.Indirect_Cost_VolumeUnitPrice = item.Indirect_Cost_VolumeUnitPrice;
spread1.Landed_Cost_VolumeUnitPrice = item.Landed_Cost_VolumeUnitPrice;
spread1.New_VolumeAmount = item.New_VolumeAmount;
spread1.Total_Percent_Weight = item.Total_Percent_Weight;
spread1.Indirect_Cost_WeightUnitPrice = item.Indirect_Cost_WeightUnitPrice;
spread1.Landed_Cost_WeightUnitPrice = item.Landed_Cost_WeightUnitPrice;
spread1.New_WeightAmount = item.New_WeightAmount;
context.PO_Landed_Cost_Spreads.Add(spread1);
context.SaveChanges();
}
}
else
{
order.LoginID = objModel.LoginID;
order.PurchaseID = latest;
order.CreatedBy = objModel.LoginID;
order.CreatedOn = objModel.CreatedOn;
order.UpdatedBy = objModel.LoginID;
order.UpdatedOn = objModel.UpdatedOn;
order.Status = StatusConstant.Active;
context.OrderDetails.Add(order);
context.SaveChanges();
PO_Landed_Cost_Spread spread = new PO_Landed_Cost_Spread();
spread.LoginID = objModel.LoginID;
spread.PurchaseID = latest;
spread.OrderID = order.OrderID;
context.PO_Landed_Cost_Spreads.Add(spread);
context.SaveChanges();
}
txn.Commit();
}
catch (Exception ex)
{
txn.Dispose();
success = false;
}
return success;
};
}
In this code i want to update records when first i need to find some values and then i need to update in the list view model and then i need to update in the table. But i am unable to do that. Please help me in this.

Automatically Slicing Large TIFF File with Photoshop and Save Slices into TIFF Files?

I have a TIFF file. I want to slice it automatically (specifying the number of slices in horizontal and vertical) and save them into TIFF files (I don't want to change the format to png or ...)
I know that in photoshop you can choose the slice tool>>right click>>Divide Slice>>Save for web
However, the "Save for web" doesn't offer saving in TIFF Format and also I don't think it can work for large file (which is the case here).
Anything that can help (script, plugin) is welcome
With the help of some online codes, I created the script below which is capable of automatically slicing a big TIFF into smaller Tiff files:
#target photoshop
function main(){
if(!documents.length) return;
var dlg=
"dialog{text:'Script Interface',bounds:[100,100,380,290],"+
"panel0:Panel{bounds:[10,10,270,180] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"title:StaticText{bounds:[60,10,220,40] , text:'File Chop' ,properties:{scrolling:undefined,multiline:undefined}},"+
"panel1:Panel{bounds:[10,40,250,130] , text:'' ,properties:{borderStyle:'etched',su1PanelCoordinates:true},"+
"statictext1:StaticText{bounds:[10,10,111,30] , text:'Accross' ,properties:{scrolling:undefined,multiline:undefined}},"+
"statictext2:StaticText{bounds:[140,10,230,27] , text:'Down' ,properties:{scrolling:undefined,multiline:undefined}},"+
"across:DropDownList{bounds:[10,30,100,50]},"+
"down:DropDownList{bounds:[140,30,230,50]},"+
"saveFiles:Checkbox{bounds:[10,60,230,80] , text:'Save and Close new files?'}},"+
"button0:Button{bounds:[10,140,110,160] , text:'Ok' },"+
"button1:Button{bounds:[150,140,250,160] , text:'Cancel' }}};"
var win = new Window(dlg,'File Chop');
if(version.substr(0,version.indexOf('.'))>9){
win.panel0.title.graphics.font = ScriptUI.newFont("Georgia","BOLD",20);
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [1.00, 1.00, 1.00, 1]);
g.backgroundColor = myBrush;
var myPen =g.newPen (g.PenType.SOLID_COLOR, [1.00, 0.00, 0.00, 1],lineWidth=1);
}
win.center();
for(var i=1;i<31;i++){
win.panel0.panel1.across.add ('item', i);
win.panel0.panel1.down.add ('item', i);
}
win.panel0.panel1.across.selection=0;
win.panel0.panel1.down.selection=0;
var done = false;
while (!done) {
var x = win.show();
if (x == 0 || x == 2) {
win.canceled = true;
done = true;
} else if (x == 1) {
done = true;
{
if(!documents.length)return;
var startRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
doc = app.activeDocument;
app.displayDialogs = DialogModes.NO;
doc.flatten();
var tilesAcross = parseInt(win.panel0.panel1.across.selection.index)+1;
var tilesDown =parseInt(win.panel0.panel1.down.selection.index)+1;
var tileWidth = parseInt(doc.width/tilesAcross);
var tileHeight = parseInt(doc.height/tilesDown);
var SaveFiles = win.panel0.panel1.saveFiles.value;
ProcessFiles(tilesDown,tilesAcross,tileWidth,tileHeight,SaveFiles);
app.preferences.rulerUnits = startRulerUnits;
}
}
}
}
main();
function ProcessFiles(Down,Across,offsetX,offsetY,SaveFiles){
try{
var newName = activeDocument.name.match(/(.*)\.[^\.]+$/)[1];
}catch(e){var newName="UntitledChop"}
var Path='';
try{
Path = activeDocument.path;
}catch(e){Path = "~/Desktop";}
if(SaveFiles){
Path = Folder(decodeURI(Path) +"/FileChop");
if(!Path.exists) Path.create();
}
TLX = 0; TLY = 0; TRX = offsetX; TRY = 0;
BRX = offsetX; BRY = offsetY; BLX = 0; BLY = offsetY;
for(var a = 0; a < Down; a++){
for(var i = 0;i <Across; i++){
var NewFileName = newName +"#"+a+"-"+i;
app.activeDocument.duplicate (NewFileName, true);
activeDocument.selection.select([[TLX,TLY],[TRX,TRY],[BRX,BRY],[BLX,BLY]], SelectionType.REPLACE, 0, false);
executeAction( charIDToTypeID( "Crop" ), undefined, DialogModes.NO );
app.activeDocument.selection.deselect();
if(SaveFiles){
var saveFile = File(decodeURI(Path+"/"+NewFileName+".tiff"));
SaveTIFF(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
activeDocument = documents[0];
TLX = offsetX * (i+1) ; TRX = TLX + offsetX; BRX = TRX; BLX = TLX;
}
TLX = 0; TLY = offsetY * (a +1); TRX = offsetX; TRY = offsetY * (a +1);
BRX = offsetX; BRY = TRY + offsetY; BLX = 0; BLY = (offsetY * (a +1)+offsetY);
}
if(SaveFiles){
Path.execute()
}
}
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.NONE;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
}

delphi ole excel container, save file

what is the syntax for this c++ question in Delphi?
After using an oleContainer, and trying to do SaveDocumentAs which didn't work. I thought this might be a good alternative.
update: thank you for the translation, however the excel file goes curropted after the call
var
ExcelOle: TOleContainer;
begin
ExcelOLE.CreateObjectFromFile(FileName, False);
ExcelOle.OleObject.application.workbooks[1].save;
end;
Simply create an Ole Object:
uses ComObj, Excel;
var Excel: OleVariant;
Excel := CreateOleObject('EXCEL.Application');
Excel.Application.Workbooks.Add;
Excel.Application.Workbooks[1].SaveAs('c:\test.xlsx', xlWorkbookDefault); // or xlOpenXMLWorkbook (51)
Excel.Application.Quit;
Excel.pas
unit Excel;
interface
uses Windows, Activex;
// originally from Excel97.pas
// XlFileFormat constants
type
XlFileFormat = TOleEnum;
const
xlAddIn = $00000012;
xlCSV = $00000006;
xlCSVMac = $00000016;
xlCSVMSDOS = $00000018;
xlCSVWindows = $00000017;
xlDBF2 = $00000007;
xlDBF3 = $00000008;
xlDBF4 = $0000000B;
xlDIF = $00000009;
xlExcel2 = $00000010;
xlExcel2FarEast = $0000001B;
xlExcel3 = $0000001D;
xlExcel4 = $00000021;
xlExcel5 = $00000027;
xlExcel7 = $00000027;
xlExcel9795 = $0000002B;
xlExcel4Workbook = $00000023;
xlIntlAddIn = $0000001A;
xlIntlMacro = $00000019;
xlWorkbookNormal = $FFFFEFD1;
xlSYLK = $00000002;
xlTemplate = $00000011;
xlCurrentPlatformText = $FFFFEFC2;
xlTextMac = $00000013;
xlTextMSDOS = $00000015;
xlTextPrinter = $00000024;
xlTextWindows = $00000014;
xlWJ2WD1 = $0000000E;
xlWK1 = $00000005;
xlWK1ALL = $0000001F;
xlWK1FMT = $0000001E;
xlWK3 = $0000000F;
xlWK4 = $00000026;
xlWK3FM3 = $00000020;
xlWKS = $00000004;
xlWorks2FarEast = $0000001C;
xlWQ1 = $00000022;
xlWJ3 = $00000028;
xlWJ3FJ3 = $00000029;
xlExcel12 =50;
xlExcel8 = 56;
xlHtml = 44;
xlOpenXMLAddIn = 55;
xlOpenXMLTemplate = 54;
xlOpenXMLTemplateMacroEnabled = 53;
xlOpenXMLWorkbook = 51;
xlOpenXMLWorkbookMacroEnabled = 52;
xlTemplate8 = 17;
xlUnicodeText = 42;
xlWebArchive = 45;
xlWorkbookDefault = 51;
xlXMLSpreadsheet = 46;
implementation
end.

Microsoft charts: transparency

I want a chart with transparent background, and therefore PNG seems a good choice. But when I set transparent background, the quality of the axis labels falls dramatically. How do I fix this? See the following code. As it stands, the chart has a transparent background, as I want, but the text quality is atrocious. If I comment out the two "Color.Transparent" settings, then the text quality is nice, but the background is not transparent.
How do I get transparency and nice text?
public static void Main(string[] args)
{
Chart c = new Chart();
c.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
Series s = new Series("Series1");
c.Series.Clear();
c.Series.Add(s);
s.ChartType = SeriesChartType.Line;
s.Color = Color.Black;
ChartArea chartArea = new ChartArea("ChartArea1");
c.ChartAreas.Clear();
c.ChartAreas.Add(chartArea);
chartArea.BackColor = Color.FromArgb(255, 255, 255);
chartArea.BackSecondaryColor = Color.FromArgb(220, 220, 220);
chartArea.BackGradientStyle = GradientStyle.TopBottom;
chartArea.AxisX.LineColor = Color.Gray;
chartArea.AxisX.LineWidth = 2;
chartArea.AxisX.LineDashStyle = ChartDashStyle.Solid;
chartArea.AxisY.LineColor = Color.Gray;
chartArea.AxisY.LineWidth = 2;
chartArea.AxisY.LineDashStyle = ChartDashStyle.Solid;
chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
chartArea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
c.BackColor = Color.Transparent;
chartArea.BackColor = Color.Transparent;
double[] x = new double[] { 1999, 2005 };
double[] y = new double[] { 3210, 13456 };
Axis ay = chartArea.AxisY;
ay.Maximum = 13456;
ay.Minimum = 3210;
Axis ax = chartArea.AxisX;
ax.Maximum = 2005;
ax.Minimum = 1999;
for (int i = 0; i < x.Length; i++)
{
double xvalue = x[i];
double yvalue = y[i];
s.Points.AddXY(xvalue, yvalue);
}
// Save chart-image to disk:
c.SaveImage("chartimage.png", ChartImageFormat.Png);
}
Set chart's AntiAliasing to AntiAliasingStyles.Graphics to disable the antialiasing on text.
Taken from this thread.
Maybe this help you
in your .aspx file where your chart code is, look for the asp:ChartArea tag. then add BackColor = "Transparent".
<asp:ChartArea Name="ChartArea1" BackColor="Transparent"
</asp:ChartArea>
Hope this help.
chart.TextAntiAliasingQuality = TextAntiAliasingQuality.SystemDefault;
I read this from here: http://forums.asp.net/p/1656335/4315304.aspx?Re%20Chart%20transparency%20and%20text%20quality

Resources