Ejemplo n.º 1
0
        void ToEscapeChars()
        {
            var txt = RequestDocument["txt"].ToString();


            try
            {
                var jsonStringData = RichTextBoxHelper.CompressJsonString(txt);

                //因为引号使用了反斜杠\ , 所以先操作反斜杠\  再操作引号
                // 如果先操作引号的话, 那引号转义后产生的反斜杠\再转义将会产生更多的反斜杠\
                string str = jsonStringData.Replace("\\", "\\\\").Replace("\"", "\\\"");

                //rpc调用(包括网站)
                var jd = new JsonData()
                {
                    ["txt"] = string.Empty
                };
                if (!string.IsNullOrEmpty(str))
                {
                    jd["txt"] = str;
                }

                Json((int)ReturnStatus_Ext.Success, string.Empty, jd);
            }
            catch (Exception exception)
            {
                Json((int)ReturnStatus_Ext.ServerError, exception.Message);
            }
        }
Ejemplo n.º 2
0
        public void Query(DatabaseObjectDisplayInfo displayInfo)
        {
            this.ucSqlQuery.Editor.AppendText(displayInfo.Content);

            RichTextBoxHelper.Highlighting(this.ucSqlQuery.Editor, displayInfo.DatabaseType, false);

            this.ucSqlQuery.RunScripts(displayInfo);
        }
Ejemplo n.º 3
0
        private readonly RichTextBoxHelper logHelper; // provides access to log


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public ConfigBuilder(IAdminContext adminContext, ScadaProject project, RichTextBoxHelper logHelper)
        {
            this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
            this.project      = project ?? throw new ArgumentNullException(nameof(project));
            this.logHelper    = logHelper ?? throw new ArgumentNullException(nameof(logHelper));

            BuildResult   = false;
            DeviceConfigs = new List <DeviceConfigEntry>();
        }
Ejemplo n.º 4
0
        private void txtEditor_SelectionChanged(object sender, EventArgs e)
        {
            this.txtEditor.SelectionFont = this.txtEditor.Font;

            if (this.isPasting)
            {
                this.isPasting = false;

                RichTextBoxHelper.Highlighting(this.txtEditor, this.DatabaseType);
            }
        }
Ejemplo n.º 5
0
        private void ShowScripts(RichTextBox textBox, string scripts)
        {
            textBox.Clear();

            if (!string.IsNullOrEmpty(scripts))
            {
                textBox.AppendText(scripts.Trim());

                RichTextBoxHelper.Highlighting(textBox, this.targetDbProfile.DatabaseType, false);
            }
        }
Ejemplo n.º 6
0
        private void SetTabPageContent(DatabaseObjectDisplayInfo info, TabPage tabPage)
        {
            if (info.DisplayType == DatabaseObjectDisplayType.Script)
            {
                UC_SqlQuery sqlQuery = this.GetUcControl <UC_SqlQuery>(tabPage);

                if (sqlQuery == null)
                {
                    sqlQuery = this.AddControlToTabPage <UC_SqlQuery>(tabPage);
                }

                sqlQuery.Show(info);

                if (!string.IsNullOrEmpty(sqlQuery.Editor.Text))
                {
                    RichTextBoxHelper.Highlighting(sqlQuery.Editor, info.DatabaseType, false);

                    if (info.Error != null)
                    {
                        RichTextBoxHelper.HighlightingError(sqlQuery.Editor, info.Error);
                    }
                }
                else
                {
                    sqlQuery.Editor.Focus();
                }
            }
            else if (info.DisplayType == DatabaseObjectDisplayType.Data)
            {
                UC_DataViewer dataViewer = this.GetUcControl <UC_DataViewer>(tabPage);

                if (dataViewer == null)
                {
                    dataViewer = this.AddControlToTabPage <UC_DataViewer>(tabPage);
                    dataViewer.OnDataFilter += this.DataFilter;
                }

                dataViewer.Show(info);
            }
            else if (info.DisplayType == DatabaseObjectDisplayType.TableDesigner)
            {
                UC_TableDesigner tableDesigner = this.GetUcControl <UC_TableDesigner>(tabPage);

                if (tableDesigner == null)
                {
                    tableDesigner             = this.AddControlToTabPage <UC_TableDesigner>(tabPage);
                    tableDesigner.OnFeedback += this.Feedback;
                }

                tableDesigner.Show(info);
            }
        }
Ejemplo n.º 7
0
        private bool stopReading;                           // indicates that a read operation should stop


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TopicReader(MqttConnectionOptions mqttConnectionOptions, RichTextBoxHelper logHelper)
        {
            connOptions    = mqttConnectionOptions ?? throw new ArgumentNullException(nameof(mqttConnectionOptions));
            this.logHelper = logHelper ?? throw new ArgumentNullException(nameof(logHelper));
            mqttLock       = new object();

            tokenSource = null;
            messageDT   = DateTime.MinValue;
            stopReading = false;

            ReadResult      = false;
            WirenBoardModel = new WirenBoardModel();
        }
Ejemplo n.º 8
0
        private void btnCompressEscapeChars_Click(object sender, EventArgs e)
        {
            try
            {
                var jsonStringData = RichTextBoxHelper.CompressJsonString(textBox.Text);

                //因为引号使用了反斜杠\ , 所以先操作反斜杠\  再操作引号
                // 如果先操作引号的话, 那引号转义后产生的反斜杠\再转义将会产生更多的反斜杠\
                string str = jsonStringData.Replace("\\", "\\\\").Replace("\"", "\\\"");
                textBox.Text = str;
                btnCompressEscapeChars.Visible = false;
            }
            catch (Exception exception)
            {
                this.ShowException(exception);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public FrmWirenBoardWizard(IAdminContext adminContext, ScadaProject project, RecentSelection recentSelection)
            : this()
        {
            this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
            this.project      = project ?? throw new ArgumentNullException(nameof(project));

            ctrlLineSelect = new CtrlLineSelect(adminContext, project, recentSelection);
            ctrlLog        = new CtrlLog();
            ctrlDeviceTree = new CtrlDeviceTree();
            ctrlEntityID   = new CtrlEntityID(adminContext, project, recentSelection);
            logHelper      = new RichTextBoxHelper(ctrlLog.RichTextBox);
            AddUserControls();

            step          = Step.SelectLine;
            topicReader   = null;
            configBuilder = null;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public FrmTransfer(AppData appData, ScadaProject project, ProjectInstance instance, DeploymentProfile profile)
            : this()
        {
            this.appData  = appData ?? throw new ArgumentNullException(nameof(appData));
            this.project  = project ?? throw new ArgumentNullException(nameof(project));
            this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
            this.profile  = profile ?? throw new ArgumentNullException(nameof(profile));

            setCancelEnabledAction = b => SetCancelEnabled(b);
            setProgressAction      = d => SetProgress(d);
            setResultAction        = (b, d) => SetResult(b, d);
            logHelper = new RichTextBoxHelper(txtLog);

            extensionLogic  = null;
            uploadMode      = false;
            operationResult = false;
            tokenSource     = null;
        }
Ejemplo n.º 11
0
        private async void LoadArticleContent(LoadedArticle item)
        {
            grLoading.Visibility = Visibility.Visible;
            grMain.IsEnabled     = false;

            SelectedArticle = item;
            SetDirection(Trend.Unknown);
            SetWeight(int.MinValue);
            rtbArticleContent.Document = RichTextBoxHelper.LoadText(item.Content);
            var needFindMatch = cbCheckAutomatically.IsChecked.HasValue && cbCheckAutomatically.IsChecked.Value;

            Pattern pattern = null;

            if (needFindMatch)
            {
                ctrAnimation.AnimationText = "Searching for patterns ...";
                await Task.Run(() =>
                {
                    pattern = FindMatch();
                });
            }

            if (pattern != null)
            {
                HighlightMatch(pattern.Regex, pattern.Trend);
                tbRegexPattern.Text = pattern.RawRegexText;
                SetDirection(pattern.Trend);
                SetWeight(pattern.Weight);
            }

            if (cbFindMarket.IsChecked.Value)
            {
                HighlightMatch(new Regex(BeforeOpeningPatternsKeeper.Market), Colors.Blue, true);
            }

            if (cbFindExpect.IsChecked.Value)
            {
                HighlightMatch(new Regex(BeforeOpeningPatternsKeeper.Expect), Colors.DarkOrange, true);
            }

            grLoading.Visibility = Visibility.Hidden;
            grMain.IsEnabled     = true;
        }
Ejemplo n.º 12
0
        private void BtnCheck_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Validate() == false)
                {
                    return;
                }

                rtbText.Document = RichTextBoxHelper.CleanAndReformat(rtbText.Document);

                var regex = tbGeneratedPattern.Text;

                var ranges = RichTextBoxMatchFinder.FindMatches(rtbText.Document, new Regex(regex, RegexOptions.Singleline | RegexOptions.IgnoreCase));

                RichTextBoxMatchFinder.HighlightMatches(ranges, Colors.Red, FontWeights.Bold);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 改变richTextBox中指定字符串的颜色
        /// 调用即可
        /// </summary>
        /// <param name="str" value="为指定的字符串"></param>

        public int changeColor(string[] str)
        {
            ArrayList list = null;
            int       b    = 0;

            for (int i = 0; i < str.Length; i++)
            {
                list = RichTextBoxHelper.getIndexArray(richTextBox1.Text.ToLower(), str[i]);
                b   += list.Count;
            }
            for (int i = 0; i < str.Length; i++)
            {
                list = RichTextBoxHelper.getIndexArray(richTextBox1.Text.ToLower(), str[i]);
                if (list.Count == 0)
                {
                    continue;
                }
                if (a == b)
                {
                    richTextBox1.SelectionColor = Color.Empty;
                    return(b);
                }
                for (int j = 0; j < list.Count; j++)
                {
                    int index = (int)list[j];
                    richTextBox1.Select(index, str[i].Length);
                    richTextBox1.SelectionColor = Color.Blue;
                    this.richTextBox1.Focus();
                    //设置光标的位置到文本尾
                    this.richTextBox1.Select(this.richTextBox1.TextLength, 0);
                    //滚动到控件光标处
                    this.richTextBox1.ScrollToCaret();
                    richTextBox1.SelectionColor = Color.Empty;
                }
            }
            return(b);
        }
Ejemplo n.º 14
0
 public static void ScrollLines(this RichTextBox richTextBox, int linesToScroll)
 {
     RichTextBoxHelper.ScrollLines(richTextBox, linesToScroll);
 }
Ejemplo n.º 15
0
 public static void HideSelection(this RichTextBox richTextBox, bool hide)
 {
     RichTextBoxHelper.HideSelection(richTextBox, hide);
 }
Ejemplo n.º 16
0
 public static int GetVisibleLines(this RichTextBox richTextBox)
 {
     return(RichTextBoxHelper.GetVisibleLines(richTextBox));
 }
Ejemplo n.º 17
0
 public static int GetLastVisibleCharIndex(this RichTextBox richTextBox)
 {
     return(RichTextBoxHelper.GetLastVisibleCharIndex(richTextBox));
 }
Ejemplo n.º 18
0
 public static void SetRedraw(this RichTextBox richTextBox, bool enableRedraw)
 {
     RichTextBoxHelper.SetRedraw(richTextBox, enableRedraw);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Sets the font name for the selected text of the RichTextBox
 /// </summary>
 /// <param name="fontName">Name of the font to use</param>
 /// <returns>Returns true on success, false on failure</returns>
 public static bool SelectionFontName(this RichTextBox richTextBox, string fontName)
 {
     return(RichTextBoxHelper.SelectionFontName(richTextBox, fontName));
 }
Ejemplo n.º 20
0
 public static int GetEventMask(this RichTextBox richTextBox)
 {
     return(RichTextBoxHelper.GetEventMask(richTextBox));
 }
Ejemplo n.º 21
0
 public static int GetHScroll(this RichTextBox richTextBox)
 {
     return(RichTextBoxHelper.GetHScroll(richTextBox));
 }
Ejemplo n.º 22
0
 private void BtnReset_OnClick(object sender, RoutedEventArgs e)
 {
     rtbText.Document = RichTextBoxHelper.CleanAndReformat(rtbText.Document);
 }
Ejemplo n.º 23
0
        void ToJson()
        {
            var txt = RequestDocument["txt"].ToString();

            txt = RemoveEscapeChars(txt);

            var strList = new List <string>();

            try
            {
                var lines = txt.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                if (lines.All(t => t.Contains(":")))
                {
                    foreach (var item in lines)
                    {
                        var keyValues = item.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        if (keyValues.Length == 2)
                        {
                            var key   = keyValues[0].Trim();
                            var value = keyValues[1].Trim();

                            value = System.Web.HttpUtility.UrlDecode(value);
                            value = value.Replace("\"", "\\\"");

                            if (!string.IsNullOrEmpty(key))
                            {
                                if (value == "true" || value == "false" || IsNum(value))
                                {
                                    strList.Add($"\"{key}\":{value},");
                                }
                                else
                                {
                                    strList.Add($"\"{key}\":\"{value}\",");
                                }
                            }
                        }
                    }
                }
                else
                {
                    var items = txt.Split(new[] { "&" }, StringSplitOptions.RemoveEmptyEntries);
                    if (items.All(t => t.Contains("=")))
                    {
                        foreach (var item in items)
                        {
                            var keyValues = item.Split(new[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
                            if (keyValues.Length == 2)
                            {
                                var key   = keyValues[0].Trim();
                                var value = keyValues[1].Trim();

                                value = System.Web.HttpUtility.UrlDecode(value);
                                value = value.Replace("\"", "\\\"");

                                if (!string.IsNullOrEmpty(key))
                                {
                                    if (value == "true" || value == "false" || IsNum(value))
                                    {
                                        strList.Add($"\"{key}\":{value},");
                                    }
                                    else
                                    {
                                        strList.Add($"\"{key}\":\"{value}\",");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }

            //rpc调用(包括网站)
            var jd = new JsonData()
            {
                ["txt"] = string.Empty
            };

            if (strList.Count > 0)
            {
                var stringBuilder = new StringBuilder();
                stringBuilder.Append("{");

                strList[strList.Count - 1] = strList.Last().TrimEnd(',');
                foreach (var str in strList)
                {
                    stringBuilder.Append(str);
                }

                stringBuilder.Append("}");

                jd["txt"] = RichTextBoxHelper.FormatJsonString(stringBuilder.ToString());
            }
            else if (JsonSerializerHelper.IsJsonString(txt))
            {
                jd["txt"] = RichTextBoxHelper.FormatJsonString(txt);
            }
            else
            {
                jd["txt"] = string.Empty;
            }

            Json((int)ReturnStatus_Ext.Success, string.Empty, jd);
        }
Ejemplo n.º 24
0
 private void ExportHelper(IWorksheet Sheet, GridModel gridModel, GridStyleInfo Style, RowColumnIndex RowColIndex)
 {
     if (Sheet != null)
     {
         int ivalue; double dvalue; bool bvalue;
         try
         {
             IRange range = Sheet.Range[RowColIndex.RowIndex, RowColIndex.ColumnIndex];
             if (!range.HasFormula || Style.Text.Length == 0 || (Style.Text.Length > 0 && Style.Text[0] != '='))
             {
                 //To new Save Formula
                 if (Style.CellValue != null && Style.CellValue.ToString() != string.Empty && Style.CellValue.ToString()[0] == '=')
                 {
                     if (Style.CellValue.ToString().Contains('!'))
                     {
                         range.Formula = ExcelLikeFormula(gridModel, Style.CellValue.ToString());
                     }
                     else
                     {
                         range.Formula = Style.CellValue.ToString().ToUpper();
                     }
                     if (int.TryParse(Style.FormattedText, out ivalue))
                     {
                         Style.HorizontalAlignment           = System.Windows.HorizontalAlignment.Right;
                         range.CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight;
                     }
                     else if (double.TryParse(Style.FormattedText, out dvalue))
                     {
                         Style.HorizontalAlignment           = System.Windows.HorizontalAlignment.Right;
                         range.CellStyle.HorizontalAlignment = ExcelHAlign.HAlignRight;
                     }
                 }
                 else
                 {
                     string cellvalue = string.Empty;
                     if (Style.CellValue != null)
                     {
                         cellvalue = Style.CellValue.ToString();
                     }
                     if (Style.CellType == "FormulaCell" && !string.IsNullOrEmpty(Style.Text) && Style.Text[0] == '=')
                     {
                         cellvalue = Style.FormattedText;
                     }
                     //To Save RichText
                     else if (Style.CellType == "RichText")
                     {
                         RichTextBoxHelper.SetRichTextValue(range, Style.CellValue as FlowDocument, Style.FormattedText);
                         return;
                     }
                     //To Save Number
                     if (int.TryParse(cellvalue, out ivalue))
                     {
                         range.Number = ivalue;
                     }
                     else if (double.TryParse(cellvalue, out dvalue))
                     {
                         range.Number = dvalue;
                     }
                     //To Save Boolean value
                     else if (bool.TryParse(cellvalue, out bvalue))
                     {
                         range.Boolean = bvalue;
                         if (bvalue)
                         {
                             Style.CellValue = "TRUE";
                         }
                         else
                         {
                             Style.CellValue = "FALSE";
                         }
                     }
                     //To Save other value
                     else
                     {
                         range.Value = cellvalue;
                     }
                 }
             }
             //To Save Formula
             else
             {
                 if (Style.FormulaTag != null && Style.CellValue != null && Style.CellValue.ToString() != string.Empty && Style.CellValue.ToString()[0] == '=')
                 {
                     if (!range.HasFormula)
                     {
                         if (Style.CellValue.ToString().Contains('!'))
                         {
                             range.Formula = ExcelLikeFormula(gridModel, Style.CellValue.ToString());
                         }
                         else
                         {
                             range.Formula = Style.CellValue.ToString().ToUpper();
                         }
                     }
                     else
                     {
                         range.Formula = ExcelLikeFormula(gridModel, Style.CellValue.ToString());
                     }
                 }
                 else if (!range.HasFormula)
                 {
                     range.Text = Style.FormattedText;
                 }
             }
         }
         catch (Exception)
         {
         }
     }
 }
Ejemplo n.º 25
0
 public static void SetHScroll(this RichTextBox richTextBox, int position)
 {
     RichTextBoxHelper.SetHScroll(richTextBox, position);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Sets the font style for the selected text of the RichTextBox
 /// </summary>
 /// <param name="fontStyle">Font style to apply to selected text</param>
 /// <returns>Returns true on success, false on failure</returns>
 public static bool SelectionFontStyle(this RichTextBox richTextBox, FontStyle fontStyle)
 {
     return(RichTextBoxHelper.SelectionFontStyle(richTextBox, fontStyle));
 }
Ejemplo n.º 27
0
 public static void SetEventMask(this RichTextBox richTextBox, int mask)
 {
     RichTextBoxHelper.SetEventMask(richTextBox, mask);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Sets the font color for the word in the selected point
 /// </summary>
 /// <param name="color">Color to apply</param>
 /// <returns>Returns true on success, false on failure</returns>
 public static bool WordFontColor(this RichTextBox richTextBox, Color color)
 {
     return(RichTextBoxHelper.WordFontColor(richTextBox, color));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Sets the font size for the selected text of the RichTextBox
 /// </summary>
 /// <param name="fontSize">Font size to use</param>
 /// <returns>Returns true on success, false on failure</returns>
 public static bool SelectionFontSize(this RichTextBox richTextBox, int fontSize)
 {
     return(RichTextBoxHelper.SelectionFontSize(richTextBox, fontSize));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Sets the background color for the selected text of the RichTextBox
 /// </summary>
 /// <param name="color">Color to apply</param>
 /// <returns>Returns true on success, false on failure</returns>
 public static bool SelectionBackColor(this RichTextBox richTextBox, Color color)
 {
     return(RichTextBoxHelper.SelectionBackColor(richTextBox, color));
 }