📄 designerviewcontent.cs
字号:
}
}
public ICollection GetCompatibleMethods(EventDescriptor edesc)
{
return generator.GetCompatibleMethods(edesc);
}
public ICollection GetCompatibleMethods(EventInfo edesc)
{
return generator.GetCompatibleMethods(edesc);
}
public override void Selected()
{
PropertyPad.PropertyValueChanged += PropertyValueChanged;
Reload();
IsFormsDesignerVisible = true;
AddSideBars();
SetActiveSideTab();
UpdatePropertyPad();
}
public override void Dispose()
{
disposing = true;
if (IsFormsDesignerVisible) {
Deselecting();
}
base.Dispose();
}
public override void Deselecting()
{
// can happen if form designer is disposed and then deselected
if (!IsFormsDesignerVisible)
return;
LoggingService.Info("Deselecting form designer, unloading..." + viewContent.TitleName);
PropertyPad.PropertyValueChanged -= PropertyValueChanged;
propertyContainer.Clear();
IsFormsDesignerVisible = false;
activeTabName = String.Empty;
if (SharpDevelopSideBar.SideBar.ActiveTab != null && ToolboxProvider.SideTabs.Contains(SharpDevelopSideBar.SideBar.ActiveTab)) {
activeTabName = SharpDevelopSideBar.SideBar.ActiveTab.Name;
}
foreach(AxSideTab tab in ToolboxProvider.SideTabs) {
if (!SharpDevelopSideBar.SideBar.Tabs.Contains(tab)) {
return;
}
SharpDevelopSideBar.SideBar.Tabs.Remove(tab);
}
SharpDevelopSideBar.SideBar.Refresh();
if (!failedDesignerInitialize) {
MergeFormChanges();
textAreaControlProvider.TextEditorControl.Refresh();
}
UnloadDesigner();
LoggingService.Info("Unloading form designer finished");
}
public override void NotifyBeforeSave()
{
base.NotifyBeforeSave();
if (IsFormsDesignerVisible)
MergeFormChanges();
}
public override void NotifyAfterSave(bool successful)
{
if (successful) {
if (designerResourceService != null) {
designerResourceService.Save();
}
}
}
void SelectionChangedHandler(object sender, EventArgs args)
{
UpdatePropertyPadSelection((ISelectionService)sender);
}
void UpdatePropertyPadSelection(ISelectionService selectionService)
{
ICollection selection = selectionService.GetSelectedComponents();
object[] selArray = new object[selection.Count];
selection.CopyTo(selArray, 0);
propertyContainer.SelectedObjects = selArray;
}
protected void UpdatePropertyPad()
{
if (IsFormsDesignerVisible) {
propertyContainer.Host = Host;
propertyContainer.SelectableObjects = Host.Container.Components;
ISelectionService selectionService = (ISelectionService)Host.GetService(typeof(ISelectionService));
if (selectionService != null) {
UpdatePropertyPadSelection(selectionService);
}
}
}
public bool IsFormsDesignerVisible = false;
#region IUndoHandler implementation
public bool EnableUndo {
get {
if (undoEngine != null) {
return undoEngine.EnableUndo;
}
return false;
}
}
public bool EnableRedo {
get {
if (undoEngine != null) {
return undoEngine.EnableRedo;
}
return false;
}
}
public virtual void Undo()
{
if (undoEngine != null) {
undoEngine.Undo();
}
}
public virtual void Redo()
{
if (undoEngine != null) {
undoEngine.Redo();
}
}
#endregion
#region IClipboardHandler implementation
public bool EnableCut {
get {
//ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));
//return selectionService.SelectionCount >= 0 && selectionService.PrimarySelection != host.RootComponent;
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(StandardCommands.Cut);
if (menuCommand == null) {
return false;
}
int status = menuCommand.OleStatus;
return menuCommand.Enabled;
}
}
public bool EnableCopy {
get {
//ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));
//return selectionService.SelectionCount >= 0 && selectionService.PrimarySelection != host.RootComponent;
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(StandardCommands.Copy);
if (menuCommand == null) {
return false;
}
int status = menuCommand.OleStatus;
return menuCommand.Enabled;
}
}
const string ComponentClipboardFormat = "CF_DESIGNERCOMPONENTS";
public bool EnablePaste {
get {
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(StandardCommands.Paste);
if (menuCommand == null) {
return false;
}
int status = menuCommand.OleStatus;
return menuCommand.Enabled;
}
}
public bool EnableDelete {
get {
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
System.ComponentModel.Design.MenuCommand menuCommand = menuCommandService.FindCommand(StandardCommands.Delete);
if (menuCommand == null) {
return false;
}
int status = menuCommand.OleStatus;
return menuCommand.Enabled;
}
}
public bool EnableSelectAll {
get {
return true;
}
}
public void Cut()
{
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.Cut);
}
public void Copy()
{
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.Copy);
}
public void Paste()
{
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.Paste);
}
public void Delete()
{
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.Delete);
}
public void SelectAll()
{
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.SelectAll);
}
#endregion
#region Tab Order Handling
bool tabOrderMode = false;
public virtual bool IsTabOrderMode {
get {
return tabOrderMode;
}
}
public virtual void ShowTabOrder()
{
if (!IsTabOrderMode) {
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.TabOrder);
tabOrderMode = true;
}
}
public virtual void HideTabOrder()
{
if (IsTabOrderMode) {
IMenuCommandService menuCommandService = (IMenuCommandService)designSurface.GetService(typeof(IMenuCommandService));
menuCommandService.GlobalInvoke(StandardCommands.TabOrder);
tabOrderMode = false;
}
}
#endregion
/// <summary>
/// Reloads the form designer if the language property has changed.
/// </summary>
void PropertyValueChanged(object source, PropertyValueChangedEventArgs e)
{
if (e.ChangedItem == null || e.OldValue == null)
return;
if (e.ChangedItem.GridItemType == GridItemType.Property) {
if (e.ChangedItem.PropertyDescriptor.Name == "Language") {
if (!e.OldValue.Equals(e.ChangedItem.Value)) {
LoggingService.Debug("Reloading designer due to language change.");
propertyContainer.Clear();
if (!failedDesignerInitialize) {
MergeFormChanges();
}
UnloadDesigner();
Reload();
UpdatePropertyPad();
}
}
}
}
void AddSideBars()
{
foreach(AxSideTab tab in ToolboxProvider.SideTabs) {
if (!SharpDevelopSideBar.SideBar.Tabs.Contains(tab)) {
SharpDevelopSideBar.SideBar.Tabs.Add(tab);
}
}
SharpDevelopSideBar.SideBar.Refresh();
}
void SetActiveSideTab()
{
if (activeTabName.Length == 0) {
return;
}
foreach(AxSideTab tab in ToolboxProvider.SideTabs) {
if (activeTabName == tab.Name) {
SharpDevelopSideBar.SideBar.ActiveTab = tab;
return;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -