Esempio n. 1
0
        private void cmdAddClick(object sender, RoutedEventArgs e)
        {
            SnippetsDataSet.SnippetsTableRow r = snippetsTable.NewSnippetsTableRow();
            r.Name         = "New Snippet";
            r.Category     = "Styles";
            r.Description  = "Add descriptive text here \r\nWill be displayed as tooltip";
            r.SampleCode   = "\\begin{tikzpicture}\r\n  \\draw (1,1)--(3,3);\r\n\\end{tikzpicture}";
            r.SnippetCode  = "draw";
            r.Dependencies = "";
            if (lstSnippets.SelectedItem != null)
            {
                SnippetsDataSet.SnippetsTableRow curr = ((DataRowView)(lstSnippets.SelectedItem)).Row as SnippetsDataSet.SnippetsTableRow;
                r.Category = curr.Category;

                if (sender == cmdAddClone)
                {
                    // copy settings from current snippet
                    r.Name        = curr.Name; r.Description = curr.Description; r.SampleCode = curr.SampleCode;
                    r.SnippetCode = curr.SnippetCode; r.Dependencies = curr.Dependencies;
                    if (!curr.IsEdgeStyleNull())
                    {
                        r.EdgeStyle = curr.EdgeStyle;
                    }
                    if (!curr.IsNodeStyleNull())
                    {
                        r.NodeStyle = curr.NodeStyle;
                    }
                }
            }

            snippetsTable.Rows.Add(r);
            //make sure lstsnippets is update to date (i.e. just added r is shown)
            lstSnippets.UpdateLayout();
            //now find entry in lstsnippets that corresponds to the just added row r
            foreach (DataRowView lstEntry in lstSnippets.Items)
            {
                if (lstEntry.Row == r)
                {
                    //get the expander of this entry in order to expand it.
                    Expander eee = GetExpander(lstEntry);
                    if (eee != null)
                    {
                        eee.IsExpanded = true;
                    }
                    else
                    {
                        eee = GetExpander(lstEntry);
                    }
                    //also select the just added entey.
                    lstSnippets.SelectedItem = lstEntry;
                    break;
                }
            }
        }
Esempio n. 2
0
        public SnippetsDataSet.SnippetsTableRow tag; // used to remember the datatable row to be changed, if applicable

        public CodeSnippet(SnippetsDataSet.SnippetsTableRow r)
        {
            Name         = r.Name;
            Category     = r.Category;
            Description  = r.Description;
            SampleCode   = r.SampleCode;
            SnippetCode  = r.SnippetCode;
            EdgeStyle    = r.IsEdgeStyleNull()?"":r.EdgeStyle;
            NodeStyle    = r.IsNodeStyleNull() ? "" : r.NodeStyle;
            Dependencies = r.Dependencies;

            IsSelected     = false;
            IsAlreadyThere = false;
            IsChanged      = false;
        }