Click here to Skip to main content
15,905,967 members

Comments by TomNidi (Top 15 by date)

TomNidi 5-Jan-11 15:16pm View    
:) I'm so stupid.. Well, you were right of course.
I just couldn't understand why it keep telling me that the input string is wrong, but when I went to check the info in the database, instead of one date I saw "?????". I had a problem with converting the right information, and it had NOTHING AT ALL to do with my function.

I would like to thank you for your time, and I hope that you will be able to help others same as you helped me:)
TomNidi 5-Jan-11 6:55am View    
Edit: The problem is in the "years" section, for example if I type "2011" instead of the "years" word in " d = d.AddYears(years - 1);", the problem is disapear, but I still can not set the child of my element host to the usercontrol. If I do it by the properties, the Visual Stuid crashes. If I do it by code, I get the error: "Object reference not set to an instance of an object.". and it yellows me the line I mention before - "foreach (Appointment appointment in (ObservableCollection<Appointment>)values[0])". Its like I changed something in it, witch I didn't..
TomNidi 5-Jan-11 6:41am View    
Well, I think I have just understood why this kept happening to me.. but I still don't know how to fix it.
The problem was in those lines in MonthViewCalendar.cs:

ap = new Appointment();
ap.Subject = reader["name"].ToString();
//
DateTime d = new DateTime();
int days = getDate(reader["date"].ToString(), "day");
int months = getDate(reader["date"].ToString(), "month");
int years = getDate(reader["date"].ToString(), "year");
d = d.AddYears(years - 1);
d = d.AddMonths(months - 1);
d = d.AddDays(days - 1);
ap.Date = d;
//
ap.Time = reader["startTime"].ToString();
ap.Dhifut = reader["dhifut"].ToString();
ap.AssignedFor = reader["assignedTo"].ToString();
ap.Type = reader["type"].ToString(); ;
ap.Description = reader["description"].ToString();
Appointments.Add(ap);

This is the GetDate function:

public int getDate(string date, string type)
{
string[] types = date.Split('/');
if (type == "day")
return Int32.Parse(types[0]);
else if (type == "month")
return Int32.Parse(types[1]);
else // type == year
return Int32.Parse(types[2]);
}

I still don't know why the designer won't load when I call this function.. the Date witch is stored in the Database witch I call the function on looks like this: "Days/Months/Years" - for example: "04/01/2011"
Do you know why this function keep causing me this problem?
TomNidi 5-Jan-11 6:02am View    
foreach (Appointment appointment in (ObservableCollection<Appointment>)values[0])

Same error line as before.
TomNidi 5-Jan-11 5:14am View    
Well, I think its the same error:
at CustomCalendar.AppointmentsConverter.Convert(Object[] values, Type targetType, Object parameter, CultureInfo culture) in C:\Users\Tom\Desktop\MyCalendar\CustomCalendar\CustomCalendar\AppointmentsConverter.cs:line 25
at System.Windows.Data.MultiBindingExpression.TransferValue()
at System.Windows.Data.MultiBindingExpression.Transfer()
at System.Windows.Data.MultiBindingExpression.UpdateTarget(Boolean includeInnerBindings)
at System.Windows.Data.MultiBindingExpression.AttachToContext(Boolean lastChance)
at System.Windows.Data.MultiBindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
at MS.Internal.Data.DataBindEngine.Run(Object arg)
at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at System.Windows.Interop.HwndSource.SetLayoutSize()
at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
at MS.Internal.Designer.VSIsolatedDesigner.ViewHolder.Initialize()
at MS.Internal.Designer.VSIsolatedDesigner.ViewHolder..ctor(UIElement content)
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.get_ViewHandle()
at MS.Internal.Host.Isolation.IsolatedView.get_ViewHandle()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()

If I uncomment my code I don't get this error, only the message that I mentioned on the tittle of the topic, and the designer doesn't show anything