Esempio n. 1
0
        public void SetText(EditableFile SelectedItem, string param)
        {
            MyAvalonEditor TextEditor = SelectedItem.TextEditor;

            string[] tagStr = (param).Split('_');
            if (tagStr.Length == 3)
            {
                if (tagStr[1].Equals("cursor"))
                {
                    TextEditor.SelectionLength = 0;
                    TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0] + tagStr[2]);

                    TextEditor.SelectionStart = TextEditor.SelectionStart - tagStr[2].Length;
                    TextEditor.Focus();
                }
                if (tagStr[1].Equals("cursorSelect"))
                {
                    TextEditor.Document.Insert(TextEditor.SelectionStart, tagStr[0]);
                    TextEditor.Document.Insert(TextEditor.SelectionStart + TextEditor.SelectionLength, tagStr[2]);

                    if (TextEditor.SelectionLength == 0)
                    {
                        TextEditor.SelectionStart = TextEditor.SelectionStart - tagStr[2].Length;
                    }
                    TextEditor.Focus();
                }
            }

            /*if (tagStr.Length == 2)
             * {
             *  if (tagStr[1].Equals("cursor"))
             *  {
             *      TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0]);
             *      //TextEditor.SelectionLength = 0;
             *      TextEditor.Focus();
             *
             *      /* SelectedItem.FastTextBox.SelectedText = tagStr[0];
             *       SelectedItem.FastTextBox.Focus();
             *  }
             *  if (tagStr[0].Equals("cursor"))
             *  {
             *      TextEditor.Document.Insert(TextEditor.CaretOffset, tagStr[0]);
             *
             *      TextEditor.CaretOffset -= tagStr[0].Length;
             *      TextEditor.Focus();
             *
             *      /*SelectedItem.FastTextBox.SelectedText = tagStr[0];
             *      SelectedItem.FastTextBox.SelectionStart = SelectedItem.FastTextBox.SelectionStart - tagStr[0].Length;
             *      SelectedItem.FastTextBox.Focus();
             *  }
             * }*/

            if (tagStr.Length == 1)
            {
                TextEditor.Document.Insert(TextEditor.SelectionStart, tagStr[0]);
                TextEditor.SelectionLength = 0;
                TextEditor.Focus();
            }
        }
Esempio n. 2
0
        public void setData(XDocument xDox, MyAvalonEditor TextEditor, ObservableCollection <TableRow> Table)
        {
            // ObservableCollection<TableRow> Table = new ObservableCollection<TableRow>();

            xDox            = RefreshTable(xDox);
            this.TextEditor = TextEditor;

            Table.Clear();

            if (xDox.XPathSelectElement("dmodule/idstatus/dmaddres/dmtitle") != null)
            {
                Name = xDox.XPathSelectElement("dmodule/idstatus/dmaddres/dmtitle").Value;
            }

            int prInd    = 0;
            int rowIndex = 0;

            try
            {
                foreach (XElement elm in xDox.Descendants("csn"))
                {
                    string item = "";
                    int    ind  = 1;

                    TableRow newRow = new TableRow();
                    newRow.Collaps = null;
                    newRow.ShowRow = Visibility.Visible;
                    if (elm.Attribute("ind") != null)
                    {
                        ind = int.Parse(elm.Attribute("ind").Value);


                        if (ind > prInd && rowIndex != 0)
                        {
                            Table[rowIndex - 1].Collaps = false;
                        }


                        prInd = ind;

                        newRow.Ind = ind;
                    }

                    if (elm.Attribute("item") != null)
                    {
                        item       += elm.Attribute("item").Value;
                        newRow.Item = item;
                    }

                    if (elm.Element("name") != null)
                    {
                        newRow.Name = elm.Element("name").Value;
                    }

                    Table.Insert(Table.Count, newRow);
                    rowIndex++;
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(e.ToString());
                MessageBox.Show("Невозможно отобразить " + (rowIndex + 1) + " строку таблицы");
            }

            // return Table;
        }