Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4964 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
17 changed files with 157 additions and 120 deletions
@ -0,0 +1,34 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using System; |
||||||
|
using ICSharpCode.Core; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Editor.Commands |
||||||
|
{ |
||||||
|
public class InsertGuidCommand : AbstractMenuCommand |
||||||
|
{ |
||||||
|
public override void Run() |
||||||
|
{ |
||||||
|
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; |
||||||
|
if (viewContent == null || !(viewContent is ITextEditorProvider)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor; |
||||||
|
if (textEditor == null) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
string newGuid = Guid.NewGuid().ToString().ToUpperInvariant(); |
||||||
|
|
||||||
|
textEditor.SelectedText = newGuid; |
||||||
|
textEditor.Select(textEditor.SelectionStart + textEditor.SelectionLength, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using System.IO; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Editor.Commands |
||||||
|
{ |
||||||
|
public class ShowColorDialog : AbstractMenuCommand |
||||||
|
{ |
||||||
|
public override void Run() |
||||||
|
{ |
||||||
|
IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; |
||||||
|
|
||||||
|
if (viewContent == null || !(viewContent is ITextEditorProvider)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor; |
||||||
|
|
||||||
|
using (SharpDevelopColorDialog cd = new SharpDevelopColorDialog()) { |
||||||
|
if (cd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { |
||||||
|
string ext = Path.GetExtension(textEditor.FileName).ToLowerInvariant(); |
||||||
|
string colorstr; |
||||||
|
if (ext == ".cs" || ext == ".vb" || ext == ".boo") { |
||||||
|
if (cd.Color.IsKnownColor) { |
||||||
|
colorstr = "Color." + cd.Color.ToKnownColor().ToString(); |
||||||
|
} else if (cd.Color.A < 255) { |
||||||
|
colorstr = "Color.FromArgb(0x" + cd.Color.ToArgb().ToString("x") + ")"; |
||||||
|
} else { |
||||||
|
colorstr = string.Format("Color.FromArgb({0}, {1}, {2})", cd.Color.R, cd.Color.G, cd.Color.B); |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (cd.Color.IsKnownColor) { |
||||||
|
colorstr = cd.Color.ToKnownColor().ToString(); |
||||||
|
} else if (cd.Color.A < 255) { |
||||||
|
colorstr = "#" + cd.Color.ToArgb().ToString("X"); |
||||||
|
} else { |
||||||
|
colorstr = string.Format("#{0:X2}{1:X2}{2:X2}", cd.Color.R, cd.Color.G, cd.Color.B); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
textEditor.SelectedText = colorstr; |
||||||
|
textEditor.Select(textEditor.SelectionStart + textEditor.SelectionLength, 0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue