Exemple #1
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            CheckUpdate();

            ThemeManager.Theme.ChangeTheme(UserSettingStorage.Instance.Theme);
            InternationalizationManager.Instance.ChangeLanguage(UserSettingStorage.Instance.Language);

            InitProgressbarAnimation();
            WindowIntelopHelper.DisableControlBox(this);

            var vm = (MainViewModel)DataContext;

            vm.TextBoxSelected  += (o, e) => QueryTextBox.SelectAll();
            vm.CursorMovedToEnd += (o, e) =>
            {
                QueryTextBox.Focus();
                QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
            };
            vm.MainWindowVisibilityChanged += (o, e) =>
            {
                if (vm.MainWindowVisibility.IsVisible())
                {
                    Activate();
                    QueryTextBox.Focus();
                }
            };

            vm.Left = GetWindowsLeft();
            vm.Top  = GetWindowsTop();
            vm.MainWindowVisibility = Visibility.Visible;
        }
Exemple #2
0
        //reset the load and gui of part 2
        private void Reset_Part2_Click(object sender, RoutedEventArgs e)
        {
            //reset GUI
            r   = null;
            p   = null;
            ind = null;
            showcatch.IsEnabled = false;
            showDic.IsEnabled   = false;
            runQuery.IsEnabled  = false;
            QueryTextBox.Clear();
            isWikiExp.IsChecked     = false;
            isSumCheck.IsChecked    = false;
            stemmcheckBox.IsChecked = false;
            //Delete Last File
            try
            {
                if (File.Exists(Results.LastFile))
                {
                    File.Delete(Results.LastFile);
                }
            }
            catch (IOException)
            {
                Debug.WriteLine("CANT DELETE!!!!!");
            }
            //Garbage Collector
            GC.Collect();
            GC.WaitForPendingFinalizers();

            //notification
            System.Windows.Forms.MessageBox.Show("The Memory is clean!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
Exemple #3
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // todo is there a way to set blur only once?
            BlurWindowHelper.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            //InitProgressbarAnimation();
            InitializePosition();
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();

            MainViewModel.Current.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        UpdatePosition();
                        if (MainViewModel.Current.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            MainViewModel.Current.LastQuerySelected = false;
                        }
                    }
                }
            };
            InitializePosition();
        }
Exemple #4
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            WindowIntelopHelper.DisableControlBox(this);
            ThemeManager.Instance.ChangeTheme(_settings.Theme);
            InitializeNotifyIcon();
            InitProgressbarAnimation();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (_viewModel.MainWindowVisibility.IsVisible())
                    {
                        Activate();
                        QueryTextBox.Focus();
                        SetWindowPosition();
                        _settings.ActivateTimes++;
                        if (_viewModel.QueryTextSelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.QueryTextSelected = false;
                        }
                    }
                }
            };
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();
        }
Exemple #5
0
 private void RegisterEvents(MainViewModel vm)
 {
     vm.TextBoxSelected  += (o, e) => QueryTextBox.SelectAll();
     vm.CursorMovedToEnd += (o, e) =>
     {
         QueryTextBox.Focus();
         QueryTextBox.CaretIndex = QueryTextBox.Text.Length;
     };
     vm.MainWindowVisibilityChanged += (o, e) =>
     {
         if (vm.MainWindowVisibility.IsVisible())
         {
             Activate();
             QueryTextBox.Focus();
             Left = GetWindowsLeft();
             Top  = GetWindowsTop();
             _settings.ActivateTimes++;
         }
         else
         {
             _settings.WindowLeft = Left;
             _settings.WindowTop  = Top;
         }
     };
 }
