/// <summary> /// Obtains a control to edit a given property. Changes to the selection set /// cause this method to be called again (and passed a new 'context'), /// unless ICacheablePropertyControl is implemented on the control. For /// performance reasons, it is highly recommended that the control implement /// the ICacheablePropertyControl interface.</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public virtual Control GetEditingControl(PropertyEditorControlContext context) { var control = new BoundedFloatControl(context, m_min, m_max); SkinService.ApplyActiveSkin(control); return(control); }
/// <summary> /// Obtains a control to edit a given property. Changes to the selection set /// cause this method to be called again (and passed a new 'context'), /// unless ICacheablePropertyControl is implemented on the control. For /// performance reasons, it is highly recommended that the control implement /// the ICacheablePropertyControl interface.</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public Control GetEditingControl(PropertyEditorControlContext context) { var control = new CollectionEditingControl(context); SkinService.ApplyActiveSkin(control); return(control); }
/// <summary> /// Gets a control to edit the given property</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public virtual Control GetEditingControl(PropertyEditorControlContext context) { NumericTextBox editingControl = new NumericTextBox(m_numericType, context); editingControl.ScaleFactor = m_scaleFactor; SkinService.ApplyActiveSkin(editingControl); return(editingControl); }
/// <summary> /// Obtains a control to edit a given property. Changes to the selection set /// cause this method to be called again (and passed a new 'context'), /// unless ICacheablePropertyControl is implemented on the control. For /// performance reasons, it is highly recommended that the control implement /// the ICacheablePropertyControl interface.</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public virtual Control GetEditingControl(PropertyEditorControlContext context) { var control = new BoundedIntControl(context, m_min, m_max); SkinService.ApplyActiveSkin(control); m_controlRefList.RemoveAll(item => !item.IsAlive); m_controlRefList.Add(new WeakReference(control)); return(control); }
private void SkinServiceSkinChangedOrApplied(object sender, EventArgs e) { if (IsDisposed) { return; } SkinService.ApplyActiveSkin(this); }
public NavigationBar() { DropDownStyle = ComboBoxStyle.DropDownList; Sorted = true; m_broker = LuaIntellisenseBroker.Get(); SkinService.ApplyActiveSkin(this); SkinService.SkinChangedOrApplied += SkinServiceSkinChangedOrApplied; }
public void Initialize() { BuildControl(); var mainForm = SledServiceInstance.TryGet <MainForm>(); mainForm.Shown += MainFormShown; SkinService.ApplyActiveSkin(SledTtyMessageColorer.Instance); SkinService.SkinChangedOrApplied += SkinServiceSkinChangedOrApplied; }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var instancingContext = TreeView.As <IInstancingContext>(); m_deleteBookmark.Enabled = instancingContext.CanDelete(); m_deleteBookmark.Visible = instancingContext.CanDelete(); SkinService.ApplyActiveSkin(m_contextMenuStrip); m_contextMenuStrip.Show(TreeControl, e.X, e.Y); } }
/// <summary> /// Gets a control to edit the given property</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public Control GetEditingControl(PropertyEditorControlContext context) { NumericMatrixControl result = new NumericMatrixControl(m_numericType, m_rows, m_columns, context); // Controls[0] is the 1st TextBox for 1st matrix element // result.Height = result.Controls[0].Font.Height * m_rows + result.Margin.Top + result.Margin.Bottom + 2; result.ScaleFactor = m_scaleFactor; SkinService.ApplyActiveSkin(result); return(result); }
private void TreeControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Right) { var instancingContext = m_layerLister.TreeView.As <IInstancingContext>(); m_deleteLayer.Enabled = instancingContext.CanDelete(); m_deleteLayer.Visible = instancingContext.CanDelete(); SkinService.ApplyActiveSkin(m_contextMenuStrip); m_contextMenuStrip.Show(m_layerLister.TreeControl, e.X, e.Y); } }
/// <summary> /// Gets a control to edit the given property</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public Control GetEditingControl(PropertyEditorControlContext context) { InVectorControl editingControl = new InVectorControl(m_numericType, m_names, context); editingControl.Height = editingControl.Font.Height + 2; editingControl.ScaleFactor = m_scaleFactor; editingControl.HideAxisLabel = HideAxisLabel; editingControl.SetLabelBackColors(m_labelColors); SkinService.ApplyActiveSkin(editingControl); return(editingControl); }
private void ApplySkin() { foreach (var frm in m_lstForms) { SkinService.ApplyActiveSkin(frm.Control); } var mode = Mode; ChangeMode(SledFindAndReplaceModes.None); ChangeMode(mode); }
public void TestSkinningNonControls() { var skinService = new SkinService(); var generalA = new GeneralObjectA(); skinService.OpenSkinFile(".\\Resources\\TestSkin.xml"); skinService.ApplyActiveSkin(); SkinService.ApplyActiveSkin(generalA); Assert.IsTrue(generalA.StringA == "TestSkinValueA"); skinService.ResetSkin(); Assert.IsTrue(generalA.StringA == null); }
/// <summary> /// Obtains a control to edit a given property. Changes to the selection set /// cause this method to be called again (and passed a new 'context'), /// unless ICacheablePropertyControl is implemented on the control. For /// performance reasons, it is highly recommended that the control implement /// the ICacheablePropertyControl interface.</summary> /// <param name="context">Context for property editing control</param> /// <returns>Control to edit the given context</returns> public Control GetEditingControl(PropertyEditorControlContext context) { m_boolControl = new BoolControl(context); SkinService.ApplyActiveSkin(m_boolControl); return(m_boolControl); }
private void SkinServiceSkinChangedOrApplied(object sender, EventArgs e) { SkinService.ApplyActiveSkin(SledTtyMessageColorer.Instance); m_lstOutput.Invalidate(true); }
// Rebuild all item controls when the selected collection object has changed private void RebuildItemControls(object collectionObject) { m_activeCollectionNode = collectionObject; var array = m_context.Descriptor.GetValue(m_context.LastSelectedObject) as Array; m_lastKnownSize = array.Length; // Set index column width to be big enough to display the highest expected index, // using double the number of current items as first estimate. // This could be done more accurately with MeasureString and could also be dynamically // adjusted if the number exceeds the current max due to add operations. m_indexColumnWidth = Math.Max(30, (array.Length * 2).ToString().Length * 10); try { SuspendLayout(); m_toolStrip.Enabled = false; // Clear and dispose all current item controls foreach (ItemControl itemControl in m_itemControls.Values) { UnsubscribeItemEvents(itemControl); Controls.Remove(itemControl); itemControl.Dispose(); } m_itemControls.Clear(); // Add controls for added items // Currently only adding at the end is supported. If we ever want to support // inserting in the middle, then we'd probably want to have this step before // the index-reordering one. int top = m_toolStrip.Height; var controlsToAdd = new List <ItemControl>(); int id = 0; foreach (object item in array) { // Work around for a very strange bug related to the parent Control having a custom font. // It seems to be important to not have this ItemControl's Font property set when adding // it to our Controls, in the call to Controls.AddRange() below. // The parent Control is probably a Sce.Atf.Controls.PropertyEditing.PropertyGridView. // See this tracker item: http://tracker.ship.scea.com/jira/browse/CORETEXTEDITOR-363 Font defaultFont = (Parent != null) ? Parent.Font : Font; var itemControl = new ItemControl(m_itemControls.Count, item, m_indexColumnWidth) { Width = m_toolStrip.Width, Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, Top = top, Index = id, Font = defaultFont }; top += itemControl.Height; m_itemControls.Add(id, itemControl); controlsToAdd.Add(itemControl); SubscribeItemEvents(itemControl); id++; } Controls.AddRange(controlsToAdd.ToArray()); Height = top; // update height of main collection control UpdateAddButton(); UpdateDeleteButton(true); UpdateMoveButtons(true); } catch (Win32Exception ex) { // For very large collections (with 1000+ items) it is possible that Windows runs out of Window handles // Such collections are currently not usable with this editor. To support such collections we'd have to // implement some kind of virtual mode (i.e. stream items in and out) but that would pose some new // challenges for editing operations (add, remove, move) // Clean up to release some window handles and keep the application running smoothly foreach (ItemControl control in m_itemControls.Values) { if (Controls.Contains(control)) { Controls.Remove(control); } control.Dispose(); } m_itemControls.Clear(); // Report error. Must be done after cleaning up, as before we may not even have the resources to show the message box. MessageBox.Show( "Failed to create item controls, probably because there were not enough Window handles available. Consider using a different editor for collections of this size and nature.\r\n\r\n" + ex.GetType().ToString() + Environment.NewLine + ex.Message, "Failed to create item controls", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { ResumeLayout(); m_toolStrip.Enabled = true; } SkinService.ApplyActiveSkin(this); // refreshes alternate back color for even/odd selected items. foreach (ItemControl control in m_itemControls.Values) { control.Selected = control.Selected; } }
public MainWindow(Type[] documentTypes, Type[] panelTypes) { DocumentManager.Init(documentTypes); skinService = new SkinService(); Reflect.Invoke(skinService, "Initialize", null); string skinPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath); if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Dark) { skinPath = System.IO.Path.Combine(skinPath, "Resources/Dark.skn"); skinService.OpenAndApplySkin(skinPath); } else if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Medium) { skinPath = System.IO.Path.Combine(skinPath, "Resources/Light.skn"); //Typically darker than Light skinService.OpenAndApplySkin(skinPath); } else if (CoreSettings.Value.SkinStyle == Settings.SkinStyle.Night) { skinPath = System.IO.Path.Combine(skinPath, "Resources/Night.skn"); skinService.OpenAndApplySkin(skinPath); } else { // Using default native UI widget styles } inst_ = this; this.UseWaitCursor = false; InitializeComponent(); Load += MainWindow_Load; FormClosing += MainWindow_FormClosing; dockPanel.ActiveDocumentChanged += dockPanel_ActiveDocumentChanged; dockPanel.SuspendLayout(true); string layoutPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); layoutPath = System.IO.Path.Combine(layoutPath, Assembly.GetEntryAssembly().GetName().Name); layoutPath = System.IO.Path.Combine(layoutPath, "layout.xml"); if (System.IO.File.Exists(layoutPath) && !CoreSettings.Value.DoNotSaveLayout) { dockPanel.LoadFromXml(layoutPath, StringToDockContent); } else // First launch { foreach (Type t in panelTypes) { if (typeof(Controls.PanelDockContent).IsAssignableFrom(t)) { Controls.PanelDockContent pnl = Activator.CreateInstance(t) as Controls.PanelDockContent; if (pnl != null) { PanelUtil.Show(pnl, dockPanel); } } } BuildUI(); } BuildMenus(documentTypes); BuildToolbars(); // Insert system UI menu "Windows" menuStrip1.Items.Add(new Menu.PanelMenuStripItem()); dockPanel.ResumeLayout(true, true); SkinService.ApplyActiveSkin(this); }
public void TestSkinApplying() { var skinService = new SkinService(); var earlyControl = new TestControlA(); Color originalBackColor = earlyControl.BackColor; SkinService.ApplyActiveSkin(earlyControl); skinService.OpenSkinFile(".\\Resources\\TestSkin.xml"); // The new value should not be applied yet. Assert.IsTrue(earlyControl.BackColor == originalBackColor); skinService.ApplyActiveSkin(); // The new color should be applied now. http://tracker.ship.scea.com/jira/browse/WWSATF-1028 Assert.IsTrue((uint)earlyControl.BackColor.ToArgb() == 0xff00000a); var controlA = new TestControlA(); SkinService.ApplyActiveSkin(controlA); Assert.IsTrue((uint)controlA.BackColor.ToArgb() == 0xff00000a); Assert.IsTrue(string.Equals(controlA.StringA, "TestSkinValueA")); var controlB = new TestControlB(); SkinService.ApplyActiveSkin(controlB); Assert.IsTrue((uint)controlB.BackColor.ToArgb() == 0xff00000b); Assert.IsTrue(string.Equals(controlB.StringA, "TestSkinValueA")); Assert.IsTrue(string.Equals(controlB.StringB, "TestSkinValueB")); var controlC = new TestControlC(); SkinService.ApplyActiveSkin(controlC); Assert.IsTrue((uint)controlC.BackColor.ToArgb() == 0xff00000c); Assert.IsTrue(string.Equals(controlC.StringA, "TestSkinValueA")); Assert.IsTrue(string.Equals(controlC.StringB, "TestSkinValueB")); Assert.IsTrue(string.Equals(controlC.StringC, "TestSkinValueC")); var controlX = new TestControlX(); SkinService.ApplyActiveSkin(controlX); Assert.IsTrue(string.Equals(controlX.StringA, "TestSkinValueX")); var controlY = new TestControlY(); SkinService.ApplyActiveSkin(controlY); Assert.IsTrue(string.Equals(controlY.StringA, "TestSkinValueY")); var controlZ = new TestControlZ(); SkinService.ApplyActiveSkin(controlZ); Assert.IsTrue(string.Equals(controlZ.StringA, "TestSkinValueZ")); //DerivedUndefinedControl derives from TestControlC, so should receive C's style var undefinedControl = new DerivedUndefinedControl(); SkinService.ApplyActiveSkin(undefinedControl); Assert.IsTrue((uint)undefinedControl.BackColor.ToArgb() == 0xff00000c); Assert.IsTrue(string.Equals(undefinedControl.StringA, "TestSkinValueA")); Assert.IsTrue(string.Equals(undefinedControl.StringB, "TestSkinValueB")); Assert.IsTrue(string.Equals(undefinedControl.StringC, "TestSkinValueC")); // Make sure that the skins are reset correctly. skinService.ResetSkin(); //sets the active skin to null Assert.IsTrue(controlA.BackColor == originalBackColor); Assert.IsTrue(controlA.StringA == null); Assert.IsTrue(controlB.BackColor == originalBackColor); Assert.IsTrue(controlB.StringA == null); Assert.IsTrue(controlB.StringB == null); Assert.IsTrue(controlC.BackColor == originalBackColor); Assert.IsTrue(controlC.StringA == null); Assert.IsTrue(controlC.StringB == null); Assert.IsTrue(controlC.StringC == null); Assert.IsTrue(undefinedControl.BackColor == originalBackColor); Assert.IsTrue(undefinedControl.StringA == null); Assert.IsTrue(undefinedControl.StringB == null); Assert.IsTrue(undefinedControl.StringC == null); // Apply the skin again, this time with new original values. // To-do: it's kind of odd that we have to reload the xml file. What if clients wanted to rapidly // switch back and forth programmatically? controlA.StringA = "OriginalA"; controlB.StringB = "OriginalB"; controlC.StringC = "OriginalC"; undefinedControl.StringC = "OriginalC"; skinService.OpenSkinFile(".\\Resources\\TestSkin.xml"); skinService.ApplyActiveSkin(); SkinService.ApplyActiveSkin(controlA); SkinService.ApplyActiveSkin(controlB); SkinService.ApplyActiveSkin(controlC); SkinService.ApplyActiveSkin(undefinedControl); skinService.ResetSkin(); Assert.IsTrue(controlA.StringA == "OriginalA"); Assert.IsTrue(controlB.StringB == "OriginalB"); Assert.IsTrue(controlC.StringC == "OriginalC"); Assert.IsTrue(undefinedControl.StringC == "OriginalC"); }
/// <summary> /// Binds the control to a property editing context</summary> /// <param name="context">Context in which properties are edited</param> public void Bind(IPropertyEditingContext context) { m_propertyGridView.EditingContext = context; SkinService.ApplyActiveSkin(m_propertyGridView); }
/// <summary> /// Opens or creates a document at the given URI. /// Creates and configures with control adapters D2dAdaptableControl to display subcircuit</summary> /// <param name="uri">Document URI</param> /// <returns>Document, or null if the document couldn't be opened or created</returns> public IDocument Open(Uri uri) { DomNode node = null; string filePath = uri.LocalPath; if (File.Exists(filePath)) { // read existing document using standard XML reader using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { CircuitReader reader = new CircuitReader(m_schemaLoader); node = reader.Read(stream, uri); } } else { // create new document by creating a Dom node of the root type defined by the schema node = new DomNode(Schema.circuitDocumentType.Type, Schema.circuitRootElement); // create an empty root prototype folder node.SetChild( Schema.circuitDocumentType.prototypeFolderChild, new DomNode(Schema.prototypeFolderType.Type)); } CircuitDocument circuitCircuitDocument = null; if (node != null) { // now that the data is complete, initialize all other extensions to the Dom data node.InitializeExtensions(); AdaptableControl control = CreateCircuitControl(node); control.AddHelp("https://github.com/SonyWWS/ATF/wiki/Adaptable-Controls".Localize()); var viewingContext = node.Cast <ViewingContext>(); viewingContext.Control = control; circuitCircuitDocument = node.Cast <CircuitDocument>(); string fileName = Path.GetFileName(filePath); ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center); //Set IsDocument to true to prevent exception in command service if two files with the // same name, but in different directories, are opened. controlInfo.IsDocument = true; circuitCircuitDocument.ControlInfo = controlInfo; circuitCircuitDocument.Uri = uri; var editingContext = node.Cast <CircuitEditingContext>(); editingContext.GetLocalBound = GetLocalBound; editingContext.GetWorldOffset = GetWorldOffset; editingContext.GetTitleHeight = GetTitleHeight; editingContext.GetLabelHeight = GetLabelHeight; editingContext.GetSubContentOffset = GetSubContentOffset; control.Context = editingContext; editingContext.SchemaLoader = m_schemaLoader; // schema needed for cut and paste between applications m_circuitControlRegistry.RegisterControl(node, control, controlInfo, this); SkinService.ApplyActiveSkin(control); // Set the zoom and translation to show the existing items (if any). var enumerableContext = editingContext.Cast <IEnumerableContext>(); if (viewingContext.CanFrame(enumerableContext.Items)) { viewingContext.Frame(enumerableContext.Items); } //var viewingAdapter = control.As<ViewingAdapter>(); // enable toggle after initial frame operation. // viewingAdapter.ToggleFramingEnabled = true; // toggle frame/unframe. } return(circuitCircuitDocument); }
private void SkinServiceSkinChangedOrApplied(object sender, EventArgs e) { SkinService.ApplyActiveSkin(m_fauxControl); }
private static void GotoDefinitions(string title, ILuaIntellisenseDocument document, Func <Expression, List <LuatValue.IReference> > func) { if ((document == null) || (document.SyntaxEditorControl == null) || (func == null)) { return; } var se = (ActiproSoftware.SyntaxEditor.SyntaxEditor)document.SyntaxEditorControl; if ((se.Document == null) || (se.SelectedView == null)) { return; } var expression = GetExpressionAt(se.Document, se.SelectedView.Selection.StartOffset); if (expression == null) { return; } var definitions = func(expression); if (definitions == null) { return; } if (definitions.Count == 0) { return; } if (definitions.Count == 1) { definitions[0].Goto(); return; } using (var gfx = se.SelectedView.CreateGraphics()) { var menu = new ContextMenuStrip { ImageList = LuaIntellisenseIcons.GetImageList() }; SkinService.ApplyActiveSkin(menu); KeyValuePair <string, LuatValue.IReference[]>[] groups = definitions.GroupItems(a => a.Context, a => a); ToolStripLabel label; { label = new ToolStripLabel(title) { Enabled = false }; menu.Items.Add(label); } int index = 0; foreach (KeyValuePair <string, LuatValue.IReference[]> group in groups) { menu.Items.Add(new ToolStripSeparator()); if (groups.Length > 0) { label = new ToolStripLabel("Context: " + group.Key) { Enabled = false }; menu.Items.Add(label); } var items = new List <ToolStripItem>(); foreach (LuatValue.IReference definition in group.Value) { string text = GetReferenceText(definition, document.Project); string file = System.IO.Path.GetFileName(definition.Path); int line = definition.Line; LuatValue.GotoReference gotoRef = definition.Goto; var item = new ToolStripMenuItem { ImageIndex = (int)(definition.Value != null ? definition.Value.Type.Icon : LuaIntellisenseIconType.Unknown), Text = string.Format("&{0} {1}({2}): {3}", index++, file, line, text), Font = se.Font, Tag = line }; item.Width = (int)gfx.MeasureString(item.Text, item.Font).Width; item.Click += (s, e) => gotoRef(); items.Add(item); } menu.Items.AddRange(items.OrderBy(x => (int)x.Tag).ToArray()); } var rect = se.SelectedView.GetCharacterBounds(se.SelectedView.Selection.StartOffset); menu.Show(se, rect.Location); } }
/// <summary> /// Creates and returns a context (right click popup) menu. /// Does not raise any events.</summary> /// <param name="commandTags">Commands in menu; nulls indicate separators</param> /// <returns>ContextMenuStrip for context menu</returns> public ContextMenuStrip CreateContextMenu(IEnumerable <object> commandTags) { ContextMenuStrip contextMenu = new ContextMenuStrip(); int itemCount; foreach (object commandTag in commandTags) { // check for separator if (commandTag == null) { itemCount = contextMenu.Items.Count; if (itemCount > 0 && !(contextMenu.Items[itemCount - 1] is ToolStripSeparator)) { contextMenu.Items.Add(new ToolStripSeparator()); } continue; } // add the command and sort it by groups since the last separator CommandInfo info = GetCommandInfo(commandTag); if (info != null && (info.Visibility & CommandVisibility.ContextMenu) != 0) { // allow client to update command appearance UpdateCommand(info); var menuItem = info.GetMenuItem(); if (menuItem.Enabled || !ContextMenuAutoCompact) { ToolStripItemCollection commands = BuildSubMenus(contextMenu.Items, info); ToolStripMenuItem clone = new ToolStripMenuItem(); clone.Text = menuItem.Text; clone.Image = menuItem.Image; clone.Name = menuItem.Name; clone.Enabled = menuItem.Enabled; clone.Checked = menuItem.Checked; clone.Tag = menuItem.Tag; clone.ToolTipText = menuItem.ToolTipText; clone.ShortcutKeys = menuItem.ShortcutKeys; clone.ShortcutKeyDisplayString = menuItem.ShortcutKeyDisplayString; clone.Click += contextMenu_itemClick; clone.ForeColor = m_mainMenuStrip.ForeColor; clone.CheckOnClick = info.CheckOnClick; commands.Add(clone); MaintainSeparateGroups(commands, clone, info.GroupTag); } } } // Remove trailing separator. itemCount = contextMenu.Items.Count; if (itemCount > 0 && (contextMenu.Items[itemCount - 1] is ToolStripSeparator)) { contextMenu.Items.RemoveAt(itemCount - 1); } SkinService.ApplyActiveSkin(contextMenu); return(contextMenu); }