Esempio n. 1
0
        private void DegreesOfFreedomAnalysis_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (m_ignoreWorkspaceChanges)
            {
                return;
            }

            DegreesOfFreedomAnalysis df = (sender as DegreesOfFreedomAnalysis);

            if (e.PropertyName.Equals("CommentsVisible"))
            {
                if (df.CommentsVisible)
                {
                    DFCommentsBorder.BorderThickness = new Thickness(2.0);
                    DFCommentsButton.Content         = "Hide comments";
                }
                else
                {
                    DFCommentsBorder.BorderThickness = new Thickness(0.0);
                    DFCommentsButton.Content         = (df.Comments.Count > 0) ?
                                                       "Show comments" : "Add comments";
                }
            }
            else if (e.PropertyName.Equals("Text"))
            {
                m_ignoreWorkspaceChanges = true;
                DFAnalysisTextBox.Text   = df.Text;
                m_ignoreWorkspaceChanges = false;
            }
        }
Esempio n. 2
0
        private void AddDFCommentButtonClick(object sender, RoutedEventArgs e)
        {
            DegreesOfFreedomAnalysis dfa = m_workspace.DegreesOfFreedomAnalysis;

            // Create an undo that will remove the comment that we're about to add
            m_workspace.AddUndo(new UndoRedoCollection("Undo adding degrees of freedom analysis comment",
                                                       new Logic.Undos.RemoveBasicComment(dfa.Comments, dfa.Comments.Count)));

            // Add a new comment to the collection. Event handlers will update the UI.
            dfa.Comments.Add(new BasicComment());
        }
Esempio n. 3
0
        private void UpdateComments()
        {
            // Clear first
            CommentsStack.Children.Clear();

            // Start with equation comments
            for (int i = 0; i < m_workspace.Equations.Count; i++)
            {
                EquationModel model = m_workspace.Equations[i];

                if (!model.CommentsVisible)
                {
                    continue;
                }

                Border brdr = new Border();
                brdr.Margin          = new Thickness(3.0, 3.0, 3.0, 0.0);
                brdr.CornerRadius    = new CornerRadius(3.0);
                brdr.BorderThickness = new Thickness(2.0);
                brdr.BorderBrush     = s_eqBorderBrush;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Vertical;
                brdr.Child     = sp;

                // Add an equation number label at the top
                Label numLabel = new Label();
                numLabel.Content             = "Equation " + (i + 1).ToString();
                numLabel.Foreground          = s_eqBorderBrush;
                numLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                sp.Children.Add(numLabel);

                // Add each comment
                foreach (BasicComment bc in model.Comments)
                {
                    PaneCommentControl cc = new PaneCommentControl();
                    cc.SetCommentObject(bc);
                    cc.Margin = new Thickness(3.0);
                    cc.XLabel.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
                    {
                        // Create and undo that adds the comment back
                        BasicComment toRemove = cc.CommentObject as BasicComment;
                        m_workspace.AddUndo(new UndoRedoCollection(
                                                "Undo deletion of equation comment",
                                                new Logic.Undos.InsertBasicComment(toRemove, model.Comments, model.Comments.IndexOf(toRemove))));

                        model.Comments.Remove(cc.CommentObject as BasicComment);
                        sp.Children.Remove(cc);
                    };
                    sp.Children.Add(cc);
                }

                // Add a button to allow addition of more comments
                Button btn = new Button();
                btn.Margin = new Thickness(3.0);
                Image btnIcon = Core.App.CreateImageFromSource("plus_16x16.png");
                btnIcon.Width = btnIcon.Height = 16;
                btn.Content   = btnIcon;
                btn.Tag       = model;
                btn.Click    += new RoutedEventHandler(AddEqCommentButtonClick);
                sp.Children.Add(btn);

                CommentsStack.Children.Add(brdr);
            }

            // Next do comments for the degrees of freedom analysis
            if (m_workspace.DegreesOfFreedomAnalysis.CommentsVisible)
            {
                Border brdr = new Border();
                brdr.Margin          = new Thickness(3.0, 3.0, 3.0, 0.0);
                brdr.CornerRadius    = new CornerRadius(3.0);
                brdr.BorderThickness = new Thickness(2.0);
                brdr.BorderBrush     = s_dfBorderBrush;
                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Vertical;
                brdr.Child     = sp;

                // Add a label at the top
                Label numLabel = new Label();
                numLabel.Content             = "DF Analysis";
                numLabel.Foreground          = s_dfBorderBrush;
                numLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                sp.Children.Add(numLabel);

                DegreesOfFreedomAnalysis dfa = m_workspace.DegreesOfFreedomAnalysis;
                foreach (BasicComment bc in dfa.Comments)
                {
                    PaneCommentControl pcc = new PaneCommentControl();
                    pcc.SetCommentObject(bc);
                    pcc.Margin = new Thickness(3.0);
                    pcc.XLabel.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e)
                    {
                        BasicComment toRemove = pcc.CommentObject as BasicComment;
                        int          index    = dfa.Comments.IndexOf(toRemove);

                        // Add an undo that will re-insert the comment that we're about to delete
                        m_workspace.AddUndo(new UndoRedoCollection(
                                                "Undo deletion of comment for degrees of freedom analysis",
                                                new Logic.Undos.InsertBasicComment(toRemove, dfa.Comments, index)));

                        // Now delete the comment
                        m_workspace.DegreesOfFreedomAnalysis.Comments.Remove(pcc.CommentObject as BasicComment);
                    };
                    sp.Children.Add(pcc);
                }

                // Add a button to allow addition of more comments
                Button btn = new Button();
                btn.Margin = new Thickness(3.0);
                Image btnIcon = Core.App.CreateImageFromSource("plus_16x16.png");
                btnIcon.Width = btnIcon.Height = 16;
                btn.Content   = btnIcon;
                btn.Click    += new RoutedEventHandler(AddDFCommentButtonClick);
                sp.Children.Add(btn);

                CommentsStack.Children.Add(brdr);
            }
        }