Exemple #6
0
        public QueryEditorView()
        {
            InitializeComponent();

            _suggestionView = new SuggestionView(QueryTextBox)
            {
                DefaultSelectedIndex = 0
            };

            ViewerForm.Theme.ApplyTo(EditorToolStrip);

            // initialize highlighting
            QueryTextBox.StyleResetDefault();
            QueryTextBox.Styles[Style.Default].Font = "Consolas";
            QueryTextBox.Styles[Style.Default].Size = 11;
            QueryTextBox.StyleClearAll();

            QueryTextBox.Styles[Style.LineNumber].ForeColor = Color.FromArgb(0x888888);
            QueryTextBox.Styles[Style.LineNumber].BackColor = Color.White;

            QueryTextBox.Styles[Style.Sql.String].ForeColor   = Color.FromArgb(0xa31515);
            QueryTextBox.Styles[Style.Sql.Word].ForeColor     = Color.FromArgb(0x0000ff);
            QueryTextBox.Styles[Style.Sql.Operator].ForeColor = Color.FromArgb(0x444444);
            QueryTextBox.Styles[Style.Sql.Number].ForeColor   = Color.FromArgb(0x09885a);

            QueryTextBox.Lexer = Lexer.Sql;
            QueryTextBox.SetKeywords(0, "select where order group by desc asc and or not union except intersect");

            QueryTextBox.Margins[0].Type  = MarginType.Number;
            QueryTextBox.Margins[0].Width = 20;

            QueryTextBox.ClearCmdKey(Keys.Control | Keys.S);
            QueryTextBox.ClearCmdKey(Keys.Control | Keys.O);
        }
Exemple #7
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // todo is there a way to set blur only once?
            ThemeManager.Instance.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            InitProgressbarAnimation();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        SetWindowPosition();
                        _settings.ActivateTimes++;
                        if (!_viewModel.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.LastQuerySelected = true;
                        }
                    }
                }
            };
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();
        }
Exemple #8
0
        /// <summary>
        /// event is fired when the 'UpdateButton' is clicked.
        /// </summary>
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            // Change the text
            QueryTextBox.Text = "Update" + Environment.NewLine + "Set ";

            // Set Focus
            QueryTextBox.Focus();
        }
Exemple #9
0
        /// <summary>
        /// Event delegate method fired when the <see cref="QueryTextBox"/> has been validated.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void QueryTextBox_Validated(object sender, EventArgs e)
        {
            if (!QueryChangedTimer.Enabled)
            {
                return;
            }

            QueryChangedTimer.Stop();

            // Identify the statements that would exceed the server's max allowed packet value and highlight them for the user.
            string queryText = QueryTextBox.Text.Trim();

            if (queryText.Length <= 0)
            {
                return;
            }

            QueryTextBox.ReadOnly = true;
            Cursor = Cursors.WaitCursor;

            bool statementsExceedingMaxAllowedPacketValueFound = false;
            bool reachedEnd             = false;
            int  statementStartPosition = 0;

            do
            {
                int statementEndPosition = queryText.IndexOf(";", statementStartPosition, StringComparison.Ordinal);
                if (statementEndPosition < 0)
                {
                    reachedEnd           = true;
                    statementEndPosition = queryText.Length - 1;
                }

                // Get SQL statement
                string sqlStatement = queryText.Substring(statementStartPosition, statementEndPosition - statementStartPosition).Trim();

                // TODO: Split statement in tokens using MySQL parser classes and paint them accordingly.

                // Highlight the statement if it exceeds the MySQL Servers's max allowed packet value.
                if (sqlStatement.ExceedsMySqlMaxAllowedPacketValue(MySqlMaxAllowedPacket))
                {
                    QueryTextBox.Select(statementStartPosition, statementEndPosition - statementStartPosition);
                    QueryTextBox.SelectionBackColor = Color.GreenYellow;
                    statementsExceedingMaxAllowedPacketValueFound = true;
                }

                statementStartPosition = statementEndPosition + 1;
                reachedEnd             = reachedEnd || statementStartPosition >= queryText.Length;
            }while (!reachedEnd);

            QueryWarningPictureBox.Visible = statementsExceedingMaxAllowedPacketValueFound;
            QueryWarningLabel.Visible      = statementsExceedingMaxAllowedPacketValueFound;

            QueryTextBox.ReadOnly       = false;
            OriginalQueryButton.Enabled = !string.Equals(OriginalSqlScript, SqlScript, StringComparison.InvariantCultureIgnoreCase);
            ApplyButton.Enabled         = SqlScript.Trim().Length > 0;
            Cursor = Cursors.Default;
        }
Exemple #10
0
 private void Reset_mini()
 {
     //reset GUI
     QueryTextBox.Clear();
     QueryTextBox.IsReadOnly = false;
     isWikiExp.IsChecked     = false;
     isSumCheck.IsChecked    = false;
     queryFile = null;
 }
