Beispiel #1
0
        Node CreateDrawingNodeByUsingDialog() {
            RichTextBox richBox;
            var window = CreateNodeDialog(out richBox);
            window.ShowDialog();

            var r = new Random();
            var i = r.Next();

            var createdNode = new Node(i.ToString());
            var s = new TextRange(richBox.Document.ContentStart, richBox.Document.ContentEnd).Text;
            createdNode.LabelText = s.Trim('\r', '\n', ' ', '\t');
            return createdNode;
        }
 private string GetCommand()
 {
     var command = new TextRange(
         richTextBox1.CaretPosition.GetLineStartPosition(0)
         .GetPositionAtOffset(prompt.Length + 1, LogicalDirection.Forward) ??
         richTextBox1.CaretPosition.GetLineStartPosition(0),
         richTextBox1.CaretPosition.GetLineStartPosition(1) ?? this.richTextBox1.CaretPosition.DocumentEnd).Text;
     command = command.Trim();
     return command;
 }
        private void button1_OnClick(object sender, RoutedEventArgs e)
        {
            var cat = new Categorys();

            byte[] photo = null;

            var image = ImageEdit1.Source as BitmapImage;
            if (image != null)
            {
                var bi = image;
                var stream = bi.StreamSource as FileStream;

                if (stream != null)
                {
                    String photoPath = stream.Name;
                    photo = Validator.ConvertImageToByteArray(photoPath);
                }
            }

            var Categoryname = CategoryNameCbx.Text ?? "";
            string subCategoryname = SubCategoryNameTxt.Text;
            if (String.IsNullOrEmpty(Categoryname))
            {
                DXMessageBox.Show(this, "Erreur dans le Nom du catégorie (ne doit pas etre vide");
                return;
            }
            if (String.IsNullOrEmpty(subCategoryname.Trim()))
            {
                DXMessageBox.Show(this, "Erreur dans le Nom du sous catégorie (ne doit pas etre vide");
                return;
            }

            if (_CategorysClient.IsSubCategoryExist(subCategoryname.Trim(), Categoryname))
            {
                DXMessageBox.Show(this, "sous catégorie existe déjà");
                return;
            }

            String description = new TextRange(RichTextBox1.Document.ContentStart, RichTextBox1.Document.ContentEnd).Text;

            String result = _CategorysClient.AddSubCategory(Categoryname.Trim(), subCategoryname.Trim(), description.Trim(), photo);

            DXMessageBox.Show(this,result);
        }