About collapse panel which panel selected - select

I have a question about collapse panel..
I have a placeholder and I add more than one headerpanel, contentpanel, collapsiblepanel dynamically.. Here is my code :
CollapsiblePanelExtender cpe = new CollapsiblePanelExtender();
Panel pnlheader,pnlcontent;
Label lblcontent,lblheader; Button btn;
for (int i = 0; i < 10; i++)
{
///// PANEL HEADER VE ICERIGI //////////
pnlheader = new Panel();
pnlheader.ID = "PanelHeader" + i;
pnlheader.BackColor = System.Drawing.Color.Blue;
lblheader = new Label();
lblheader.ID = "LabelHeader" + i.ToString();
lblheader.Text = (i + 1) + ". Header";
pnlheader.Controls.Add(lblheader);
/////////PANEL CONTENT VE ICERIGI //////////
pnlcontent = new Panel();
pnlcontent.ID = "PanelContent" + i;
pnlcontent.BackColor = System.Drawing.Color.DarkRed;
lblcontent = new Label();
lblcontent.ID = "LabelContent" + i.ToString();
lblcontent.Text = "<table><tr><td border=\"1\">DENEMEE</td></tr></table>";
btn = new Button();
btn.ID = "Button" + i.ToString();
btn.Text = "Deneme.Button";
pnlcontent.Controls.Add(lblcontent);
pnlcontent.Controls.Add(btn);
///////// COLLAPSEPANEL ICERIGI///////
cpe = new CollapsiblePanelExtender();
cpe.ID = "CollapsePanel" + i;
cpe.TargetControlID = "PanelContent" + i;
cpe.ExpandControlID = "PanelHeader" + i;
cpe.CollapseControlID = "PanelHeader" + i;
PlaceHolder2.Controls.Add(pnlheader);
PlaceHolder2.Controls.Add(pnlcontent);
PlaceHolder2.Controls.Add(cpe);
}
How can I understand which panel expanded..
it is very important, please help..

Firstly you should to find all controls of CollapsiblePanelExtender type inside the scope of PlaceHolder2.
Then you'll be able to get Collapsed property of each found CollapsiblePanelExtender instance.

Related

How to NOT flatten the image applied in a pdf with Itext in c#?