Exemple #11
0
 private void SearchPage_Loaded(object sender, RoutedEventArgs e)
 {
     Loaded -= SearchPage_Loaded;
     App.EntriesManager.Construct();
     // tfw best practice :p
     VisualStateManager.GoToState(this, QueryState.Name, true);
     QueryTextBox.Focus(FocusState.Programmatic);
     DictsCheck();
     App.DictsManager.DictDatabaseChanged += (s, f) => DictsCheck();
 }
Exemple #12
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            InitializeNotifyIcon();
            // todo is there a way to set blur only once?
            ThemeManager.Instance.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            InitProgressbarAnimation();
            InitializePosition();
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        UpdatePosition();
                        _settings.ActivateTimes++;
                        if (!_viewModel.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.LastQuerySelected = true;
                        }
                    }
                    return;
                }

                if (e.PropertyName == nameof(MainViewModel.ProgressBarVisibility))
                {
                    if (_viewModel.ProgressBarVisibility == Visibility.Visible)
                    {
                        ProgressBar.BeginStoryboard(_progressBarStoryboard);
                    }
                    else
                    {
                        _progressBarStoryboard.Stop(ProgressBar);
                    }
                }
            };
            _settings.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(Settings.HideNotifyIcon))
                {
                    _notifyIcon.Visible = !_settings.HideNotifyIcon;
                }
            };
            InitializePosition();
        }
    public MemberListBox(CompletionForm completionForm, QueryTextBox textBox, ColorTheme colorTheme)
    {
        // This call is required by the Windows.Forms Form Designer.
        InitializeComponent();

        // TODO: Add any initialization after the InitForm call
        _completionForm = completionForm;
        _textBox        = textBox;

        if (colorTheme != null)
        {
            ListBox.ForeColor = colorTheme.ForeColor;
            ListBox.BackColor = colorTheme.BackColor;
        }
    }
Exemple #14
0
        private void OnLoaded(object sender, RoutedEventArgs _)
        {
            // show notify icon when flowlauncher is hidden
            InitializeNotifyIcon();

            // todo is there a way to set blur only once?
            ThemeManager.Instance.SetBlurForWindow();
            WindowsInteropHelper.DisableControlBox(this);
            InitProgressbarAnimation();
            InitializePosition();
            // since the default main window visibility is visible
            // so we need set focus during startup
            QueryTextBox.Focus();

            _viewModel.PropertyChanged += (o, e) =>
            {
                if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
                {
                    if (Visibility == Visibility.Visible)
                    {
                        Activate();
                        QueryTextBox.Focus();
                        UpdatePosition();
                        _settings.ActivateTimes++;
                        if (!_viewModel.LastQuerySelected)
                        {
                            QueryTextBox.SelectAll();
                            _viewModel.LastQuerySelected = true;
                        }
                    }
                }
            };
            _settings.PropertyChanged += (o, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(Settings.HideNotifyIcon):
                    _notifyIcon.Visible = !_settings.HideNotifyIcon;
                    break;

                case nameof(Settings.Language):
                    UpdateNotifyIconText();
                    break;
                }
            };

            InitializePosition();
        }
Exemple #15
0
        private void OnQueryVisible(object sender, DependencyPropertyChangedEventArgs e)
        {
            var visible = (bool)e.NewValue;

            if (visible)
            {
                // the Focusable and the IsVisible both needs to be true when set focus
                // logical is set in xaml
                QueryTextBox.Focus();

                if (_viewModel.QueryTextSelected)
                {
                    QueryTextBox.SelectAll();
                    _viewModel.QueryTextSelected = false;
                }
            }
        }
Exemple #16
0
        private void OnInsertClicked(object sender, RoutedEventArgs routedEventArgs)
        {
            var mi     = (MenuItem)sender;
            var parent = (MenuItem)mi.Parent;
            var code   = $"{parent.Header}.{mi.Header}";
            var length = 0;

            QueryTextBox.Focus();
            var start = QueryTextBox.CaretIndex;

            if (QueryTextBox.SelectionLength > 0)
            {
                length = QueryTextBox.SelectionLength;
                start  = QueryTextBox.SelectionStart;
            }

            var methodInfo = Type.GetType($"Couchbase.Lite.Query.{parent.Header}, Couchbase.Lite").GetMethod(mi.Header.ToString());
            var isProperty = false;
            var arguments  = Enumerable.Empty <QueryArgument>();

            if (methodInfo == null)
            {
                if (Type.GetType($"Couchbase.Lite.Query.{parent.Header}, Couchbase.Lite")
                    .GetProperty(mi.Header.ToString()) == null)
                {
                    throw new ApplicationException("Unknown item, weird...");
                }

                isProperty = true;
            }
            else
            {
                arguments = methodInfo.GetParameters()
                            .Select(x => new QueryArgument(x.ParameterType == typeof(string), x.Name));
            }

            var range = ((QueryViewModel)DataContext).InsertQueryText(start, length, code, isProperty, arguments);

            QueryTextBox.SelectionStart  = range.start;
            QueryTextBox.SelectionLength = range.length;
        }
Exemple #17
0
        private void OnOpenClicked(object sender, RoutedEventArgs e)
        {
            var dialog = new VistaFolderBrowserDialog();
            var result = dialog.ShowDialog();

            if (result == true)
            {
                try {
                    DataContext = new QueryViewModel(dialog.SelectedPath);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error opening database");
                    return;
                }

                ((QueryViewModel)DataContext).Error += ShowError;
                QueryTextBox.Focus();
                ((QueryViewModel)DataContext).QueryText = "QueryBuilder.Select()";
                QueryTextBox.SelectionStart             = ((QueryViewModel)DataContext).QueryText.IndexOf('(') + 1;
                if (InsertMenu.Items.Count == 0)
                {
                    PopulateInsertMenu();
                }
            }
        }
 public MainWindow()
 {
     InitializeComponent();
     QueryTextBox.Focus();
     //TODO:ssdsf
 }
 private void OnMainWindowLoaded(object sender, RoutedEventArgs e) => QueryTextBox.Focus();
        /// <summary>
        /// 初始化控件
        /// </summary>
        public void CreateControls()
        {
            Paramater    _para        = new Paramater();
            ParamProcess _paraProcess = new ParamProcess();

            propertyPanel.Controls.Clear();
            bool    dtbegin = true;
            Control ctrl    = new Control();

            int y_local = 9;

            for (int i = 0; i < _paralist.Count; i++)
            {
                Paramater config = new Paramater();
                config = _paralist[i];

                #region 设置控件和列样式
                if (config.PARAMETER == "V_CURREMPLOYEEID")
                {
                    ctrl         = new TextBox();
                    ctrl.Enabled = false;
                    ctrl.Text    = _employyid.ToString();
                }
                else if (config.PARAMETER == "V_CURRDEPTID")
                {
                    ctrl         = new TextBox();
                    ctrl.Enabled = false;
                    ctrl.Text    = _deptid.ToString();
                }
                else if (config.UIC_TYPE == 4)
                {
                    #region  quertytext
                    GWI.HIS.Windows.Controls.QueryTextBox txtDepartment = new QueryTextBox();
                    txtDepartment.AllowSelectedNullRow = false;
                    txtDepartment.BackColor            = System.Drawing.Color.White;
                    txtDepartment.DisplayField         = "name";
                    txtDepartment.Location             = new System.Drawing.Point(120, 12);
                    txtDepartment.MatchMode            = GWI.HIS.Windows.Controls.MatchModes.ByAnyString;
                    txtDepartment.MemberField          = "id";
                    txtDepartment.MemberValue          = null;
                    txtDepartment.Name               = "txtDepartment";
                    txtDepartment.NextControl        = null;
                    txtDepartment.NextControlByEnter = false;
                    txtDepartment.OffsetX            = 0;
                    txtDepartment.OffsetY            = 0;
                    txtDepartment.QueryFields        = new string[] {
                        "PY_CODE"
                    };
                    txtDepartment.SelectedValue = null;
                    txtDepartment.SelectionCardAlternatingRowBackColor = System.Drawing.Color.WhiteSmoke;
                    txtDepartment.SelectionCardBackColor          = System.Drawing.Color.White;
                    txtDepartment.SelectionCardColumnHeaderHeight = 20;
                    GWI.HIS.Windows.Controls.SelectionCardColumn selectionCardColumn1 = new GWI.HIS.Windows.Controls.SelectionCardColumn();
                    GWI.HIS.Windows.Controls.SelectionCardColumn selectionCardColumn2 = new GWI.HIS.Windows.Controls.SelectionCardColumn();
                    GWI.HIS.Windows.Controls.SelectionCardColumn selectionCardColumn3 = new GWI.HIS.Windows.Controls.SelectionCardColumn();
                    GWI.HIS.Windows.Controls.SelectionCardColumn selectionCardColumn4 = new GWI.HIS.Windows.Controls.SelectionCardColumn();
                    selectionCardColumn1.AutoFill      = true;
                    selectionCardColumn1.DataBindField = "name";
                    selectionCardColumn1.HeaderText    = "名称";
                    selectionCardColumn1.IsNameField   = false;
                    selectionCardColumn1.IsSeachColumn = true;
                    selectionCardColumn1.TextAlign     = System.Windows.Forms.DataGridViewContentAlignment.NotSet;
                    selectionCardColumn1.Visiable      = true;
                    selectionCardColumn1.Width         = 75;
                    selectionCardColumn2.AutoFill      = false;
                    selectionCardColumn2.DataBindField = "PY_CODE";
                    selectionCardColumn2.HeaderText    = "拼音码";
                    selectionCardColumn2.IsNameField   = false;
                    selectionCardColumn2.IsSeachColumn = true;
                    selectionCardColumn2.TextAlign     = System.Windows.Forms.DataGridViewContentAlignment.NotSet;
                    selectionCardColumn2.Visiable      = false;
                    selectionCardColumn2.Width         = 75;
                    selectionCardColumn3.AutoFill      = false;
                    selectionCardColumn3.DataBindField = "id";
                    selectionCardColumn3.HeaderText    = "id";
                    selectionCardColumn3.IsNameField   = false;
                    selectionCardColumn3.IsSeachColumn = false;
                    selectionCardColumn3.TextAlign     = System.Windows.Forms.DataGridViewContentAlignment.NotSet;
                    selectionCardColumn3.Visiable      = false;
                    selectionCardColumn3.Width         = 75;


                    DataTable dtSource = new DataTable();
                    if (config.FOREIGNER_FILTER_SQL != "")
                    {
                        dtSource = _para.GetDataSource(config.FOREIGNER_FILTER_SQL);
                    }
                    else
                    {
                        if (config.ENUMEID != -1)
                        {
                            dtSource = _para.GetDataSource(_paraProcess.GetEnumSql(config.ENUMEID).REMARK);
                        }
                    }
                    if (dtSource.Columns.Contains("备注"))
                    {
                        selectionCardColumn1.AutoFill      = false;
                        selectionCardColumn4.AutoFill      = true;
                        selectionCardColumn4.DataBindField = "备注";
                        selectionCardColumn4.HeaderText    = "备注";
                        selectionCardColumn4.IsNameField   = false;
                        selectionCardColumn4.IsSeachColumn = false;
                        selectionCardColumn4.TextAlign     = System.Windows.Forms.DataGridViewContentAlignment.NotSet;
                        selectionCardColumn4.Visiable      = true;
                        selectionCardColumn4.Width         = 200;
                        txtDepartment.SelectionCardColumns = new GWI.HIS.Windows.Controls.SelectionCardColumn[] {
                            selectionCardColumn1,
                            selectionCardColumn2,
                            selectionCardColumn3,
                            selectionCardColumn4
                        };
                        txtDepartment.SelectionCardWidth = 350;
                    }
                    else
                    {
                        txtDepartment.SelectionCardColumns = new GWI.HIS.Windows.Controls.SelectionCardColumn[] {
                            selectionCardColumn1,
                            selectionCardColumn2,
                            selectionCardColumn3
                        };
                        txtDepartment.SelectionCardWidth = 150;
                    }
                    txtDepartment.SelectionCardFont                 = null;
                    txtDepartment.SelectionCardHeight               = 200;
                    txtDepartment.SelectionCardInfoLabelBackColor   = System.Drawing.Color.Empty;
                    txtDepartment.SelectionCardRowHeaderWidth       = 35;
                    txtDepartment.SelectionCardRowHeight            = 23;
                    txtDepartment.SelectionCardSelectedRowBackColor = System.Drawing.Color.DarkBlue;
                    txtDepartment.SelectionCardType                 = GWI.HIS.Windows.Controls.SelectionCardTypes.List;
                    //  txtDepartment.SelectionCardWidth = 225;
                    txtDepartment.ShowRowNumber = true;
                    txtDepartment.ShowSelectionCardAfterEnter = true;
                    txtDepartment.Size       = new System.Drawing.Size(123, 21);
                    txtDepartment.TabIndex   = 0;
                    txtDepartment.TextFormat = GWI.HIS.Windows.Controls.TextFormatStyle.AnyString;
                    txtDepartment.Visible    = true;
                    #endregion
                    if (config.FOREIGNER_FILTER_SQL != "")
                    {
                        txtDepartment.SetSelectionCardDataSource(dtSource);
                    }
                    else
                    {
                        if (config.ENUMEID != -1)
                        {
                            txtDepartment.SetSelectionCardDataSource(dtSource);
                        }
                    }
                    txtDepartment.DisplayField = "name";
                    txtDepartment.MemberField  = "id";
                    txtDepartment.MemberValue  = -1;
                    ctrl = txtDepartment;
                }
                else if (config.UIC_TYPE == 2)
                {
                    #region checkbox
                    ctrl = new CheckBox();
                    ((CheckBox)ctrl).Text     = config.PARAMETER_CN;
                    ((CheckBox)ctrl).AutoSize = true;
                    #endregion
                }
                else if (config.UIC_TYPE == 1)
                {
                    #region combobox
                    ctrl = new ComboBox();

                    if (config.FOREIGNER_FILTER_SQL != "")
                    {
                        ((ComboBox)ctrl).DataSource = _para.GetDataSource(config.FOREIGNER_FILTER_SQL);
                    }
                    else
                    {
                        if (config.ENUMEID != -1)
                        {
                            string sql = _paraProcess.GetEnumSql(config.ENUMEID).REMARK;
                            if (sql != null && sql != "")
                            {
                                ((ComboBox)ctrl).DataSource = _para.GetDataSource(sql);
                            }
                            else
                            {
                                ((ComboBox)ctrl).DataSource = _paraProcess.GetEnumOrders(config.ENUMEID);
                            }
                        }
                    }
                    ((ComboBox)ctrl).DisplayMember    = "name";
                    ((ComboBox)ctrl).ValueMember      = "id";
                    ((ComboBox)ctrl).MaxDropDownItems = 25;
                    ((ComboBox)ctrl).DropDownStyle    = ComboBoxStyle.DropDownList;

                    #endregion
                }
                else if (config.UIC_TYPE == 0)
                {
                    #region textbox
                    ctrl = new TextBox();

                    ((TextBox)ctrl).MaxLength = config.DATALENGTH;
                    #endregion
                }
                else if (config.UIC_TYPE == 3)
                {
                    #region datetimepicker
                    DateTimePicker dtpicter = new DateTimePicker();
                    dtpicter.CustomFormat = "yyyy-MM-dd HH:mm:ss";
                    dtpicter.Format       = DateTimePickerFormat.Custom;

                    if (dtbegin)
                    {
                        dtpicter.Value = Convert.ToDateTime(DateTime.Now.Date.ToString("yyyy-MM-dd") + " 00:00:00");
                        dtbegin        = false;
                    }
                    else
                    {
                        dtpicter.Value = Convert.ToDateTime(DateTime.Now.Date.ToString("yyyy-MM-dd") + " 23:59:59");
                    }
                    ctrl = dtpicter;
                    #endregion
                }
                else
                {
                }

                #endregion

                #region 创建控件和列
                // 定义标签
                Label lbl = new Label();
                lbl.Text     = config.PARAMETER_CN != "" ? config.PARAMETER_CN : config.PARAMETER;
                lbl.AutoSize = true;
                int lblWidth  = 0;
                int lblHeight = 0;
                using (System.Drawing.Graphics g = propertyPanel.CreateGraphics())
                {
                    System.Drawing.SizeF size = g.MeasureString(lbl.Text, propertyPanel.Font);
                    lblWidth  = Convert.ToInt32(size.Width);
                    lblHeight = Convert.ToInt32(size.Height);
                }

                //定义控件
                ctrl.Name     = config.PARAMETER;
                ctrl.Size     = new System.Drawing.Size(140, 21);
                ctrl.Location = new System.Drawing.Point(117, y_local);
                ctrl.Tag      = config;

                if (config.UIC_TYPE != 2)
                {
                    lbl.Left = ctrl.Left - lblWidth - 4;
                    lbl.Top  = ctrl.Top + (21 - lblHeight);
                    propertyPanel.Controls.Add(lbl);
                }
                if (_paralist[i].PARAMETER_TYPE == "OUT")
                {
                    ctrl.Visible = false;
                    lbl.Visible  = false;
                }
                propertyPanel.Controls.Add(ctrl);
                y_local += 27;

                #endregion
            }
        }
