本文整理汇总了C#中System.Windows.Controls.StackPanel.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.FindName方法的具体用法?C# StackPanel.FindName怎么用?C# StackPanel.FindName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.StackPanel
的用法示例。
在下文中一共展示了StackPanel.FindName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditerTag
public void EditerTag(StackPanel objStckPan, string fichierATagger)
{
if (Morceau != null)
{
Morceau.accTitre = ((TextBox)objStckPan.FindName("txtbTitre")).Text;
Morceau.accArtiste = ((TextBox)objStckPan.FindName("txtbAuteur")).Text;
Morceau.accGenre = short.Parse(((ComboBox)objStckPan.FindName("cbxType")).SelectedValue.ToString());
}
EcrireTag(fichierATagger);
}
示例2: programDetailMode
private void programDetailMode(StackPanel parentStackPanel)
{
mainWindow.LoadMap(project.path); //每次打开时, 重新读一下地图.
ProgramStepUserControl programStepUserControl = parentStackPanel.FindName("ProgramStepUserControl") as ProgramStepUserControl;
if (programStepUserControl.Visibility == System.Windows.Visibility.Visible)
{
hideProgramDetailMode(parentStackPanel);
this.programStepUserControl = null;
}
else
{
showProgramDetailMode(parentStackPanel);
this.programStepUserControl = programStepUserControl;
TextBlock programIDTextBlock = parentStackPanel.FindName("ProgramIDTextBlock") as TextBlock;
int programID = Int32.Parse(programIDTextBlock.Text);
initProgramDetailMode(programStepUserControl, programID);
}
}
示例3: MainWindow
public MainWindow()
{
InitializeComponent();
currentPanel = this.Content as StackPanel;
currentPanel = currentPanel.FindName("World") as StackPanel;
xmlDoc = new XmlDocument();
rootNode = xmlDoc.CreateElement("world");
XmlAttribute attribute = xmlDoc.CreateAttribute("Name");
TextBox Name = currentPanel.FindName("WorldName") as TextBox;
attribute.Value = Name.Text;
rootNode.Attributes.Append(attribute);
xmlDoc.AppendChild(rootNode);
Scroller.Height = (Window.ActualHeight);
Scroller.Width = Window.ActualWidth;
}
示例4: Add_Click
private void Add_Click(object sender, RoutedEventArgs e)
{
var button = sender as Button;
currentPanel = this.Content as StackPanel;
currentPanel = currentPanel.FindName("World") as StackPanel;;
CurrentNode = rootNode;
SelectionWindow win2 = new SelectionWindow(this, int.Parse(button.Tag.ToString()));
win2.Show();
}
示例5: Open_Cliick
private void Open_Cliick(object sender, RoutedEventArgs e)
{
rootNode.RemoveAll();
int offset = 0;
currentPanel = this.Content as StackPanel;
currentPanel = currentPanel.FindName("World") as StackPanel;
currentPanel.Children.RemoveRange(1, currentPanel.Children.Count);
currentPanel.Name = "World";
//rootNode = xmlDoc.CreateElement("world");
CurrentNode = rootNode;
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog() == true)
{
XmlTextReader reader = new XmlTextReader(open.FileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
reader.Read();
if (reader.HasAttributes)
{
while (reader.MoveToNextAttribute())
{
XmlAttribute attribut = xmlDoc.CreateAttribute(reader.Name);
attribut.Value = reader.Value;
rootNode.Attributes.Append(attribut);
TextBox box = currentPanel.FindName("WorldName") as TextBox;
box.Text = reader.Value;
}
}
Hashtable items = new Hashtable();
Hashtable hasText = new Hashtable();
string name = reader.Name;
while (reader.Read())
{
switch (reader.NodeType)
{
//Section(int offset, MainWindow main, StackPanel parent, XmlNode root, XmlDocument xmlDoc, Hashtable table, string name, bool hasText)
case XmlNodeType.Element:
name = reader.Name;
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
items[name] = list;
bool isEmpty = reader.IsEmptyElement;
if (reader.HasAttributes)
{
List<Tuple<string, string>> templist = items[name] as List<Tuple<string, string>>;
while (reader.MoveToNextAttribute())
{
Tuple<string, string> tuple = new Tuple<string, string>(reader.Name, reader.Value);
templist.Add(tuple);
}
}
currentPanel = AddSection(++offset, name, items, hasText);
CurrentNode = (currentPanel as Section).GetXmlNode();
if (isEmpty)
{
offset--;
CurrentNode = CurrentNode.ParentNode;
currentPanel = currentPanel.Parent as StackPanel;
}
break;
case XmlNodeType.Text:
hasText[name] = reader.Value;
StackPanel tempPanel = currentPanel.Parent as StackPanel;
tempPanel.Children.Remove(currentPanel);
currentPanel = tempPanel;
XmlNode tempNode = CurrentNode.ParentNode;
tempNode.RemoveChild(CurrentNode);
CurrentNode = tempNode;
currentPanel = AddSection(offset, name, items, hasText);
XmlText tex = xmlDoc.CreateTextNode(reader.Value);
CurrentNode = (currentPanel as Section).GetXmlNode();
CurrentNode.InnerText = tex.Value;
break;
case XmlNodeType.Comment:
name = "comment";
List<Tuple<string, string>> lis = new List<Tuple<string, string>>();
items[name] = lis;
if (reader.HasAttributes)
{
List<Tuple<string, string>> templist = items[name] as List<Tuple<string, string>>;
while (reader.MoveToNextAttribute())
{
Tuple<string, string> tuple = new Tuple<string, string>(reader.Name, reader.Value);
templist.Add(tuple);
}
}
AddSection(offset, name, items, hasText);
//CurrentNode = (currentPanel as Section).GetXmlNode();
break;
case XmlNodeType.EndElement:
--offset;
CurrentNode = CurrentNode.ParentNode;
currentPanel = currentPanel.Parent as StackPanel;
break;
}
}
reader.Close();
}
}
示例6: New_Click
private void New_Click(object sender, RoutedEventArgs e)
{
rootNode.RemoveAll();
currentPanel = this.Content as StackPanel;
currentPanel = currentPanel.FindName("World") as StackPanel;
currentPanel.Children.RemoveRange(1, currentPanel.Children.Count);
currentPanel.Name = "World";
CurrentNode = rootNode;
}
示例7: ShowItemDetails
private void ShowItemDetails(StackPanel parent)
{
var title = parent.FindName("ItemTitleText") as TextBlock;
title.TextWrapping = TextWrapping.Wrap;
var storyboard = AnimationUtils.GetStoryboard();
FrameworkElement toolbar = parent.FindName("ToolBar") as FrameworkElement;
AnimationUtils.SetHeightAnimation(storyboard, toolbar, 80, 0.3);
AnimationUtils.SetOpacityAnimation(storyboard, toolbar, 1, 0.3);
FrameworkElement modifyButton = parent.FindName("ModifyButton") as FrameworkElement;
modifyButton.Visibility = Visibility.Visible;
AnimationUtils.SetOpacityAnimation(storyboard, modifyButton, 1, 0.3);
storyboard.Begin();
}
示例8: hideProgramDetailMode
private void hideProgramDetailMode(StackPanel programStackPanel)
{
TextBlock programIDTextBlock = programStackPanel.FindName("ProgramIDTextBlock") as TextBlock;
int programID = Int32.Parse(programIDTextBlock.Text);
foreach (Program program in programList)
{
if (program.id == programID)
program.visible = false;
}
}
示例9: SetItemCompleted
private void SetItemCompleted(StackPanel parent, ToDoItem item)
{
if (item == null || parent == null)
{
return;
}
var storyboard = AnimationUtils.GetStoryboard();
FrameworkElement completedLine = parent.FindName("CompletedLine") as FrameworkElement;
AnimationUtils.SetWidthAnimation(storyboard, completedLine, 400, 0.3);
if (mCurrentItemPanel == parent)
{
FrameworkElement toolbar = parent.FindName("ToolBar") as FrameworkElement;
AnimationUtils.SetHeightAnimation(storyboard, toolbar, AnimationUtils.AnimationHeightHide, 0.3);
FrameworkElement modifyButton = parent.FindName("ModifyButton") as FrameworkElement;
AnimationUtils.SetOpacityAnimation(storyboard, modifyButton, 0, 0.3);
mCurrentItemPanel = null;
}
var storyboard2 = AnimationUtils.GetStoryboard();
FrameworkElement listItem = parent.FindName("ListItem") as FrameworkElement;
AnimationUtils.SetTranslateAnimation(storyboard2, parent, 0, Application.Current.Host.Content.ActualHeight, 0.5);
AnimationUtils.SetHeightAnimation(storyboard2, listItem, 0, 0.5);
item.IsCompleted = true;
storyboard.Completed += delegate(object sender, EventArgs e)
{
storyboard2.Begin();
};
storyboard2.Completed += delegate(object sender, EventArgs e)
{
App.ViewModel.ChangeCompletedStatus(item, true);
};
storyboard.Begin();
}
示例10: SetItemUnCompleted
private void SetItemUnCompleted(StackPanel parent, ToDoItem item)
{
if (item == null || parent == null)
{
return;
}
var storyboard = AnimationUtils.GetStoryboard();
FrameworkElement completedLine = parent.FindName("CompletedLine") as FrameworkElement;
AnimationUtils.SetWidthAnimation(storyboard, completedLine, 0, 0.3);
storyboard.Completed += delegate(object sender, EventArgs e)
{
item.IsCompleted = false;
};
storyboard.Begin();
}
示例11: ModifyItemTitle
private void ModifyItemTitle(StackPanel parent, ToDoItem item)
{
if (item == null || parent == null)
{
return;
}
const int topOffset = 180;
var text = parent.FindName("ItemTitleText") as FrameworkElement;
var transform = text.TransformToVisual(Application.Current.RootVisual);
var pointOffset = transform.Transform(new Point(0, 0));
Log.Info(TAG, "pointOffset.Y:" + pointOffset.Y.ToString());
double verticalOffset = pointOffset.Y - topOffset;
ModifyTitleControl modify = new ModifyTitleControl(item)
{
TitleHeight = (verticalOffset > 0) ? topOffset : pointOffset.Y
};
SetPopupedControlEvent(modify);
modify.Closed += delegate(object sender, PopupEventArgs e)
{
if (verticalOffset > 0)
{
var storyboard2 = AnimationUtils.GetStoryboard();
AnimationUtils.SetHeightAnimation(storyboard2, VacancyStackPanel as FrameworkElement, 0, 0.3);
storyboard2.Begin();
}
};
if (verticalOffset > 0)
{
var storyboard = AnimationUtils.GetStoryboard();
AnimationUtils.SetHeightAnimation(storyboard, VacancyStackPanel as FrameworkElement, verticalOffset + 1000, 0.3);
AnimationUtils.SetAnyAnimation(storyboard, this as FrameworkElement, ScrowViewerVerticalOffsetProperty,
MainScrollViewer.VerticalOffset, MainScrollViewer.VerticalOffset + verticalOffset, 0.3);
storyboard.Completed += delegate(object sender1, EventArgs e1)
{
PopupWindow.ShowWindow(modify, PopupWindow.PopupWindowBackgroundType.Flash);
};
storyboard.Begin();
}
else
{
PopupWindow.ShowWindow(modify, PopupWindow.PopupWindowBackgroundType.Flash);
}
}
示例12: HideItemDetails
private void HideItemDetails(StackPanel parent)
{
var title = parent.FindName("ItemTitleText") as TextBlock;
title.TextWrapping = TextWrapping.NoWrap;
var storyboard = AnimationUtils.GetStoryboard();
FrameworkElement toolbar = parent.FindName("ToolBar") as FrameworkElement;
AnimationUtils.SetHeightAnimation(storyboard, toolbar, AnimationUtils.AnimationHeightHide, 0.2);
AnimationUtils.SetOpacityAnimation(storyboard, toolbar, 0, 0.2);
FrameworkElement modifyButton = parent.FindName("ModifyButton") as FrameworkElement;
AnimationUtils.SetOpacityAnimation(storyboard, modifyButton, 0, 0.2);
storyboard.Completed += delegate(object sender, EventArgs e)
{
modifyButton.Visibility = Visibility.Collapsed;
};
storyboard.Begin();
}
示例13: PropagateWinner
//emptyWinner tells us if we're emptying the next game's slot.
//We do that when Final is unchecked for a game.
//In case of a tie, I assign the home team as the winner.
private void PropagateWinner(StackPanel currentGame, bool emptyWinner)
{
System.Windows.Controls.RadioButton final = currentGame.Children[2] as System.Windows.Controls.RadioButton;
if (!(bool)final.IsChecked)
{
emptyWinner = true;
}
string gameName = currentGame.Name;
int gameID = int.Parse(gameName.Substring(4)); //Substring(4) skips "game" and just gets the number.
if (gameID == 63) //Last game, nowhere to propagate to.
{
return;
}
int nextGameID = FindNextGameID(gameID);
string nextGameName = "game" + nextGameID;
StackPanel nextGame = currentGame.FindName(nextGameName) as StackPanel;
//Find the slot in the next game where the current game's winner goes.
StackPanel winnerInNextGame = nextGame.Children[4] as StackPanel;
if ((gameID % 2) == 0) //if it's even numbered, it moves up as the Away team instead.
{
winnerInNextGame = nextGame.Children[3] as StackPanel;
}
//if we're clearing, just do it and move on.
if (emptyWinner)
{
(winnerInNextGame.Children[1] as TextBlock).Text = "";
if (gameID == 0)
{
(winnerInNextGame.Children[1] as TextBlock).Text = "Op. Rd. Winner";
}
PropagateWinner(nextGame, true);
return;
}
StackPanel currentHomePanel = currentGame.Children[4] as StackPanel;
StackPanel currentAwayPanel = currentGame.Children[3] as StackPanel;
string homeTeamName = (currentHomePanel.Children[1] as TextBlock).Text;
string awayTeamName = (currentAwayPanel.Children[1] as TextBlock).Text;
if ((homeTeamName == "") || (awayTeamName == "") || (awayTeamName == "Op. Rd. Winner")) //Missing a team from current game.
{
return;
}
int homeScore = int.Parse((currentHomePanel.Children[0] as System.Windows.Controls.TextBox).Text);
int awayScore = int.Parse((currentAwayPanel.Children[0] as System.Windows.Controls.TextBox).Text);
string winner = homeTeamName; //default to Home team as winner in case of a tie.
if (awayScore > homeScore)
{
winner = awayTeamName;
}
(winnerInNextGame.Children[1] as TextBlock).Text = winner;
PropagateWinner(nextGame, false);
}
示例14: DrawLines
private void DrawLines(StackPanel panel, bool showEndpoints)
{
if (panel == null) return;
var endpointHeight = showEndpoints ? -14 : 0;
var caption = (FrameworkElement)panel.FindName("StepName");
var captionPosition = GetPosition("StepName", panel);
var message = (FrameworkElement)panel.FindName("InitialMessage");
var messagePosition = GetPosition("InitialMessage", panel);
var messageData = ((FrameworkElement)((ContentPresenter)message).ContentTemplate.FindName("MessageDataPanel", message));
var messageDataHeight = messageData.Visibility == Visibility.Visible ? messageData.ActualHeight : 0;
var parent = panel.Parent as Grid;
RemoveExistingLines(parent);
AddLine(new Point(messagePosition.X, message.ActualHeight + endpointHeight - messageDataHeight), new Point(captionPosition.X + caption.ActualWidth, message.ActualHeight + endpointHeight - messageDataHeight), parent);
var stepName = (Panel)panel.FindName("StepName");
var icon = stepName.Children.Cast<FrameworkElement>().OfType<ContentControl>().FirstOrDefault(c => c.Visibility == Visibility.Visible);
var iconPosition = icon.TransformToAncestor(panel).Transform(new Point(0, 0));
var lastPoint = new Point(iconPosition.X + icon.ActualWidth / 2, message.ActualHeight + endpointHeight - messageDataHeight);
var timeoutPoint = new Point(0, 0);
var timeoutMessages = (ItemsControl)panel.FindName("TimeoutMessages");
for (var i = 0; i < timeoutMessages.Items.Count; i++)
{
var timeout = VisualTreeHelper.GetChild(timeoutMessages.ItemContainerGenerator.ContainerFromIndex(i), 0) as Panel;
var timeoutMessage = timeout.FindName("TimeoutMessage") as FrameworkElement;
var timeoutMessagePosition = timeoutMessage.TransformToAncestor(panel).Transform(new Point(0, 0));
AddTimeoutVerticalLine(timeout, panel, parent, ref lastPoint, ref timeoutPoint, i);
AddLine(timeoutPoint, new Point(timeoutPoint.X, timeoutPoint.Y + 12), parent);
AddLine(new Point(timeoutPoint.X, timeoutPoint.Y + 12), new Point(timeoutMessagePosition.X + timeoutMessage.ActualWidth / 2, timeoutPoint.Y + 12), parent);
AddLine(new Point(timeoutMessagePosition.X + timeoutMessage.ActualWidth / 2, timeoutPoint.Y + 12), new Point(timeoutMessagePosition.X + timeoutMessage.ActualWidth / 2, timeoutMessagePosition.Y + (endpointHeight + 14)), parent);
AddArrow(parent, new Point(timeoutMessagePosition.X + timeoutMessage.ActualWidth / 2, timeoutMessagePosition.Y + (endpointHeight + 14)));
}
var sagaMessagesPosition = GetPosition("SagaMessages", panel);
var sagaMessages = (ItemsControl)panel.FindName("SagaMessages");
if (sagaMessages.Items.Count > 0)
{
AddLine(new Point(captionPosition.X + caption.ActualWidth, message.ActualHeight + endpointHeight - messageDataHeight), new Point(sagaMessagesPosition.X + (sagaMessages.ActualWidth / 2), message.ActualHeight + endpointHeight - messageDataHeight), parent);
AddLine(new Point(sagaMessagesPosition.X + (sagaMessages.ActualWidth / 2), message.ActualHeight + endpointHeight - messageDataHeight), new Point(sagaMessagesPosition.X + (sagaMessages.ActualWidth / 2), sagaMessagesPosition.Y + (endpointHeight + 14)), parent);
AddArrow(parent, new Point(sagaMessagesPosition.X + (sagaMessages.ActualWidth / 2), sagaMessagesPosition.Y + (endpointHeight + 14)));
}
}
示例15: programDetailMode
private void programDetailMode(StackPanel parentStackPanel)
{
mainWindow.mask();
Thread t = new Thread(delegate()
{
mainWindow.Dispatcher.BeginInvoke((ThreadStart)delegate()
{
System.Threading.Thread.Sleep(5000);
mainWindow.LoadMap(project.path); //每次打开时, 重新读一下地图.
ProgramStepUserControl programStepUserControl = parentStackPanel.FindName("ProgramStepUserControl") as ProgramStepUserControl;
if (programStepUserControl.Visibility == System.Windows.Visibility.Visible)
{
hideProgramDetailMode(parentStackPanel);
this.programStepUserControl = null;
}
else
{
showProgramDetailMode(parentStackPanel);
this.programStepUserControl = programStepUserControl;
TextBlock programIDTextBlock = parentStackPanel.FindName("ProgramIDTextBlock") as TextBlock;
int programID = Int32.Parse(programIDTextBlock.Text);
initProgramDetailMode(programStepUserControl, programID);
}
mainWindow.unmask();
});
});
t.Start();
}