//private void OnBrowseManifest(object sender, ExecutedRoutedEventArgs e) //{ // var dlg = new OpenFileDialog(); // if (curManifest != null && curManifest.Length > 0) // dlg.FileName = curManifest; // dlg.DefaultExt = ".manifest.xml"; // dlg.Filter = "DSS Manifest (.manifest.xml)|*.manifest.xml"; // if (dlg.ShowDialog(this) == true) // { // lock (connectionThreadLock) // { // curManifest = dlg.FileName; // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } // } //} //private void ToggleConnect(object sender, RoutedEventArgs e) //{ // if (curManifest == null || curManifest.Length <= 0) // BrowseManifest(sender, e); // lock (connectionThreadLock) // { // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } //} private void OnInitialized(object sender, EventArgs e) { try { commandWindow.StartScripting(); commandWindow.PythonExecuting += delegate(object source, EventArgs e2) { //Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, // new ThreadStart(delegate() { runButton.BitmapEffect = new OuterGlowBitmapEffect() { GlowColor = Colors.Orange, GlowSize = 5 }; })); }; commandWindow.PythonFinished += delegate(object source, EventArgs e2) { //Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, // new ThreadStart(delegate() { runButton.BitmapEffect = null; })); }; editor = new Editor(this); editor.InsertedEditor += OnEditorInserted; editor.RemovedEditor += OnEditorRemoved; editor.ActivatedEditor += OnEditorActivated; editor.ModifiedChanged += OnEditorNameChanged; editor.NameChanged += OnEditorNameChanged; //SetButtonsEnabled(); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
private IEnumerator Calculate() { var bakeCheck = GUIUtilities.BakeCheckAndRun(); while (bakeCheck.MoveNext()) { yield return(null); } if (!(bool)bakeCheck.Current) { yield break; } float?byteCount = null; AssetUtility.TemporaryDestroyObjectsOutsideOfRootObjectAndRunCallback(AssetUtility.GetId(this.baseFolder), () => { byteCount = Calculator.ForceRebuild(); }); if (byteCount == null) { EditorUtility.DisplayDialog("VitDeck", LocalizedMessage.Get("BuildSizeCalculator.BuildFailed"), "OK"); yield break; } EditorUtility.DisplayDialog( "VitDeck", LocalizedMessage.Get("BuildSizeCalculator.BuildSize", AssetUtility.GetScenePath(this.baseFolder), (byteCount.Value / Math.Pow(2, 20)).ToString("0.00' MiB'")), "OK" ); }
protected override void OnPaint(PaintEventArgs e) { if (!this.Visible || Parent != null && !Parent.Visible) { return; } DrawInternalBackground(e, false); // Presumably only one of the image, line and hatching will be defined... Image image = null; int drawSize = 0; // usually the image is drawn at its actual size, but if we are to make it expand we must draw at a specific size if (!string.IsNullOrEmpty(m_ImageName)) { image = (Image)GUIUtilities.RM.GetObject(m_ImageName); } else if (m_Parameter == Parameters.Tool) { drawSize = this.Width - EXCESSSIZE; drawSize += EXCESSSIZE * m_SelectionDisplayFraction / 300; // maximum value of m_SelectionDisplayFraction is 255; deliberately dividing by bit more to keep the image smaller image = GUIUtilities.ShapeImage((Shape.Shapes)m_ParameterValue, drawSize); } if (m_Image != null) { image = m_Image; } if (m_Parameter == Parameters.Tool) { if ((Shape.Shapes)m_ParameterValue == Shape.Shapes.Polygon) { // for the polygon we draw the current number of sides Rectangle rctNumber = new Rectangle(INSET + 1, INSET + 4, Width - INSET * 2 - 5, Height - INSET * 2 - 5); e.Graphics.DrawString(Polygon.CURRENTSIDES.ToString(), GUIUtilities.ShortcutFont, Brushes.Black, rctNumber, GUIUtilities.StringFormatCentreCentre); } } if (image != null) { DrawStandardImage(e.Graphics, image, drawSize); if (image != m_Image) { image.Dispose(); } } if (m_SampleLine != null) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.DrawLine(m_SampleLine, SAMPLEINSET, SAMPLEINSET, Width - SAMPLEINSET, Height - SAMPLEINSET); } if (m_SampleHatch != null) { e.Graphics.FillRectangle(m_SampleHatch, SAMPLEINSET, SAMPLEINSET, Width - SAMPLEINSET * 2, Height - SAMPLEINSET * 2); } DrawHighlightAndKey(e); }
//private void OnBrowseManifest(object sender, ExecutedRoutedEventArgs e) //{ // var dlg = new OpenFileDialog(); // if (curManifest != null && curManifest.Length > 0) // dlg.FileName = curManifest; // dlg.DefaultExt = ".manifest.xml"; // dlg.Filter = "DSS Manifest (.manifest.xml)|*.manifest.xml"; // if (dlg.ShowDialog(this) == true) // { // lock (connectionThreadLock) // { // curManifest = dlg.FileName; // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } // } //} //private void ToggleConnect(object sender, RoutedEventArgs e) //{ // if (curManifest == null || curManifest.Length <= 0) // BrowseManifest(sender, e); // lock (connectionThreadLock) // { // if (connectionThread == null || connectionThread.IsAlive == false) // { // connectionThread = new Thread(new ThreadStart(delegate() { connect(); })); // connectionThread.Start(); // } // } //} private void OnInitialized(object sender, EventArgs e) { try { commandWindow.StartScripting(); commandWindow.PythonExecuting += delegate(object source, EventArgs e2) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate() { topBar.IsRunning = true; })); }; commandWindow.PythonFinished += delegate(object source, EventArgs e2) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate() { topBar.IsRunning = false; })); }; editor = new Editor(this); editor.InsertedEditor += OnEditorInserted; editor.RemovedEditor += OnEditorRemoved; editor.ActivatedEditor += OnEditorActivated; editor.ModifiedChanged += OnEditorNameChanged; editor.NameChanged += OnEditorNameChanged; //SetButtonsEnabled(); editor.RequestNewDocument(); webcamDisplay.StartUpdate(); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { if (Editor.MovingPalette != null) { Editor.CompletePaletteMove(); } Control over = GUIUtilities.YoungestChildUnderMouse(Editor); if (source == EditableView.ClickPosition.Sources.Pad) { over = pnlView; // if triggered by mouse in control pad, target must be drawing area, not living back to the control pad! } if (over == pnlView) { pnlView.TriggerVerb(Codes.Choose, source); } else if (over is Button) { ((Button)over).PerformClick(); } else if (over is IInvokeable) { ((IInvokeable)over).PerformClick(); } }
private static string GenerateKeyLine(Keys key) { // generate one line for the above table. This includes all the variations of shift and control // the Alt key must be put on a separate line System.Text.StringBuilder output = new System.Text.StringBuilder(); bool defined = false; // true if any keys were defined output.Append("<tr><td>").Append(GUIUtilities.KeyDescription(key).Replace("<", "")).Append("</td>"); foreach (Keys modifier in new[] { Keys.None, Keys.Shift, Keys.Control, Keys.Shift | Keys.Control }) { Functions.Action action = Globals.Root.CurrentConfig.KeyAction(key | modifier); output.Append("<td>"); if (!action.IsEmpty) { output.Append(action.DescriptionWithoutAccelerator()); defined = true; } output.Append("</td>"); } if (!defined) { return(""); } output.AppendLine("</tr>"); return(output.ToString()); }
//private void disconnect() //{ // Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, // new ThreadStart(delegate() // { // manifestBox.Text = "Disconnecting from robot..."; // })); // controlPanel.SetRobot(null); // if (robot != null) // robot.Shutdown(); // robot = null; // Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, // new ThreadStart(delegate() // { // controlPanel.IsEnabled = false; // try // { // ((Image)connectButton.Content).Source = new BitmapImage(new Uri("disconnect.png", UriKind.Relative)); // manifestBox.Text = (curManifest == null ? "Disconnected" : curManifest + " (disconnected)"); // } // catch (Exception e) { Console.WriteLine(e); } // })); //} private void connect(MyroConfigFiles config) { try { if (connected == false) { //Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, // new ThreadStart(delegate() // { //manifestBox.Text = "Connecting to robot..."; commandWindow.ExecuteCommandInteractive("from myro import *"); commandWindow.LogText("> init('" + config.BaseName + "')\n", Colors.MediumBlue); //})); Robot.Init(config); } } catch (Exception e) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ThreadStart(delegate() { GUIUtilities.ReportUnexpectedException(e); MessageBox.Show(this, Strings.TrySpecifyCOMPort, "Myro"); })); } }
private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e) { if (m_Filling) { return; } TreeNode node = tvOutline.SelectedNode; if (node == null) { return; } object selected = node.Tag; while (node.Parent != null) { node = node.Parent; } Page pageWithin = (Page)node.Tag; if (pageWithin != Globals.Root.CurrentPage) { RequestSelectPage?.Invoke(this, pageWithin); } if (selected is Page page) { txtInfo.Text = Strings.Item("Info_PageBounds") + " " + GUIUtilities.RectangleToUserString(page.Bounds, page); txtInfo.Cursor = Cursors.Arrow; } if (!(selected is Shape)) // presumably the page itself was clicked on { return; } pageWithin.SelectOnly((Shape)selected); }
private IEnumerator Calculate() { var bakeCheck = GUIUtilities.BakeCheckAndRun(); while (bakeCheck.MoveNext()) { yield return(null); } if (!(bool)bakeCheck.Current) { yield break; } var editorPlay = Calculator.EditorPlay(AssetUtility.GetId(this.baseFolder), this.spaceSize); while (editorPlay.MoveNext()) { yield return(null); } if (editorPlay.Current == null) { yield break; } var(setPassCalls, batches) = ((int, int))editorPlay.Current; EditorUtility.DisplayDialog( "VitDeck", LocalizedMessage.Get("PerformanceCalculator0.Result", AssetUtility.GetScenePath(this.baseFolder), setPassCalls, batches), "OK" ); }
public virtual void Paint(Graphics gr, Rectangle bounds, TileList list) { // If only one item is provided it fills the tile; otherwise the image is on the left and the text on the right, unless the tile is // not very wide in which case both are superimposed if (Image != null) { Rectangle imageRect = bounds; if (!string.IsNullOrEmpty(Text) && bounds.Width > bounds.Height * 2) { imageRect.Width = imageRect.Height; // just uses the left-hand part } GUIUtilities.CalcDestRect(Image.Size, ref imageRect); gr.DrawImage(Image, imageRect); } if (!string.IsNullOrEmpty(Text)) { Rectangle textRect = bounds; if (Image != null && bounds.Width > bounds.Height * 2) { textRect.X += bounds.Height; textRect.Width -= bounds.Height; } var format = GUIUtilities.StringFormatCentreLeft; if (bounds.Width <= bounds.Height * 2) { format = GUIUtilities.StringFormatCentreCentre; } gr.DrawString(Text, list.Font, Brushes.Black, textRect.ToRectangleF(), format); } }
public void frmCreateActivity_Load(object sender, EventArgs e) { Strings.Translate(this); GUIUtilities.ScaleDPI(this); // no need to scale since the entire form is auto size m_AppliedUser = Globals.Root.GenerateAppliedConfig(Users.User, Globals.Root.CurrentDocument); m_AppliedTeacher = Globals.Root.GenerateAppliedConfig(Users.Editor, Globals.Root.CurrentDocument); }
public void txtKey_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.ShiftKey: case Keys.LMenu: case Keys.ControlKey: case Keys.RMenu: case Keys.RShiftKey: case Keys.RWin: case Keys.LWin: case Keys.LControlKey: case Keys.RControlKey: break; case Keys.RButton: case Keys.Menu: break; default: m_eKey = e.KeyData; CombinedKeyEvent eCombined = new CombinedKeyEvent(e); // on Mac this will modify the key as needed txtKey.Text = GUIUtilities.KeyDescription(eCombined.KeyData); break; } e.Handled = true; e.SuppressKeyPress = false; if (ctrActions.SelectedAction.Change == Parameters.Action_Key || ctrActions.SelectedAction.Change == Parameters.Action_Character) { btnAdd.Enabled = true; } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { DrawInternalBackground(e, true); Image image = null; if (!string.IsNullOrEmpty(m_ImageName)) { image = (Bitmap)GUIUtilities.RM.GetObject(m_ImageName); } else if (m_eVerb != Codes.None) { image = GUIUtilities.VariableSizeImage("Verb", "_" + m_eVerb, this.Width - EXCESSSIZE); } if (m_Image != null) { image = m_Image; } if (image != null) { DrawStandardImage(e.Graphics, image); if (image != m_Image) { image.Dispose(); } } DrawHighlightAndKey(e); }
public override void DrawImage(string resourceName, int preferredSize, RectangleF destination, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null) { Image image = GUIUtilities.VariableSizeImage(resourceName, "", preferredSize); string ID = PrepareImage((Bitmap)image, resourceName.GetHashCode(), sourceRect); SimpleImage(ID, sourceRect.Size, destination); }
public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction) { // passed to the current colour panel if any Control ctrFocused = GUIUtilities.GetFocusControl(); (ctrFocused as ColourPanel)?.TriggerAction(this); }
private void OnIconClick(object sender, MouseButtonEventArgs e) { try { if (currentConfigFiles != null) { var dlg = new OpenFileDialog(); if (currentConfigFiles.IconFilePath != null) { dlg.FileName = currentConfigFiles.IconFilePath; } if (dlg.ShowDialog(this) == true) { try { setIcon(new BitmapImage(new Uri("file://" + dlg.FileName))); modifiedIconPath = dlg.FileName; currentModified = true; setModifiedStyle(); } catch (NotSupportedException) { MessageBox.Show(this, "We cannot understand this image type. Try another image type such as png, bmp, gif, jpeg, etc.", "Image type not supported", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK); } } } } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }
public void Start() { //Called 2nd GUIUtilities.Log("[Kerbal Launch Vehicles] Start"); RefreshAllConfigurations(); Load(); }
/// <summary>Edits the item(s) currently selected in the view</summary> public static DialogResult Display(StaticView view) { Transaction transaction = new Transaction(); List <Item> items = new List <Item>(); List <Scriptable> scriptables = new List <Scriptable>(); // probably selected items are scriptables, but this is written to cope with all cases (eg naked Items not inside a Scriptable) foreach (Shape selected in view.CurrentPage.SelectedShapes) { if (selected is Item item) { items.Add(item); if (item.Parent is Scriptable scriptable) { scriptables.Add(scriptable); } } else if (selected is Scriptable s) { scriptables.Add(s); if (s.Element is Item item1) { items.Add(item1); } } } foreach (Scriptable s in scriptables) { transaction.Edit(s); } foreach (Item i in items) { transaction.Edit(i); i.BeingEdited = true; } // there must always be at least one item, but not necessarily scriptables Globals.StoreEvent("Log " + items.Count + " items, " + scriptables.Count + " scriptable, first ID=" + (scriptables?.First()?.SAWID ?? 0)); using (var frm = new frmSAWItem(items, scriptables, transaction)) { // deselect it, so that we get a better preview of what it looks like: frm.m_Page.SelectOnly((Shape)null); Shape beside = scriptables.Any() ? (Shape)scriptables.First() : items.First(); GUIUtilities.PositionNewFormBeside(frm, view.ShapeBounds(beside, true)); bool ok = frm.ShowDialog() == DialogResult.OK; foreach (Item i in items) { i.BeingEdited = false; } frm.SetPreviewState(ButtonShape.States.Normal); view.CurrentPage.SelectOnly(scriptables.Cast <Shape>().ToList()); if (ok) { Globals.Root.StoreNewTransaction(transaction); return(DialogResult.OK); } transaction.Cancel(); return(DialogResult.Cancel); } }
void OnGUI() { GUI.skin = skin; Rect windowBox = GUIUtilities.getRect(Screen.width * 0.6f, Screen.height * 0.9f); GUI.Box(windowBox, "Welcome to Enlightened!"); float margin = windowBox.height * 0.07f; Rect textBox = new Rect(windowBox.x + margin, windowBox.y + 60, windowBox.width - (margin * 2), windowBox.height * 0.75f); float height = skin.FindStyle("Label").CalcHeight(new GUIContent(text), textBox.width - 20); Rect insideBox = new Rect(0, 0, textBox.width - 20, height); scrollPosition = GUI.BeginScrollView(textBox, scrollPosition, insideBox); GUI.Label(insideBox, text); GUI.EndScrollView(); float buttonHeight = 40; float buttonYBase = windowBox.y + windowBox.height - buttonHeight; if (GUI.Button(new Rect((Screen.width / 2.0f) - 50, buttonYBase - (windowBox.height * 0.05f), 100, buttonHeight), "Okay")) { if (ScreenBlocker.instance != null) { ScreenBlocker.instance.setBlocking(false); } enabled = false; } }
protected void DrawBackgroundImage(PaintEventArgs e, int alpha, string suffix) { int width = Convert.ToInt32(Math.Ceiling(Width / 16f) * 16); using (Bitmap image = (Bitmap)GUIUtilities.VariableSizeImageRoundButton(BackgroundImagePrefix + suffix, "", width)) { if (image == null) { if (!this.DesignMode) { Utilities.LogSubError("RoundButton::DrawBackgroundImage failed to load image for suffix = " + suffix); } return; } if (alpha == 255) { e.Graphics.DrawImage(image, new Rectangle(0, 0, Width, Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel); } else { using (System.Drawing.Imaging.ImageAttributes objAttr = GUIUtilities.GetImageAttrForAlpha(alpha)) { e.Graphics.DrawImage(image, new Rectangle(0, 0, Width, Height), objAttr); } } } }
public void pnlPreview_Paint(object sender, PaintEventArgs e) { Rectangle rect = new Rectangle(0, 0, pnlPreview.Width, pnlPreview.Height); GUIUtilities.CalcDestRect(m_OriginalImage.Size, ref rect); m_OriginalImage.Draw(e.Graphics, rect); }
private void Form_MouseMove(object sender, MouseEventArgs e) { if (!m_DragTrigger.IsEmpty && !m_DragTrigger.Contains(e.X, e.Y) && !m_DragControlResize) { Size offset = new Size(-e.X, Accordion.TITLEHEIGHT - e.Y); Main.StartPaletteFormMove(m_Palette, offset); m_DragTrigger = Rectangle.Empty; } else if (IsResizing && Controls.Count > 0) { // Currently resizing Size sz = m_ResizeOriginal + e.Location.Subtract(m_StartResize); if (sz.Width < 10 || sz.Height < 10) { return; } sz = m_Control.SizeFromSize(sz); if (sz.Equals(Controls[0].Size)) { return; } Rectangle rct = new Rectangle(this.Left, this.Top, sz.Width + BORDER * 2, sz.Height + BORDER + Accordion.TITLEHEIGHT); GUIUtilities.CheckRectOnScreen(rct); Controls[0].Size = sz; this.Bounds = rct; Invalidate(new Rectangle(0, 0, Width, Accordion.TITLEHEIGHT + BORDER)); } }
public void frmMoreColours_Load(object sender, EventArgs e) { Strings.Translate(this); GUIUtilities.ScaleDPI(this); btnOK.Visible = pnlColours.DisplayAdvanced; btnWindows.Visible = Globals.Root.User == Users.Editor; }
public Image GetNetImage(int sizeIfResource = 32) { // once the image is created it is not disposed at the moment. If it is being drawn on-screen it will be needed repeatedly if (!string.IsNullOrEmpty(m_ResourceName)) { return(GUIUtilities.VariableSizeImage(m_ResourceName, "", sizeIfResource)); // RM.GetObject(m_strResourceName) } return(m_Image.GetNetImage()); }
public override void renderMe(bool isScrolling) { GUIUtilities.Text(new Rect( 10 * GUIUtilities.SizeFactor, 30 * GUIUtilities.SizeFactor, Screen.width, GUIUtilities.getSize(bigHeadlineStyle, new GUIContent(headLine)).y) , this.headLine, bigHeadlineStyle); }
protected virtual void SendCombinedKeyEvent(CombinedKeyEvent e, bool down) { // note e may not be the event sent by Windows; so changing Handled or SuppressKeyPress won't always do much // IF DOWN KEYS AREN'T ARRIVING FOR SPECIAL KEYS (cursors, etc) - check that controls all implement IsInputKey for relevant keys Control current = GUIUtilities.GetFocusControl(); //if (current is TextBoxAllKeys) //{ // e.Handled = false; // return; //} m_PendingDown = null; #if DEBUG if (down) { //Debug.WriteLine(IIf(e.Alt, "Alt-", "") + IIf(e.Shift, "Sh-", "") + IIf(e.Control, "Ctrl-", "") + e.KeyCode.ToString + "=" + CInt(e.KeyCode).ToString + " with " + IIf(CurrentFocus Is Nothing, " no focus", "focus in "+curr)) //If Not CurrentFocus Is Nothing Then Debug.WriteLine("CurrentFocus = " + CurrentFocus.GetType.Name) //If Not GetFocusControlFromWindows() Is Nothing Then Debug.WriteLine("CurrentFocusFromWindows = " + GetFocusControlFromWindows.GetType.Name) } #endif while (current != null && e.Handled == false) { if (e.DoNotHandle) // shouldn't really be set on first pass, but just in case { return; } if (current is IKeyControl control) { if (down) { control.CombinedKeyDown(e); } else { control.CombinedKeyUp(e); } } else if (current is Button button) { if (down && e.KeyCode == Keys.Space) { button.PerformClick(); e.Handled = true; } } if (current.Parent == null && current is Form form) { // .Parent doesn't follow form ownership - doing this ensures that we end up back here, which is essential for misc control keys to work current = form.Owner; } else { current = current.Parent; } } }
public Bitmap CreateSampleImage(int size = 32) { string resourceID = GetSampleImageResourceID(size); if (!string.IsNullOrEmpty(resourceID)) { return((Bitmap)GUIUtilities.VariableSizeImage(resourceID, "", size)); // RM.GetObject(strResourceID) } return(CreateSampleImage2(size)); }
void OnGUI() { if (!show) { return; } GUI.skin = skin; GUI.Window(0, GUIUtilities.getRect(250, 250), layoutWindow, "Menu"); }
public void SetTool(Shape.Shapes shape) { AttachParameter(Parameters.Tool, (int)shape); var key = Globals.Root.CurrentConfig.GetFirstKeyForAction(new ToolAction(shape)); if (Utilities.Key_Shortcuts_Safe()) { ShortcutDisplay = GUIUtilities.KeyShortDescription(key); } }
private void OnRevert(object sender, RoutedEventArgs e) { try { revertChanges(); } catch (Exception err) { GUIUtilities.ReportUnexpectedException(err); } }