Example #1
0
        public void Add(TabControl mainTabControl, DbHolder holder, TabNavigation tabEngine, SdeEditor editor)
        {
            holder.AddTable(_adb);
            GDbTab copy = holder.GetTab(_adb, mainTabControl);

            if (_adb is AbstractDb <int> )
            {
                _adb.To <int>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To <int>());
            }
            else if (_adb is AbstractDb <string> )
            {
                _adb.To <string>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To <string>());
            }

            copy._listView.SelectionChanged += delegate(object sender, SelectionChangedEventArgs args) {
                if (sender is ListView)
                {
                    ListView view = (ListView)sender;
                    tabEngine.StoreAndExecute(new SelectionChanged(copy.Header.ToString(), view.SelectedItem, view, copy));
                }
            };

            ((DisplayLabel)copy.Header).ContextMenu.Items.Cast <MenuItem>().ToList().ForEach(p => p.IsEnabled = true);

            MenuItem mitem = new MenuItem();

            mitem.Icon = new Image {
                Source = ApplicationManager.GetResourceImage("delete.png")
            };
            mitem.Header = "Delete table";
            mitem.Click += delegate {
                holder.RemoveTable(_adb);
                mainTabControl.Items.Remove(copy);

                List <string> tabs = ProjectConfiguration.CustomTabs;
                tabs.Remove(_file);
                ProjectConfiguration.CustomTabs = tabs.Distinct().ToList();
            };

            ((DisplayLabel)copy.Header).ContextMenu.Items.Add(mitem);

            mainTabControl.Items.Insert(mainTabControl.Items.Count, copy);
            _adb.LoadDb();

            if (_adb is AbstractDb <int> )
            {
                copy.To <int>().SearchEngine.Filter(this);
            }
            else if (_adb is AbstractDb <string> )
            {
                copy.To <string>().SearchEngine.Filter(this);
            }

            editor.GdTabs.Add(copy);
        }
Example #2
0
		public void Add(TabControl mainTabControl, DbHolder holder, TabNavigation tabEngine, SdeEditor editor) {
			holder.AddTable(_adb);
			GDbTab copy = holder.GetTab(_adb, mainTabControl);

			if (_adb is AbstractDb<int>)
				_adb.To<int>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To<int>());
			else if (_adb is AbstractDb<string>)
				_adb.To<string>().Table.Commands.CommandIndexChanged += (e, a) => editor.UpdateTabHeader(_adb.To<string>());

			copy._listView.SelectionChanged += delegate(object sender, SelectionChangedEventArgs args) {
				if (sender is ListView) {
					ListView view = (ListView)sender;
					tabEngine.StoreAndExecute(new SelectionChanged(copy.Header.ToString(), view.SelectedItem, view, copy));
				}
			};

			((DisplayLabel) copy.Header).ContextMenu.Items.Cast<MenuItem>().ToList().ForEach(p => p.IsEnabled = true);

			MenuItem mitem = new MenuItem();
			mitem.Icon = new Image { Source = ApplicationManager.GetResourceImage("delete.png") };
			mitem.Header = "Delete table";
			mitem.Click += delegate {
				holder.RemoveTable(_adb);
				mainTabControl.Items.Remove(copy);

				List<string> tabs = ProjectConfiguration.CustomTabs;
				tabs.Remove(_file);
				ProjectConfiguration.CustomTabs = tabs.Distinct().ToList();
			};

			((DisplayLabel) copy.Header).ContextMenu.Items.Add(mitem);

			mainTabControl.Items.Insert(mainTabControl.Items.Count, copy);
			_adb.LoadDb();

			if (_adb is AbstractDb<int>)
				copy.To<int>().SearchEngine.Filter(this);
			else if (_adb is AbstractDb<string>)
				copy.To<string>().SearchEngine.Filter(this);

			editor.GdTabs.Add(copy);
		}