private void SetupScreen() { CLI.ForceClear(Color.Black); Shell.DrawTitleBar(); TextGraphics.FillRect(2, 2, CLI.Width - 4, CLI.Height - 3, ' ', Color.White, Color.Blue); CLI.SetCursorPos(2, 2); }
// draw debug information public static void DrawDebug() { // draw registers string regs = ""; for (int i = 0; i < MaxRegisters; i++) { regs += DataUtils.IntToHex(Registers[i], "X2") + " "; } if (regs.Length > 0) { TextGraphics.DrawString(0, CLI.Height - 1, regs, Color.Cyan, CLI.BackColor); } // draw program counter TextGraphics.DrawString(48, CLI.Height - 1, "PC=" + DataUtils.IntToHex(ProgCtr), Color.Yellow, CLI.BackColor); // draw i register TextGraphics.DrawString(58, CLI.Height - 1, "I=" + DataUtils.IntToHex(I), Color.Green, CLI.BackColor); // draw w register TextGraphics.DrawString(67, CLI.Height - 1, "W=" + DataUtils.IntToHex(W), Color.Magenta, CLI.BackColor); // draw waiting TextGraphics.DrawString(72, CLI.Height - 1, "WAIT=" + (IsWaiting ? "1" : "0"), Color.DarkRed, CLI.BackColor); }
/// <summary> /// Constructor for Inventory. /// </summary> /// <param name="state">Holds all of the data and state for the Game currently running.</param> /// <param name="userInput">Holds the data and state for the user input, i.e. keyboard and mouse input.</param> /// <param name="textGraphics">Provides methods for drawing text on to the AGI screen.</param> /// <param name="pixels">The pixels array for the AGI screen, in which the text will be drawn.</param> public Inventory(GameState state, UserInput userInput, TextGraphics textGraphics, int[] pixels) { this.state = state; this.userInput = userInput; this.textGraphics = textGraphics; this.pixels = pixels; }
/// <summary> /// Builds the components. /// </summary> private void BuildComponents() { this.frame = new Frame(this.Width, this.Height, this.FrameColor, PositionFactory.Center(), this.Border); this.frame.Initialise(this.GetBounds()); this.textGraphics = new TextGraphics(this.Text, this.Font, this.TextColor, this.Width - (Gutter * 2), FontFlow.Scale, PositionFactory.Center()); this.textGraphics.Initialise(this.GetContentBounds()); }
private static void Save() { // save file string document = ""; try { for (int i = 0; i < Lines.Count; i++) { document += Lines[i] + "\n"; } PMFAT.WriteAllText(CurrentFile, document); TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Successfully saved \"" + CurrentFile + "\"", Color.Green, Color.Black); } catch (Exception ex) { TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Unable to save file \"" + CurrentFile + "\"", Color.Red, Color.Black); } // finish Kernel.Delay(500); Draw(); }
public TextGraphics DrawText( string text, bool scalable, GraphicsNode node) { try { AdnGraphics graphicsData = WorkingGraphics; if (node == null) { node = graphicsData.ClientGraphics.AddNode( graphicsData.GetGraphicNodeFreeId()); } TextGraphics graphic = (scalable ? node.AddScalableTextGraphics() : node.AddTextGraphics()); graphic.Text = text; return(graphic); } catch { return(null); } }
private void ResetPayCursor() { TextGraphics graphics = new TextGraphics(base.CreateGraphics()); this._sizeInputPayText = graphics.MeasureText("A", this.lbPayInput.Font); graphics.Dispose(); this._inputPayDisplayMax = (this.lbPayInput.Width / this._sizeInputPayText.Width) - 1; }
/// <summary> /// Constructor for Menu. /// </summary> /// <param name="state"></param> /// <param name="textGraphics"></param> /// <param name="pixels"></param> /// <param name="userInput"></param> public Menu(GameState state, TextGraphics textGraphics, int[] pixels, UserInput userInput) { this.state = state; this.textGraphics = textGraphics; this.headers = new List <MenuHeader>(); this.pixels = pixels; this.userInput = userInput; }
private void SetupScreen() { CLI.ForceClear(Color.Black); Shell.DrawTitleBar(); TextGraphics.FillRect(2, 2, CLI.Width - 4, CLI.Height - 3, ' ', Color.White, Color.Blue); TextGraphics.DrawLineH(2, 2, CLI.Width - 4, ' ', Color.White, Color.Cyan); TextGraphics.DrawString(2, 2, " CMD DESCRIPTION", Color.Black, Color.Cyan); TextGraphics.DrawLineH(0, 3, CLI.Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(Shell.TitleBarTime.Length, 0, " | Run \"help [cmd]\" for usage", Shell.TitleColor, Shell.TitleBarColor); CLI.SetCursorPos(2, 2); }
public override void Execute(string line, string[] args) { TextGraphics.Clear(CLI.BackColor); Shell.DrawTitleBar(); if (Shell.TitleBarVisible) { CLI.SetCursorPos(0, 2); } else { CLI.SetCursorPos(0, 0); } }
/// <summary> /// Creates a new instance of our transmitting phone /// with default configuration and graphics. /// </summary> /// <returns>A new SimpleDigitalTransmitter.</returns> private SimpleDigitalTransmitter CreateTransmittingPhone() { var earth = CentralBodiesFacet.GetFromContext().Earth; // Create a new SimpleDigitalTransmitter and assign its basic properties. // Even though we are using a static location for our transmitter, // it can easily be changed to a moving one by simply modifying the // LocationPoint to something else, for example a route generated // with the Route Design Library. double longitude = Trig.DegreesToRadians(39.6333); double latitude = Trig.DegreesToRadians(11.1333); var phone = new SimpleDigitalTransmitter { Name = "Dessie, Ethiopia", LocationPoint = new PointCartographic(earth, new Cartographic(longitude, latitude, 0.0)), CarrierFrequency = m_intendedSignal.TargetFrequency, EffectiveIsotropicRadiatedPower = CommunicationAnalysis.FromDecibels(m_transmitPowerTrackBar.Value), DataRate = 50000.0 }; //Add a default marker phone.Extensions.Add(new MarkerGraphicsExtension(new MarkerGraphics { Texture = new ConstantGraphicsParameter <Texture2D>(m_phoneTexture) })); //Add a label based on the name and show just below the marker. var textGraphics = new TextGraphics { Color = new ConstantGraphicsParameter <Color>(Color.Yellow), Font = new ConstantGraphicsParameter <Font>(m_labelFont), Outline = new ConstantGraphicsParameter <bool>(true), OutlineColor = new ConstantGraphicsParameter <Color>(Color.Black), Text = new ConstantGraphicsParameter <string>(phone.Name), Origin = new ConstantGraphicsParameter <Origin>(Origin.TopCenter), PixelOffset = new ConstantGraphicsParameter <PointF>(new PointF(0, -m_phoneTexture.Template.Height / 2)), DisplayParameters = { MaximumDistance = new ConstantGraphicsParameter <double>(75000000.0) } }; if (TextureFilter2D.Supported(TextureWrap.ClampToEdge)) { textGraphics.TextureFilter = new ConstantGraphicsParameter <TextureFilter2D>(TextureFilter2D.NearestClampToEdge); } phone.Extensions.Add(new TextGraphicsExtension(textGraphics)); return(phone); }
/// <summary> /// Creates a new instance of our receiving phone /// with default configuration and graphics. /// </summary> /// <returns>A new SimpleReceiver.</returns> private SimpleReceiver CreateReceivingPhone() { var earth = CentralBodiesFacet.GetFromContext().Earth; // Create a receiving phone with a gain of 100 and a noisefactor of 2 - adding 290 Kelvin worth of noise to the call. // Even though we are using a static location for our receiver, // it can easily be changed to a moving one by simply modifying the // LocationPoint to something else, for example a route generated // with the Route Design Library. double longitude = Trig.DegreesToRadians(77.5833); double latitude = Trig.DegreesToRadians(12.9833); var phone = new SimpleReceiver { Name = "Bangalore, India", LocationPoint = new PointCartographic(earth, new Cartographic(longitude, latitude, 0)), Gain = 100.0, NoiseFactor = 2.0, TargetFrequency = m_intendedSignal.TargetFrequency }; //Add a default marker phone.Extensions.Add(new MarkerGraphicsExtension(new MarkerGraphics { Texture = new ConstantGraphicsParameter <Texture2D>(m_phoneTexture) })); //Add a label based on the name and show just below the marker. var textGraphics = new TextGraphics { Color = new ConstantGraphicsParameter <Color>(Color.Yellow), Font = new ConstantGraphicsParameter <Font>(m_labelFont), Outline = new ConstantGraphicsParameter <bool>(true), OutlineColor = new ConstantGraphicsParameter <Color>(Color.Black), Text = new ConstantGraphicsParameter <string>(phone.Name), Origin = new ConstantGraphicsParameter <Origin>(Origin.TopCenter), PixelOffset = new ConstantGraphicsParameter <PointF>(new PointF(0, -m_phoneTexture.Template.Height / 2)), DisplayParameters = { MaximumDistance = new ConstantGraphicsParameter <double>(75000000.0) } }; if (TextureFilter2D.Supported(TextureWrap.ClampToEdge)) { textGraphics.TextureFilter = new ConstantGraphicsParameter <TextureFilter2D>(TextureFilter2D.NearestClampToEdge); } phone.Extensions.Add(new TextGraphicsExtension(textGraphics)); return(phone); }
public static bool F_PIX() { byte col = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte xx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte yy = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (col > 0xF) { col = 0xF; } TextGraphics.SetPixel(xx, yy, (Color)col); CPU.StepProgramCounter(I_PIX.Arguments); return(true); }
public static bool F_PIXA() { byte col = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte rx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (col > 0xF) { col = 0xF; } TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], (Color)col); CPU.StepProgramCounter(I_PIXA.Arguments); return(true); }
/// <summary> /// Constructor for Interpreter. /// </summary> /// <param name="game"></param> /// <param name="userInput"></param> /// <param name="pixels"></param> public Interpreter(Game game, UserInput userInput, int[] pixels) { this.state = new GameState(game); this.userInput = userInput; this.pixels = pixels; this.textGraphics = new TextGraphics(pixels, state, userInput); this.parser = new Parser(state); this.soundPlayer = new SoundPlayer(state); this.menu = new Menu(state, textGraphics, pixels, userInput); this.commands = new Commands(pixels, state, userInput, textGraphics, parser, soundPlayer, menu); this.ego = state.Ego; this.state.Init(); this.textGraphics.UpdateInputLine(); }
/// <summary> /// Builds the components. /// </summary> private void BuildComponents() { int textMaxWidth = this.Width - (Gutter * 2); if (this.Border != null && this.Border.Width > 0) { textMaxWidth -= this.Border.Width * 2; } this.frame = new Frame(this.Width, this.Height, Color.Cyan, PositionFactory.Center(), this.Border); this.frame.Initialise(this.GetBounds()); this.textGraphics = new TextGraphics(this.Text, this.Font, Color.Yellow, textMaxWidth, FontFlow.Wrap, PositionFactory.TopCenter()); this.textGraphics.Initialise(this.GetContentBounds()); }
private static void Load() { // draw Draw(); TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "FILENAME: ", Color.White, Color.Black); CLI.SetCursorPos(10, StartY); // get file string file = Console.ReadLine(); // load file LoadFile(file); }
// clear screen, draw title bar, set cursor pos public static void DrawFresh() { // clear screen TextGraphics.Clear(CLI.BackColor); // draw title bar if (TitleBarVisible) { DrawTitleBar(); CLI.SetCursorPos(0, 2); } else { CLI.SetCursorPos(0, 0); } }
public static bool F_PIXAR() { byte r = Memory.Read((ushort)(CPU.ProgCtr + 1)); byte rx = Memory.Read((ushort)(CPU.ProgCtr + 2)); byte ry = Memory.Read((ushort)(CPU.ProgCtr + 3)); if (CPU.Registers[r] <= 0xF) { TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], (Color)CPU.Registers[r]); } else { TextGraphics.SetPixel(CPU.Registers[rx], CPU.Registers[ry], Color.White); } CPU.StepProgramCounter(I_PIXAR.Arguments); return(true); }
public static void LoadFile(string file) { // format filename if (!file.StartsWith(@"0:\")) { file = @"0:\" + file; } // load file bool error = false; if (PMFAT.FileExists(file)) { try { string[] lines = PMFAT.ReadLines(file); Clear(false); for (int i = 0; i < lines.Length; i++) { Lines.Add(lines[i]); } TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Successfully loaded \"" + file + "\"", Color.Green, Color.Black); error = false; } catch (Exception ex) { error = true; } } else { error = true; } if (error) { TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Unable to load file \"" + file + "\"", Color.Red, Color.Black); } if (!error) { CurrentFile = file; } Kernel.Delay(500); Draw(); ReadInput(); }
public override void Execute(string line, string[] args) { // show menu if (args.Length == 1) { // draw SetupScreen(); DrawMessage(); // exit message TextGraphics.DrawString(2, CLI.Height - 2, "Press any key to exit...", Color.White, Color.Blue); // exit CLI.SetCursorPos(CLI.Width - 13, 0); CLI.ReadKey(true); Shell.DrawFresh(); } // show command usage else { string cmd = args[1].ToUpper(); bool invalid = false; for (int i = 0; i < Shell.Commands.Count; i++) { if (Shell.Commands[i].Name == cmd) { CLI.WriteLine(Shell.Commands[i].Help); if (Shell.Commands[i].Usage.Length > 0) { CLI.WriteLine(Shell.Commands[i].Usage, Color.Gray); } invalid = false; break; } else { invalid = true; } } if (invalid) { CLI.WriteLine("Invalid argument!", Color.Red); CLI.WriteLine("Type help without an argument to see available commands.", Color.White); } } }
private static void SaveAs() { // draw Draw(); TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "FILENAME: ", Color.White, Color.Black); CLI.SetCursorPos(10, StartY); // get file string file = Console.ReadLine(); // format filename if (!file.StartsWith(@"0:\")) { file = @"0:\" + file; } // save file string document = ""; try { for (int i = 0; i < Lines.Count; i++) { document += Lines[i] + "\n"; } PMFAT.WriteAllText(file, document); TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Successfully saved \"" + file + "\"", Color.Green, Color.Black); } catch (Exception ex) { TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black); TextGraphics.DrawString(0, StartY, "Unable to save file \"" + file + "\"", Color.Red, Color.Black); } // finish CurrentFile = file; Kernel.Delay(500); Draw(); }
private static void Draw() { // draw fresh DrawFresh(); // draw document for (int i = 0; i < CLI.Height; i++) { int pos = i + Scroll; if (pos < Lines.Count) { TextGraphics.DrawString(StartX, StartY + i, Lines[pos], Color.Black, Color.White); } } // draw doc pos TextGraphics.DrawString(Shell.TitleBarTime.Length, 0, " | CUR: " + DocX.ToString() + " LINE:" + DocY.ToString(), Shell.TitleColor, Shell.TitleBarColor); // return cursor position to document SendScreenPos(); }
private void DrawMessage() { int dx = 3, dy = 4; for (int i = 0; i < Shell.Commands.Count; i++) { TextGraphics.DrawString(dx, dy, "---------------------", Color.DarkGray, Color.Blue); TextGraphics.DrawString(dx, dy, Shell.Commands[i].Name + " ", Color.White, Color.Blue); TextGraphics.DrawString(dx + 22, dy, Shell.Commands[i].Help, Color.Gray, Color.Blue); dy += 1; if (dy >= 23) { // next message TextGraphics.DrawString(2, CLI.Height - 2, "Press any key to goto next page", Color.White, Color.Blue); CLI.SetCursorPos(CLI.Width - 13, 0); // goto next page CLI.ReadKey(true); SetupScreen(); dy = 4; } } }
public override void Execute(string line, string[] args) { bool result = true; bool error = false; if (args[1] == "0" || args[1].ToLower() == "false" || args[1].ToLower() == "no" || args[1].ToLower() == "off") { result = false; } else if (args[1] == "1" || args[1].ToLower() == "true" || args[1].ToLower() == "yes" || args[1].ToLower() == "on") { result = true; } else { CLI.Write("Invalid argument!", Color.Red); CLI.WriteLine("Usage: tbar (1,0) (true,false) (yes,no) (on,off) "); error = true; } if (!error) { Shell.TitleBarVisible = result; int oldX = CLI.CursorX, oldY = CLI.CursorY; SystemInfo.SaveConfig(PMFAT.ConfigFile); if (result) { Shell.DrawTitleBar(); CLI.WriteLine("Title bar is now visible."); } else { TextGraphics.DrawLineH(0, 0, CLI.Width, ' ', Color.Black, CLI.BackColor); CLI.SetCursorPos(oldX, oldY); CLI.WriteLine("Title bar hidden."); } } }
////////////////////////////////////////////////////////////////////////////////////////////// // Description: Displays a TextGraphics with different styles and properties. // ////////////////////////////////////////////////////////////////////////////////////////////// static public void TextGraphicsDemo() { PartDocument doc = AdnInventorUtilities.InvApplication.ActiveDocument as PartDocument; string clientId = "{Add-in Guid}"; ClientGraphics graphics = null; GraphicsDataSets dataSets = null; try { graphics = doc.ComponentDefinition.ClientGraphicsCollection[clientId]; dataSets = doc.GraphicsDataSetsCollection[clientId]; } catch { graphics = doc.ComponentDefinition.ClientGraphicsCollection.Add(clientId); dataSets = doc.GraphicsDataSetsCollection.Add(clientId); } TransientGeometry Tg = AdnInventorUtilities.InvApplication.TransientGeometry; GraphicsNode node = graphics.AddNode(graphics.Count + 1); //Create scalable text graphics TextGraphics scalableTxt = node.AddScalableTextGraphics(); //Set the properties of the text scalableTxt.Text = "Scalable Text"; scalableTxt.Anchor = Tg.CreatePoint(0, 20, 0); scalableTxt.Bold = true; scalableTxt.Font = "Arial"; scalableTxt.FontSize = 10; scalableTxt.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft; scalableTxt.Italic = true; scalableTxt.PutTextColor(119, 187, 17); scalableTxt.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle; //Create anchored text graphics TextGraphics anchoredTxt = node.AddTextGraphics(); //Set the properties of the text. anchoredTxt.Text = "Anchored Text"; anchoredTxt.Bold = true; anchoredTxt.FontSize = 30; anchoredTxt.PutTextColor(255, 170, 0); Point anchorPoint = Tg.CreatePoint(1, 1, 1); //Set the text's anchor in model space. anchoredTxt.Anchor = anchorPoint; //Anchor the text graphics in the view. anchoredTxt.SetViewSpaceAnchor( anchorPoint, Tg.CreatePoint2d(30, 30), ViewLayoutEnum.kTopLeftViewCorner); TextGraphics symbolTxt1 = node.AddTextGraphics(); symbolTxt1.Text = "n "; Point modelAnchorPoint = Tg.CreatePoint(50, 0, 0); //Because this text will have pixel scaling behavior these coordinates are in pixel space. symbolTxt1.Anchor = Tg.CreatePoint(0, 0, 0); symbolTxt1.Font = "AIGDT"; symbolTxt1.FontSize = 25; symbolTxt1.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft; symbolTxt1.PutTextColor(221, 0, 0); symbolTxt1.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle; symbolTxt1.SetTransformBehavior( modelAnchorPoint, DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling, 1); Box box = symbolTxt1.RangeBox; //Draw the next section of the string relative to the first section. TextGraphics symbolTxt2 = node.AddTextGraphics(); symbolTxt2.Text = "9.4 - 9.8"; //The range of the previous character is used to determine where to position //the next string. The range is returned in pixels. symbolTxt2.Anchor = Tg.CreatePoint(box.MaxPoint.X, 0, 0); symbolTxt2.Font = "Arial"; symbolTxt2.FontSize = 25; symbolTxt2.HorizontalAlignment = HorizontalTextAlignmentEnum.kAlignTextLeft; symbolTxt2.PutTextColor(221, 0, 0); symbolTxt2.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle; symbolTxt2.SetTransformBehavior( modelAnchorPoint, DisplayTransformBehaviorEnum.kFrontFacingAndPixelScaling, 1); doc.Views[1].Update(); }
/// <summary> /// Builds the components. /// </summary> private void BuildComponents() { textGraphics = new TextGraphics(this.Value, this.Font, this.Color, this.MaxWidth, this.FontFlow, this.PositionProfile); textGraphics.Initialise(this.GetBounds()); }
private void NotifyCustomDrawMenuBar(ref Message m) { m.Result = (IntPtr) NativeMethods.CDRF_DODEFAULT; NativeMethods.LPNMTBCUSTOMDRAW tbcd = (NativeMethods.LPNMTBCUSTOMDRAW) m.GetLParam(typeof(NativeMethods.LPNMTBCUSTOMDRAW)); bool hot = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_HOT) != 0); bool selected = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_SELECTED) != 0); if (hot || selected) { NativeMethods.RECT rect = tbcd.nmcd.rc; using (Graphics graphics = Graphics.FromHdc(tbcd.nmcd.hdc)) { graphics.FillRectangle(SystemBrushes.Highlight, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } using (TextGraphics textGraphics = new TextGraphics(tbcd.nmcd.hdc)) { Font font = this.Font; string text = this.items[(int) tbcd.nmcd.dwItemSpec].Text; Size size = textGraphics.MeasureText(text, font); Point point = new Point(rect.left + ((rect.right - rect.left - size.Width) / 2), rect.top + ((rect.bottom - rect.top - size.Height) / 2)); textGraphics.DrawText(text, point, font, SystemColors.HighlightText); } m.Result = (IntPtr) NativeMethods.CDRF_SKIPDEFAULT; } }
private void UpdateSize() { if (this.style == CommandBarStyle.Menu) { int fontHeight = Font.Height; using (Graphics graphics = this.CreateGraphics()) { using (TextGraphics textGraphics = new TextGraphics(graphics)) { foreach (CommandBarItem item in items) { Size textSize = textGraphics.MeasureText(item.Text, this.Font); if (fontHeight < textSize.Height) { fontHeight = textSize.Height; } } } } NativeMethods.SendMessage(this.Handle, NativeMethods.TB_SETBUTTONSIZE, 0, (fontHeight << 16) | 0xffff); } Size size = new Size(0, 0); for (int i = 0; i < items.Count; i++) { NativeMethods.RECT rect = new NativeMethods.RECT(); NativeMethods.SendMessage(Handle, NativeMethods.TB_GETRECT, i, ref rect); int height = rect.bottom - rect.top; if (height > size.Height) { size.Height = height; } size.Width += rect.right - rect.left; CommandBarComboBox comboBox = items[i] as CommandBarComboBox; if ((comboBox != null) && (comboBox.ComboBox != null)) { if (comboBox.ComboBox.Height > size.Height) { size.Height = comboBox.ComboBox.Height; } this.UpdateComboBoxLocation(comboBox, i); } } this.Size = size; }
private void DrawMessage() { TextGraphics.DrawLineH(2, 2, CLI.Width - 4, ' ', Color.White, Color.Cyan); TextGraphics.DrawString(2, 2, " C COLOR VALUE", Color.Black, Color.Cyan); TextGraphics.DrawLineH(0, 3, CLI.Width, ' ', Color.White, Color.Black); int dx = 3, dy = 4; Color bg = Color.Black; // black TextGraphics.DrawChar(dx, dy, '#', Color.Black, bg); TextGraphics.DrawString(dx + 5, dy, "BLACK", Color.White, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Black, "X2"), Color.Yellow, Color.Blue); dy++; // dark gray TextGraphics.DrawChar(dx, dy, '#', Color.DarkGray, bg); TextGraphics.DrawString(dx + 5, dy, "DARK GRAY", Color.DarkGray, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkGray, "X2"), Color.Yellow, Color.Blue); dy++; // gray TextGraphics.DrawChar(dx, dy, '#', Color.Gray, bg); TextGraphics.DrawString(dx + 5, dy, "GRAY", Color.Gray, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Gray, "X2"), Color.Yellow, Color.Blue); dy++; // white TextGraphics.DrawChar(dx, dy, '#', Color.White, bg); TextGraphics.DrawString(dx + 5, dy, "WHITE", Color.White, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.White, "X2"), Color.Yellow, Color.Blue); dy++; // dark red TextGraphics.DrawChar(dx, dy, '#', Color.DarkRed, bg); TextGraphics.DrawString(dx + 5, dy, "DARK RED", Color.DarkRed, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkRed, "X2"), Color.Yellow, Color.Blue); dy++; // red TextGraphics.DrawChar(dx, dy, '#', Color.Red, bg); TextGraphics.DrawString(dx + 5, dy, "RED", Color.Red, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Red, "X2"), Color.Yellow, Color.Blue); dy++; // dark yellow TextGraphics.DrawChar(dx, dy, '#', Color.DarkYellow, bg); TextGraphics.DrawString(dx + 5, dy, "DARK YELLOW", Color.DarkYellow, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkYellow, "X2"), Color.Yellow, Color.Blue); dy++; // yellow TextGraphics.DrawChar(dx, dy, '#', Color.Yellow, bg); TextGraphics.DrawString(dx + 5, dy, "YELLOW", Color.Yellow, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Yellow, "X2"), Color.Yellow, Color.Blue); dy++; // dark green TextGraphics.DrawChar(dx, dy, '#', Color.DarkGreen, bg); TextGraphics.DrawString(dx + 5, dy, "DARK GREEN", Color.DarkGreen, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkGreen, "X2"), Color.Yellow, Color.Blue); dy++; // green TextGraphics.DrawChar(dx, dy, '#', Color.Green, bg); TextGraphics.DrawString(dx + 5, dy, "GREEN", Color.Green, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Green, "X2"), Color.Yellow, Color.Blue); dy++; // dark cyan TextGraphics.DrawChar(dx, dy, '#', Color.DarkCyan, bg); TextGraphics.DrawString(dx + 5, dy, "DARK CYAN", Color.DarkCyan, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkCyan, "X2"), Color.Yellow, Color.Blue); dy++; // cyan TextGraphics.DrawChar(dx, dy, '#', Color.Cyan, bg); TextGraphics.DrawString(dx + 5, dy, "CYAN", Color.Cyan, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Cyan, "X2"), Color.Yellow, Color.Blue); dy++; // dark blue TextGraphics.DrawChar(dx, dy, '#', Color.DarkBlue, bg); TextGraphics.DrawString(dx + 5, dy, "DARK BLUE", Color.Blue, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkBlue, "X2"), Color.Yellow, Color.Blue); dy++; // blue TextGraphics.DrawChar(dx, dy, '#', Color.Blue, bg);; TextGraphics.DrawString(dx + 5, dy, "BLUE", Color.Blue, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Blue, "X2"), Color.Yellow, Color.Blue);; dy++; // dark magenta TextGraphics.DrawChar(dx, dy, '#', Color.DarkMagenta, bg); TextGraphics.DrawString(dx + 5, dy, "DARK MAGENTA", Color.DarkMagenta, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkMagenta, "X2"), Color.Yellow, Color.Blue); dy++; // magenta TextGraphics.DrawChar(dx, dy, '#', Color.Magenta, bg); TextGraphics.DrawString(dx + 5, dy, "MAGENTA", Color.Magenta, Color.Blue); TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Magenta, "X2"), Color.Yellow, Color.Blue); dy++; // exit message TextGraphics.DrawString(2, CLI.Height - 2, "Press any key to exit...", Color.White, Color.Blue); }
private void DrawText(TextGraphics textGraphics, string text, Point point, bool selected, bool disabled) { Color color = (disabled ? (selected ? SystemColors.GrayText : SystemColors.ControlDark) : (selected ? SystemColors.HighlightText : SystemColors.MenuText)); if ((!this.IsFlatMenu) && (disabled) && (!selected)) { textGraphics.DrawText(text, new Point(point.X + 1, point.Y + 1), font, SystemColors.ControlLightLight); } textGraphics.DrawText(text, point, font, color); }
protected override void OnMeasureItem(MeasureItemEventArgs e) { base.OnMeasureItem(e); Graphics graphics = e.Graphics; if (item is CommandBarSeparator) { e.ItemWidth = 0; e.ItemHeight = SystemInformation.MenuHeight / 2; } else { Size size = new Size(0, 0); size.Width += 3 + imageSize.Width + 3 + 3 + 1 + 3 + imageSize.Width + 3; size.Height += 3 + imageSize.Height + 3; string text = item.Text; CommandBarButtonBase buttonBase = item as CommandBarButtonBase; if ((buttonBase != null) && (buttonBase.Shortcut != Keys.None)) { text += TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(null, CultureInfo.InvariantCulture, buttonBase.Shortcut); } using (TextGraphics textGraphics = new TextGraphics(graphics)) { Size textSize = textGraphics.MeasureText(text, font); size.Width += textSize.Width; textSize.Height += 8; if (textSize.Height > size.Height) { size.Height = textSize.Height; } } e.ItemWidth = size.Width; e.ItemHeight = size.Height; } }
// draw title bar public static void DrawTitleBar() { TextGraphics.DrawLineH(0, 0, CLI.Width, ' ', Color.Black, TitleBarColor); // draw background DrawTime(); // draw time TextGraphics.DrawString(CLI.Width - TitleBarText.Length, 0, TitleBarText, TitleColor, TitleBarColor); // draw title }
// draw time public static void DrawTime() { TextGraphics.DrawString(0, 0, TitleBarTime, DateTimeColor, TitleBarColor); }
protected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); Graphics graphics = e.Graphics; Rectangle bounds = e.Bounds; bool selected = ((e.State & DrawItemState.Selected) != 0); bool disabled = ((e.State & DrawItemState.Disabled) != 0); if (item is CommandBarSeparator) { Rectangle r = new Rectangle(bounds.X, bounds.Y + (bounds.Height / 2), bounds.Width, bounds.Height); ControlPaint.DrawBorder3D(graphics, r, Border3DStyle.Etched, Border3DSide.Top); } else { this.DrawImage(graphics, bounds, selected, disabled); int width = 6 + imageSize.Width; this.DrawBackground(graphics, new Rectangle(bounds.X + width, bounds.Y, bounds.Width - width, bounds.Height), selected); using (TextGraphics textGraphics = new TextGraphics(graphics)) { if ((this.Text != null) && (this.Text.Length != 0)) { Size size = textGraphics.MeasureText(this.Text, font); Point point = new Point(); point.X = bounds.X + 3 + imageSize.Width + 6; point.Y = bounds.Y + ((bounds.Height - size.Height) / 2); this.DrawText(textGraphics, this.Text, point, selected, disabled); } CommandBarButtonBase buttonBase = item as CommandBarButtonBase; if ((buttonBase != null) && (buttonBase.Shortcut != Keys.None)) { string text = TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(null, CultureInfo.InvariantCulture, buttonBase.Shortcut); Size size = textGraphics.MeasureText(text, font); Point point = new Point(); point.X = bounds.X + bounds.Width - 3 - imageSize.Width - 3 - size.Width; point.Y = bounds.Y + ((bounds.Height - size.Height) / 2); this.DrawText(textGraphics, text, point, selected, disabled); } } } }