I need to apply an image on all my pages from my PDF, but without flattening it ( I want to have the ability to move it in my PDF reader afterwards)
My code:
String basePath = "d:\\zPDF\\";
DirectoryInfo d = new DirectoryInfo(basePath);//Assuming Test is your Folder
FileInfo[] Files = d.GetFiles("*.pdf"); //Getting Text files
List<string> listS = new List<string>();
foreach (FileInfo file in Files)
{
listS.Add(file.Name);
}
foreach (string s in listS)
{
using (System.IO.Stream inputPdfStream = new FileStream(basePath + s, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite))
//using (System.IO.Stream inputImageStream = new FileStream(basePath + "x1.wmf", FileMode.Open, System.IO.FileAccess.Read, FileShare.Read))
using (System.IO.Stream inputImageStream2 = new FileStream(basePath + "x2.wmf", FileMode.Open, System.IO.FileAccess.Read, FileShare.Read))
using (System.IO.Stream outputPdfStream = new FileStream(basePath + "zResult" + s, FileMode.Create, System.IO.FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
//stamper.FormFlattening = true;
//stamper.FreeTextFlattening = true;
int numberOfPages = reader.NumberOfPages;
Image myImage = Image.GetInstance(inputImageStream2);
float f-Image1, f-Image2;
for (int i = 1; i <= numberOfPages; i++)
{
int nr, plusMinus = 25;
Rectangle mediabox = reader.GetPageSize(i);
int getTOP = (int)mediabox.GetTop(0);
int getRight = (int)mediabox.GetRight(0);
var pdfContentByte = stamper.GetOverContent(i);
nr = getRight - 600;
f-Image1 = row1(nr, nr + plusMinus);
//row1 - generates a random number between those 2 values
nr = 40;
f-Image2 = row1(nr, nr + plusMinus);
//row1 - generates a random number between those 2 values
myImage.SetAbsolutePosition(f-Image1, f-Image2);
myImage.RotationDegrees = row1(-35, 35);
pdfContentByte.AddImage(myImage);
}
stamper.Close();
}
I've tried:
stamper.FormFlattening = false;
stamper.FreeTextFlattening = false;
but no results. The image is still flatten.
I think, after I've read some posts, that I need to set up my PdfStamper in useAppendMode() but I don't know how should I do this and, I don't know if this is this right direction.

Object does not return to original position when released cs4

I am making a drag and drop activity where multiple items are to be placed at the same target. I have action code on the main time line and then code attached to a sprite.
Problems:
When I release the object if it is correct it should snap to the top of that section. If it is incorrect it should return to its original orientation to be picked up again. Unfortunately it stays where I placed it, and does not move back to original place when it is incorrect. I have fixed other issues with this flash file as to if code is supposed to be on the main time line or in the sprite, but this does not seem to have an effect after the object is released. Near the end of the script there is _root.rlamp1.gotoAndPlay(1) this is a buzzer that goes off if the answer is incorrect. This is working correctly.
I do not know if these are related Items but if the correct placement is given I want the next item to start in the original position, but it is starting where my mouse is instead of the original position. I am relatively new to coding and am trying to make an activity for my science class to get instant feedback to see if they understand to concept.
Thanks for your help.
// [Action in Frame 1]
answername = Array();
answerdest = Array();
answername[0] = "gravel";
answerdest[0] = "1";
answername[1] = "nuts and bolts";
answerdest[1] = "1";
answername[2] = "oxygen";
answerdest[2] = "2";
answername[3] = "helium";
answerdest[3] = "2";
answername[4] = "gold";
answerdest[4] = "2";
dbCount = 0;
dbutton.duplicateMovieClip("dbutton" + dbCount,dbCount * 100);
dbutton.visible = false;
dbutton0.answer = answerdest[dbCount];
dbutton0.theText.text = answername[dbCount];
// This code is on the sprite and not on the main actionscript
onClipEvent (load)
{
this.defx = _x;
this.defy = _y;
if (this.theText.text.length > 20)
{
this.theText._height = 31;
this.theBox._height = 27;
}
else
{
this.theText._height = 19;
this.theBox._height = 19;
} // end else if
}
on (press)
{
if (this.noDrag !=true)
{
startDrag (this,false);
}
}
on (release)
{
if (this.noDrag != true)
{
stopDrag ();
if(this.hitTest(_root["dz" + this.answer]))
{
totalHeight = 0;
for (v = 0; v < _root.dbCount; v++)
{
if (_root["dbutton" + v].answer == this.answer)
{
totalHeight = totalHeight + _root["button" + v].theBox._height ;
} // end if
} // end of for
++_root.dbCount;
this .duplicateMovieClip("dbutton" + _root.dbCount, _root.dbCount * 100);
_root["dbutton" + _root.dbCount]._x = this.defX;
_root["dbutton" + _root.dbCount]._y = this.defY;
_root["dbutton" + _root.dbCount].answer = _root.answerdest[_root.dbCount + 1];
_root["dbutton" + _root.dbCount].theText.text = _root.answername[_root.dbCount +1];
if (_root["dbutton" + _root.dbCount].theText.text == "undefined")
{
_root["dbutton" + _root.dbCount].theText.text = "Finished!";
_root["dbutton" + _root.dbCount].noDrag = true;
} // end if
this.noDrag = true;
this._y = _root["dz" + this.answer]._y + totalHeight;
this._x = _root["dz" + this.answer]._x - _root["dz" + this.answer]._width / 2;
++_root["dz" + this.answer].numItems;
_root.glamp1.gotoAndPlay (1);
}
else
{
this.X = this.defX;
this._Y = this.defY;
_root.rlamp1.gotoAndPlay(1);
} // end if
} // end else if
}
The problem is that there are misspelled variable names and properties in the sprite code.
Replace these lines
this.X = this.defX;
this._Y = this.defY;
with those lines
this._x = this.defx;
this._y = this.defy;
and your code should work.

How to add buttons to a grid WP8.1 MVVM Light?

I'm having trouble building a dashboard in WP8.1.
I'm using the MVVM Light toolkit.
I'm looking after this outcome:
screenshot of dashboard
I can currently build a dashboard but only with one object per row.
I've searched a lot but haven't found anything to get the desired effect.
Here's the code of the dashboard done programatically:
int i = 0;
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition());
for (int ct = 0; ct < 3; ct++)
grid.ColumnDefinitions.Add(new ColumnDefinition());
StackPanel stackPanel = new StackPanel();
stackPanel.Name = "stackPanel";
stackPanel.Background = new SolidColorBrush(new Windows.UI.Color());
foreach (var flow in dashboard.DashboardFlows)
{
if (flow.Flow.IsInstalled)
{
//if next object should change line
if (i == 3)
{
stackPanel.Children.Add(grid);
grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition());
for (int ct = 0; ct < 3; ct++)
grid.ColumnDefinitions.Add(new ColumnDefinition());
i = 0;
}
Button button = new Button();
if (flow.Flow.Type.Equals("COMPNEWS"))
{
button.Click += delegate { Frame.Navigate(typeof(NewsPage), flow); };
}
//button stackpanel
StackPanel stack = new StackPanel();
//Button image
Image buttonImage = new Image();
if (!String.IsNullOrEmpty(flow.Flow.IconUrl) || !String.IsNullOrWhiteSpace(flow.Flow.IconUrl))
buttonImage.Source = new BitmapImage(new Uri(flow.Flow.IconUrl));
buttonImage.Height = 45;
buttonImage.VerticalAlignment = VerticalAlignment.Top;
stack.Children.Add(buttonImage);
//Button name
TextBlock buttonName = new TextBlock();
buttonName.Text = flow.Flow.Name;
buttonName.FontSize = 12;
buttonName.TextWrapping = TextWrapping.Wrap;
stack.Children.Add(buttonName);
button.Content = stack;
button.Margin = new Thickness(5, 0, 5, 0);
button.SetValue(Grid.ColumnProperty, i);
button.SetValue(Grid.RowProperty, 0);
button.HorizontalAlignment = HorizontalAlignment.Stretch;
button.VerticalAlignment = VerticalAlignment.Stretch;
button.Background = new SolidColorBrush(Color.FromArgb(130, 30, 30, 30));
grid.Children.Add(button);
i++;
}
}
scroll.Content = stackPanel;
Thank you in advance.

