Jump to content

Problem with snippets program

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
matio

matio

    Learning Programmer

  • Members
  • PipPipPip
  • 51 posts
Hi everybody,
I'm trying to create a program that saves my programming snippets. I'm having problems with a list and a dialog:

using System;
using System.Collections.Generic;
using Gtk;
using GtkSourceView;

namespace Kronos
{
    public partial class AddDialog : Gtk.Dialog
    {
        SourceLanguageManager LangMan;
        SourceLanguage Lang;
        SourceBuffer Buff;
        SourceView Source;
        string NewItem = "";
        List<string> Rows = new List<string>();
        ComboBoxManager LanguageManager;

        public AddDialog (List<string> rows)
        {
            this.Build ();
            HideNewItem ();
            LoadComboBoxLanguage ();
            LangMan = new SourceLanguageManager ();
            Lang = LangMan.GetLanguage ("c-sharp");
            Buff = new SourceBuffer (Lang);
            Source = new SourceView ();
            Source.Buffer = Buff;
            Buff.Language = Lang;
            scrolledwindowSource.Add (Source);
            scrolledwindowSource.ShowAll ();
            Rows = rows;
        }

        void LoadComboBoxLanguage ()
        {
            LanguageManager = new ComboBoxManager (comboboxLanguage);
            Console.WriteLine(Rows.Count);
            foreach (string row in Rows) {
                Console.WriteLine(row == null);
                LanguageManager.AppendValue (row);
            }
        }

        void ShowNewItem ()
        {
            label5.Show ();
            entryNewitem.Show ();
            buttonNewitem.Show ();
        }

        void HideNewItem ()
        {
            label5.Hide ();
            entryNewitem.Hide ();
            buttonNewitem.Hide ();
        }

        protected virtual void onButtonLanguageClicked (object sender, System.EventArgs e)
        {
            NewItem = "Language";
            ShowNewItem ();
        }

        protected virtual void onOK (object sender, System.EventArgs e)
        {
            this.Destroy ();
        }

        protected virtual void onCancel (object sender, System.EventArgs e)
        {
            this.Destroy ();
        }
        
        
        
    }
}
using System;
using System.Collections.Generic;
using Gtk;

namespace Kronos
{
    public class TreeViewManager
    {
        ListStore Store;
        TreeViewColumn Column;
        CellRendererText Text;
        List<string> Rows;
        
        public TreeViewManager (TreeView view)
        {
            Store = new ListStore (typeof(string));
            Column = new TreeViewColumn ();
            Text = new CellRendererText ();
            
            Column.PackStart (Text, true);
            Column.AddAttribute (Text, "text", 0);
            view.AppendColumn (Column);
            
            view.Model = Store;        
            
            Rows = new List<string>();
        }
        
        public void AppendValue(string val){
            Rows.Add(val);
            Store.AppendValues(val);
        }
        
        public List<string> GetRows(){
            return Rows;
        }
    }
}
        protected virtual void onAddActivated (object sender, System.EventArgs e)
        {
            Console.WriteLine(TreeViewLanguageMan.GetRows().Count);
            AddDialog dialog = new AddDialog(TreeViewLanguageMan.GetRows());
        }
When I run this the call in onAdd says there is 1 row but in the dialog it says there are none?

#2
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
Can you please explain you problem so we can give an answer to it? Or are we supposed to browse through your code searching for it?
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics

#3
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
I still don't understand what you wanted ? or Is my brain dumb :p.