private void buttonDown_Click(object sender, EventArgs e)
        {
            ColumnsListView colList = CurrentList;

            if (colList == null)
            {
                return;
            }

            ColParams colParams = ColumnsLists[colList];

            if (colParams == null)
            {
                return;
            }

            if (colList.SelectedRows.Count == 1)
            {
                colList.SuspendLayout();
                int row = colList.SelectedRows[0].Index;
                if (row < colList.Rows.Count - 1)
                {
                    int    col = colList.Columns["OrderIndex"].Index;
                    object a   = colList[col, row].Value;
                    object b   = colList[col, row + 1].Value;

                    colList[col, row].Value     = b;
                    colList[col, row + 1].Value = a;
                }
                colList.Sort(colList.Columns["OrderIndex"], ListSortDirection.Ascending);
                colList.ResumeLayout();
            }
            UpdateButtons(colList, e);
        }
        private void buttonResetSort_Click(object sender, EventArgs e)
        {
            ColumnsListView colList = CurrentList;

            if (colList == null)
            {
                return;
            }
            colList.ResetSortOrder();
        }
示例#3
0
 private void ColumnsListView_Loaded(object sender, RoutedEventArgs e)
 {
     if (ReferenceEquals(e.OriginalSource, ColumnsListView))
     {
         var scrollViewer = ColumnsListView.GetFirstDescendantBreadthFirst <ScrollViewer>();
         if (scrollViewer != null)
         {
             ListBoxScrollViewer = scrollViewer;
         }
     }
 }
