This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, Is it available to attach a note and a binary file for a scheduler event? I have to add some comments on the schedule and attach a file to let user has to know. Thank you in advance. Hobin |
|
|
Hello Hobin You can do this by creating a custom schedule item implementation that includes properties for these values. Take a look at the custom-schedule-item and colored-schedule-item demos in the sample explorer that comes with WPF Elements. You can find the code for the demo pages in Mindscape/WPF Elements/Samples/SampleExplorer/Demos/Scheduler. And you can find the code for the dialog and schedule item implementations in Mindscape/WPF Elements/Samples/SampleExplorer/Model/Scheduler. You create a custom schedule item by extending the ScheduleItem class and including additional properties that you need. You then create a class that implements the IScheduleItemBuilder interface. This is where you can show a custom dialog and build instances of your custom schedule item based on what the user sets in your dialog. You can set the Scheduler.Schedule.ScheduleItemBuilder to be an instance of your custom builder. All of this is demonstrated in the samples I mentioned. Let me know if you have any questions about this. Jason Fauchelle |
|
|
Dear Jason, I'm trying to make an extended schedule item, namely ExtendedScheduleItem, which additionally holds a string for the attached file (string AttachedFilename). As you advised, I defined an inherited ExtendedScheduleItem from ScheduleItem, an interited ScheduleItemBuilder class from IScheduleItemBuilder, and AddScheduleItemDialog as a new dialog box. I'm suffering from some troubles. 1) When I double-click a schedule item on a Scheduler component, a newly defined AddScheduleItemDialog does not pop-up. 2) When I move or double-click a chedule item, a schedule item seems to lose its class property. Let me explain. When I load & unload SchedulePage.xaml, items in the Scheduler are also loaded & unloaded. Save to & load from a file of ExtendedScheduleItem looks fine so far. However, if I edit an item with double-clicking or dragging and save, then the additional property (AttachedFilename) does not exist on the saved file, i.e. the item seems to be no longer a ExtendedScheduleItem class. 3) How can I pop-up a RecurrenceDialog on my AddScheduleItemDialog? Can you look at my codes and help me to tackle these things? Thank you. Sincerely, Hobin. |
|
|
Dear Jason, I'm trying to make an extended schedule item, namely ExtendedScheduleItem, which additionally holds a string for the attached file (string AttachedFilename). As you advised, I defined an inherited ExtendedScheduleItem from ScheduleItem, an interited ScheduleItemBuilder class from IScheduleItemBuilder, and AddScheduleItemDialog as a new dialog box. I'm suffering from some troubles. 1) When I double-click a schedule item on a Scheduler component, a newly defined AddScheduleItemDialog does not pop-up. 2) When I move or double-click a chedule item, a schedule item seems to lose its class property. Let me explain. When I load & unload SchedulePage.xaml, items in the Scheduler are also loaded & unloaded. Save to & load from a file of ExtendedScheduleItem looks fine so far. However, if I edit an item with double-clicking or dragging and save, then the additional property (AttachedFilename) does not exist on the saved file, i.e. the item seems to be no longer a ExtendedScheduleItem class. 3) How can I pop-up a RecurrenceDialog on my AddScheduleItemDialog? Can you look at my codes and help me to tackle these things? Thank you. Sincerely, Hobin. |
|
|
Hello Hobin 1) The Scheduler does not have built in support for double clicking an item and showing the dialog. The DoubleClick case in the builder is actually for when a user double clicks on a time slot or day element in the Scheduler, not an item. To implement this functionality, listen to the Scheduler.ItemActivated event. This is raised when a user double clicks on an item. In the event handler, you can do a similar thing that you are doing in the builder to display your dialog. Here you should also set the Subject and AttachedFileName properties of the dialog to show the values of the item that the user clicked on. You can get the item from the event arguments. 2) In the demo you attached, your ReadSchedule method creates new ScheduleItems instead of ExtendedScheduleItems. It should be something like this instead:
3) Here is some code you need in your dialog to open the recurrence dialog:
When this code is called, make sure the _item field is not null. You may need to change some stuff around to get this to work. For example, rather than creating the ExtendedScheduleItem when the dialog is closed, you should create an instance first and have it ready for if the user clicks the recurrence button. You may want to include an ExtendedScheduleItem in the constructor of your dialog. When an item is double clicked, you'd pass the item into the constructor. When you listen to your dialog closing, you'd want to get back the item from the dialog, rather than creating a new instance. You may also want to include logic for removing recurrence from an item. This should give you a place to start. Let me know if you have any questions as you implement these. Handy Tip: I noticed in your dialog code, you have logic for changing the text of the TextBox. Rather than doing this, you should bind the Text property of the TextBox in xaml to the AttachedFileName property on your dialog. (Similar to what you did for the Subject text box). Then in the xaml, you can use our PromptDecorator control to display "No File" or "Attach a File". Wrap a PromptDecorator tag around the TextBox and set what you want to be displayed using the Prompt property. Now you don't need to listen to MouseDown, StylusDown, or GotFocus events on the TextBox. The PromptDecorator will take care of this logic for you.
Jason Fauchelle |
|
|
Dear Jason, Thank you for your reply. For my ReadSchedule code, there was a piece of my mistake. I applied your recurrence dialog to my code. I got a hint from your code, passing recurrence information through info, and tried to mimic by exchanging "ExtendedScheduleItem _item" through dialog. Unfortunately, it doesn't work. (Please see mySchedulerItemActivated in SchedulePage.xaml.cs) Can you look at it? For removing recurrence information, how about this procedure?
Is there any way to do it in a neat way? Many thanks in advance! :-) Sincerely, Hobin |
|
|
I don't know why my post is repeated. :( Sorry! Sincerely, Hobin |
|
|
Hello Hobin The mySchedulerItemActivated method looks correct, so your dialog should at least be displaying the values of the item you double clicked on. But it looks like when the dialog is closed, you aren't setting the values from the dialog back to the item. This would probably be done in the SchedulePage.AddScheduleItemDialogEdited event handler. Let me know if you need more help finding the issue. For the recurrence info, in the current version of the scheduler, you can't actually change the recurrence info of an item once it has been set. So the Add/Remove recurrence button should not be displayed if the item being edited already has recurrence info. If the item does not have recurrence info, clicking the Add Recurrence button will bring up the dialog allowing the user to create/edit a recurrence info. When this dialog is closed, the resulting recurrence info gets stored in the _info field. Only when the AddScheduleItemDialog is closed will the RecurrenceInfo property of the item be set. If the "Delete Recurrence" button is pressed, you simply set the _info field to null. Let me know if you need more advice with this and I'll help you out. Jason Fauchelle |
|
|
Dear Jason, Can you be more specific on the first issue, returning the values back to the item? I can't figure out how do I return the value. Sincerely, Hobin |
|
|
Hello Hobin I will get back to you about this early next week. Jason Fauchelle |
|
|
Hello Hobin I have attached a sample to show you what to do. This sample is based on the code files you sent. First of all, I found a small bug in the scheduler where the recurrence engine doesn't fully support custom schedule item implementations. To solve this, I added a ScheduleItem method you can override in your ExtendedScheduleItem class. The method is called CreateInstanceCore where you need to return a new instance of ExtendedScheduleItem. You can also set the AttachedFileName property of the new item if you want all items in the same recurrence pattern to use the same file. Because of this new method, you'll need to get the next nightly build to run the sample and get the bug fix. Also, make sure to add a reference to your copy of the Mindscape.WpfElements.dll to run the sample. In the sample, I have disabled the load/save functionality because you already have this sorted out. Also, this is a WPF application rather than a WinForms application which I think your one is. But the code will be the same. To make the code more clear, I created a new class called DialogHelper. This class manages all the AddScheduleItemDialog logic. This has 2 main method. One of them is for creating a new item from scratch (the "Add Item" button was pressed). And the other method is for when an existing item is double clicked. I've made it so the AddScheduleItemDialog requires an item to be passed into the constructor. When an item is double clicked, we simply pass that item into the dialog constructor. If we are creating a new item, the DialogHelper first creates the item instance, sets some properties, and then passes it into the dialog constructor. In this case, we also cache the Schedule in a static field so that when the dialog is closed, we then add the item to the schedule. The dialog holds the current item, so we don't need to store the item in a field. Note that if your application has multiple Scheduler controls in it, you'll want to have a DialogHelper instance for each Scheduler, and don't make the field static. When the item is passed to the dialog constructor, the Subject and AttachedFileName properties of the dialog are set based on the property values of the item. When the OK button is pressed, we then set the properties on the item based on the values input by the user in the text boxes. Now only the dialog manages setting it's own properties from the item, and then setting them back to the item which makes the code easier to follow. I noticed you were setting the Text property of the AttachedFile text box within your dialog code. This would have been destroying the binding you set in xaml which is why you may have noticed the AttachedFileName property wasn't being set properly. You should not set the Text property in code. Only use the AttachedFilName property. It's best if you do not set the Name of the text boxes in the dialog so that you can't access them in code behind. Ideally you should also use bindings to set the RecurrenceButton content in xaml rather than in code too, though this is just a minor detail. If you look through the code in the attached sample, you will see that when the add button is pressed, or an item is double clicked, or your builder is called, we just make a simple call to the DialogHelper class which will make the code easier to maintain. Your recurrence stuff all looks correct. I changed the button content to say "Edit Recurrence" instead of "Remove Recurrence" since the recurrence dialog has the delete-recurrence logic. Make sure to set the RecurrenceInfo of the item when the OK button is clicked. Let me know if you have troubles transferring these changes to your own project. Jason Fauchelle |
|
|
Dear Jason, Thank you for your amazingly kind help. I applied your code and it works fine so far. Now I encountered a new problem: how can I apply localization format to RecurrenceDialog and DeleteRecurrenceDialog to my custom dialog? You gave me an answer how to change labels and titles maybe months ago. I tried to change labels in RecurrenceDialog called by AddScheduleItemDialog with the following code and failed:
In addition, can you help me to change the format for the scheduler date view range? It's marked with a red rectangle in the attached picture. Many thanks in advance. Sincerely, Hobin |
|
|
Hello Hobin To apply styling to the recurrence dialog, you'll need your AddScheduleItemDialog to get a hold of the formatter. Here is how to do this: Step 1: Add a private SchedulerFormatter field to your AddScheduleItemDialog. Step 2: Add a SchedulerFormatter parameter to the AddScheduleItemDialog constructor, then set the field with the parameter value. Step 3: In the Recurrence_Click event handler, use the formatter to set the Style property of the RecurrenceDialog. It's best to have null checks here.
Step 4: In the DialogHelper class I showed you in the sample, add a static SchedulerFormatter property.
Step 5: now in the DialogHelper, you can pass the Formatter property value into the AddScheduleItemDialog constructor. Step 6: I recommend starting with a simple recurrence dialog style to test that it's working. Here is a recurrence dialog style that simply applies our OfficeBlue theme. When you run up the application later, if all the buttons are blue then you'll know it's working.
Step 7: Set the RecurrenceDialogStyle property of the SchedulerFormatter, and set the Formatter property of the Scheduler which you're probably already doing. Step 8: Finally, in the constructor of SchedulePage, set the static DialogHelper.Formatter property to be the myScheduler.Formatter.
Once you've got this working, apply whatever recurrence dialog style you want. For the date range display, it will use the current culture of the application. So if you set the culture of the application to Korean, it format the strings appropriately. If this formatting is not what you want, please let me know what string formatting for each view (Day, Week, Month) you want and I'll find the best way to apply this. Jason Fauchelle |
|
|
Dear Jason, I resolved that localization problem. Thank you so much! Sincerely, Hobin |
|
|
Dear Jason, Now my code is almost done with your kind help. Now I'm translating recurrence dialog in Korean, but I found something curios. Red rectangle in the attached picture, are not automatically translated in Korean, whereas the name of months are correct. I set the culture with
in the constructor of the SchedulePage which contains the Scheduler. How do I complete the localization by translating DayOfRecurrenceList, OccurrenceList, etc. ? Sincerely, Hobin |
|
|
Dear Jason, In addition to the above problem, I have another minor issue: "delete recurrence" button is inactivated when open a recurrence dialog of recurrence item. Can you look at this? Sincerely, Hobin |
|
|
Hello Hobin 1) Changing the language of the Scheduler will allow WPF to automatically localize date time values. It does not know how to translate the recurrence words as these are part of our control suite. To translate these, you can use your custom recurrence dialog style/template where you have access to modify any of the labels and controls in the dialog. For the recurrence words, you'd use an item template for the combo box items and either triggers or a converter to display the correct Korean words. Although you may think the day-of-week labels for the weekly-recurrence pattern would be localized, these labels have been hard coded in xaml. In your custom recurrence dialog style, you can simply change the content of these labels. 2) In the current version of the Scheduler, a recurrence pattern can not be removed from an item that has been created and added to the schedule. I've noted this down as something to improve in a future version. Jason Fauchelle |
|