void HideDiffPanel()
        {
            // Remove the property grid from the split container back to
            // this control.
            diffSplitContainer.Panel1.Controls.Remove(propertyGrid);
            splitContainer.Panel2.Controls.Add(propertyGrid);

            // Fix the tab order.
            diffSplitContainer.TabStop = false;

            // Send the diff split container to the back.
            diffSplitContainer.SendToBack();

            // Bring the property grid back to the front.
            propertyGrid.BringToFront();
        }
        public ControlFilePropertyEditForm(ControlFile Control)
        {
            this.Height = 500;
            this.Width = 500;
            if (null == Control) {
                throw new Exception("Must specify a valid control file.");
            }
            this.Icon = LayoutDetails.Instance.MainFormIcon;
            FormUtils.SizeFormsForAccessibility(this, LayoutDetails.Instance.MainFormFontSize);

            Button OK = new Button();
            OK.Text = Loc.Instance.GetString ("OK");
            OK.Dock =  DockStyle.Bottom;
            OK.DialogResult = DialogResult.OK;
            this.Controls.Add (OK);

            PropertyGrid grid = new PropertyGrid();
            grid.Dock = DockStyle.Fill;
            this.Controls.Add (grid);
            grid.BringToFront();

            grid.SelectedObject = Control;
        }
        public dashboardMarketEdit(DataTable _dataSource, Action<string, string> _UpdateSelectedMarket, LayoutPanelBase _CurrentLayout)
        {
            CurrentLayout = _CurrentLayout;
            if (null == _dataSource)
                throw new Exception ("invalid data source passed in");
            UpdateSelectedMarket = _UpdateSelectedMarket;

            MarketFilters = BuildMarketFilterBox ();

            //	NewMessage.Show ("boo");
            ListOfMarkets = new ListBox ();

            if (_dataSource.PrimaryKey.Length == 0) {
                _dataSource.PrimaryKey = new DataColumn[] { _dataSource.Columns ["Guid"] };
            }

            ViewOfTheData = new DataView (_dataSource);
            ViewOfTheData.Sort = "Caption ASC";
            ViewOfTheData.ListChanged += new System.ComponentModel.ListChangedEventHandler (OnListChanged);

            //ViewOfTheData.RowFilter = BuildRowFilter();

            ListOfMarkets.DataSource = ViewOfTheData;//_dataSource;
            ListOfMarkets.SelectedIndexChanged += HandleMarketListSelectedIndexChanged;
            ListOfMarkets.DisplayMember = "Caption";

            //ListOfMarkets.DoubleClick+= HandleListOfDoubleClick;
            //	ListOfMarkets.MouseDown+= HandleListOfMarketsMouseDown;

            //ListOfMarkets.Sorted = true;
            //ListOfMarkets.Width = 200;
            //
            // TAB CONTROL SIDE
            //

            TabControl Tabs = new TabControl ();
            Tabs.Dock = DockStyle.Fill;

            TabPage MarketEditing = new TabPage ();
            MarketEditing.Text = Loc.Instance.GetString ("Market Details");

            TabPage MarketSubmissions = new TabPage ();
            MarketSubmissions.Text = Loc.Instance.GetString ("Market Submissions");

            TabPage MarketNotes = new TabPage ();
            MarketNotes.Text = Loc.Instance.GetString ("Market Notes");

            Tabs.TabPages.Add (MarketEditing);
            Tabs.TabPages.Add (MarketNotes);
            Tabs.TabPages.Add (MarketSubmissions);

            Tabs.SelectedIndexChanged += HandleMiniTabSelectedIndexChanged;

            SubLabel = new Label ();
            SubLabel.Text = Loc.Instance.GetString ("Submissions");
            SubLabel.Dock = DockStyle.Top;
            DestLabel = new Label ();
            DestLabel.Dock = DockStyle.Bottom;
            DestLabel.Text = Loc.Instance.GetString ("Destinations");

            PreviousSubmissions = new ListBox ();
            PreviousSubmissions.DoubleClick += HandlePreviousSubmissionsDoubleClick;
            PreviousSubmissions.Dock = DockStyle.Fill;
            //PreviousSubmissions.Height = 100;

            Destinations = new ListBox ();
            Destinations.Dock = DockStyle.Bottom;
            Destinations.Height = 100;

            tmpEditor = new PropertyGrid ();
            tmpEditor.Dock = DockStyle.Fill;
            tmpEditor.PropertyValueChanged += HandlePropertyValueChanged;
            tmpEditor.Height = 300;

            MarketEditing.Controls.Add (tmpEditor);
            MarketSubmissions.Controls.Add (DestLabel);
            MarketSubmissions.Controls.Add (PreviousSubmissions);
            PreviousSubmissions.BringToFront ();

            MarketSubmissions.Controls.Add (SubLabel);
            MarketSubmissions.Controls.Add (Destinations);

            //
            // MAIN TABlE
            //

            //	Panel EasyMarketEdit = new Panel();

            //	EasyMarketEdit.BackColor = Color.Green;
            //	EasyMarketEdit.Height = 200;

            //	EasyMarketEdit.Dock = DockStyle.Fill;

            //	EasyMarketEdit.Controls.Add (Tabs);

            //	tmpEditor.Enabled = false;
            tmpEditor.BringToFront ();

            AddMarket = new Button ();
            AddMarket.Dock = DockStyle.Bottom;
            AddMarket.Text = Loc.Instance.GetString ("Add Market");
            AddMarket.Click += HandleAddMarketClick;

            EditMarket = new Button ();
            EditMarket.Text = Loc.Instance.GetString ("Save Edits");
            EditMarket.Dock = DockStyle.Fill;
            EditMarket.Enabled = false;
            EditMarket.Click += HandleEditMarketClick;

            EditMarketCancel = new Button ();
            EditMarketCancel.Dock = DockStyle.Fill;
            EditMarketCancel.Text = Loc.Instance.GetString ("Cancel Edit");
            EditMarketCancel.Enabled = false;
            EditMarketCancel.Click += HandleEditMarketCancelClick;

            TableLayoutPanel MarketListPanel = new TableLayoutPanel ();

            MarketListPanel.RowCount = 2;
            MarketListPanel.ColumnCount = 3;

            MarketListPanel.Controls.Add (EditMarket, 1, 0);
            MarketListPanel.Controls.Add (AddMarket, 0, 0);
            MarketListPanel.Controls.Add (EditMarketCancel, 2, 0);

            //MarketListPanel.Controls.Add (EditMarketCancel, 1, 0);

            //MarketListPanel.Controls.Add (ListOfMarkets, 0, 1);
            MarketListPanel.Controls.Add (Tabs, 1, 1);
            MarketListPanel.SetColumnSpan (Tabs, 2);

            //	MarketListPanel.Controls.Add (PreviousSubmissions, 1, 2);

            //	MarketListPanel.Controls.Add (AddMarket, 0, 3);

            Panel RightSide = new Panel();

            RightSide.Controls.Add (MarketFilters);
            RightSide.Controls.Add (ListOfMarkets);

            ListOfMarkets.Dock = DockStyle.Fill;
            ListOfMarkets.BringToFront();
            RightSide.Dock = DockStyle.Fill;
            RightSide.BringToFront ();

            MarketListPanel.Controls.Add (RightSide, 0, 1);

            MarketListPanel.SetRowSpan(Tabs, 2);
            MarketListPanel.SetRowSpan(RightSide, 2);
            MarketListPanel.Dock = DockStyle.Fill;

            //this.Controls.Add (AddMarket);

            //NewMessage.Show ("boo2");
            this.Controls.Add (MarketListPanel);
            MarketListPanel.BringToFront();
            //	AddMarket.SendToBack();

            //
            // Setup Market Notes Pages
            //

            richBox = new RichTextBox();
            MarketNotes.Controls.Add (richBox);
            richBox.Dock = DockStyle.Fill;
            richBox.KeyDown+= HandleNotesKeyDown;

            MarketListPanel.ColumnStyles.Clear();
            for (int i = 0; i < MarketListPanel.ColumnCount; i++)
            {
                ColumnStyle style = new ColumnStyle(SizeType.Percent, 33.0f);
                MarketListPanel.ColumnStyles.Add(style);
            }

            MarketListPanel.RowStyles.Clear();
            for (int i = 0; i < MarketListPanel.RowCount; i++)
            {
                MarketListPanel.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }
        }