I am using below code to add a slide in PPT file at run time:
Presentation pres = ppta.Open(#"C:\Users\prabhat.kumar.yadav\Desktop\PPT\ParentPlan.pptx");
DataPrepration dataObject = new DataPrepration();//Populating Data
int noOfChildSlids = 19;//No of slide we need to add
int sildeInsertPosition = 22;//position where we need to insert child slide
int NoOfChilds = 2;
for (int j = 0; j < NoOfChilds - 1; j++)
{
int sildeCopyPosition = 3;//POstion from where we need to start copy slide
for (int i = 0; i < noOfChildSlids; i++)
{
Slide slideToCopy = pres.Slides[sildeCopyPosition++];
pres.Slides.CopySlide(slideToCopy, (sildeInsertPosition++));
}
}
But the section is not getting copied in the slide added at run time.
There was a bug in SoftArtisan's PowerPointWriter. This was fixed in version 10.1.2.350 of PowerPointWriter. This fix allows the notes of a slide to be copied when copying a slide.
Related
Hi guys I want the user to choose a list of files (txt file) and I wanna show the path of those file in a groupbox, I can do this perfectly in c# but I am having some problem with c++\cli
p.s I working in visual studio 2017 community
this is my code:
openFileDialog1 = gcnew System::Windows::Forms::OpenFileDialog();
openFileDialog1->InitialDirectory = DefaultProgramPath;
openFileDialog1->FileName = "";
openFileDialog1->Filter = "ESA Files (*.esa)|*.esa|txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1->FilterIndex = 1;
openFileDialog1->RestoreDirectory = true;
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
String^ toBeAdded= openFileDialog1->FileName;
Label^job = gcnew Label();
job->Text = toBeAdded;
job->Location.X = 150;
job->Location.Y = 250;
groupBox1->Controls->Add(job);
}
with this code the label is added to the groupbox But I can't set its position properly within it
Thanks for your help
System.Drawing.Point is a value type (struct in C#, value class/value struct in C++/CLI), therefore the property Location is returning a copy of its current location. In order to update it, you need to set the entire value type at once.
Point newLocation;
newLocation.X = 150;
newLocation.Y = 250;
job->Location = newLocation;
I am making a 2d(25x20) grid of sprites. But somehow sprites are getting re positioned by itself.enter image description here
makeLandBlocksMatrix : function () {
this.LAND_BLOCK_TAG = 1;
var blockCounter = 0;
var prices = MMMapData.getPrices();
this._blocks = MMUtility.createArray(MMConstants.totalNoRowsPerMap,MMConstants.totalNoColsPerMap);
for (var i = 0; i< MMConstants.totalNoRowsPerMap; i++){
for (var j = 0; j< MMConstants.totalNoColsPerMap; j++){
var block = new MMLandBlockSprite();
block.initWithData(res.BlockBlack,prices[blockCounter],this.LAND_BLOCK_TAG);
block.setPosition(cc.p(block.getContentSize().width*0.5 + i * block.getContentSize().width * 1.0, (this._size.height - block.getContentSize().height*0.5) - j * block.getContentSize().height * 1.0));
this.addChild(block);
block.setBg();
block._bg.setOpacity(0.0);
block.setPriceLabel();
block._priceLabel.setOpacity(0.0);
this._blocks[i][j] = block;
this.LAND_BLOCK_TAG++;
blockCounter++;
}
}
}
And same code is working fine with cocos2d-x(c++).
Thanks.
After lots of tweaks and googling, i just used lower version of cocos2d-html(version 3.7). And same code work as expected.There might be problem in rendering pipeline in latest cocos2d-html. And same issue persist in case we try to make Grid of UI component or Basic components(Sprite,Label) as components number increases positioning difference increases(i.e as show in reference image).
I am newbie in Unity platform. I have 2D game that contains 10 boxes vertically following each other in chain. When a box goes off screen, I change its position to above of the box at the top. So the chain turns infinitely, like repeating Parallax Scrolling Background.
But I check if a box goes off screen by comparing its position with a specified float value. I am sharing my code below.
void Update () {
offSet = currentSquareLine.transform.position;
currentSquareLine.transform.position = new Vector2 (0f, -2f) + offSet;
Vector2 vectorOne = currentSquareLine.transform.position;
Vector2 vectorTwo = new Vector2 (0f, -54f);
if(vectorOne.y < vectorTwo.y) {
string name = currentSquareLine.name;
int squareLineNumber = int.Parse(name.Substring (11)) ;
if(squareLineNumber < 10) {
squareLineNumber++;
} else {
squareLineNumber = 1;
}
GameObject squareLineAbove = GameObject.Find ("Square_Line" + squareLineNumber);
offSet = (Vector2) squareLineAbove.transform.position + new Vector2(0f, 1.1f);
currentSquareLine.transform.position = offSet;
}
}
As you can see, when I compare vectorOne.y and vectorTwo.y, things get ugly. Some boxes lengthen and some boxes shorten the distance between each other even I give the exact vector values in the code above.
I've searched for a solution for a week, and tried lots of codes like Mathf.Approximate, Mathf.Round, but none of them managed to compare float values properly. If unity never compares float values in the way I expect, I think I need to change my way.
I am waiting for your godlike advices, thanks!
EDIT
Here is my screen. I have 10 box lines vertically goes downwards.
When Square_Line10 goes off screen. I update its position to above of Square_Line1, but the distance between them increases unexpectedly.
Okay, I found a solution that works like a charm.
I need to use an array and check them in two for loops. First one moves the boxes and second one check if a box went off screen like below
public GameObject[] box;
float boundary = -5.5f;
float boxDistance = 1.1f;
float speed = -0.1f;
// Update is called once per frame
void Update () {
for (int i = 0; i < box.Length; i++) {
box[i].transform.position = box[i].transform.position + new Vector3(0, speed, 0);
}
for (int i = 0; i < box.Length; i++)
{
if(box[i].transform.position.y < boundary)
{
int topIndex = (i+1) % box.Length;
box[i].transform.position = new Vector3(box[i].transform.position.x, box[topIndex].transform.position.y + boxDistance, box[i].transform.position.z);
break;
}
}
}
I attached it to MainCamera.
Try this solution:
bool IsApproximately(float a, float b, float tolerance = 0.01f) {
return Mathf.Abs(a - b) < tolerance;
}
The reason being that the tolerances in the internal compare aren't good to use. Change the tolerance value in a function call to be lower if you need more precision.
Im beggineer in programming and i'm trying to delete the master slide usign the c# but it always throws an exception "Specified cast is not valid" Is there any way to delete the master slide or shapes on the master slide .. please suggest.
for (int i = 1; i <= SlideCount; i++)
{
int j=i;
slide = Slides[i];
//iterate over all the shapes of notespage of given slide to find the notespage's shape which has text.
for (int k = 1; k <= slide.NotesPage.Shapes.Count; k++)
{
var noteShape = slide.NotesPage.Shapes[k];
//check if the selected notespage has text or not
if (noteShape.Type ==MsoShapeType.msoPlaceholder)
{
if (noteShape.PlaceholderFormat.Type ==PpPlaceholderType.ppPlaceholderBody)
{
if (noteShape.HasTextFrame ==MsoTriState.msoTrue)
{
if (noteShape.TextFrame2.HasText ==MsoTriState.msoTrue)
{
//create a new slide
newslide = tempslides.AddSlide(++j, customLayout);
// set the title of newslide as the text of notepage of previous slide.
newslide.Shapes.Title.TextFrame.TextRange.Text = noteShape.TextFrame.TextRange.Text;
//delete the notepage text;
noteShape.TextFrame.TextRange.Delete();
//delete footer from slide.
//if (newslide.HeadersFooters.Footer.Visible == MsoTriState.msoTrue)
// newslide.HeadersFooters.Footer.Text = string.Empty;
//newslide.HeadersFooters.DateAndTime.Text = string.Empty;
//newslide.HeadersFooters.SlideNumber.Text = string.Empty;
newslide.HeadersFooters.Clear();
newslide.Master.Delete();
//jump to next slide
i++;
//increase the slide count becoz one slide has been added.
SlideCount = tempslides.Count;
}
}
}
}
}
}
You can't delete a master or layout that any slides are based on. Why do you want to delete the master slide?
To delete the shapes:
newslide.Master.Shapes.Range.Delete
That will delete the shapes from the slide master, but not the layout that the slide is based on, so it may not be exactly what you need.
Ok, so what i am doing is adding a new Overlay to an existing DICOM file & saving it(The DICOM file now has two overlays). Everything saves without errors & both DICOM viewers Sante & ClearCanvas-Workstation open the file, but only Sante displays both overlays.
Now when I look at the tags within the DICOM file, the OverlayData(6000) 'VR' is 'OW' & the OverlayData(6002) 'VR' is 'OB'.
So my problem is how to create a new Tag with a 'VR' of 'OW' because that is the correct one to use for OverlayData.
Here is the code i'm using to add the new Overlay to the DicomFile.DataSet::
NOTE, after I create the overlay I do write visible pixel data into it.
void AddOverlay()
{
int newOverlayIndex = 0;
for(int i = 0; i != 16; ++i)
{
if(!DicomFile.DataSet.Contains(GetOverlayTag(i, 0x3000)))
{
newOverlayIndex = i;
break;
}
}
//Columns
uint columnsTag = GetOverlayTag(newOverlayIndex, 0x0011);
DicomFile.DataSet[columnsTag].SetUInt16(0, (ushort)CurrentData.Width);
//Rows
uint rowTag = GetOverlayTag(newOverlayIndex, 0x0010);
DicomFile.DataSet[rowTag].SetUInt16(0, (ushort)CurrentData.Height);
//Type
uint typeTag = GetOverlayTag(newOverlayIndex, 0x0040);
DicomFile.DataSet[typeTag].SetString(0, "G");
//Origin
uint originTag = GetOverlayTag(newOverlayIndex, 0x0050);
DicomFile.DataSet[originTag].SetUInt16(0, 1);
DicomFile.DataSet[originTag].SetUInt16(1, 1);
//Bits Allocted
uint bitsAllocatedTag = GetOverlayTag(newOverlayIndex, 0x0100);
DicomFile.DataSet[bitsAllocatedTag].SetUInt16(0, 1);
//Bit Position
uint bitPositionTag = GetOverlayTag(newOverlayIndex, 0x0100);
DicomFile.DataSet[bitPositionTag].SetUInt16(0, 0);
//Data
uint dataTag = GetOverlayTag(newOverlayIndex, 0x3000);
DicomFile.DataSet[dataTag].SetNullValue();//<<< Needs to be something else
byte[] bits = new byte[(CurrentData.Width*CurrentData.Height)/8];
for(int i = 0; i != bits.Length; ++i) bits[i] = 0;
DicomFile.DataSet[dataTag].Values = bits;
}
public static uint GetOverlayTag(int overlayIndex, short element)
{
short group = (short)(0x6000 + (overlayIndex*2));
byte[] groupBits = BitConverter.GetBytes(group);
byte[] elementBtis = BitConverter.GetBytes(element);
return BitConverter.ToUInt32(new byte[]{elementBtis[0], elementBtis[1], groupBits[0], groupBits[1]}, 0);
}
So it would seem to me there would be some method like 'DicomFile.DataSet[dataTag].SetNullValue();' to create the tag with a 'VR' of 'OW'. Or maybe theres a totally different way to add an overlay in ClearCanvas idk...
Ok, my confusion was accually caused by a bug in my program.
I was trying to create the "Bit Position" tag by using element "0x0100" instead of "0x0102".
OW vs OB is irrelevant.
Sorry about that...