Пример #1
0
        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
0
 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
0
        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
0
 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
0
        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
0
 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
0
        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
0
 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
0
        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
0
        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
0
        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
0
        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
0
        //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);
        }
        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
0
        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();
        }