public Game() { state = new BootState(this); window = new GameWindow(960, 540); window.Load += Window_Load; window.RenderFrame += Window_RenderFrame; window.UpdateFrame += Window_UpdateFrame; window.Closing += Window_Closing; window.Closed += Window_Closed; window.Resize += Window_Resize; window.FocusedChanged += Window_FocusedChanged; Console.WriteLine("OpenGL: {0}", GL.GetString(StringName.Version)); keyHandler = new KeyHandler(window); Canvas = new SceneCanvas(keyHandler); shaderManager = new ShaderManager(); shader = new StaticShader(); shaderManager.Add(shader); fontShader = new FontShader(); fontManager = new FontManager(fontShader); fontShader.Compile(); font = FontParser.ParseFNT(@"Fonts/Verdana.fnt"); fontManager.Add(font); lastMousePosition = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); }
public Game() { _game = new GameWindow(); _stateManager = new ScreenManager(); _textureManager = new TextureManager(); _fontManager = new FontManager(); SetupViewport(); }
public static Font GetFont(FontManager.FontType type) { int size; switch (type) { case FontManager.FontType.droid_reg08: size = 8; break; case FontManager.FontType.droid_reg09: size = 9; break; case FontManager.FontType.droid_reg10: size = 10; break; case FontManager.FontType.droid_reg11: size = 11; break; case FontManager.FontType.droid_reg12: size = 12; break; case FontManager.FontType.droid_reg14: size = 14; break; case FontManager.FontType.droid_reg18: size = 18; break; case FontManager.FontType.droid_reg24: size = 24; break; case FontManager.FontType.droid_reg32: size = 32; break; case FontManager.FontType.droid_reg48: size = 48; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var font = new Sd.Font("Arial", size, Sd.FontStyle.Regular); return new Win32Font(font); }
/// <summary> /// Core framework constructor. /// </summary> public FrameworkCore() : base() { game = this; graphicsDeviceManager = new GraphicsDeviceManager(this); viewer = new Viewer(this); inputManager = new InputComponentManager(); fontManager = new FontManager(); screenManager = new GameScreenManager(this); textManager = new TextManager(this); resourceManager = new ResourceManager(this, "Content"); particleManager = new ParticleManager(); collisionContext = new CollisionContext(); soundManager = new SoundManager(); gameEventManager = new GameEventManager(); fpsCounter = new FpsCounter(); // Entry GameScreenManager AddComponent(screenManager); // Disable vertical retrace to get highest framerates possible for // testing performance. //graphicsDeviceManager.SynchronizeWithVerticalRetrace = false; // Update as fast as possible, do not use fixed time steps IsFixedTimeStep = false; }
protected override void OnPaint(PaintEventArgs e) { // background var backColor = YamuiThemeManager.Current.ButtonBg(BackColor, UseCustomBackColor, IsFocused, IsHovered, IsPressed, Enabled); if (backColor != Color.Transparent) { e.Graphics.Clear(backColor); } else { PaintTransparentBackground(e.Graphics, DisplayRectangle); } // foreground var borderColor = YamuiThemeManager.Current.ButtonBorder(IsFocused, IsHovered, IsPressed, Enabled); var foreColor = YamuiThemeManager.Current.ButtonFg(ForeColor, UseCustomForeColor, IsFocused, IsHovered, IsPressed, Enabled); if (borderColor != Color.Transparent) { using (var p = new Pen(borderColor)) { var borderRect = new Rectangle(0, 0, Width - 1, Height - 1); e.Graphics.DrawRectangle(p, borderRect); } } // highlight is a border with more width if (Highlight && !IsHovered && !IsPressed && Enabled) { using (var p = new Pen(YamuiThemeManager.Current.AccentColor, 4)) { var borderRect = new Rectangle(2, 2, Width - 4, Height - 4); e.Graphics.DrawRectangle(p, borderRect); } } TextRenderer.DrawText(e.Graphics, Text, FontManager.GetStandardFont(), ClientRectangle, foreColor, FontManager.GetTextFormatFlags(TextAlign)); }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color borderColor = YamuiThemeManager.Current.ButtonBorder(_isFocused, _isHovered, _isPressed, Enabled); Color foreColor = YamuiThemeManager.Current.ButtonFg(ForeColor, UseCustomForeColor, _isFocused, _isHovered, _isPressed, Enabled); Color backColor = YamuiThemeManager.Current.ButtonBg(BackColor, UseCustomBackColor, _isFocused, _isHovered, _isPressed, Enabled); // Paint the back + border of the checkbox using (SolidBrush b = new SolidBrush(backColor)) { Rectangle boxRect = new Rectangle(0, Height / 2 - 6, 12, 12); e.Graphics.FillRectangle(b, boxRect); } if (borderColor != Color.Transparent) { using (Pen p = new Pen(borderColor)) { Rectangle boxRect = new Rectangle(0, Height / 2 - 6, 12, 12); e.Graphics.DrawRectangle(p, boxRect); } } // paint the form inside if (Checked) { using (SolidBrush b = new SolidBrush(YamuiThemeManager.Current.AccentColor)) { Rectangle boxRect = new Rectangle(4, Height / 2 - 2, 5, 5); e.Graphics.FillRectangle(b, boxRect); } } Rectangle textRect = new Rectangle(16, 0, Width - 16, Height); TextRenderer.DrawText(e.Graphics, Text, FontManager.GetStandardFont(), textRect, foreColor, FontManager.GetTextFormatFlags(TextAlign)); }
public static List <int> GetFontSizes(string name) { return(FontManager.GetSpecifiedFontHeight(name)); }
private bool SaveOptions(bool closeOptionsAfterSave) { if (enableProxySettingsCheckBox.Checked && (String.IsNullOrEmpty(usernameTextBox.Text) || String.IsNullOrEmpty(passwordTextBox.Text))) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("proxyWarning", Name)); return(false); } if (backupCustomFolderRadioButton.Checked && !Directory.Exists(backupCustomFolderTextBox.Text)) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("backupLocationWarning", Name)); return(false); } if (String.IsNullOrEmpty(backupExtensionTextBox.Text)) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("backupExtensionWarning", Name)); return(false); } TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font)); int settingFolder = 0; if (lastUsedFolderRadioButton.Checked) { settingFolder = 1; } int backupExtensionPosition = 0; if (backupReplaceExtensionRadioButton.Checked) { backupExtensionPosition = 1; } int backupLocation = 0; if (backupCustomFolderRadioButton.Checked) { backupLocation = 1; } int searchReturn = 0; if (searchReturnRadioButton2.Checked) { searchReturn = 1; } int tabsSwitchType = 0; if (tabsSwitchModeMouseRadioButton.Checked) { tabsSwitchType = 1; } int periodicVersionCheck = 0; if (enableAutomaticUpdateCheckBox.Checked && frequencyAutomaticUpdateComboBox.SelectedIndex == 0) { periodicVersionCheck = 1; } else if (enableAutomaticUpdateCheckBox.Checked && frequencyAutomaticUpdateComboBox.SelectedIndex == 1) { periodicVersionCheck = 2; } String[] parameterNames = { "SettingFolder", "SpecificFolder", "OverrideFolderWithActiveFile", "MaxNumRecentFile", "MaxNumSearchHistory", "StayOnTopDisabled", "ToolbarInvisible", "StatusBarInvisible", "MinimizeOnTrayIconDisabled", "LookAndFeel", "Language", "ProxyEnabled", "ProxyHost", "ProxyPort", "UseDefaultBrowser", "CustomBrowserCommand", "SearchReplacePanelDisabled", "SearchCaseSensitive", "SearchLoopAtEOF", "SearchHighlightsResults", "SearchReturn", "WordWrapDisabled", "FontInUse", "FontInUseColorARGB", "BackgroundColorARGB", "HighlightURL", "InternalExplorerInvisible", "TabCloseButtonMode", "TabPosition", "TabOrientation", "TabMultiline", "DefaultEncoding", "Encoding", "LineNumbersVisible", "BackupEnabled", "BackupExtension", "BackupExtensionPosition", "BackupLocation", "BackupLocationCustom", "BackupIncremental", "SpacesInsteadTabs", "KeepInitialSpacesOnReturn", "KeepBulletListOnReturn", "ShowSplashScreen", "AutomaticSessionSave", "Translation", "TranslationUseSelect", "CheckLineNumber", "CheckLineNumberMax", "AutoFormatFiles", "AutoOpenHostsConfigurator", "ColorHostsConfigurator", "PeriodicVersionCheck", "ActiveJumpList", "EnableDropboxDelete", "RememberDropboxAccess", "IgnoreNullChar", "NoteModeTabs", "NoteModeSizeX", "NoteModeSizeY", "TabsSwitchType" }; String[] parameterValues = { settingFolder.ToString(), specificFolderTextBox.Text, folderOpenedFileCheckBox.Checked.ToString(), recentFilesNumberNumericUpDown.Value.ToString(), searchHistoryNumericUpDown.Value.ToString(), (!stayOnTopCheckBox.Checked).ToString(), (!toolbarCheckBox.Checked).ToString(), (!statusBarCheckBox.Checked).ToString(), (!minimizeOnTrayIconCheckBox.Checked).ToString(), renderModeComboBox.SelectedIndex.ToString(), languageComboBox.SelectedItem.ToString(), enableProxySettingsCheckBox.Checked.ToString(), proxyHostTextBox.Text, proxyPortNumericUpDown.Value.ToString(), defaultBrowserRadioButton.Checked.ToString(), customBrowserTextBox.Text, (!showSearchPanelCheckBox.Checked).ToString(), caseSensitiveCheckBox.Checked.ToString(), loopAtEOFCheckBox.Checked.ToString(), highlightsResultsCheckBox.Checked.ToString(), searchReturn.ToString(), (!wordWrapCheckBox.Checked).ToString(), tc.ConvertToString(TextFont), FontManager.SetARGBString(TextFontColor), FontManager.SetARGBString(TextBackgroundColor), urlsCheckBox.Checked.ToString(), (!internalExplorerCheckBox.Checked).ToString(), tabCloseButtonOnComboBox.SelectedIndex.ToString(), tabPositionComboBox.SelectedIndex.ToString(), tabOrientationComboBox.SelectedIndex.ToString(), tabMultilineCheckBox.Checked.ToString(), useExistingCheckBox.Checked.ToString(), defaultComboBox.SelectedIndex.ToString(), lineNumbersCheckBox.Checked.ToString(), createBackupCheckBox.Checked.ToString(), backupExtensionTextBox.Text, backupExtensionPosition.ToString(), backupLocation.ToString(), backupCustomFolderTextBox.Text, backupIncrementalCheckBox.Checked.ToString(), useSpacesInsteadTabsCheckBox.Checked.ToString(), keepInitialSpacesOnReturnCheckBox.Checked.ToString(), keepBulletListOnReturnCheckBox.Checked.ToString(), splashScreenCheckBox.Checked.ToString(), automaticSessionSaveCheckBox.Checked.ToString(), LanguageUtil.GetReallyShortCultureForGoogleTranslator(sourceImageComboBoxEdit.SelectedItem.ToString()) + "|" + LanguageUtil.GetReallyShortCultureForGoogleTranslator(destinationImageComboBoxEdit.SelectedItem.ToString()), useSelectedSettingsLanguageCheckBox.Checked.ToString(), hideLinesCheckBox.Checked.ToString(), hideLinesNumericUpDown.Value.ToString(), GetAutoFormatFilesString(), hostsConfiguratorCheckBox.Checked.ToString(), ColorUtil.GetColorFromTabInt(hostsConfiguratorTabColorComboBox.SelectedIndex).Name, periodicVersionCheck.ToString(), jumpListCheckBox.Checked.ToString(), dropboxDeleteCheckBox.Checked.ToString(), dropboxRememberCheckBox.Checked.ToString(), nullCharCheckBox.Checked.ToString(), noteModeTabsCheckBox.Checked.ToString(), noteModeSizeXNumericUpDown.Value.ToString(), noteModeSizeYNumericUpDown.Value.ToString(), tabsSwitchType.ToString() }; String[] passwordNames = { "ProxyUsername", "ProxyPassword", "ProxyDomain" }; String[] passwordValues = { usernameTextBox.Text, CodingUtil.EncodeString(passwordTextBox.Text), domainTextBox.Text }; OptionManager.SaveOptionsGroup(parameterNames, parameterValues, passwordNames, passwordValues); OptionManager.RefreshOwner(this, closeOptionsAfterSave, previousFont, TextFont, previousFontColor, TextFontColor, previousBackgroundColor, TextBackgroundColor, previousHighlightURL, previousLanguage, previousJumpListActivated); SetShellIntegration(); return(true); }
public GameStatePlay(string playerSkin) { _backColor = new Color4(0.6f, 0.8f, 0.85f, 1f); // SHADERS RETRIEVING *********************************************************** // _flatColorShader = ShaderManager.Get("FlatColorShader"); _baseShader = ShaderManager.Get("Shader"); _3dSpriteShader = ShaderManager.Get("SpriteSheet"); // FONT RETRIEVING ************************************************************** // _font = FontManager.Get("glyphs"); // TEXT INITIALISATION ********************************************************** // _scoreText = new Text(new Vector2(13, 30), _font, _flatColorShader, "Test"); var x = ((24 / 32f) * 1.7f) / 2; var u = 24.0f / 240; _playerMesh = new Object3D(new[] { new Mesh { Vertices = new List <Vertex> { new Vertex(new Vector3(-x, 1.7f, 0f), new Vector2(0, 0)), new Vertex(new Vector3(-x, 0f, 0f), new Vector2(0, 1)), new Vertex(new Vector3(x, 1.7f, 0f), new Vector2(u, 0)), new Vertex(new Vector3(x, 1.7f, 0f), new Vector2(u, 0)), new Vertex(new Vector3(-x, 0f, 0f), new Vector2(0, 1)), new Vertex(new Vector3(x, 0f, 0f), new Vector2(u, 1)), } } }); _playerMesh.LoadInGl(_3dSpriteShader); // TEXTURES INITIALISATION ****************************************************** // _playerSpriteSheet = new SpriteSheet(_playerMesh, playerSkin, 24, 32, TextureMinFilter.Nearest, TextureMagFilter.Nearest); // MESH INITIALISATION ********************************************************** // _groundMesh = new Object3D("wall.obj", false, false, true); _groundMesh.LoadInGl(_baseShader); GroundSimple.MeshToUse = _groundMesh; _groundStairsMesh = new Object3D("stairs.obj", false, false, true); _groundStairsMesh.LoadInGl(_baseShader); GroundStairs.MeshToUse = _groundStairsMesh; _groundClusterMesh = new Object3D("cluster.obj", false, false, true); _groundClusterMesh.LoadInGl(_baseShader); GroundCluster.MeshToUse = _groundClusterMesh; _cubeMesh = new Object3D("cube.obj", false, false, false); _cubeMesh.LoadInGl(_baseShader); AxisAlignedBB.SetMesh(_cubeMesh); _interLeftMesh = new Object3D("inter_l.obj", false, false, true); _interLeftMesh.LoadInGl(_baseShader); Intersection.Left_Mesh = _interLeftMesh; _interRightMesh = new Object3D("inter_r.obj", false, false, true); _interRightMesh.LoadInGl(_baseShader); Intersection.Right_Mesh = _interRightMesh; _interLeftRightMesh = new Object3D("inter_lr.obj", false, false, true); _interLeftRightMesh.LoadInGl(_baseShader); Intersection.LeftRight_Mesh = _interLeftRightMesh; _trashMesh = new Object3D("trash.obj", false, false, true); _trashMesh.LoadInGl(_baseShader); ObstacleTrash.MeshToUse = _trashMesh; _coinMesh = new Object3D("coin.obj", false, false, true); _coinMesh.LoadInGl(_baseShader); Coin.MeshToUse = _coinMesh; // WORLD INITIALISATION ********************************************************* // _world = new World(); // PLAYER INITIALISATION ******************************************************** // _player = new Player { World = _world, Position = new Vector3(0, 0, -3f), Speed = 12.5f }; _camera = new Camera(new Vector3(0, 2f, 2f), _player.PositionForCamera + new Vector3(0, 2.5f, 0), (float)(80f * (Math.PI / 180f))); // TERRAIN GENERATION *********************************************************** // var tilesToGenerate = 10; for (int i = 0; i < tilesToGenerate; i++) { _world.Grounds.Add(new Ground { BoundingBox = new AxisAlignedBB(new Vector3(-3f, -0.5f, -6f), new Vector3(3f, 0f, 0f)), Mesh = _groundMesh, Position = new Vector3(0, 0, -6f * i), Direction = Direction.NORTH }); } var intersection = GroundFactory.NewIntersection(_player, _world, new Vector3(0, 0, -6f * tilesToGenerate), Direction.NORTH, (int)Intersection.IntersectionDirection.LEFT); _world.Grounds.Add(intersection); var rotation = DirectionHelper.GetRotationFromDirection(Direction.NORTH); var w1p1 = new Vector3(new Vector4(-3f, 0f, -7f, 1) * rotation); var w1p2 = new Vector3(new Vector4(3f, 5f, -6f, 1) * rotation); _world.Obstacles.Add(new Obstacle(new AxisAlignedBB(Vector3.ComponentMin(w1p1, w1p2), Vector3.ComponentMax(w1p1, w1p2)), intersection.Position, Direction.NORTH)); var w2p1 = new Vector3(new Vector4(3f, 0f, -6f, 1) * rotation); var w2p2 = new Vector3(new Vector4(4f, 5f, 0f, 1) * rotation); _world.Obstacles.Add(new Obstacle(new AxisAlignedBB(Vector3.ComponentMin(w2p1, w2p2), Vector3.ComponentMax(w2p1, w2p2)), intersection.Position, Direction.NORTH)); GC.Collect(); GC.WaitForPendingFinalizers(); }
public mnuJobDescription(string name, Job job, bool missionBoardView) : base(name) { base.Size = new Size(300, 460); base.MenuDirection = Enums.MenuDirection.Vertical; if (missionBoardView) { base.Location = new Point(305, 10); } else { base.Location = new Point(160, 10); } lblDescription = new Label("lblDescription"); lblDescription.Font = FontManager.LoadFont("PMU", 48); lblDescription.AutoSize = true; lblDescription.Text = "Description"; lblDescription.ForeColor = Color.WhiteSmoke; lblDescription.Location = new Point(20, 0); lblNullTitle = new Label("lblNullTitle"); lblNullTitle.Font = FontManager.LoadFont("PMU", 32); lblNullTitle.Size = new Size(this.Width - 20, 40); lblNullTitle.ForeColor = Color.Gray; lblNullTitle.Text = "-----"; lblNullTitle.Location = new Point(20, 50); picCreator = new PictureBox("picCreator"); picCreator.Size = new Size(40, 40); picCreator.Location = new Point(30, 50); picCreator.BorderStyle = SdlDotNet.Widgets.BorderStyle.FixedSingle; picCreator.BorderWidth = 1; lblTitle = new Label("lblTitle"); lblTitle.Font = FontManager.LoadFont("PMU", 16); lblTitle.AutoSize = true; lblTitle.ForeColor = Color.WhiteSmoke; lblTitle.Location = new Point(picCreator.X + picCreator.Width + 10, picCreator.Y); lblCreatorName = new Label("lblCreatorName"); lblCreatorName.Font = FontManager.LoadFont("PMU", 16); lblCreatorName.AutoSize = true; lblCreatorName.ForeColor = Color.WhiteSmoke; lblCreatorName.Location = new Point(picCreator.X + picCreator.Width + 10, picCreator.Y + 20); lblSummary = new Label("lblSummary"); lblSummary.Font = FontManager.LoadFont("PMU", 16); lblSummary.Size = new Size(this.Width - 50, 120); lblSummary.ForeColor = Color.WhiteSmoke; lblSummary.Location = new Point(lblNullTitle.X, picCreator.Y + picCreator.Height + 4); lblObjective = new Label("lblObjective"); lblObjective.Font = FontManager.LoadFont("PMU", 16); lblObjective.Size = new Size(this.Width - 20, 40); lblObjective.ForeColor = Color.WhiteSmoke; lblObjective.Location = new Point(lblNullTitle.X, lblNullTitle.Y + lblNullTitle.Height + 5); lblGoal = new Label("lblGoal"); lblGoal.Font = FontManager.LoadFont("PMU", 16); lblGoal.Size = new Size(this.Width - 20, 40); lblGoal.ForeColor = Color.WhiteSmoke; lblGoal.Location = new Point(lblNullTitle.X, lblSummary.Y + lblSummary.Height + 5); lblDifficulty = new Label("lblDifficulty"); lblDifficulty.Font = FontManager.LoadFont("PMU", 16); lblDifficulty.AutoSize = true; lblDifficulty.ForeColor = Color.WhiteSmoke; lblDifficulty.Location = new Point(lblNullTitle.X, lblGoal.Y + 20); picReward = new PictureBox("picReward"); picReward.Size = new Size(32, 32); picReward.BackColor = Color.Transparent; picReward.Location = new Point(lblNullTitle.X, lblDifficulty.Y + 24); lblReward = new Label("lblMissionReward"); lblReward.Font = FontManager.LoadFont("PMU", 16); lblReward.Size = new Size(this.Width - 20, 40); lblReward.ForeColor = Color.WhiteSmoke; lblReward.Location = new Point(lblNullTitle.X + 32, lblDifficulty.Y + 20); lblPressEnter = new Label("lblPressEnter"); lblPressEnter.Font = FontManager.LoadFont("PMU", 32); lblPressEnter.Size = new Size(this.Width - 20, 40); lblPressEnter.ForeColor = Color.WhiteSmoke; lblPressEnter.Text = "Press Enter to take this job."; lblPressEnter.Location = new Point(lblNullTitle.X, this.Height - 50); this.AddWidget(lblDescription); this.AddWidget(picCreator); this.AddWidget(lblTitle); this.AddWidget(lblCreatorName); this.AddWidget(lblNullTitle); this.AddWidget(lblSummary); //this.AddWidget(lblObjective); this.AddWidget(lblGoal); this.AddWidget(lblDifficulty); this.AddWidget(picReward); this.AddWidget(lblReward); if (missionBoardView) { this.AddWidget(lblPressEnter); } UpdateJob(job); }
public void CleanUp(System.ComponentModel.CancelEventArgs e = null, bool crash = false) { if (!crash) { for (int i = 0; i < graphs.Count; i++) { UIGraph g = graphs[i]; if (g.Modified && !g.ReadOnly) { var result = MessageBox.Show(this, g.GraphName + " has been modified. Do you want to save the changes?", "Save Changes", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes) { HandleSave(g); } else if (result == MessageBoxResult.Cancel) { if (e != null) { e.Cancel = true; return; } } } } } recent.Save(); //release all opengl content foreach (UIGraph g in graphs) { if (crash) { if (!string.IsNullOrEmpty(g.FilePath)) { if (g.FromArchive) { if (string.IsNullOrEmpty(g.FromArchivePath)) { g.Save(g.FilePath + ".recovery.mtga", true); } else { g.Save(g.FromArchivePath + ".recovery.mtga", true); } } else { g.Save(g.FilePath + ".recovery.mtg", true); } } } g.DeleteTempArchiveData(); g.Release(); } graphs.Clear(); FontManager.Release(); //clear material and shader caches PBRMaterial.ReleaseBRDF(); ImageProcessor.ReleaseAll(); Material.Material.ReleaseAll(); //release gl view if (UI3DPreview.Instance != null) { UI3DPreview.Instance.Release(); } if (UIPreviewPane.Instance != null) { UIPreviewPane.Instance.Release(); } ViewContext.Dispose(); }
public Label(TGraphics graphics, string name, string text, Point location, Size size) : this(graphics, name, text, new Rectangle(location, size), FontManager.GetInstance(graphics, 18, FontTypes.Sans)) { }
public Label(TGraphics graphics, string name, string text, int x, int y, int width, int height) : this(graphics, name, text, new Rectangle(x, y, width, height), FontManager.GetInstance(graphics, 18, FontTypes.Sans)) { }
public Label(TGraphics graphics, string name, string text, Point location, Size size, FontManager fontInfo) : this(graphics, name, text, new Rectangle(location, size), fontInfo) { }
public Label(TGraphics graphics, string name, string text, int x, int y, int width, int height, FontManager fontInfo) : this(graphics, name, text, new Rectangle(x, y, width, height), fontInfo) { }
protected virtual void DrawFilteredTypeRow(Graphics g, FilteredTypeListItem item, Rectangle drawRect, YamuiListRow row) { var foreColor = YamuiThemeManager.Current.MenuFg(row.IsSelected, row.IsHovered, !item.IsDisabled); // Highlighted row if (item.IsRowHighlighted) { using (SolidBrush b = new SolidBrush(YamuiThemeManager.Current.ButtonImageFocusedIndicator)) { GraphicsPath path = new GraphicsPath(); path.AddLines(new[] { new Point(drawRect.X, drawRect.Y), new Point(drawRect.X + drawRect.Height / 2, drawRect.Y), new Point(drawRect.X, drawRect.Y + drawRect.Height / 2), new Point(drawRect.X, drawRect.Y) }); g.FillPath(b, path); } } // Image icon Image img = item.ItemImage; if (img == null && item.ItemTypeImage != null) { img = item.ItemTypeImage; } if (img != null) { var recImg = new Rectangle(new Point(drawRect.X + 1, drawRect.Y + (drawRect.Height - img.Height) / 2), new Size(img.Width, img.Height)); g.DrawImage(img, recImg); } // tag images var xPos = 1; var listImg = item.TagImages; if (listImg != null) { listImg.Reverse(); // draw the image with a given opacity ColorMatrix imgColor = new ColorMatrix(); imgColor.Matrix33 = FlagImagesOpacity; using (ImageAttributes imgAttrib = new ImageAttributes()) { imgAttrib.SetColorMatrix(imgColor); foreach (var image in listImg) { xPos += image.Width; g.DrawImage(image, new Rectangle(new Point(drawRect.X + drawRect.Width - xPos, (drawRect.Height - image.Height) / 2), new Size(image.Width, image.Height)), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imgAttrib); } } } // sub text var subText = item.SubText; if (!string.IsNullOrEmpty(subText)) { var textFont = FontManager.GetFont(FontStyle.Bold, 10); var textSize = TextRenderer.MeasureText(subText, textFont); var subColor = !item.IsDisabled ? YamuiThemeManager.Current.SubTextFore : foreColor; var drawPoint = new PointF(drawRect.X + drawRect.Width - xPos - textSize.Width - 3, (drawRect.Height / 2) - (textSize.Height / 2) - 1); // using Drawstring here because TextRender (GDI) can't draw semi transparent text g.DrawString(subText, textFont, new SolidBrush(Color.FromArgb((int)(SubTextOpacity * 255), subColor)), drawPoint); using (var pen = new Pen(Color.FromArgb((int)(SubTextOpacity * 0.8 * 255), subColor), 1) { Alignment = PenAlignment.Left }) { g.DrawPath(pen, Utilities.GetRoundedRect(drawPoint.X - 2, drawPoint.Y - 1, textSize.Width + 2, textSize.Height + 3, 3f)); } } var textRectangle = new Rectangle(drawRect.X + 3 + (img != null ? img.Width : 0), 0, drawRect.Width - 3 - (img != null ? img.Width : 0), drawRect.Height); // letter highlight if (!(item.IsDisabled || item.IsSeparator)) { DrawTextHighlighting(g, item.InternalFilterMatchedRanges, textRectangle, item.DisplayText, TextFlags); } // text TextRenderer.DrawText(g, item.DisplayText, FontManager.GetStandardFont(), textRectangle, foreColor, TextFlags); }
/// <summary> /// Set the items that will be displayed in the list /// </summary> public override void SetItems(List <ListItem> listItems) { var firstItem = listItems.FirstOrDefault(); if (firstItem != null && !(firstItem is FilteredTypeListItem)) { throw new Exception("listItems should contain objects of type FilteredTypeItem"); } // measure the space taken by the label "showing x items" using (var gImg = new Bitmap(1, 1)) using (var g = Graphics.FromImage(gImg)) { _itemsNbLabelWidth = TextRenderer.MeasureText(g, _nbItems + PaintItemsText, FontManager.GetFont(FontFunction.Small), ClientSize, TextRightFlags).Width.ClampMin(MinItemLabelWidth); } // set the type buttons needed if (_typeListLock.TryEnterWriteLock(-1)) { try { ComputeTypeButtonsNeeded(listItems); } finally { _typeListLock.ExitWriteLock(); } } base.SetItems(listItems); }
protected override void OnPaint(PaintEventArgs e) { var backColor = YamuiThemeManager.Current.ButtonBg(BackColor, UseCustomBackColor, IsFocused, IsHovered, IsPressed, Enabled); var borderColor = YamuiThemeManager.Current.ButtonBorder(IsFocused, IsHovered, IsPressed, Enabled); var foreColor = YamuiThemeManager.Current.ButtonFg(ForeColor, UseCustomForeColor, IsFocused, IsHovered, IsPressed, Enabled); // background if (backColor != Color.Transparent) { e.Graphics.Clear(backColor); } else { PaintTransparentBackground(e.Graphics, DisplayRectangle); } // border? if (borderColor != Color.Transparent) { using (var p = new Pen(borderColor)) { var borderRect = new Rectangle(0, 0, Width - 1, Height - 1); e.Graphics.DrawRectangle(p, borderRect); } } // highlight is a border with more width if (Highlight && !IsHovered && !IsPressed && Enabled) { using (var p = new Pen(YamuiThemeManager.Current.AccentColor, 4)) { var borderRect = new Rectangle(2, 2, Width - 4, Height - 4); e.Graphics.DrawRectangle(p, borderRect); } } // text + image if (BackGrndImage != null || !SetImgSize.IsEmpty) { // ReSharper disable once PossibleNullReferenceException Size imgSize = !SetImgSize.IsEmpty ? SetImgSize : BackGrndImage.Size; float gap = ((float)ClientRectangle.Height - imgSize.Height) / 2; var rectImg = new RectangleF(gap, gap, imgSize.Width, imgSize.Height); if (DesignMode || BackGrndImage == null) { // in design mode using (SolidBrush b = new SolidBrush(Color.Fuchsia)) e.Graphics.FillRectangle(b, rectImg); } else { // draw main image, in greyscale if not activated if (BackGrndImage != null) { e.Graphics.DrawImage((!Enabled || UseGreyScale) ? GreyScaleBackGrndImage : BackGrndImage, rectImg); } } // text int xPos = (int)(gap * 2 + 0.5) + imgSize.Width; TextRenderer.DrawText(e.Graphics, Text, FontManager.GetStandardFont(), new Rectangle(xPos, 0, ClientRectangle.Width - xPos - (int)(gap + 0.5), ClientRectangle.Height), foreColor, FontManager.GetTextFormatFlags(TextAlign)); } else { // text only TextRenderer.DrawText(e.Graphics, Text, FontManager.GetStandardFont(), ClientRectangle, foreColor, FontManager.GetTextFormatFlags(TextAlign)); } }
public mnuItemSelected(string name, int itemSlot) : base(name) { if ((int)Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.GetInvItemNum(itemSlot)].Type < 8 || (int)Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.GetInvItemNum(itemSlot)].Type == 15) { //cannot use item base.Size = new Size(165, 165); maxItems = 3; useable = false; } else { //can use item base.Size = new Size(165, 195); maxItems = 4; useable = true; } base.MenuDirection = Enums.MenuDirection.Horizontal; base.Location = new Point(335, 40); itemPicker = new Widgets.MenuItemPicker("itemPicker"); itemPicker.Location = new Point(18, 23); int widgetY = 8; //add choices lblHold = new Label("lblHold"); lblHold.Size = new System.Drawing.Size(120, 32); lblHold.Font = FontManager.LoadFont("PMDCP", 32); //lblHold.AutoSize = true; lblHold.Text = "Hold"; lblHold.Location = new Point(30, widgetY); lblHold.HoverColor = Color.Red; lblHold.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblHold_Click); lblHold.ForeColor = Color.WhiteSmoke; this.AddWidget(lblHold); widgetY += 30; if (useable) { lblUse = new Label("lblUse"); lblUse.Font = FontManager.LoadFont("PMDCP", 32); lblUse.AutoSize = true; lblUse.Text = "Use"; lblUse.Location = new Point(30, widgetY); lblUse.HoverColor = Color.Red; lblUse.ForeColor = Color.WhiteSmoke; lblUse.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblUse_Click); this.AddWidget(lblUse); widgetY += 30; } lblThrow = new Label("lblThrow"); lblThrow.Size = new System.Drawing.Size(120, 32); lblThrow.Location = new Point(30, widgetY); lblThrow.Font = FontManager.LoadFont("PMDCP", 32); lblThrow.Text = "Throw"; lblThrow.HoverColor = Color.Red; lblThrow.ForeColor = Color.WhiteSmoke; lblThrow.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblThrow_Click); widgetY += 30; lblSummary = new Label("lblSummary"); lblSummary.Size = new System.Drawing.Size(120, 32); lblSummary.Location = new Point(30, widgetY); lblSummary.Font = FontManager.LoadFont("PMDCP", 32); lblSummary.Text = "Summary"; lblSummary.HoverColor = Color.Red; lblSummary.ForeColor = Color.WhiteSmoke; lblSummary.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblSummary_Click); widgetY += 30; lblDrop = new Label("lblDrop"); lblDrop.Font = FontManager.LoadFont("PMDCP", 32); lblDrop.Size = new System.Drawing.Size(130, 32); lblDrop.AutoSize = false; //lblDrop.Text = "Drop"; lblDrop.Location = new Point(30, widgetY); lblDrop.HoverColor = Color.Red; lblDrop.ForeColor = Color.WhiteSmoke; lblDrop.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblDrop_Click); widgetY += 32; if (Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.GetInvItemNum(itemSlot)].Type == Enums.ItemType.Currency || Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.GetInvItemNum(itemSlot)].StackCap > 0) { lblDrop.Text = "Drop Amount:"; nudAmount = new NumericUpDown("nudAmount"); nudAmount.Size = new Size(120, 24); nudAmount.Location = new Point(32, widgetY); nudAmount.Maximum = Players.PlayerManager.MyPlayer.Inventory[itemSlot].Value; nudAmount.Minimum = 1; this.AddWidget(nudAmount); } else { lblDrop.Text = "Drop"; } this.AddWidget(lblDrop); this.AddWidget(lblSummary); this.AddWidget(lblThrow); this.AddWidget(itemPicker); this.ItemSlot = itemSlot; }
public Panel() { this.Font = FontManager.GetDefaultTextFont(); }
/// <summary> /// Runs the applications /// </summary> /// <remarks> /// This method makes sure the environment is sane. If so, it creates the required services /// and launches the main form. /// </remarks> /// <param name="args">The command line arguments passed to the application.</param> /// <returns><c>true</c> if the application started as expected; /// <c>false</c> otherwise.</returns> public bool RunMainForm(string[] args) { if (!SandboxCheck(_environmentInfo)) { return(false); } SetCompressorPath(_environmentInfo); var deletedDll = CheckModScriptDLL(); string requestedGameMode = null; Uri modToAdd = null; if (args.Length > 0 && !args[0].StartsWith("-")) { if (Uri.TryCreate(args[0], UriKind.Absolute, out modToAdd) && modToAdd.Scheme.Equals("nxm", StringComparison.OrdinalIgnoreCase)) { requestedGameMode = DetermineRequestedGameMode(modToAdd.Host); } } else { for (var i = 0; i < args.Length; i++) { var strArg = args[i]; if (strArg == "-game") { requestedGameMode = args[i + 1]; Trace.Write("Game Specified On Command line: " + requestedGameMode + ") "); } } } var changeDefaultGameMode = false; var supportedGames = GetSupportedGameModes(); do { var fontSetResolver = SetUpFonts(); var installedGames = GetInstalledGameModes(supportedGames); if (installedGames == null) { Trace.TraceInformation("No installed games."); MessageBox.Show($"No games were detected! {_environmentInfo.Settings.ModManagerName} will now close.", "No Games", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } CheckIfDefaultGameModeIsInstalled(installedGames); var selector = new GameModeSelector(supportedGames, installedGames, _environmentInfo); var gameModeFactory = selector.SelectGameMode(requestedGameMode, changeDefaultGameMode); if (selector.RescanRequested) { _environmentInfo.Settings.InstalledGamesDetected = false; _environmentInfo.Settings.Save(); changeDefaultGameMode = true; continue; } if (gameModeFactory == null) { return(false); } Trace.TraceInformation($"Game Mode Factory Selected: {gameModeFactory.GameModeDescriptor.Name} ({gameModeFactory.GameModeDescriptor.ModeId})"); Mutex gameModeMutex = null; var ownsMutex = false; try { for (var attemptCount = 0; attemptCount < 3; attemptCount++) { Trace.TraceInformation($"Creating Game Mode mutex (Attempt: {attemptCount})"); gameModeMutex = new Mutex(true, $"{_environmentInfo.Settings.ModManagerName}-{gameModeFactory.GameModeDescriptor.ModeId}-GameModeMutex", out ownsMutex); //If the mutex is owned, you are the first instance of the mod manager for game mode, so break out of loop. if (ownsMutex) { break; } try { //If the mutex isn't owned, attempt to talk across the messager. using (var messager = MessagerClient.GetMessager(_environmentInfo, gameModeFactory.GameModeDescriptor)) { if (messager != null) { //Messenger was created OK, send download request, or bring to front. if (modToAdd != null) { Trace.TraceInformation($"Messaging to add: {modToAdd}"); messager.AddMod(modToAdd.ToString()); } else { Trace.TraceInformation("Messaging to bring to front."); messager.BringToFront(); } return(true); } } gameModeMutex.Close(); gameModeMutex = null; } catch (InvalidOperationException) { var stbPromptMessage = new StringBuilder(); stbPromptMessage.AppendLine($"{_environmentInfo.Settings.ModManagerName} was unable to start. It appears another instance of {_environmentInfo.Settings.ModManagerName} is already running."); stbPromptMessage.AppendLine($"If you were trying to download multiple files, wait for {_environmentInfo.Settings.ModManagerName} to start before clicking on a new file download."); MessageBox.Show(stbPromptMessage.ToString(), "Already running", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } //Messenger couldn't be created, so sleep for a few seconds to give time for opening // the running copy of the mod manager to start up/shut down Thread.Sleep(TimeSpan.FromSeconds(5.0d)); } if (!ownsMutex) { var htlListener = (HeaderlessTextWriterTraceListener)Trace.Listeners["DefaultListener"]; htlListener.ChangeFilePath(Path.Combine(Path.GetDirectoryName(htlListener.FilePath), "Messager" + Path.GetFileName(htlListener.FilePath))); Trace.TraceInformation("THIS IS A MESSAGER TRACE LOG."); if (!htlListener.TraceIsForced) { htlListener.SaveToFile(); } var stbPromptMessage = new StringBuilder(); stbPromptMessage.AppendLine($"{_environmentInfo.Settings.ModManagerName} was unable to start. It appears another instance of {_environmentInfo.Settings.ModManagerName} is already running."); stbPromptMessage.AppendLine("A Trace Log file was created at:"); stbPromptMessage.AppendLine(htlListener.FilePath); stbPromptMessage.AppendLine("Before reporting the issue, don't close this window and check for a fix here (you can close it afterwards):"); stbPromptMessage.AppendLine(NexusLinks.FAQs); stbPromptMessage.AppendLine("If you can't find a solution, please make a bug report and attach the TraceLog file here:"); stbPromptMessage.AppendLine(NexusLinks.Issues); MessageBox.Show(stbPromptMessage.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } ApplicationInitializer appInitializer = null; while ((appInitializer == null) || (appInitializer.Status == TaskStatus.Retrying)) { appInitializer = new ApplicationInitializer(_environmentInfo, fontSetResolver, deletedDll); var appInitializerForm = new ApplicationInitializationForm(appInitializer); appInitializer.Initialize(gameModeFactory, SynchronizationContext.Current); appInitializerForm.ShowDialog(); } if (appInitializer.Status != TaskStatus.Complete) { if (appInitializer.Status == TaskStatus.Error) { return(false); } changeDefaultGameMode = true; DisposeServices(appInitializer.Services); continue; } var gameMode = appInitializer.GameMode; var services = appInitializer.Services; var mainFormViewModel = new MainFormVM(_environmentInfo, installedGames, gameMode, services.ModRepository, services.DownloadMonitor, services.ModActivationMonitor, services.ModManager, services.PluginManager); var mainForm = new MainForm(mainFormViewModel); using (var msgMessager = MessagerServer.InitializeListener(_environmentInfo, gameMode, services.ModManager, mainForm)) { if (modToAdd != null) { Trace.TraceInformation("Adding mod: " + modToAdd); msgMessager.AddMod(modToAdd.ToString()); modToAdd = null; } Trace.TraceInformation("Running Application."); try { Application.Run(mainForm); services.ModInstallLog.Backup(); requestedGameMode = mainFormViewModel.RequestedGameMode; changeDefaultGameMode = mainFormViewModel.DefaultGameModeChangeRequested; } finally { DisposeServices(services); gameMode.Dispose(); } } } finally { if (gameModeMutex != null) { if (ownsMutex) { gameModeMutex.ReleaseMutex(); } gameModeMutex.Close(); } FileUtil.ForceDelete(_environmentInfo.TemporaryPath); //Clean up created font's. FontManager.Dispose(); } } while (!string.IsNullOrEmpty(requestedGameMode) || changeDefaultGameMode); return(true); }
public mnuShop(string name, int itemSelected) : base(name) { base.Size = new Size(421, 360); base.MenuDirection = Enums.MenuDirection.Vertical; base.Location = new Point(10, 40); currentTen = itemSelected / 10; itemPicker = new Widgets.MenuItemPicker("itemPicker"); itemPicker.Location = new Point(18, 63); lblItemCollection = new Label("lblItemCollection"); lblItemCollection.AutoSize = true; lblItemCollection.Font = FontManager.LoadFont("PMDCP", 48); lblItemCollection.Text = "Shop"; lblItemCollection.Location = new Point(20, 0); lblItemCollection.ForeColor = Color.WhiteSmoke; picPreview = new PictureBox("picPreview"); picPreview.Size = new Size(32, 32); picPreview.BackColor = Color.Transparent; picPreview.Location = new Point(361, 20); lblItemNum = new Label("lblItemNum"); //lblItemNum.Size = new Size(100, 30); lblItemNum.AutoSize = true; lblItemNum.Location = new Point(288, 15); lblItemNum.Font = FontManager.LoadFont("PMDCP", 32); lblItemNum.BackColor = Color.Transparent; lblItemNum.Text = "0/0"; lblItemNum.ForeColor = Color.WhiteSmoke; lblVisibleItems = new Label[10]; lblVisiblePrices = new Label[10]; for (int i = 0; i < lblVisibleItems.Length; i++) { lblVisibleItems[i] = new Label("lblVisibleItems" + i); //lblVisibleItems[i].AutoSize = true; lblVisibleItems[i].Size = new Size(200, 32); //lblVisibleItems[i].Width = 200; lblVisibleItems[i].Font = FontManager.LoadFont("PMDCP", 32); lblVisibleItems[i].Location = new Point(35, (i * 30) + 48); //lblVisibleItems[i].HoverColor = Color.Red; lblVisibleItems[i].ForeColor = Color.WhiteSmoke; lblVisibleItems[i].Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(shopItem_Click); this.AddWidget(lblVisibleItems[i]); lblVisiblePrices[i] = new Label("lblVisiblePrices" + i); //lblVisiblePrices[i].AutoSize = true; lblVisiblePrices[i].Size = new Size(200, 32); //lblVisiblePrices[i].Width = 200; lblVisiblePrices[i].Font = FontManager.LoadFont("PMDCP", 32); lblVisiblePrices[i].Location = new Point(240, (i * 30) + 48); //lblVisiblePrices[i].HoverColor = Color.Red; lblVisiblePrices[i].ForeColor = Color.WhiteSmoke; lblVisiblePrices[i].Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(shopPrice_Click); this.AddWidget(lblVisiblePrices[i]); } this.AddWidget(picPreview); this.AddWidget(lblItemCollection); this.AddWidget(lblItemNum); this.AddWidget(itemPicker); tempSelected = itemSelected % 10; //DisplayItems(currentTen * 10 + 1); //ChangeSelected((itemSelected - 1) % 10); //UpdateSelectedItemInfo(); //loaded = true; lblVisibleItems[0].Text = "Loading..."; }
public mnuMainMenu(string name) : base(name) { this.Size = new Size(135, 178); this.MenuDirection = Enums.MenuDirection.Vertical; this.Location = new Point(10, 40); itemPicker = new Logic.Widgets.MenuItemPicker("itemPicker"); itemPicker.Location = new Point(18, 23); lblMoves = new Label("lblMoves"); lblMoves.AutoSize = true; lblMoves.Location = new Point(30, 8); lblMoves.Font = FontManager.LoadFont("PMDCP", 32); lblMoves.Text = "Moves"; lblMoves.HoverColor = Color.Red; lblMoves.ForeColor = Color.WhiteSmoke; lblMoves.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblMoves_Click); lblItems = new Label("lblItems"); lblItems.AutoSize = true; lblItems.Location = new Point(30, 38); lblItems.Font = FontManager.LoadFont("PMDCP", 32); lblItems.Text = "Items"; lblItems.HoverColor = Color.Red; lblItems.ForeColor = Color.WhiteSmoke; lblItems.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblItems_Click); lblTeam = new Label("lblTeam"); lblTeam.AutoSize = true; lblTeam.Location = new Point(30, 68); lblTeam.Font = FontManager.LoadFont("PMDCP", 32); lblTeam.Text = "Team"; lblTeam.HoverColor = Color.Red; lblTeam.ForeColor = Color.WhiteSmoke; lblTeam.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblTeam_Click); //lblGuild = new Label("lblGuild"); //lblGuild.AutoSize = true; //lblGuild.Location = new Point(30, 98); //lblGuild.Font = FontManager.LoadFont("PMDCP", 32); //lblGuild.Text = "Guild"; //lblGuild.HoverColor = Color.Red; //lblGuild.ForeColor = Color.WhiteSmoke; //lblGuild.Click += new EventHandler<SdlDotNet.Widgets.MouseButtonEventArgs>(lblGuild_Click); lblJobList = new Label("lblJobList"); lblJobList.AutoSize = true; lblJobList.Location = new Point(30, 98); lblJobList.Font = FontManager.LoadFont("PMDCP", 32); lblJobList.Text = "Job List"; lblJobList.HoverColor = Color.Red; lblJobList.ForeColor = Color.WhiteSmoke; lblJobList.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblJobList_Click); lblOthers = new Label("lblOthers"); lblOthers.AutoSize = true; lblOthers.Location = new Point(30, 128); lblOthers.Font = FontManager.LoadFont("PMDCP", 32); lblOthers.Text = "Others"; lblOthers.HoverColor = Color.Red; lblOthers.ForeColor = Color.WhiteSmoke; lblOthers.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblOthers_Click); this.AddWidget(itemPicker); this.AddWidget(lblMoves); this.AddWidget(lblItems); this.AddWidget(lblTeam); //this.AddWidget(lblGuild); this.AddWidget(lblJobList); this.AddWidget(lblOthers); }
protected virtual void OnPaintForeground(PaintEventArgs e) { Color foreColor = YamuiThemeManager.Current.LabelsFg(ForeColor, UseCustomForeColor, false, false, false, !FakeDisabled); TextRenderer.DrawText(e.Graphics, Text, FontManager.GetFont(Function), ClientRectangle, foreColor, FontManager.GetTextFormatFlags(TextAlign, _wrapToLine)); }
public mnuTournamentRulesEditor(string name, TournamentRules rules) : base(name) { this.rules = rules; base.Size = new Size(315, 360); base.MenuDirection = Enums.MenuDirection.Vertical; base.Location = new Point(10, 40); lblEditRules = new Label("lblEditRules"); lblEditRules.AutoSize = true; lblEditRules.Font = FontManager.LoadFont("PMDCP", 48); lblEditRules.Text = "Edit Rules"; lblEditRules.ForeColor = Color.WhiteSmoke; lblEditRules.Location = new Point(20, 0); chkSleepClause = new CheckBox("chkSleepClause"); chkSleepClause.Location = new Point(15, 48); chkSleepClause.Size = new System.Drawing.Size(200, 32); chkSleepClause.BackColor = Color.Transparent; chkSleepClause.Font = FontManager.LoadFont("PMDCP", 32); chkSleepClause.ForeColor = Color.WhiteSmoke; chkSleepClause.Text = "Sleep Clause"; chkSleepClause.Checked = rules.SleepClause; chkAccuracyClause = new CheckBox("chkAccuracyClause"); chkAccuracyClause.Location = new Point(15, 80); chkAccuracyClause.Size = new System.Drawing.Size(200, 32); chkAccuracyClause.BackColor = Color.Transparent; chkAccuracyClause.Font = FontManager.LoadFont("PMDCP", 32); chkAccuracyClause.ForeColor = Color.WhiteSmoke; chkAccuracyClause.Text = "Accuracy Clause"; chkAccuracyClause.Checked = rules.AccuracyClause; chkSpeciesClause = new CheckBox("chkSpeciesClause"); chkSpeciesClause.Location = new Point(15, 112); chkSpeciesClause.Size = new System.Drawing.Size(200, 32); chkSpeciesClause.BackColor = Color.Transparent; chkSpeciesClause.Font = FontManager.LoadFont("PMDCP", 32); chkSleepClause.ForeColor = Color.WhiteSmoke; chkSpeciesClause.Text = "Species Clause"; chkSpeciesClause.Checked = rules.SpeciesClause; chkFreezeClause = new CheckBox("chkFreezeClause"); chkFreezeClause.Location = new Point(15, 144); chkFreezeClause.Size = new System.Drawing.Size(200, 32); chkFreezeClause.BackColor = Color.Transparent; chkFreezeClause.Font = FontManager.LoadFont("PMDCP", 32); chkFreezeClause.ForeColor = Color.WhiteSmoke; chkFreezeClause.Text = "Freeze Clause"; chkFreezeClause.Checked = rules.FreezeClause; chkOHKOClause = new CheckBox("chkOHKOClause"); chkOHKOClause.Location = new Point(15, 176); chkOHKOClause.Size = new System.Drawing.Size(200, 32); chkOHKOClause.BackColor = Color.Transparent; chkOHKOClause.Font = FontManager.LoadFont("PMDCP", 32); chkOHKOClause.ForeColor = Color.WhiteSmoke; chkOHKOClause.Text = "OHKO Clause"; chkOHKOClause.Checked = rules.OHKOClause; chkSelfKOClause = new CheckBox("chkSelfKOClause"); chkSelfKOClause.Location = new Point(15, 208); chkSelfKOClause.Size = new System.Drawing.Size(200, 32); chkSelfKOClause.BackColor = Color.Transparent; chkSelfKOClause.Font = FontManager.LoadFont("PMDCP", 32); chkSelfKOClause.ForeColor = Color.WhiteSmoke; chkSelfKOClause.Text = "Self-KO Clause"; chkSelfKOClause.Checked = rules.SelfKOClause; btnSave = new Button("btnSave"); btnSave.Location = new Point(15, 245); btnSave.Size = new Size(100, 15); btnSave.Text = "Save"; btnSave.Click += new EventHandler <MouseButtonEventArgs>(btnSave_Click); this.AddWidget(chkSleepClause); this.AddWidget(chkAccuracyClause); this.AddWidget(chkSpeciesClause); this.AddWidget(chkFreezeClause); this.AddWidget(chkOHKOClause); this.AddWidget(chkSelfKOClause); this.AddWidget(btnSave); this.AddWidget(lblEditRules); }
protected override void OnPaint(PaintEventArgs e) { // background Color backColor = YamuiThemeManager.Current.LabelsBg(BackColor, UseCustomBackColor); if (backColor != Color.Transparent) { e.Graphics.Clear(backColor); } else { PaintTransparentBackground(e.Graphics, DisplayRectangle); } // foreground Color foreColor = YamuiThemeManager.Current.LabelsFg(ForeColor, UseCustomForeColor, IsFocused, IsHovered, IsPressed, Enabled); TextRenderer.DrawText(e.Graphics, Text, FontManager.GetFont(Function), ClientRectangle, foreColor, FontManager.GetTextFormatFlags(TextAlign)); }
//------------------------------------------------- #region Initialize Method's Region private void InitializeComponent() { //--------------------------------------------- //news: this.TitleElement = new FlatElement(this, true); this.BodyElement = new FlatElement(this, true); this.BackButton = new ButtonElement(this); //--------------------------------------------- //loading: this.LeftTexture = Content.Load <Texture2D>(LEFT_BABYLONIA_ENTRANCE); this.RightTexture = Content.Load <Texture2D>(RIGHT_BABYLONIA_ENTRANCE); this.LineTexture = Content.Load <Texture2D>(LINE_BABYLONIA_ENTRANCE); //names: this.TitleElement.SetLabelName(SandBoxLabel1NameInRes); this.BodyElement.SetLabelName(SandBoxLabel2NameInRes); this.BackButton.SetLabelName(SandBoxButton1NameInRes); //status: this.TitleElement.SetStatus(1); this.BodyElement.SetStatus(1); this.BackButton.SetStatus(1); //fontAndTextAligns: this.TitleElement.ChangeFont(FontManager.GetSprite(SAO_SFonts.sao_tt_regular, 18)); this.BodyElement.ChangeFont(FontManager.GetSprite(SAO_SFonts.sao_tt_regular, 16)); this.BackButton.ChangeFont(FontManager.GetSprite(SAO_SFonts.sao_tt_regular, 15)); this.TitleElement.ChangeAlignmation(StringAlignmation.MiddleCenter); this.BodyElement.ChangeAlignmation(StringAlignmation.MiddleCenter); this.BackButton.ChangeAlignmation(StringAlignmation.MiddleCenter); //priorities: this.SandBoxPriority = SandBoxPriority.LowErrorSandBox; this.TitleElement.ChangePriority(ElementPriority.Normal); this.BodyElement.ChangePriority(ElementPriority.Normal); this.BackButton.ChangePriority(ElementPriority.High); //sizes: this.ChangeSize(2f * (UnderForm.Width / 5), UnderForm.Height / 3); this.TitleElement.ChangeSize(Width - from_the_edge, (Height / 3) - (SeparatorLine_Height / 2)); this.BodyElement.ChangeSize(Width - from_the_edge, (1 * (Height / 3)) - (SeparatorLine_Height / 2)); this.BackButton.ChangeSize(); //ownering: this.TitleElement.SetOwner(this); this.BodyElement.SetOwner(this); this.BackButton.SetOwner(this); //locations: this.CenterToScreen(); this.TitleElement.ChangeLocation(from_the_edge / 2, 0); this.BodyElement.ChangeLocation(TitleElement.RealPosition.X, TitleElement.RealPosition.Y + TitleElement.Height + SeparatorLine_Height); this.BackButton.ChangeLocation((this.Width / 2) - (this.BackButton.Width / 2), this.BodyElement.RealPosition.Y + this.BodyElement.Height + (2 * from_the_edge)); //rectangles: this.CalculateTexturesRect(); //movements: this.TitleElement.ChangeMovements(ElementMovements.NoMovements); this.BodyElement.ChangeMovements(ElementMovements.NoMovements); //colors: this.TitleElement.ChangeForeColor(Color.White); this.BodyElement.ChangeForeColor(Color.White); this.BackButton.ChangeBorder(ButtonColors.Red); //enableds: this.TitleElement.EnableOwnerMover(); this.BodyElement.EnableOwnerMover(); this.BackButton.EnableMouseEnterEffect(); //texts: this.TitleElement.SetLabelText(); this.BodyElement.SetLabelText(); this.BackButton.SetLabelText(); //images: this._flat.ChangeImageSizeMode(ImageSizeMode.Center); this._flat.ChangeImageContent(this.MyRes.GetString(SandBoxBackGNameInRes)); //applyAndShow: this.TitleElement.Apply(); this.TitleElement.Show(); this.BodyElement.Apply(); this.BodyElement.Show(); this.BackButton.Apply(); this.BackButton.Show(); //events: //--------------------------------------------- //addRanges: //--------------------------------------------- //finalBlow: //--------------------------------------------- }
public mnuJobSelected(string name, int jobSlot) : base(name) { int size = 95; maxItems = 1; if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Finished || Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Failed) { } else { size += 30; maxItems++; } if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].CanSend) { size += 60; maxItems++; } base.Size = new Size(180, size); base.MenuDirection = Enums.MenuDirection.Horizontal; base.Location = new Point(300, 34); itemPicker = new Widgets.MenuItemPicker("itemPicker"); itemPicker.Location = new Point(18, 23); int locY = 8; if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Finished || Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Failed) { } else { lblAccept = new Label("lblAccept"); lblAccept.Font = FontManager.LoadFont("PMDCP", 32); lblAccept.AutoSize = true; if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Obtained || Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Suspended) { lblAccept.Text = "Accept"; } else if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].Accepted == Enums.JobStatus.Taken) { lblAccept.Text = "Cancel"; } lblAccept.Location = new Point(30, locY); lblAccept.HoverColor = Color.Red; lblAccept.ForeColor = Color.WhiteSmoke; lblAccept.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblAccept_Click); this.AddWidget(lblAccept); locY += 30; } lblDescription = new Label("lblDescription"); lblDescription.Font = FontManager.LoadFont("PMDCP", 32); lblDescription.AutoSize = true; lblDescription.Text = "Description"; lblDescription.Location = new Point(30, locY); lblDescription.HoverColor = Color.Red; lblDescription.ForeColor = Color.WhiteSmoke; lblDescription.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblDescription_Click); locY += 30; lblDelete = new Label("lblDelete"); lblDelete.Font = FontManager.LoadFont("PMDCP", 32); lblDelete.AutoSize = true; lblDelete.Text = "Delete"; lblDelete.Location = new Point(30, locY); lblDelete.HoverColor = Color.Red; lblDelete.ForeColor = Color.WhiteSmoke; lblDelete.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblDelete_Click); locY += 30; if (Players.PlayerManager.MyPlayer.JobList.Jobs[jobSlot].CanSend) { lblSend = new Label("lblSend"); lblSend.Font = FontManager.LoadFont("PMDCP", 32); lblSend.AutoSize = true; lblSend.Text = "Send to:"; lblSend.Location = new Point(30, locY); lblSend.HoverColor = Color.Red; lblSend.ForeColor = Color.WhiteSmoke; lblSend.Click += new EventHandler <SdlDotNet.Widgets.MouseButtonEventArgs>(lblSend_Click); locY += 40; txtSend = new TextBox("txtSend"); txtSend.Size = new Size(120, 24); txtSend.Location = new Point(32, locY); txtSend.Font = FontManager.LoadFont("PMDCP", 16); Skins.SkinManager.LoadTextBoxGui(txtSend); this.AddWidget(lblSend); this.AddWidget(txtSend); } this.AddWidget(itemPicker); this.AddWidget(lblDescription); this.AddWidget(lblDelete); this.jobSlot = jobSlot; }
public static ushort GetFontSytleByNameAndSize(string fontName, int fontSize) { return(FontManager.GetFontStyle(fontName, fontSize)); }
public bool Initalize(int screenWidth, int screenHeight, DirectoryInfo dataSet, bool showTutorial, Form parentForm, out string reason) { _parentForm = parentForm; Random = new Random(); MousePos = new Point(); ScreenWidth = screenWidth; ScreenHeight = screenHeight; GameDataSet = dataSet; Galaxy = new Galaxy(); EmpireManager = new EmpireManager(this); ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3); StarShader = GorgonLibrary.Graphics.FXShader.FromFile("StarShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3); if (!SpriteManager.Initialize(GameDataSet, out reason)) { return(false); } if (!FontManager.Initialize(GameDataSet, out reason)) { return(false); } RaceManager = new RaceManager(); if (!RaceManager.Initialize(GameDataSet, Random, out reason)) { return(false); } AIManager = new AIManager(); if (!AIManager.Initialize(GameDataSet, out reason)) { return(false); } MasterTechnologyManager = new MasterTechnologyManager(); if (!MasterTechnologyManager.Initialize(this, out reason)) { return(false); } _mainGameMenu = new MainGameMenu(); if (!_mainGameMenu.Initialize(this, out reason)) { return(false); } _screenInterface = _mainGameMenu; _currentScreen = Screen.MainMenu; _situationReport = new SituationReport(this); Cursor = SpriteManager.GetSprite("Cursor", Random); if (Cursor == null) { reason = "Cursor is not defined in sprites.xml"; return(false); } reason = string.Empty; return(true); }
public override Size GetPreferredSize(Size proposedSize) { Size preferredSize; base.GetPreferredSize(proposedSize); using (var g = CreateGraphics()) { proposedSize = new Size(int.MaxValue, int.MaxValue); preferredSize = TextRenderer.MeasureText(g, Text, FontManager.GetStandardFont(), proposedSize, FontManager.GetTextFormatFlags(TextAlign)); preferredSize.Width += 16; } return(preferredSize); }
public mnuAssembly(string name, string[] parse) : base(name) { this.Size = new Size(315, 450); this.MenuDirection = Enums.MenuDirection.Vertical; this.Location = new Point(10, 20); currentTen = 0; team = new int[4]; recruitList = new List <Players.Recruit>(); recruitIndex = new List <int>(); itemPicker = new Logic.Widgets.MenuItemPicker("itemPicker"); lblAssembly = new Label("lblAssembly"); lblAssembly.AutoSize = true; lblAssembly.Font = FontManager.LoadFont("PMU", 48); lblAssembly.Text = "Assembly"; lblAssembly.Location = new Point(20, 0); lblAssembly.ForeColor = Color.WhiteSmoke; lblRecruitNum = new Label("lblRecruitNum"); //lblItemNum.Size = new Size(100, 30); lblRecruitNum.AutoSize = true; lblRecruitNum.Location = new Point(222, 14); lblRecruitNum.Font = FontManager.LoadFont("PMU", 32); lblRecruitNum.BackColor = Color.Transparent; lblRecruitNum.Text = "0/0"; lblRecruitNum.ForeColor = Color.WhiteSmoke; txtFind = new TextBox("txtFind"); txtFind.Size = new Size(130, 20); txtFind.Location = new Point(32, 48); txtFind.Font = FontManager.LoadFont("PMU", 16); Skins.SkinManager.LoadTextBoxGui(txtFind); btnFind = new Button("btnFind"); btnFind.Size = new System.Drawing.Size(40, 20); btnFind.Location = new Point(174, 48); btnFind.Font = Client.Logic.Graphics.FontManager.LoadFont("PMU", 16); btnFind.Text = "Find"; Skins.SkinManager.LoadButtonGui(btnFind); btnFind.Click += new EventHandler <MouseButtonEventArgs>(btnFind_Click); picMugshot = new PictureBox("picMugshot"); picMugshot.Size = new Size(40, 40); picMugshot.BackColor = Color.Transparent; picMugshot.Location = new Point(35, 76); lblName = new Label("lblName"); lblName.AutoSize = true; lblName.Centered = true; lblName.Font = FontManager.LoadFont("PMU", 16); lblName.ForeColor = Color.WhiteSmoke; lblName.Location = new Point(75, 76); lblLevel = new Label("lblLevel"); lblLevel.AutoSize = true; lblLevel.Centered = true; lblLevel.Font = FontManager.LoadFont("PMU", 16); lblLevel.ForeColor = Color.WhiteSmoke; lblLevel.Location = new Point(75, 96); lblAllRecruits = new Label[10]; for (int i = 0; i < 10; i++) { lblAllRecruits[i] = new Label("lblAllRecruits" + i); //lblAllRecruits[i].AutoSize = true; //lblAllRecruits[i].Centered = true; lblAllRecruits[i].Width = 200; lblAllRecruits[i].Font = FontManager.LoadFont("PMU", 32); lblAllRecruits[i].Location = new Point(35, (i * 30) + 114); //lblAllRecruits[i].HoverColor = Color.Red; //lblAllRecruits[i].Click += new EventHandler<SdlDotNet.Widgets.MouseButtonEventArgs>(assemblyItem_Click); this.AddWidget(lblAllRecruits[i]); } LoadRecruitsFromPacket(parse); this.AddWidget(itemPicker); this.AddWidget(txtFind); this.AddWidget(btnFind); this.AddWidget(lblAssembly); this.AddWidget(lblRecruitNum); this.AddWidget(picMugshot); this.AddWidget(lblName); this.AddWidget(lblLevel); FindMaxItems(); DisplayRecruitList(); UpdateSelectedRecruitInfo(); ChangeSelected(0); }
public void SetFontmanager(FontManager manager) { this.manager = manager; }
public void Initialise() { _cellModel = Content.Load <Model>("Models/cell"); _cellModel.EnableDefaultLighting(); _connectorLargeModel = Content.Load <Model>("Models/connector1"); _connectorLargeModel.EnableDefaultLighting(); _connectorSmallModel = Content.Load <Model>("Models/connector2"); _connectorSmallModel.EnableDefaultLighting(); _turret1Model = Content.Load <Model>("Models/turret1"); _turret1Model.EnableDefaultLighting(); _turret1Model.SetDiffuseColour(Color.Purple); _turret2aModel = Content.Load <Model>("Models/turret2a"); _turret2aModel.EnableDefaultLighting(); _turret2aModel.SetDiffuseColour(Color.LightSteelBlue); _turret2bModel = Content.Load <Model>("Models/turret2b"); _turret2bModel.EnableDefaultLighting(); _turret2bModel.SetDiffuseColour(Color.Purple); _turret2cModel = Content.Load <Model>("Models/turret2c"); _turret2cModel.EnableDefaultLighting(); _turret2cModel.SetDiffuseColour(Color.Red); _powerModule = Content.Load <Model>("Models/power"); _powerModule.EnableDefaultLighting(); _powerModule.SetDiffuseColour(Color.Yellow); _researchCenterModule = Content.Load <Model>("Models/lifesupport"); _researchCenterModule.EnableDefaultLighting(); _researchCenterModule.SetDiffuseColour(Color.White); _tankModel = Content.Load <Model>("Models/tank"); _tankModel.EnableDefaultLighting(); _tankModel.SetDiffuseColour(Color.Red); _rotaryModel = Content.Load <Model>("Models/rotary"); _rotaryModel.EnableDefaultLighting(); _rotaryModel.SetDiffuseColour(Color.Orange); _rocket1Model = Content.Load <Model>("Models/rocket1"); _rocket1Model.EnableDefaultLighting(); _rocket1Model.SetDiffuseColour(Color.LightSteelBlue); _rocket2aModel = Content.Load <Model>("Models/rocket2a"); _rocket2aModel.EnableDefaultLighting(); _rocket2aModel.SetDiffuseColour(Color.LightSteelBlue); _rocket2bModel = Content.Load <Model>("Models/rocket2b"); _rocket2bModel.EnableDefaultLighting(); _rocket2bModel.SetDiffuseColour(Color.GhostWhite); _armourModel = Content.Load <Model>("Models/armour"); _armourModel.EnableDefaultLighting(); _armourModel.SetDiffuseColour(Color.DarkRed); _shieldGeneratorModel = Content.Load <Model>("Models/shieldgenerator"); _shieldGeneratorModel.EnableDefaultLighting(); _shieldGeneratorModel.SetDiffuseColour(Color.Green); _trailModel = Content.Load <Model>("Models/trail"); _trailModel.EnableDefaultLighting(); _trailModel.SetDiffuseColour(Color.Yellow); _d = FontManager.Get("Default"); }
/// <summary> /// Dispose all managers. /// </summary> protected override void Dispose(bool disposing) { if (fpsCounter != null) { fpsCounter = null; } if (textManager != null) { textManager.Dispose(); textManager = null; } if (fontManager != null) { fontManager.Dispose(); fontManager = null; } inputManager = null; if (collisionContext != null) { collisionContext.ClearAllLayer(); collisionContext = null; } if (particleManager != null) { particleManager.ClearAllParticles(); particleManager = null; } if (soundManager != null) { soundManager.Dispose(); soundManager = null; } if (screenManager != null) { screenManager.Dispose(); screenManager = null; } if (viewer != null) { viewer.Dispose(); viewer = null; } if (resourceManager != null) { resourceManager.Dispose(); resourceManager = null; } if (debugFont != null) debugFont = null; base.Dispose(disposing); }
protected virtual void Paginate() { if (ItemControls.Count == 0) { return; } UILabel lbl = ItemControls[0] as UILabel; if (lbl == null) { return; } float pixelWidth = Rect.GetPixelSize().X - ScrollWidth - (BorderPadding * 2); // we can't ask the label, since it may not have max text in it. int fontSize = lbl.GetNominalFontHeight(ActualItemHeight); string[] lines = CurrentText.Replace("\n", string.Empty).Split("\r".ToCharArray()); ItemList.Clear(); foreach (var line in lines) { string text = line; while (text.Length > 0) { string thisText = string.Empty; var size = FontManager.MeasureText(Font, fontSize, text); if (size.X <= pixelWidth) { thisText = text; } else { thisText = text; bool done = false; while (!done) { int prevWhitespace = thisText.LastIndexOfAny(" \t".ToCharArray()); if (prevWhitespace == -1) { done = true; // the word is too big, let it clip } else { if (prevWhitespace == 0) { done = true; } else { thisText = thisText.Substring(0, prevWhitespace); size = FontManager.MeasureText(Font, fontSize, thisText); done = size.X < (pixelWidth); } } } } thisText = thisText.Trim(); if (thisText != string.Empty) { ControlInfo info = new ControlInfo(); info.Text = thisText; info.Index = ItemList.Count; ItemList.Add(info); } if (thisText == text) { text = string.Empty; } else { text = text.Substring(thisText.Length).Trim(); } } } }