示例#4
0
        private void ShowColumns()
        {
            Cursor       csr = null;
            ListViewItem ColumnListViewItem;
            Table        tbl;

            try
            {
                csr         = this.Cursor;        // Save the old cursor
                this.Cursor = Cursors.WaitCursor; // Display the waiting cursor

                // Delay rendering until after list filled
                ColumnsListView.BeginUpdate();

                // Clear the columns list
                ColumnsListView.Items.Clear();

                // Show the current columns for the selected table
                if (TablesComboBox.SelectedIndex >= 0)
                {
                    // Get the selected table object
                    tbl = (Table)TablesComboBox.SelectedItem;

                    // Iterate through all the columns to fill list
                    foreach (Column col in tbl.Columns)
                    {
                        ColumnListViewItem =
                            ColumnsListView.Items.Add(col.Name);
                        ColumnListViewItem.SubItems.Add(col.DataType.Name);
                        ColumnListViewItem.SubItems.Add(col.DataType.
                                                        MaximumLength.ToString(
                                                            System.Globalization.CultureInfo.InvariantCulture));
                        ColumnListViewItem.SubItems.Add(
                            col.Nullable.ToString());
                        ColumnListViewItem.SubItems.Add(
                            col.InPrimaryKey.ToString());
                    }
                }

                // Now we render the listview
                ColumnsListView.EndUpdate();
                UpdateButtons();
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
            finally
            {
                this.Cursor = csr;  // Restore the original cursor
            }
        }
        public SettingsColumnsDialog(Style style, Folder optionFolder, Style finalStyle)
        {
            try
            {
                this.finalStyle = finalStyle;
                InitializeComponent();
                ComponentResourceManager resources = new ComponentResourceManager(typeof(Forms.MainFormDialog));
                this.Text         = resources.GetObject("menuItem8.Text").ToString() + "->" + resources.GetObject("mIColumns.Text").ToString().TrimEnd('.');
                this.optionFolder = optionFolder;
                FolderCollection savedStyles = optionFolder.GetSavedFolders();
                m_style = style;

                if (/*style == null &&*/ savedStyles.Count > 0)
                {
                    panelColumns.Controls.Remove(list);
                    list.Visible = false;

                    int countAvailableStyles = 0;

                    foreach (Folder folder in savedStyles)
                    {
                        string    name    = folder.Name;
                        ColParams colsNew = new ColParams(folder, false);
                        if (colsNew.WasInited && colsNew.NotEmpty(true))
                        {
                            ColumnsListView listNew = (ColumnsListView)list.Clone();
                            ColumnsLists.Add(listNew, colsNew);

                            countAvailableStyles++;
                        }
                    }

                    if (countAvailableStyles == 1)
                    {
                        ColumnsLists.Clear();
                        TheOnlyStyleToEdit(finalStyle);
                    }
                    else
                    {
                        subLayout = Environment.Layout.Folders.Add("SettingsColumns");
                        Closed   += SettingsColumnsDialog_Closed;
                    }
                }
                //else
                //    TheOnlyStyleToEdit(style);
            }
            catch (Exception ex)
            {
                Environment.CmdManager.Commands["ResetColumns"].Execute();
            }
        }
            private ColumnsListView(ColumnsListView list)
            {
                ShowCellToolTips      = list.ShowCellToolTips;
                DoubleBuffered        = list.DoubleBuffered;
                AutoGenerateColumns   = list.AutoGenerateColumns;
                MultiSelect           = list.MultiSelect;
                SelectionMode         = list.SelectionMode;
                EditMode              = list.EditMode;
                AutoSize              = list.AutoSize;
                AutoSizeColumnsMode   = list.AutoSizeColumnsMode;
                AutoSizeRowsMode      = list.AutoSizeRowsMode;
                AllowUserToResizeRows = list.AllowUserToResizeRows;
                AllowUserToAddRows    = list.AllowUserToAddRows;
                AllowUserToDeleteRows = list.AllowUserToDeleteRows;
                Dock = list.Dock;
                ColumnHeadersVisible     = list.ColumnHeadersVisible;
                RowHeadersVisible        = list.RowHeadersVisible;
                AllowUserToResizeColumns = list.AllowUserToResizeColumns;
                GridColor = list.GridColor;
                Anchor    = list.Anchor;

                Init();
            }
        private void UpdateButtons(object sender, EventArgs e)
        {
            bool up   = false;
            bool down = false;

            ColumnsListView colList = sender as ColumnsListView;

            if (colList == null)
            {
                return;
            }

            colList.SuspendLayout();
            if (colList.SelectedRows.Count == 1)
            {
                DataGridViewRow item = colList.SelectedRows[0];
                if (item.Index > 0)
                {
                    up = true;
                }
                if (item.Index < colList.Rows.Count - 1)
                {
                    down = true;
                }
            }
            colList.ResumeLayout();

            if (buttonUp.Enabled != up)
            {
                buttonUp.Enabled = up;
            }

            if (buttonDown.Enabled != down)
            {
                buttonDown.Enabled = down;
            }
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsColumnsDialog));
     this.panelColumns    = new System.Windows.Forms.Panel();
     this.list            = new Kesco.App.Win.DocView.Settings.SettingsColumnsDialog.ColumnsListView();
     this.tabControl      = new System.Windows.Forms.TabControl();
     this.buttonUp        = new System.Windows.Forms.Button();
     this.buttonDown      = new System.Windows.Forms.Button();
     this.buttonReset     = new System.Windows.Forms.Button();
     this.buttonCancel    = new System.Windows.Forms.Button();
     this.buttonOK        = new System.Windows.Forms.Button();
     this.panelButtons    = new System.Windows.Forms.Panel();
     this.buttonResetSort = new System.Windows.Forms.Button();
     this.panelColumns.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.list)).BeginInit();
     this.panelButtons.SuspendLayout();
     this.SuspendLayout();
     //
     // panelColumns
     //
     resources.ApplyResources(this.panelColumns, "panelColumns");
     this.panelColumns.Controls.Add(this.list);
     this.panelColumns.Controls.Add(this.tabControl);
     this.panelColumns.Controls.Add(this.buttonUp);
     this.panelColumns.Controls.Add(this.buttonDown);
     this.panelColumns.Name = "panelColumns";
     //
     // list
     //
     this.list.AllowUserToAddRows       = false;
     this.list.AllowUserToDeleteRows    = false;
     this.list.AllowUserToResizeColumns = false;
     this.list.AllowUserToResizeRows    = false;
     resources.ApplyResources(this.list, "list");
     this.list.BackgroundColor      = System.Drawing.SystemColors.Window;
     this.list.CellBorderStyle      = System.Windows.Forms.DataGridViewCellBorderStyle.None;
     this.list.ColumnHeadersVisible = false;
     this.list.EditMode             = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
     this.list.MultiSelect          = false;
     this.list.Name = "list";
     this.list.RowHeadersVisible = false;
     this.list.SelectionMode     = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
     this.list.ShowCellToolTips  = false;
     //
     // tabControl
     //
     resources.ApplyResources(this.tabControl, "tabControl");
     this.tabControl.Name          = "tabControl";
     this.tabControl.SelectedIndex = 0;
     //
     // buttonUp
     //
     resources.ApplyResources(this.buttonUp, "buttonUp");
     this.buttonUp.Name   = "buttonUp";
     this.buttonUp.Click += new System.EventHandler(this.buttonUp_Click);
     //
     // buttonDown
     //
     resources.ApplyResources(this.buttonDown, "buttonDown");
     this.buttonDown.Name   = "buttonDown";
     this.buttonDown.Click += new System.EventHandler(this.buttonDown_Click);
     //
     // buttonReset
     //
     resources.ApplyResources(this.buttonReset, "buttonReset");
     this.buttonReset.Name   = "buttonReset";
     this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click);
     //
     // buttonCancel
     //
     resources.ApplyResources(this.buttonCancel, "buttonCancel");
     this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     this.buttonCancel.Name         = "buttonCancel";
     this.buttonCancel.Click       += new System.EventHandler(this.buttonCancel_Click);
     //
     // buttonOK
     //
     resources.ApplyResources(this.buttonOK, "buttonOK");
     this.buttonOK.Name   = "buttonOK";
     this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
     //
     // panelButtons
     //
     this.panelButtons.Controls.Add(this.buttonResetSort);
     this.panelButtons.Controls.Add(this.buttonReset);
     this.panelButtons.Controls.Add(this.buttonCancel);
     this.panelButtons.Controls.Add(this.buttonOK);
     resources.ApplyResources(this.panelButtons, "panelButtons");
     this.panelButtons.Name = "panelButtons";
     //
     // buttonResetSort
     //
     resources.ApplyResources(this.buttonResetSort, "buttonResetSort");
     this.buttonResetSort.Name   = "buttonResetSort";
     this.buttonResetSort.Click += new System.EventHandler(this.buttonResetSort_Click);
     //
     // SettingsColumnsDialog
     //
     this.AcceptButton = this.buttonOK;
     resources.ApplyResources(this, "$this");
     this.CancelButton = this.buttonCancel;
     this.Controls.Add(this.panelColumns);
     this.Controls.Add(this.panelButtons);
     this.KeyPreview  = true;
     this.MaximizeBox = false;
     this.MinimizeBox = false;
     this.Name        = "SettingsColumnsDialog";
     this.Load       += new System.EventHandler(this.SettingsColumnsDialog_Load);
     this.panelColumns.ResumeLayout(false);
     ((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
     this.panelButtons.ResumeLayout(false);
     this.ResumeLayout(false);
 }
        private void UiLoginMessage(DataToolsUIMsg message)
        {
            this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
            {
                switch (message.type)
                {
                case "ShowTables":
                    //显示某个数据库的数据表
                    if (null != message.dataSet && message.dataSet.Tables[0].Rows.Count > 0)
                    {
                        TablesListView.BeginInit();
                        //TablesListView.Items.Clear();
                        tableLists.Clear();
                        int i = 0;
                        foreach (DataRow row in message.dataSet.Tables[0].Rows)
                        {
                            i++;
                            tableLists.Add(new DataList(i.ToString(), row[0].ToString()));
                        }
                        TablesListView.ItemsSource = tableLists;
                        TablesListView.EndInit();
                    }
                    break;

                case "ShowTableColumns":
                    //显示某个数据库的数据表的所有字段
                    if (null != message.dataSet && message.dataSet.Tables[0].Rows.Count > 0)
                    {
                        ColumnsListView.BeginInit();
                        columnsLists.Clear();
                        int i = 0;
                        foreach (DataRow row in message.dataSet.Tables[0].Rows)
                        {
                            i++;
                            columnsLists.Add(new DataList(i.ToString(), row[0].ToString(), row[1].ToString()));
                        }
                        ColumnsListView.ItemsSource = columnsLists;
                        ColumnsListView.EndInit();
                    }
                    break;

                case "ShowDataBases":
                    //显示所有数据库
                    if (null != message.dataSet && message.dataSet.Tables[0].Rows.Count > 0)
                    {
                        DataBaseList.BeginInit();
                        DataBaseList.Items.Clear();
                        foreach (DataRow row in message.dataSet.Tables[0].Rows)
                        {
                            DataBaseList.Items.Add(row[0].ToString());
                        }
                        DataBaseList.EndInit();
                    }
                    if (DataBaseList.Items.Count > 0)
                    {
                        DataBaseList.SelectedIndex = 0;
                    }
                    break;

                case "ShowTableData":
                    //显示表中数据
                    if (null != message.dataSet && message.dataSet.Tables[0].Rows.Count > 0)
                    {
                        AllTableData.BeginInit();
                        AllTableData.ItemsSource = message.dataSet.Tables[0].DefaultView;
                        AllTableData.EndInit();
                    }
                    else
                    {
                        AllTableData.BeginInit();
                        AllTableData.ItemsSource = null;
                        AllTableData.EndInit();
                    }
                    break;

                case "exception":
                    MessageBox.Show(message.message);
                    Status1.Content = message.message;
                    break;
                }
            }));
        }