Exemple #21
0
 private void ClearAllButton_Click(object sender, EventArgs e)
 {
     QueryTextBox.Clear();
     dataGridView1.DataSource = "";
     dataGridView1.Refresh();
 }
Exemple #22
0
 public void ClearEditBox()
 {
     QueryTextBox.Clear();
 }
 public MainWindow()
 {
     InitializeComponent();
     QueryTextBox.AppendText("https://www.youtube.com/watch?v=hG0KHghzSPI");
 }
        public DataTable GetSchemaTable()
        {
            PropertyDataCollection properties = null;

            if (_firstObject == null)
            {
                var moveNext = _enumerator.MoveNext();
                _firstRead = true;

                if (moveNext)
                {
                    _firstObject = _enumerator.Current;
                    properties   = _firstObject.Properties;
                }
                else
                {
                    var    query     = _command.CommandText;
                    var    index     = 0;
                    var    fromFound = false;
                    string className = null;

                    while (true)
                    {
                        var wordStart = QueryTextBox.NextWordStart(query, index);
                        var wordEnd   = QueryTextBox.WordEnd(query, wordStart);
                        var word      = query.Substring(wordStart, wordEnd - wordStart + 1);

                        if (fromFound)
                        {
                            className = word;
                            break;
                        }
                        else
                        {
                            if (word.ToLower() == "from")
                            {
                                fromFound = true;
                            }

                            index = wordEnd + 1;
                        }
                    }

                    query = $"SELECT * FROM meta_class WHERE __this ISA '{className}'";
                    var objectQuery = new ObjectQuery(query);
                    var searcher    = new ManagementObjectSearcher(_command.Connection.Scope, objectQuery);
                    var objects     = searcher.Get();
                    var enumerator2 = objects.GetEnumerator();
                    enumerator2.MoveNext();
                    properties = enumerator2.Current.Properties;
                }
            }

            var schemaTable = new DataTable();

            schemaTable.Columns.Add("ColumnName", typeof(string));
            schemaTable.Columns.Add("ColumnSize", typeof(int));
            schemaTable.Columns.Add("DataType", typeof(Type));
            schemaTable.Columns.Add("ProviderType", typeof(int));
            schemaTable.Columns.Add("ProviderTypeStr", typeof(string));
            schemaTable.Columns.Add("NumericPrecision", typeof(int));
            schemaTable.Columns.Add("NumericScale", typeof(int));
            schemaTable.Columns.Add("IsArray", typeof(bool));
            var values = new object[8];

            foreach (var propertyData in properties)
            {
                var  cimType = propertyData.Type;
                Type dataType;
                int  size;

                switch (cimType)
                {
                case CimType.Boolean:
                    dataType = typeof(bool);
                    size     = 1;
                    break;

                case CimType.DateTime:
                    dataType = typeof(DateTime);
                    size     = 8;
                    break;

                case CimType.UInt8:
                    dataType = typeof(byte);
                    size     = 1;
                    break;

                case CimType.UInt16:
                    dataType = typeof(ushort);
                    size     = 2;
                    break;

                case CimType.UInt32:
                    dataType = typeof(uint);
                    size     = 4;
                    break;

                case CimType.UInt64:
                    dataType = typeof(ulong);
                    size     = 8;
                    break;

                case CimType.String:
                    dataType = typeof(string);
                    size     = 0;
                    break;

                default:
                    dataType = typeof(object);
                    size     = 0;
                    break;
                }

                int    providerType;
                string providerTypeStr;

                if (propertyData.IsArray)
                {
                    providerType = (int)cimType | 0x1000;
                    var typeName = dataType.FullName + "[]";
                    dataType        = Type.GetType(typeName);
                    providerTypeStr = cimType.ToString() + "[]";
                }
                else
                {
                    providerType    = (int)cimType;
                    providerTypeStr = cimType.ToString();
                }

                values[0] = propertyData.Name;
                values[1] = size;
                values[2] = dataType;
                values[3] = providerType;
                values[4] = providerTypeStr;
                values[7] = propertyData.IsArray;
                schemaTable.Rows.Add(values);
            }

            FieldCount = schemaTable.Rows.Count;

            return(schemaTable);
        }