"Preferred Order" support to Workspace/SmartPartInfo

May 8, 2007 at 9:57 PM
Hello,

I guess it would be very helpful if add an PreferredOrder property to OutlookbarSmartPartInfo and OutlookbarWorkspace. The order in which views are presented sometimes is very important, top-down.

http://www.codeplex.com/cabextensions/WorkItem/View.aspx?WorkItemId=222

-
Thanks,
Leonid
Coordinator
May 8, 2007 at 11:26 PM
As a workaround you can change the module load order. I know is not the solution but if that does not affect your app you can change the profilecatalog with the order of modules you want.
May 27, 2007 at 11:14 AM
Hi there,
to implement a prefered order (index in my case) see following changes.

OutlookBarSmartPartInfo.cs
public class OutlookBarSmartPartInfo : SmartPartInfo
{		
		...
		private double index = -1.0; 
		
		/// <summary>
		/// Set or get the Index property of the object.
		/// <remarks>-1.0 means adding at the end..</remarks>
		/// </summary>
		public double Index
		{
			get { return this.index; }
			set { this.index = value; }
		}
		...
}

OutlookBarWorkspace.cs
public partial class OutlookBarWorkspace : UserControl, IWorkspace
{
	...
	protected virtual void AddNewButton(OutlookBarSmartPartInfo info, object smartPart, out ToolStripButton stackStripButton, out ToolStripButton overflowStripButton)
	{
		...
		//  this.overflowStrip.Items.Add(overflowStripButton);
		//  this.stackStrip.Items.Add(stackStripButton);
		//  UpdateSplitter();
		//}
 
		int index = this.GetInsertIndex(info.Index);
		this.overflowStrip.Items.Insert(index + 1, overflowStripButton);
		this.stackStrip.Items.Insert(index, stackStripButton);
		this.UpdateSplitter();
	}
 
	private int GetInsertIndex(double index)
	{
		if (index == -1.0)
		return this.stackStrip.Items.Count;
 
		int lastIndex = 0;
		foreach (ToolStripButton button in this.stackStrip.Items)
		{
			OutlookBarSmartPartInfo info = ((ISmartPartInfoProvider)button.Tag).GetSmartPartInfo(typeof(OutlookBarSmartPartInfo)) as OutlookBarSmartPartInfo;
			if (info != null)
			{
				if (info.Index == -1.0 || info.Index > index)
					break;
				lastIndex++;
			}
		}
		return lastIndex;
	}
	...
}

Thanks to Matias sharing the OutlookBarWorkspace with us.
Coordinator
May 31, 2007 at 5:28 PM
Edited May 31, 2007 at 5:29 PM
Thanks man. I will be adding this in the next release.
By the way, I'm moving the outlook bar to the SCSF Contrib project (www.codeplex.com/scsfcontrib)

Thanks
Matias