Example #1
0
        void ConfigureListBox()
        {
            // class member init
            portfolio = new Portfolio();
            builtinPortfolios = 
                new Dictionary<string,string> { { "-DJIA", "Dow Jones Industrial Avg" }, { "-NASDAQ", "All NASDAQ Market Symbols" } };

            icon = Gdk.Pixbuf.LoadFromResource("Windows.Controls.Resources.meeting-observer.png");
            mktSymbols = new StockSymbols();
            portSymbols = new ListStore(typeof(Gdk.Pixbuf), typeof(string), typeof(string));
            portfolio = new Portfolio();

            // local var init
            var imgRndr = new CellRendererPixbuf();
            var render = new [] { new CellRendererText(), new CellRendererText() };

            // Disable the add symbol button (+)
            btnAdd.Sensitive = false;

            // ComboBoxEntry will display the symbol and company name
            // symbol is being used by default as the control takes the first
            // colum in the model by default.
            comboboxentry.TextColumn = 0;

            // Image
            comboboxentry.PackStart(imgRndr, false);
            comboboxentry.AddAttribute(imgRndr, "pixbuf", 2);        

            // Company Name
            comboboxentry.PackStart(render[1], true);
            comboboxentry.AddAttribute(render[1], "text", 1);        

            // Apply / Bind the data the combobox
            comboboxentry.Entry.Completion = new EntryCompletion();
            comboboxentry.Entry.Completion.TextColumn = 0;

            // Bind comboboxentry to datasource
            comboboxentry.Model = mktSymbols;
            comboboxentry.Entry.Completion.Model = mktSymbols;

            // Listbox will display the symbol and company name
            listbox.AppendColumn(" ", imgRndr, "pixbuf", 0);        
            listbox.AppendColumn("Symbol", render[0], "text", 1);        
            listbox.AppendColumn("Name", render[1], "text", 2);    

            listbox.Model = portSymbols;
            listbox.Reorderable = true;
            listbox.Selection.Mode = SelectionMode.Multiple;
            listbox.ShowAll();
        }
Example #2
0
        void Initialize(Book b, Portfolio current = null)
        {                   
            // Initialize member variables
            book = b;
            CurrentPortfolio = current;
            newportfolioCounter = 1;
            state = WindowStateBehavior.Default;

            // Initialize widgets to the starting state
            WindowState = WindowStateBehavior.Default;

            // Images to make the gui pop...pop...pop
            lockedIcon = (Gtk.Image)btnRename.Image;
            unlockedIcon = new Gtk.Image();
            unlockedIcon.Pixbuf = Gdk.Pixbuf.LoadFromResource("QuoteView.Resources.rename-locked.png");
            portfolioIcon = Gdk.Pixbuf.LoadFromResource("QuoteView.Resources.portfolio.png");

            // Load combobox with Portfolios model
            var portfolios = new Gtk.ListStore(typeof(string), typeof(Gdk.Pixbuf));
            foreach (var pfolio in book)
                portfolios.AppendValues(pfolio.Name, portfolioIcon); 

            // Configure combobox
            var imgRndr = new CellRendererPixbuf();
            comboPortfolios.PackEnd(imgRndr, false);
            comboPortfolios.AddAttribute(imgRndr, "pixbuf", 1);  

            comboPortfolios.Model = portfolios;
            if (book.Any())
                comboPortfolios.Active = 0;
            comboPortfolios.ShowAll();

            // Setup change event on listbox
            IsDirty = (object sender, EventArgs e) => book.IsDirty = true;

            listSymbols.ListBoxChanged += IsDirty;

            WindowStateChanged(WindowStateBehavior.Default);
        }
Example #3
0
 public PortfolioMgr(Book b, Portfolio current = null)
 {
     this.Build();    
     Initialize(b, current);
 }
Example #4
0
 protected void OnBtnNewClicked(object sender, EventArgs e)
 {
     CurrentPortfolio = new Portfolio("New Portfolio" + newportfolioCounter++);
     WindowState = WindowStateBehavior.Add;
 }