We use redemption tools to populate stub-mails with real content. After calling RDOMail.Import(...) on the selected item, we close and reopen the preview (reading) pane in outlook using
m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, false);
m_Explorer.ShowPane(MSOutlook.OlPane.olPreview, true);
This method works well in Outlook 2007.
But in Outlook 2010 programmatical refresh attempts (Close/Open Reading pane, Deselect/Select the updated item) do not work at all. Outlook 2010 still shows the old version.
Does anyone have a hint or a possible solution?
Many thanks in advance.
Did you try just calling Close on the MailItem? This refreshes content if the item is selected for me. Seems an easier solution to what you are suggesting.
Finally, we solved it!
The solution is to
1) Remove the item to update context.RemoveItem(TargetData.EntryID); (We are using some abstractions over RDOMessage, MailItem, RDOFolder and MAPIFolder. But I think, the principle behind is quiet clear.
2) Add the new item (WithComCleanup is from VSTOContrib project)
using (var msg = RDOSession.Resource.GetMessageFromMsgFile(pathToMSG)
.WithComCleanup())
{
msg.Resource.Move(context.RDOFolder);
msg.Resource.Save();
}
3) Attach an ItemAdd handler to RDOFolder or MAPIFolder, note that the items collection has to be declared on class level!
Why ItemAdd? Because neither RDOMail.OnModified nor RDOMail.OnMoved provided a valid EntryID required for MailItem retrieval. We write custom UserAttributes on fetching, and read them in ItemAdd...
//...
m_OwnItems = m_Folder.Items
m_OwnItems.ItemAdd += new MSOutlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
//...
void Items_ItemAdd(object Item)
{
//Outlook 2010: Version 14, only Outlook 2010 supports `ClearSelection` and `AddToSelection`
if (Item is MSOutlook.MailItem && ApplicationController.Instance.ApplicationVersion.Major >= 14)
{
var mail = Item as MSOutlook.MailItem;
//Check that the added item is the one you added with GetMessageFromMsgFile
//...
if (m_Explorer.IsItemSelectableInView(mail))
{
m_Explorer.ClearSelection();
m_Explorer.AddToSelection(mail);
}
}
}
4) It's done! This behavior of Outlook 2010 annoyed us for the whole development time...
Keep in mind that RDOMail.Move returns the new object (just like OOM).
Since you are recreating the message, its creation time will change.
Related
I want to split one method to many little methods, but I want my code to still be simple to read. Is it possible to display content of methods in place, the way it was before the split? I want to display them in the same way explorer displays folders: you see files and folders, click on the triangle left to a folder to show what's inside.
No, you can't. However you can use the "Peek Definition" feature of Visual Studio (since VS 2013, not in Express Versions however).
If you have your newly refactored method like:
public void RefactoredMethod()
{
DoStuff();
SomeMore();
Validate();
Save();
}
you can right-click any of the smaller methods and choose "Peek Definition" to show the method inline at the current place. You can also bind it to a shortcut.
I wanted to add a lazy loading list box(load content when swipe) in a panorama page in one of my windows phone 7 applications. I could however do it using a pivot page. I referred this link
But this is not working with panorama page. Can anyone please help me?
Okay, you're going to need to do one of two things: use the BCL Async package (basically adds async Tasks and such to WP7) or use a background worker. I highly suggest the BCL Async package, it's easy to get on Nuget.
Now, in your ViewModel (you are using MVVM, yes?) the property that it's bound to, let's call it Items should return an ObservableCollection of the item type you need. Now, here's where the magic happens. In the Getter of that property, return a new collection and use a task to fill it. Something like this:
public ObservableCollection<object> Items
{
get
{
ObservableCollection<object> retCollection = new ObservableCollection<object>();
FillCollection(retCollection);
return retCollection;
}
}
public async void FillCollection(ObservableCollection<object> collectionToFill)
{
Task.Factory.StartNew(() =>
{
foreach(object objectToAdd in collectionImGettingThisDataFrom)
{
// We do this using the Dispatcher to
// be sure to pop back into the UI thread.
Deployment.Current.Dispatcher.BeginInvoke(
() => collectionToFill.Add(objectToAdd));
}
}
}
Because FillCollection is async, the Get method will continue and return the current collection. On another thread, the Task that's created will find the data to add, then push it to the UI thread to add it into the collection. This way, you'll be able to lazy load the data only when you ask for it, without completely blocking your UI thread. If it turns out that it's still making your UI slow, you can add the line:
await TaskEx.Delay(25); // Some time in milliseconds. Too much and it will
// take a long time to load the list,
// too little and it will still bog down your UI.
At the end of the foreach block, but not in the Dispatcher invokation.
Happy coding!
Have you looked at the Telerik Rad Controls yet? They have all types of pull to refresh controls. I used them in a recent app I released called "Rad Libs". You can see the controls here http://www.telerik.com/products/windows-phone.aspx and you can also download an app that demos all of their controls. (Disclaimer: I have no affiliation with telerik. I stand to gain nothing from promoting them here)
I'm using IsolatedStorageSettings on WP7 to store an objects list:
List<T>
I need to search an item inside my list and to update some properties of the searched item.
I'm using this code:
List<Article> listArt = null;
IsolatedStorageSettings.ApplicationSettings.TryGetValue("ArticleListStorage", out listArt);
var queryList = (from anItem in listArt where (anItem.Id == _id) select anItem).ToList<Article>();
a = queryList[0] as Article;
//mark Article as read
a.Readed = true;
When I continuously navigate the various page inside the app, I can see the property Readed correctly evalued.
But, when I click on WP7 Start button and reopen my app (without close emulator) I see the property not correctly evalued.
Need I to update my object inside list and so inside Isolated Storage?
Not updated by reference?
I tried also this, ant it doesn't work:
listArt[0].Readed = true;
listArt[0].Favorite = true;
IsolatedStorageSettings.ApplicationSettings["ArticleListStorage"] = listArt;
IsolatedStorageSettings.ApplicationSettings.Save();
What is wrong?
Thank you so much!
You can either explicitly call Save() on the settings or wait for the app to close normally and then they will be saved automatically.
As a general rule I'd suggest always explicitly saving settings once you change them. (Unless you have a very good reason not to.)
What's happening in your situation is that you are pressing the start button which causes your app to tombstone. When you launch a new instance of the app the tombstoned version is destroyed without all the code which normally runs on application close (including auto-saving settings) being executed.
Here's and example of using Save:
var settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("some-key"))
{
settings.Remove("some-key");
}
settings.Add("some-key", "my-new-value");
settings.Save();
Yes, you've got to save your list again. Think of isolated storage as a file system - you wouldn't expect to be able to load an XDocument from disk, make changes in memory and automatically see those changes reflected on disk, would you? Well, it's the same with isolated storage.
This should be quite a common problem, but I couldn't find anything helpful on the topic.
We are developing an application with Eclipse RCP. The application shows data in an editor of which usually multiple instances are open. In an additional view you can edit the editor-values. When the values are changed in the view they are updated in the editor and it's dirty flag is set.
So far it works fine. What we're missing is: When another editor instance gets the focus, our view should show the data of this editor.
I managed to do that for two views. The second view is sucessfully updated using a TableViewer as selection Provider and registering a SelectionListener in the other view. I tried the same thing for the editor using a Viewer I subclassed from ContentViewer, but it didn't work.
Can this approach be working?
Or do I need a different approach on the problem?
May be you can subclass your view from PageBookView and then provide special adapter for your editor. Outline View is implemented using this approach.
Thank you cerealk, that was exactly what I needed. :-)
Update the View when another Editor is selected
public class myView {
// Create an IPartListener2
IPartListener2 pl = new IPartListener2() {
// If the Editor I'm interested in was updated ...
public void partActivated(IWorkbenchPartReference ref) {
IWorkbenchPart part = ref.getPart(true);
if (part instanceof DetailEditor) {
// ... update the view
Contact contactFromSelectedEditor = ((DetailEditor) part).detailComposite.contact;
detailComposite.update(contactFromSelectedEditor);
}
}
...
}
// Add the IPartListener2 to the page
IWorkbenchPage page = this.getSite().getPage();
page.addPartListener(pl);
}
Why use an IPartListener2 instead of an IPartListener
The IPartListener2 replaces IPartListener with 3.5.
As explained in this this answer:
You should always use IPartListener2 as it can handle part-change events on parts that have not yet been
created because they are hidden in a stack behind another part.
This
listener will also tell you when a part is made visible or hidden or
when an editor's input is changed.
I'm fairly new to SharePoint so apologies in advance for sounding like a 'Newbie'.
I have created a simple Webpart, which uses a Web User Control - [.ascx file] to provide all the controls for the Webpart. On the .ascx file, there is a DropDownList which is hard-coded at the moment and works well in the Webpart (within a SharePoint site).
However, I want the DropDownList on the .ascx file to be bound to a particular Column of a SharePoint List, so that when I update that column of the SharePoint List, the DropDownList reflects the update automatically.
Do any of you kind folk have any ideas on how to achieve this please?
Thank you very much in advance,
Ash 8-)
(p.s. Happy New Year to you All !)
I found the answer within minutes of posting the above article (typical).
The solution is to place the following code in the Page_Load event of the .ascx.cs (code-behind) file:
if (!Page.IsPostBack)
{
using (SPSite site = new SPSite("http://yoursharepointsite"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["NameOfYourList"];
dropSite.DataSource = list.Items;
dropSite.DataValueField = "Title"; // List field holding value - first column is called Title anyway!
dropSite.DataTextField = "Title"; // List field holding name to be displayed on page
dropSite.DataBind();
}
}
}
I found the solution here:
http://blogs.msdn.com/mattlind/archive/2008/02/12/bind-a-asp-dropdownlist-to-a-sharepoint-list.aspx
Thanks,
Ash