Add Object To Other Object Scripts that require an Object

Ok , I have problem with adding object let's first see what is this about.
I Have Map when i click at map i create Sphere on map.
then i serialized the point, msg and name .....
void Start () {
Ser = new Serial();
Ser.read();
for (int i =0 ; i < Ser.list.Count; i++)
{
Data d = new Data();
d = Ser.list[i];
GameObject a = GameObject.CreatePrimitive(PrimitiveType.Sphere);
a.name = d.Id;
a.transform.position = new Vector3(d.x,d.y,0);
a.transform.localScale =new Vector3(0.5f , 0.5f , 0.5f);
Follow putTarget = new Follow();
Data Pos_In_File = new Data();
Pos_In_File = Ser.list[i];
GUIText GText = new GUIText();
Vector3 SP = new Vector3();
GameObject TextObj = new GameObject("GUIText" + Convert.ToString(i));
GText = (GUIText)TextObj.AddComponent(typeof(GUIText));
GText.text = Pos_In_File.msg;
GText.material.color = new Color(0 , 0 , 1);
GText.fontSize = 20;
GText.fontStyle = FontStyle.Bold;
SP = Camera.main.WorldToViewportPoint(new Vector3(Pos_In_File.x , Pos_In_File.y , Pos_In_File.z));
TextObj.transform.position = SP;
TextObj.AddComponent(typeof(Follow));
GameObject OBJ = GameObject.Find(Pos_In_File.Id);
putTarget =GetComponent<Follow>();
putTarget.target = OBJ.transform;
}
}
now in last three lines i want to add OBJ to TextOBJ->Follow(Script)->target
What i am messing up ?
i asked this quastion long ago my software have been finnished a 10 month
and the i get through this problem is
void Start () {
Resources.UnloadUnusedAssets();
Ser = new Serial();
Screen.fullScreen = true;
Ser.read();
for (int i =0 ; i < Ser.list.Count; i++)
{
Data d = new Data();
d = Ser.list[i];
GameObject a = GameObject.CreatePrimitive(PrimitiveType.Sphere);
a.name = d.Id;
a.transform.position = new Vector3(d.x,d.y,0);
a.renderer.material.color = Color.green;
Data Pos_In_File = new Data();
Pos_In_File = Ser.list[i];
GUIText GText = new GUIText();
Vector3 SP = new Vector3();
GameObject TextObj = new GameObject(Pos_In_File.Id+"h");
GText = (GUIText)TextObj.AddComponent(typeof(GUIText));
GText.text = Pos_In_File.msg;
GText.material.color = new Color(0 , 0 , 1);
GText.fontSize = 20 + (int)Camera.main.transform.position.z;
GText.fontStyle = FontStyle.Bold;
SP = Camera.main.WorldToViewportPoint(new Vector3(Pos_In_File.x , Pos_In_File.y , Pos_In_File.z));
TextObj.transform.position = SP;
TextObj.AddComponent(typeof(Follow));
}

adding controls dynamically

how to add dynamically a menupanel with menuitems inside a accordion using coolite controls toolkit.
you can try my sample here :
private void CreateMenu(int index, string title, string url, MenuPanel menuPanel, Panel panel)
{
MenuItem menuItem = new MenuItem();
menuItem.ID = "MenuItem" + index;
menuItem.Text = title;
menuItem.Listeners.Click.Handler += "addTab(#{TabPanel1},#{" + menuPanel.ID + "},'MenuItem" + index + "',' " + title + "',' " + url + "');";
menuItem.Icon = Icon.ApplicationForm;
menuPanel.Menu.Items.Add(menuItem);
panel.BodyControls.Add(menuPanel);
Accordion1.Items.Add(panel);
}
private void PopulateMenus()
{
string[] menus = new string[] { null, "Menu 1", null, "Menu 2"};
MenuPanel menuPanel = null;
Panel panel = null;
for (int i = 0; i < menus.Length; i++)
{
if (menus[i] == null)
{
panel = new Panel();
panel.AutoScroll = true;
panel.ID = "Menu" + i;
panel.Title = menus[i + 1];
panel.Border = false;
panel.BodyStyle = "padding:6px;";
panel.Icon = Icon.ApplicationCascade;
menuPanel = new MenuPanel();
menuPanel.AutoScroll = true;
menuPanel.ID = "MenuPanel" + i;
menuPanel.Border = false;
menuPanel.BodyStyle = "padding:6px;";
continue;
}
CreateMenu(i, "Sub-" + menus[i], "www.test.com", menuPanel, panel);
}
}
Hope it helps.