Esempio n. 1
0
 /// <summary>
 /// Most controls are data bound, however, this is not (directly) possible for the AvalonEditors.
 /// (Text is not a dependency property). Hence we need this eventhandler here to update them manually.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lstSnippets_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     lProgrammatic = true;
     if (lstSnippets.SelectedItem == null)
     {
         txtSnippetCode.Clear();
         //txtSnippetCode.IsEnabled = false;
     }
     else
     {
         SnippetsDataSet.SnippetsTableRow r = ((DataRowView)lstSnippets.SelectedItem).Row as SnippetsDataSet.SnippetsTableRow;
         if (r.IsNull(snippetsTable.SnippetCodeColumn))
         {
             txtSnippetCode.Clear();
         }
         else
         {
             txtSnippetCode.Text = r.SnippetCode;
         }
         if (r.IsNull(snippetsTable.SampleCodeColumn))
         {
             txtSampleCode.Clear();
         }
         else
         {
             txtSampleCode.Text = r.SampleCode;
         }
     }
     lProgrammatic = false;
 }
Esempio n. 2
0
        public void HandleInsertFullCodeClick(SnippetsDataSet.SnippetsTableRow r)
        {
            string c = "", d = "";

            if (!r.IsNull(snippetsTable.SampleCodeColumn))
            {
                c = r.SampleCode;
            }
            if (!r.IsNull(snippetsTable.DependenciesColumn))
            {
                d = r.Dependencies;
            }

            TheView.RaiseOnInsert(new InsertEventArgs()
            {
                code = c, dependencies = d
            });
        }
Esempio n. 3
0
        public void HandleUseStyleButtonClick(SnippetsDataSet.SnippetsTableRow r)
        {
            UseStylesEventArgs args = new UseStylesEventArgs();

            if (!r.IsNull(snippetsTable.NodeStyleColumn))
            {
                args.nodestyle = r.NodeStyle;
            }
            if (!r.IsNull(snippetsTable.EdgeStyleColumn))
            {
                args.edgestyle = r.EdgeStyle;
            }
            if (!r.IsNull(snippetsTable.DependenciesColumn))
            {
                args.dependencies = r.Dependencies;
            }
            args.InAddition = System.Windows.Forms.Control.ModifierKeys.HasFlag(Keys.Control);

            TheView.RaiseOnUseStyle(args);
        }
Esempio n. 4
0
        public void HandleInsertAsTikzStyleClick(SnippetsDataSet.SnippetsTableRow r)
        {
            string toinsert = "", dependencies = "";

            if (!r.IsNull(snippetsTable.NodeStyleColumn) && !(r.NodeStyle.Trim() == ""))
            {
                toinsert += "\\tikzstyle{mynodestyle} = [" + r.NodeStyle + "]" + Environment.NewLine;
            }
            if (!r.IsNull(snippetsTable.EdgeStyleColumn) && !(r.EdgeStyle.Trim() == ""))
            {
                toinsert += "\\tikzstyle{myedgestyle} = [" + r.EdgeStyle + "]" + Environment.NewLine;
            }
            if (!r.IsNull(snippetsTable.DependenciesColumn))
            {
                dependencies = r.Dependencies;
            }

            TheView.RaiseOnInsert(new InsertEventArgs()
            {
                code = toinsert, dependencies = dependencies
            });
        }
Esempio n. 5
0
        private void cmdCompile_Click(object sender, RoutedEventArgs e)
        {
            if (lstSnippets.SelectedItem == null)
            {
                MessageBox.Show("Select an item from snippet table on the left!");
                return;
            }

            SnippetsDataSet.SnippetsTableRow r = ((DataRowView)lstSnippets.SelectedItem).Row as SnippetsDataSet.SnippetsTableRow;
            if (!r.IsNull(snippetsTable.SampleCodeColumn))
            {
                fact.AddJob(r.SampleCode, Helper.GetSnippetsPath() + r.ID + Consts.SnippetsExtension, new Rect(0, 0, 0, 0), r.Name, true);
            }
        }
Esempio n. 6
0
        public void HandleInsertDependenciesClick(SnippetsDataSet.SnippetsTableRow r)
        {
            string d = "";

            if (!r.IsNull(snippetsTable.DependenciesColumn))
            {
                d = r.Dependencies;
            }

            TheView.RaiseOnInsert(new InsertEventArgs()
            {
                code = @"\usetikzlibrary{" + d + "}" + Environment.NewLine, dependencies = d
            });
        }
Esempio n. 7
0
        /// <summary>
        /// Finds items in the current snippet list that are already there in the
        /// current snippet database and marks them as such.
        /// Note: duplicates based on category+name
        /// </summary>
        void FindDuplicates()
        {
            foreach (CodeSnippet s in snippetList)
            {
                SnippetsDataSet.SnippetsTableRow r = SnippTable.Cast <SnippetsDataSet.SnippetsTableRow>().FirstOrDefault(rr => rr.Category == s.Category && rr.Name == s.Name);
                if (r != null)
                {
                    s.IsAlreadyThere = true;
                    s.tag            = r;

                    // Check if changed
                    s.IsChanged = !(
                        StrCompare(s.Description, (r.IsNull(SnippTable.DescriptionColumn) ? null : r.Description)) &&
                        StrCompare(s.SnippetCode, (r.IsNull(SnippTable.SnippetCodeColumn) ? null : r.SnippetCode)) &&
                        StrCompare(s.SampleCode, (r.IsNull(SnippTable.SampleCodeColumn) ? null : r.SampleCode)) &&
                        StrCompare(s.NodeStyle, (r.IsNull(SnippTable.NodeStyleColumn) ? null : r.NodeStyle)) &&
                        StrCompare(s.EdgeStyle, (r.IsNull(SnippTable.EdgeStyleColumn) ? null : r.EdgeStyle)) &&
                        StrCompare(s.Dependencies, (r.IsNull(SnippTable.DependenciesColumn) ? null : r.Dependencies)));
                }
            }
        }