|
Since you are posting on a C# forum, I assume you want to read/parse a HAPI file using C#: there's a C# open-source (free) tookit here [^]:
"NHapi is a port of the original project HAPI.
NHapi allows Microsoft .NET developers to easily use an HL7 2.x object model. This object model allows for parsing and encoding HL7 2.x data to/from Pipe Delimited or XML formats. A very handy program for use in the health care industry.
This project is NOT affiliated with the HL7 organization. This software just conforms to the HL7 2.x specifications.
« I am putting myself to the fullest possible use which is all, I think, that any conscious entity can ever hope to do » HAL (Heuristically programmed ALgorithmic computer) in "2001, A Space Odyssey"
|
|
|
|
|
Disclaimer: I haven't worked with NHapi yet.
Since it is a custom segment, you must define it somewhere. Can you cope with a single occurrence of that segement? If not, try to achieve this first.
Next, there needs to be some kind of flag indicating that a segment can occur multiple times - look e.g. at the NTE segments.
|
|
|
|
|
currently i am working on a project which is related to WordWrapping in RichTextBox using C#. here i am using "." instead of using "spacebar" (for some other Regional language purpose) and i want to wrap the words after every"." and every lines shall end with "." but here the problem is "." is appearing at starting of every lines. so how can i avoid that the problem ?
therefore your kind threads are more than every thing. Thank you
|
|
|
|
|
I interpret your question to mean:
0. in a WinForm Project with a RichTextBox Control at run-time when the end-user:
a. types a period at the end of a group of non-white-space characters: a newline is inserted after the period
b. enters a return/enter character: if the last non-space character before the return/enter was not a period, then a period should be added before the return/enter.
It's quite possible that's an incorrect interpretation; if it's incorrect, then post an accurate description here of exactly how you want the RichTextBox to behave when the user types a period, or enters a return/enter character.
« I am putting myself to the fullest possible use which is all, I think, that any conscious entity can ever hope to do » HAL (Heuristically programmed ALgorithmic computer) in "2001, A Space Odyssey"
|
|
|
|
|
Thanks for your great interpretation. Yeah thats what i want to do
like before starting of the new line the previous line should end with non-space char pluse "." and "." shouldn't come beginning of the new line
Thanks BillWoodruff and your kinds suggestions are most appreciated.
modified 29-Oct-14 0:40am.
|
|
|
|
|
So, have you started trying to code the behavior you want ? Have any questions ?
One difficulty you may need to address is the fact that the RichTextBox performs no notification when a word-wrap is performed: it inserts no special character in the string. That means if you need to dynamically detect word-wrap you are going to have to use Win API calls. For an example, see: [^].
Here's a quick sketch ... just to show an idea ... in code of the kind of processing I expect you will be doing as the user types in the RichTextBox:
private int whiteSpaceSeenSoFar = 0;
private void handleEnterReturn()
{
}
private void YourRichTextBox_KeyUp(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.OemPeriod:
break;
case Keys.Enter:
handleEnterReturn();
break;
case Keys.Tab:
break;
case Keys.Space:
whiteSpaceSeenSoFar++;
break;
case Keys.Back:
break;
case Keys.Delete:
break;
default:
break;
}
}
« I am putting myself to the fullest possible use which is all, I think, that any conscious entity can ever hope to do » HAL (Heuristically programmed ALgorithmic computer) in "2001, A Space Odyssey"
modified 29-Oct-14 5:50am.
|
|
|
|
|
Hi,
It's hard to understand your problem. It would be easier if you post an example of what is wrong, and what you need.
If you're wrapping the words after "." you can solve the problem by adding a control to not wrap if there is a "\n" in the word.
|
|
|
|
|
Thanks @Member 10515897 for your response.
suppose i have string like
This.is.my.best.site.ever. // here i used "." instead of using "space"
but the problem is every starting line or new line "." is appearing first means like:
.This.is.my.best.site.ever // once i wrap the strings "." is appearing at the beginning of the new line. i shall avoid that
Therefore your kind suggestions are most appreciated. Thanks
|
|
|
|
|
Hello to everybody!
Excuse me for my question, but i really met with difficult situation.
I use pdfsharp library for making pdf reports, i read http://www.pdfsharp.net/ here samples and all as good, while i had to make a simple chart. For example this one:
public static Chart CombinationChart()
{
Chart chart = new Chart();
Series series = chart.SeriesCollection.AddSeries();
series.ChartType = ChartType.Column2D;
series.Add(new double[] { 1, 17, 45, 5, 3, 20, 11, 23, 8, 19 });
series.HasDataLabel = true;
series = chart.SeriesCollection.AddSeries();
series.ChartType = ChartType.Line;
series.Add(new double[] { 41, 7, 5, 45, 13, 10, 21, 13, 18, 9 });
XSeries xseries = chart.XValues.AddXSeries();
xseries.Add("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N");
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.XAxis.Title.Caption = "X-Axis";
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
chart.PlotArea.LineFormat.Width = 1;
chart.PlotArea.LineFormat.Visible = true;
chart.Legend.Docking = DockingType.Left;
chart.Legend.LineFormat.Visible = true;
return chart;
}
This function returns the chart, but i can't place it to my pdf any way(((
My way creating pdf:
PdfDocument document = new PdfDocument();
document.Info.Title = "Created with PDFsharp";
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
const string filename = "HelloWorld.pdf";
document.Save(filename);
Process.Start(filename);
So the chart is to be in HelloWorld.pdf, but how to send it there, is it possible? Or it is possible only if i download library Migradoc?
Thank you, I'd appreciate any information you could give me
|
|
|
|
|
The Chart type is a MigraDoc object, so you'll need to use MigraDoc to add it to your PDF.
Have a look at the DefineCharts method in the "Hello MigraDoc" sample[^].
Edit: The Chart type is in the additional PdfSharp.Charting assembly, which I missed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 28-Oct-14 8:17am.
|
|
|
|
|
Thank you for answering, you confirmed my assumption about MigraDoc library, so i will try to use it, and check how it works, think i will have to setup MigraDoc instead of pdfsharp...so after i will write what i would get in result...
But the method
CombinationChart as i cited in my previous message, for what it?
I suppose it is based only on
PdfSharp.Charting library...so and there are no ways to get result of method
CombinationChart in pdf document... it is very sad if it is so...
|
|
|
|
|
Sorry, looks like my answer was wrong.
The sample you pasted is using the separate PdfSharp.Charting assembly, which is why I couldn't see the Chart type in the PdfSharp assembly. It looks like it comes from this example[^], which demonstrates how to add the chart to a PDF file using a ChartFrame :
PdfPage page = document.AddPage();
page.Size = PageSize.A4;
Chart chart = CombinationChart();
ChartFrame = new ChartFrame();
chartFrame.Location = new XPoint(30, 30);
chartFrame.Size = new XSize(500, 600);
chartFrame.Add(chart);
XGraphics gfx = XGraphics.FromPdfPage(page);
chartFrame.Draw(gfx);
document.Close();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Create a bitmap from the chart. If you're using WPF, you can create a bitmap (RenderTargetBitmap) from the chart's visual.
Use PdfSharp to convert the bmp to an XImage and draw it on the page using .DrawImage.
|
|
|
|
|
Yes, for me it is difficult too) I will try to make so, will search sample in internet, i am not similar with this method too...
thank you...
|
|
|
|
|
Yes; Google is your friend.
Once you have a bmp from your chart, it's easy.
Give it a try (making a bmp) and if you get stuck, come back here (with what you've tried).
|
|
|
|
|
I am trying to write a small search functionality in LINQ-to-SQL (with Sharp Repository and Entity Framework) where given a string value, I should be able to search it through all properties and return the entities which have the input string value "Contained" (as in someString.Contains ) in any of their properties (with "searchable" types like int, long, etc since search by ID should be possible).
I have written a method which does this for a "single" string property (which was the requirement earlier ) and returns an Expression predicate which I pass to my SharpRepository instance as the selector.
public static Expression<Func<T, bool>> ContainsExpression<T>(string propertyName, string propertyValue)
{
var parameterExpression = Expression.Parameter(typeof(T), typeof(T).Name);
var propertyExpression = Expression.PropertyOrField(parameterExpression, propertyName);
var stringTypeArray = new[] { typeof(String) };
var containsMethod = typeof(String).GetMethod("Contains", stringTypeArray);
var valueToBeChecked = Expression.Constant(propertyValue, typeof(String));
var finalContainsExpression = Expression.Call(propertyExpression, containsMethod, valueToBeChecked);
return Expression.Lambda<Func<T, bool>>(finalContainsExpression, parameterExpression);
}
I have even tried overriding ToString() method in my entity (simple Employee type at the moment) as:
public override string ToString()
{
string instance = String.Concat(Id, ",", Name, ",", Department, ",", DateOfJoining.ToString("dd-MMM-yyyy"), ",", Salary);
return instance;
} and then generate an Expression as:
Employee => Employee.ToString().Contains(ValueToBeSearched)
But needless to say, the first one won't work for the types other than String (since I will need to do someTypeOtherThanString.ToString().Contains(..) which is not supported in LINQ-to-SQL and the later one also won't work due to the similar reason!
I do know that I can simply write an SP for this functionality, I want to know if there's a way to achieve this using LINQ-to-SQL. Also, I need to pass the Expression as the selector to my SharpRepository instance so although I am not sure if a .ToList<T>() on all entities followed by a filter expression will work, unfortunately I am not open to that, I would rather write an SP.
[EDIT]
Just came across SqlFunctions[^].StringConvert() method overloads. Unfortunately they only support numeric types. But I think I have the necessary things to go ahead with string and numeric types. Will see what could be done for rest of the types, if they exist at all and should be search-enabled.
[/EDIT]
Any pointers will be appreciated. Thanks!
Your time will come, if you let it be right.
modified 28-Oct-14 1:58am.
|
|
|
|
|
Agent__007 wrote: I do know that I can simply write an SP for this functionality, I want to know
if there's a way to achieve this using LINQ-to-SQL Even if it is possible, the SP is still the recommended way. That way the server would search for the data, as opposed to having the server blow all tables over the network to each client and have each client search their own in-memory-copies.
Look into reflection and recursion, that should do the trick. You'd iterate every property, and if it isn't an interface or a class, you'd convert it to a string and search the string-represenation. This way you should be able to search most items, as an enum, a long and a boolean would all convert nicely. If the property represents a class, interface or struct, then you call the method again, but now passing the value of that property and not the object you're looking at. That'd be the recursive part.
Should work for POCO's, can't say with certainty that it will work nicely on entities.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for your reply, Sir. I always like your answers.
Fortunately they are now okay with my initial suggestion of using an SP.
Your time will come, if you let it be right.
|
|
|
|
|
Ehr, thanks
|
|
|
|
|
Any time you have an application send SQL to a database that identifies the data tables, you are doing it *so* wrong§. You should treat the data model as an implementation detail and the stored procedures and Table Valued Functions (if MSSQL) as your data services. It would be much, much nicer if the SQL Server team had followed through on their rhetoric that table valued parameters would be able to be OUTPUT parameters "in the next release of SQL Server" (which should have been 2008R2...that would allow the DataTransferObject to be registered directly with the DBMS) but an ADO.NET bridging layer that performs your data transfer into the application domain is *ridiculously simple*
§...and that's why Entity Framework is pure, unadulterated evil; It's the ADO.NET DataSet 2.0
"I need build Skynet. Plz send code"
|
|
|
|
|
Thanks for your reply. An SP is the way now!
Your time will come, if you let it be right.
|
|
|
|
|
Anyway, now that I have managed to get it working for string and numeric properties (which are going to be "most" of them), I have been "suggested" to go with the SP approach - which was my suggestion to them in the first place.
If anyone is interested how I implemented the property-search (for string and numeric types only), here are the methods (please don't point out the refactoring/coding conventions, etc needed, this was just a quick one):
private static Expression<Func<T, bool>> ContainsInStringTypeExpression<T>(string propertyName, string propertyValue)
{
var parameterExpression = Expression.Parameter(typeof(T), typeof(T).Name);
var propertyExpression = Expression.PropertyOrField(parameterExpression, propertyName);
var stringTypeArray = new[] { typeof(String) };
var containsMethod = typeof(String).GetMethod("Contains", stringTypeArray);
var valueToBeChecked = Expression.Constant(propertyValue, typeof(String));
var finalContainsExpression = Expression.Call(propertyExpression, containsMethod, valueToBeChecked);
return Expression.Lambda<Func<T, bool>>(finalContainsExpression, parameterExpression);
}
private static Expression<Func<T, bool>> ContainsInNumericTypeExpression<T>(string propertyName, string propertyValue)
{
var parameterExpression = Expression.Parameter(typeof(T), typeof(T).Name);
var propertyExpression = Expression.PropertyOrField(parameterExpression, propertyName);
var decimalPropertyExpression = Expression.Convert(propertyExpression, typeof(System.Nullable<Decimal>));
var nullableDecimalType = new[] { typeof(System.Nullable<Decimal>) };
var stringConvertExp = Expression.Call(null, typeof(SqlFunctions).GetMethod("StringConvert", nullableDecimalType), decimalPropertyExpression);
var stringTypeArray = new[] { typeof(String) };
var containsMethod = typeof(String).GetMethod("Contains", stringTypeArray);
var valueToBeChecked = Expression.Constant(propertyValue, typeof(String));
var finalContainsExpression = Expression.Call(stringConvertExp, containsMethod, valueToBeChecked);
return Expression.Lambda<Func<T, bool>>(finalContainsExpression, parameterExpression);
}
And finally,
public static Expression<Func<T, bool>> ContainsExpression<T>(string value)
{
var properties = typeof(T).GetProperties();
Expression<Func<T, bool>> finalExpression = PredicateBuilder.False<T>();
var parameterExpression = Expression.Parameter(typeof(T), typeof(T).Name);
string propertyName = String.Empty;
foreach (var property in properties)
{
var propertyType = property.PropertyType.Name;
if (propertyType == "String")
{
var propContainsExpression = ContainsInStringTypeExpression<T>(property.Name, value);
finalExpression = finalExpression.Or(propContainsExpression);
}
else if (IsNumericType(propertyType))
{
var propContainsExpression = ContainsInNumericTypeExpression<T>(property.Name, value);
finalExpression = finalExpression.Or(propContainsExpression);
}
else
{
}
}
return finalExpression;
}
Where, I have ORed the generated Expression using Universal Predicate Builder[^].
As always, thank you all for your suggestions.
Your time will come, if you let it be right.
modified 28-Oct-14 23:40pm.
|
|
|
|
|
I want to inherit a observablecollection<t>,
class Student : INotifyPropertyChanged
{
private string _IDstudent;
private string _nameStudent;
private string _familyStudent;
private double _avg;
public ObservableCollection<grade> Grades { get; set; }
public Student()
{
Grades = new ObservableCollection<grade>();
}
}
class StudentList : ObservableCollection<student>, INotifyPropertyChanged
{
private ObservableCollection<student> _students = new ObservableCollection<student>();
public ObservableCollection<student> Students
{
get { return _students; }
set { _students = value;
NotifyPropertyChanged("Students");
}
}
public StudentList()
{
_students.Add(new Student());
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
are i use notify in Studentlist correctly .
|
|
|
|
|
Edit #1: I wonder if what you are really after is a way to encapsulate PropertyChanged Events within an ObservableCollection: so that you could assign one Delegate to the ObservableCollection that would route all PropertyChanged notifications to one EventHandler you defined ? I can't say I understand your code, since it is not clear to me what your goal is in mixing and matching ObservableCollection and INotifyPropertyChanged: note you never implement a CollectionChanged Event. And, you have another ObservableCollection, 'Grades, inside your 'Student Class which promises to implement INotifyPropertyChanged.
I strongly suggest you study implementing INotifyPropertyChanged first, and, when you understand it, move on to using ObservableCollection. When you know how to use both, then make a list of exactly what events you wish to be notified of ... which notifications you want to use from the ObservableCollection (Add, Remove, Move, Replace, Reset). Of course, INotifyPropertyChanged even handling is only going to give you one thing: the PropertyName (string) of the changed Property.
But, I can try to help you understand inheriting from ObservableCollection to some degree (I hope):
There should be a "good reason" to inherit from something like ObservableCollection<T>: "good reasons" are usually because:
1. you need to extend the inherited-from object: i.e., add functionality
2. you want to over-ride behavior (methods) in the inherited-from object.
Assume I have a class 'Student which has a constructor like this: note that only one parameter is required to be specified to create a new instance:
public Student(DateTime admissionDate, string stuName = "", string stuClass = "", string stuAddress = "")
{
AdmissionDate = admissionDate;
StuName = stuName;
StuClass = stuClass;
StuAddress = stuAddress;
} If I inherit from ObservableCollection<Student> and extend it by adding my own 'Add method:
public class Students : ObservableCollection<Student>
{
internal void Add(string admDate, string name)
{
base.Add(new Student(Convert.ToDateTime(admDate), name));
}
} I can enable easy in-line syntax entry of new Items in the ObservableCollection:
Students StudentsCollection = new Students
{
{"02/05/2012", "Moe"},
{"11/05/2013", "Curly"},
{"02/05/2014", "Larry"},
{"01/05/2010", "Mutt"},
{"02/05/2010", "Jeff"},
{"01/05/2009", "Dagwood"}
}; So, assuming you wanted to use the functionality in ObservableCollection to observe something
StudentsCollection.CollectionChanged += StudentsCollection_CollectionChanged;
private void StudentsCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
break;
case NotifyCollectionChangedAction.Remove:
break;
}
}
« There is only one difference between a madman and me. The madman thinks he is sane. I know I am mad. » Salvador Dali
modified 27-Oct-14 9:24am.
|
|
|
|
|