public LineInfo(int startY) { cutOffPositions = null; VisibleState = CogEngine.ScriptEditor.VisibleState.Visible; this.startY = startY; bottomPadding = 0; }
private void ChangeVisibleState(Vector3Axial position, VisibleState state) { switch (state) { case VisibleState.Invisible: _visibleTiles.Remove(position); _seenTiles.Remove(position); ChangedVisibleTile(position, VisibleState.Invisible); break; case VisibleState.Seen: _visibleTiles.Remove(position); if (_seenTiles.Add(position)) { ChangedVisibleTile(position, VisibleState.Seen); } break; case VisibleState.Visible: _seenTiles.Remove(position); if (_visibleTiles.Add(position)) { ChangedVisibleTile(position, VisibleState.Visible); } break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
public LineInfo(int startY) { cutOffPositions = null; VisibleState = FastColoredTextBoxNS.VisibleState.Visible; this.startY = startY; bottomPadding = 0; }
public LineInfo(int startY) { cutOffPositions = null; VisibleState = VisibleState.Visible; this.startY = startY; bottomPadding = 0; }
public Category(Product.ProductCategory category_, List <CategorySubType> categorySubTypes) { // Startup constructor, default settings category = category_; visibleState = VisibleState.notVisible; subCategories = categorySubTypes; collapsed = false; }
public RenderForm(CompletedSimulation demoResult, IAiFactory demoAi) { DemoResult = demoResult ?? throw new ArgumentNullException(nameof(demoResult)); DemoAi = demoAi ?? throw new ArgumentNullException(nameof(demoAi)); OutputDirectory = Path.Combine(Directory.GetCurrentDirectory(), DemoAi.Name); InitializeComponent(); RenderControl.VisibleState = VisibleState.GenerateBlank(DemoResult.Parameters); }
public LineInfo(int startY) { _cutOffPositions = null; VisibleState = VisibleState.Visible; StartY = startY; BottomPadding = 0; WordWrapIndent = 0; }
public UserAction NextStep(VisibleState state) { if (state.Wire <= Integer.Int(100)) { return(UserAction.BuyWire); } return(UserAction.MakeClip); }
public virtual void ToggleVisibilty() { if (this.IsVisible) { this.visibleState = VisibleState.Hidden; } else { this.visibleState = VisibleState.Visible; } }
private void Open(int index, VisibleState pos) { // Opens the dictionary to the page number index dictionary.transform.parent = ((pos == VisibleState.LEFT)?(LeftHandDictionarySlot):(RightHandDictionarySlot)).transform; // Sets the transform to be the correct transform according to pos dictionary.transform.localPosition = Vector3.zero; dictionary.transform.localEulerAngles = Vector3.zero; pgNum = index; SetEntry(index); dictionary.SetActive(true); visible = pos; audioSource.Play(); }
private void BeginRender_Click(object sender, EventArgs e) { IAi ai = DemoAi.Create(DemoResult.Parameters); Level level = DemoResult.ProtoLevel.Generate(); _rover = new Rover(level, DemoResult.Parameters); _stats = RoverStats.Create(DemoResult.Parameters); _state = VisibleState.GenerateBlank(level.BottomRight, _rover.Position); _actionEnumerator = ai.Simulate(_rover.Accessor).GetEnumerator(); beginRender.Enabled = false; UpdateTimer.Start(); }
private static void ExportFrames(CompletedSimulation sim, IAiFactory aiFactory, String outputDir) { const Int32 tileSize = 10; IAi ai = aiFactory.Create(sim.Parameters); Level level = sim.ProtoLevel.Generate(); Rover rover = new Rover(level, sim.Parameters); VisibleState state = VisibleState.GenerateBlank(level.BottomRight, rover.Position); using var actionEnumerator = ai.Simulate(rover.Accessor).GetEnumerator(); Int32 maxFrameCount = sim.Parameters.InitialMovesLeft; Int32 filenameDigits = (Int32)Math.Ceiling(Math.Log10(maxFrameCount)) + 1; String fileBase = Path.Combine(outputDir, $"frame-{sim.ProtoLevel.Seed}-"); DirectoryInfo dir = new DirectoryInfo(outputDir); if (dir.Exists) { foreach (var file in dir.EnumerateFiles()) { file.Delete(); } } else { dir.Create(); } Int32 width = level.Width * tileSize; Int32 height = level.Height * tileSize; using Bitmap bitmap = new Bitmap(width, height); using Graphics surface = Graphics.FromImage(bitmap); Update update = new Update(terrain: rover.Adjacent); Int32 frameIndex = 0; do { if (!state.Apply(update)) { continue; } GdiRenderer.Draw(surface, width, height, state); String suffix = frameIndex.ToString().PadLeft(filenameDigits, '0'); String filename = fileBase + suffix + ".png"; bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png); frameIndex++; }while (actionEnumerator.MoveNext() && rover.Perform(actionEnumerator.Current, out update)); }
public void Update() { this.previousVisibleState = this.currentVisibleState; this.previousMouseState = this.currentMouseState; this.currentMouseState = Mouse.GetState(); if (this.rectangle.Contains(this.currentMouseState.X, this.currentMouseState.Y)) { if (this.currentMouseState.LeftButton == ButtonState.Pressed) { if (this.previousMouseState.LeftButton == ButtonState.Released) { this.OnMouseDown(EventArgs.Empty); this.currentVisibleState = VisibleState.Pressed; } else { if (this.currentVisibleState != VisibleState.Pressed) { this.currentVisibleState = VisibleState.Hover; } } } else { if (this.previousVisibleState == VisibleState.Pressed) { this.OnMouseClick(null); } this.currentVisibleState = VisibleState.Hover; } } else { if (this.previousVisibleState == VisibleState.Hover || this.previousVisibleState == VisibleState.Pressed) { this.OnMouseOut(EventArgs.Empty); } this.currentVisibleState = VisibleState.Normal; } if (this.currentMouseState.LeftButton == ButtonState.Released && this.previousVisibleState == VisibleState.Pressed) { this.OnMouseUp(EventArgs.Empty); } }
public RenderViewModel(IAiFactory aiFactory, CompletedSimulation simulation) { Ai = aiFactory ?? throw new ArgumentNullException(nameof(aiFactory)); Simulation = simulation ?? throw new ArgumentNullException(nameof(simulation)); Start = ReactiveCommand.CreateFromObservable(() => { IAi ai = Ai.Create(Simulation.Parameters); Level level = Simulation.ProtoLevel.Generate(); Rover rover = new Rover(level, Simulation.Parameters); return(Observable.Create <(RoverAction action, Update update)>(obs => { return Task.Run(async() => { var actionEnumerator = ai.Simulate(rover.Accessor).GetEnumerator(); while (actionEnumerator.MoveNext() && rover.Perform(actionEnumerator.Current, out Update update)) { obs.OnNext((actionEnumerator.Current, update)); Int32 delay = actionEnumerator.Current.Instruction switch { Instruction.Move => 75, Instruction.CollectSample => 50, _ => 0 }; if (delay != 0) { await Task.Delay(delay); } } }); })); }); Stats = Start.Aggregate(RoverStats.Create(Simulation.Parameters), (s, update) => s.Add(update.action, update.update)); State = this .WhenAnyObservable(m => m.Start) .Select(update => update.update) .Scan(VisibleState.GenerateBlank(Simulation.Parameters), (state, update) => { state.Apply(update); return(state); }); }
public void ChangeState(bool inVisible) { gameObject.layer += inVisible ? -1 : 1; Color color = animationRenderer.GetSpriteRenderer().color; if (inVisible) { color.a = 1; } else { color.a = invisibleAlpha; } animationRenderer.GetSpriteRenderer().color = color; visibleState = inVisible ? VisibleState.VISIBLE : VisibleState.INVISIBLE; }
private static InlineKeyboardMarkup RenderButtons(VisibleState currentMove) { InlineKeyboardMarkup answerButtons = null; if (currentMove.Answers?.Length > 0) { List <InlineKeyboardButton> groupBy3 = null; List <InlineKeyboardButton> groupBy2 = null; var buttonCategories = new List <List <InlineKeyboardButton> >(); foreach (var answer in currentMove.Answers) { var len = answer.Length; if (len == 1) { if (groupBy3 == null || groupBy3.Count >= 3) { groupBy3 = new List <InlineKeyboardButton>(); buttonCategories.Add(groupBy3); } groupBy3.Add(InlineKeyboardButton.WithCallbackData(answer[0].ToSmile())); } else if (len < 12) { if (groupBy2 == null || groupBy2.Count >= 2) { groupBy2 = new List <InlineKeyboardButton>(); buttonCategories.Add(groupBy2); } groupBy2.Add(InlineKeyboardButton.WithCallbackData(answer)); } else { buttonCategories.Add(new List <InlineKeyboardButton> { InlineKeyboardButton.WithCallbackData(answer) }); } } answerButtons = new InlineKeyboardMarkup(buttonCategories); } return(answerButtons); }
public static void Draw(Graphics surface, Int32 width, Int32 height, VisibleState state) { Int32 widthMultiplier = width / state.Width; Int32 heightMultiplier = height / state.Height; Point point = new Point(); Size size = new Size(widthMultiplier, heightMultiplier); for (Int16 i = 0; i < state.Width; i++) { for (Int16 j = 0; j < state.Height; j++) { DrawTile(surface, state[i, j], point, size); point.Offset(0, size.Height); } point.Offset(size.Width, 0); point.Y = 0; } DrawRover(surface, state.RoverPosition.X, state.RoverPosition.Y, size.Width, size.Height); }
public virtual void ToggleVisibilty() { if (this.IsVisible) { this.visibleState = VisibleState.Hidden; } else this.visibleState = VisibleState.Visible; }
protected override void Start() { currentInvisibleCooldown = 0; currentInvisibleTime = 0; visibleState = VisibleState.VISIBLE; }
public void Close() { // Close the dictionary pgNum = -1; visible = VisibleState.NONE; }
private VisibleState CreateVisibleState(VOGStateBase state) { VisibleState visibleState = VisibleStates.Find(s => s.State == state); if (visibleState == null) { visibleState = new VisibleState() { State = state, }; if (state != null) { VisibleStates.Add(visibleState); } } return visibleState; }
public LineInfo(int startY) { cutOffPositions = null; VisibleState = SplasherStudio.Controls.VisibleState.Visible; this.startY = startY; }
public LineInfo(int startY) { cutOffPositions = null; VisibleState = ucCodeEditor.VisibleState.Visible; this.startY = startY; }
private async Task <Message> SendTextMessage(string chatId, VisibleState currentMove, BotState botState, InlineKeyboardMarkup answerButtons, int?answerToMessageId = null) { var response = currentMove.Message; Message message = null; if (response != null && response.GetHashCode() != botState.PreviousMessageHash) { if (answerToMessageId.HasValue && botState.PreviousMessageIsText) { try { message = await botClient.EditMessageTextAsync( chatId : chatId, messageId : answerToMessageId.Value, text : response, replyMarkup : answerButtons, parseMode : ParseMode.Markdown ); } catch (Exception exception) { Console.WriteLine(exception); } } if (message == null) { var messageToDelete = botState.PreviousMessageIsText ? botState.PreviousMessageId : answerToMessageId; if (messageToDelete.HasValue) { try { await botClient.DeleteMessageAsync( chatId : chatId, messageId : messageToDelete.Value ); } catch (Exception exception) { Console.WriteLine(exception); } } try { message = await botClient.SendTextMessageAsync( chatId : chatId, text : response, replyMarkup : answerButtons, parseMode : ParseMode.Markdown ); } catch (Exception exception) { Console.WriteLine(exception); } } botState.PreviousMessageIsText = true; botState.PreviousMessageId = message?.MessageId; botState.PreviousMessageHash = response.GetHashCode(); } return(message); }
private async Task <Message> SendMediaMessage(string chatId, VisibleState currentMove, BotState botState, InlineKeyboardMarkup answerButtons, int?answerToMessageId = null) { var response = currentMove.Message; var photo = currentMove.Photo; Message message = null; if (photo != null && photo.GetHashCode() != botState.PreviousMessageHash) { var filePath = photo.Split(';').FirstOrDefault(); var fileId = photo.Split(';').LastOrDefault(); if (answerToMessageId.HasValue) { try { await botClient.DeleteMessageAsync( chatId : chatId, messageId : answerToMessageId.Value ); } catch (Exception exception) { Console.WriteLine(exception); } } if (!string.IsNullOrEmpty(fileId) && fileId != filePath) { try { message = await botClient.SendPhotoAsync( chatId : chatId, photo : new InputMedia(fileId), replyMarkup : answerButtons, caption : response ); } catch (Exception e) { Console.WriteLine(e); } } if (message == null && filePath != null) { try { using (var fileStream = new FileStream(filePath, FileMode.Open)) { message = await botClient.SendPhotoAsync( chatId : chatId, photo : new InputMedia(fileStream, photo), replyMarkup : answerButtons, caption : response ); Console.WriteLine("FILE UPLOADED. " + string.Join("\n", message.Photo.Select(p => $"W: {p.Width}, H: {p.Height}, ID:{p.FileId}"))); } } catch (Exception e) { Console.WriteLine(e); } } botState.PreviousMessageIsText = false; botState.PreviousMessageId = message?.MessageId; botState.PreviousMessageHash = photo.GetHashCode(); } return(message); }
public void Render(DrawArgs drawArgs) { if (m_sprite == null) { m_sprite = new Sprite(drawArgs.device); } if (mouseCursor != CursorType.Arrow) { DrawArgs.MouseCursor = mouseCursor; } foreach (MenuButton button in m_toolsMenuButtons) { if (button.IsPushed()) { // Does not render the button, but the functionality behind the button button.Render(drawArgs); } } foreach (MenuButton button in m_toolsMenuButtons) { button.Update(drawArgs); } foreach (MenuButton button in m_layersMenuButtons) { button.Update(drawArgs); } if (!World.Settings.ShowToolbar) { return; } if (this._isHideable) { if (this._visibleState == VisibleState.NotVisible) { if ( (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y < MenuButton.NormalSize) || (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y > drawArgs.ScreenHeight - MenuButton.NormalSize) || (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X > drawArgs.ScreenWidth - MenuButton.NormalSize) ) { this._visibleState = VisibleState.Ascending; this._lastVisibleChange = System.DateTime.Now; } } else if ( (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y > 2 * this._outerPadding + MenuButton.NormalSize) || (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y < drawArgs.ScreenHeight - 2 * this._outerPadding - MenuButton.NormalSize) || (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X < drawArgs.ScreenWidth - MenuButton.NormalSize) ) { if (this._visibleState == VisibleState.Visible) { this._visibleState = VisibleState.Descending; this._lastVisibleChange = System.DateTime.Now; } else if (this._visibleState == VisibleState.Descending) { if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.NotVisible; this._lastVisibleChange = System.DateTime.Now; } } } else if (this._visibleState == VisibleState.Ascending) { if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.Visible; this._lastVisibleChange = System.DateTime.Now; } } else if (this._visibleState == VisibleState.Descending) { if (System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.NotVisible; this._lastVisibleChange = System.DateTime.Now; } } } else { this._visibleState = VisibleState.Visible; } int totalNumberButtons = m_toolsMenuButtons.Count + m_layersMenuButtons.Count; MenuButton.NormalSize = MenuButton.SelectedSize / 2; _outerPadding = MenuButton.NormalSize * padRatio; float menuWidth = (MenuButton.NormalSize + _outerPadding) * totalNumberButtons + _outerPadding; if (menuWidth > drawArgs.ScreenWidth) { MenuButton.NormalSize = (drawArgs.ScreenWidth) / ((padRatio + 1) * totalNumberButtons + padRatio); _outerPadding = MenuButton.NormalSize * padRatio; // recalc menuWidth if we want to center the toolbar menuWidth = (MenuButton.NormalSize + _outerPadding) * totalNumberButtons + _outerPadding; } if (m_anchor == MenuAnchor.Left) { x = 0; y = (int)MenuButton.NormalSize; } else if (m_anchor == MenuAnchor.Right) { x = (int)(drawArgs.ScreenWidth - 2 * _outerPadding - MenuButton.NormalSize); y = (int)MenuButton.NormalSize; } else if (m_anchor == MenuAnchor.Top) { x = (int)(drawArgs.ScreenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding); y = 0; } else if (m_anchor == MenuAnchor.Bottom) { x = (int)(drawArgs.ScreenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding); y = (int)(drawArgs.ScreenHeight - 2 * _outerPadding - MenuButton.NormalSize); } if (this._visibleState == VisibleState.Ascending) { TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange); if (t.Milliseconds < hideTimeMilliseconds) { double percent = (double)t.Milliseconds / hideTimeMilliseconds; int dx = (int)((MenuButton.NormalSize + 5) - (percent * (MenuButton.NormalSize + 5))); if (m_anchor == MenuAnchor.Left) { x -= dx; } else if (m_anchor == MenuAnchor.Right) { x += dx; } else if (m_anchor == MenuAnchor.Top) { y -= dx; } else if (m_anchor == MenuAnchor.Bottom) { y += dx; } } } else if (this._visibleState == VisibleState.Descending) { TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange); if (t.Milliseconds < hideTimeMilliseconds) { double percent = (double)t.Milliseconds / hideTimeMilliseconds; int dx = (int)((percent * (MenuButton.NormalSize + 5))); if (m_anchor == MenuAnchor.Left) { x -= dx; } else if (m_anchor == MenuAnchor.Right) { x += dx; } else if (m_anchor == MenuAnchor.Top) { y -= dx; } else if (m_anchor == MenuAnchor.Bottom) { y += dx; } } } lock (m_toolsMenuButtons.SyncRoot) { MenuButton selectedButton = null; if (_curSelection >= 0 & _curSelection < totalNumberButtons) { if (_curSelection < m_toolsMenuButtons.Count) { selectedButton = (MenuButton)m_toolsMenuButtons[_curSelection]; } else { selectedButton = (MenuButton)m_layersMenuButtons[_curSelection - m_toolsMenuButtons.Count]; } } //_outerPadding = MenuButton.NormalSize*padRatio; //float menuWidth = (MenuButton.NormalSize+_outerPadding)*totalNumberButtons+_outerPadding; //if(menuWidth>drawArgs.screenWidth) //{ // //MessageBox.Show(drawArgs.screenWidth.ToString()); // MenuButton.NormalSize = (drawArgs.screenWidth)/((padRatio+1)*totalNumberButtons+padRatio); // //MessageBox.Show(MenuButton.NormalSize.ToString()); // _outerPadding = MenuButton.NormalSize*padRatio; //} if (this._visibleState != VisibleState.NotVisible) { if (m_anchor == MenuAnchor.Top) { MenuUtils.DrawBox(0, 0, drawArgs.ScreenWidth, (int)(MenuButton.NormalSize + 2 * _outerPadding), 0.0f, World.Settings.toolBarBackColor, drawArgs.device); } else if (m_anchor == MenuAnchor.Bottom) { MenuUtils.DrawBox(0, (int)(y - _outerPadding), drawArgs.ScreenWidth, (int)(MenuButton.NormalSize + 4 * _outerPadding), 0.0f, World.Settings.toolBarBackColor, drawArgs.device); } } float total = 0; float extra = 0; for (int i = 0; i < totalNumberButtons; i++) { MenuButton button; if (i < m_toolsMenuButtons.Count) { button = (MenuButton)m_toolsMenuButtons[i]; } else { button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count]; } total += button.CurrentSize; extra += button.CurrentSize - MenuButton.NormalSize; } float pad = ((float)_outerPadding * (totalNumberButtons + 1) - extra) / (totalNumberButtons + 1); float buttonX = pad; // TODO - to center the menubar set the buttonX to center-half toolbar width // float buttonX = (drawArgs.screenWidth - menuWidth) / 2; m_sprite.Begin(SpriteFlags.AlphaBlend); for (int i = 0; i < totalNumberButtons; i++) { MenuButton button; if (i < m_toolsMenuButtons.Count) { button = (MenuButton)m_toolsMenuButtons[i]; } else { button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count]; } if (button.IconTexture == null) { button.InitializeTexture(drawArgs.device); } if (this._visibleState != VisibleState.NotVisible) { int centerX = (int)(buttonX + button.CurrentSize * 0.5f); buttonX += button.CurrentSize + pad; float buttonTopY = y + _outerPadding; if (m_anchor == MenuAnchor.Bottom) { buttonTopY = (int)(drawArgs.ScreenHeight - _outerPadding - button.CurrentSize); } if (button.IsPushed()) { // Draw the chevron float chevronSize = button.CurrentSize * padRatio; enabledChevron[0].Color = chevronColor; enabledChevron[1].Color = chevronColor; enabledChevron[2].Color = chevronColor; if (m_anchor == MenuAnchor.Bottom) { enabledChevron[2].X = centerX - chevronSize; enabledChevron[2].Y = y - 2; enabledChevron[2].Z = 0.0f; enabledChevron[0].X = centerX; enabledChevron[0].Y = y - 2 + chevronSize; enabledChevron[0].Z = 0.0f; enabledChevron[1].X = centerX + chevronSize; enabledChevron[1].Y = y - 2; enabledChevron[1].Z = 0.0f; } else { enabledChevron[2].X = centerX - chevronSize; enabledChevron[2].Y = y + 2; enabledChevron[2].Z = 0.0f; enabledChevron[0].X = centerX; enabledChevron[0].Y = y + 2 + chevronSize; enabledChevron[0].Z = 0.0f; enabledChevron[1].X = centerX + chevronSize; enabledChevron[1].Y = y + 2; enabledChevron[1].Z = 0.0f; } drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable; drawArgs.device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, enabledChevron); drawArgs.device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; } button.RenderEnabledIcon( m_sprite, drawArgs, centerX, buttonTopY, i == this._curSelection, m_anchor); } } m_sprite.End(); } }
public void Render(DrawArgs drawArgs) { if(m_sprite==null) m_sprite = new Sprite(drawArgs.device); if(mouseCursor!=CursorType.Arrow) DrawArgs.MouseCursor = mouseCursor; foreach(MenuButton button in m_toolsMenuButtons) if(button.IsPushed()) // Does not render the button, but the functionality behind the button button.Render(drawArgs); foreach(MenuButton button in m_toolsMenuButtons) button.Update(drawArgs); foreach(MenuButton button in m_layersMenuButtons) button.Update(drawArgs); if(!World.Settings.showToolbar) return; if(this._isHideable) { if(this._visibleState == VisibleState.NotVisible) { if( (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y < MenuButton.NormalSize) || (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y > drawArgs.screenHeight - MenuButton.NormalSize) || (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X > drawArgs.screenWidth - MenuButton.NormalSize) ) { this._visibleState = VisibleState.Ascending; this._lastVisibleChange = System.DateTime.Now; } } else if( (m_anchor == MenuAnchor.Top && DrawArgs.LastMousePosition.Y > 2 * this._outerPadding + MenuButton.NormalSize) || (m_anchor == MenuAnchor.Bottom && DrawArgs.LastMousePosition.Y < drawArgs.screenHeight - 2 * this._outerPadding - MenuButton.NormalSize) || (m_anchor == MenuAnchor.Right && DrawArgs.LastMousePosition.X < drawArgs.screenWidth - MenuButton.NormalSize) ) { if(this._visibleState == VisibleState.Visible) { this._visibleState = VisibleState.Descending; this._lastVisibleChange = System.DateTime.Now; } else if(this._visibleState == VisibleState.Descending) { if(System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.NotVisible; this._lastVisibleChange = System.DateTime.Now; } } } else if(this._visibleState == VisibleState.Ascending) { if(System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.Visible; this._lastVisibleChange = System.DateTime.Now; } } else if(this._visibleState == VisibleState.Descending) { if(System.DateTime.Now.Subtract(this._lastVisibleChange) > System.TimeSpan.FromMilliseconds(hideTimeMilliseconds)) { this._visibleState = VisibleState.NotVisible; this._lastVisibleChange = System.DateTime.Now; } } } else { this._visibleState = VisibleState.Visible; } int totalNumberButtons = m_toolsMenuButtons.Count + m_layersMenuButtons.Count; MenuButton.NormalSize = MenuButton.SelectedSize/2; _outerPadding = MenuButton.NormalSize * padRatio; if(m_anchor == MenuAnchor.Left) { x = 0; y = (int)MenuButton.NormalSize; } else if(m_anchor == MenuAnchor.Right) { x = (int)(drawArgs.screenWidth - 2 * _outerPadding - MenuButton.NormalSize); y = (int)MenuButton.NormalSize; } else if(m_anchor == MenuAnchor.Top) { x = (int)(drawArgs.screenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding); y = 0; } else if(m_anchor == MenuAnchor.Bottom) { x = (int)(drawArgs.screenWidth / 2 - totalNumberButtons * MenuButton.NormalSize / 2 - _outerPadding); y = (int)(drawArgs.screenHeight - 2 * _outerPadding - MenuButton.SelectedSize); } if(this._visibleState == VisibleState.Ascending) { TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange); if(t.Milliseconds < hideTimeMilliseconds) { double percent = (double)t.Milliseconds / hideTimeMilliseconds; int dx = (int)((MenuButton.NormalSize + 5) - (percent * (MenuButton.NormalSize + 5))); if(m_anchor == MenuAnchor.Left) { x -= dx; } else if(m_anchor == MenuAnchor.Right) { x += dx; } else if(m_anchor == MenuAnchor.Top) { y -= dx; } else if(m_anchor == MenuAnchor.Bottom) { y += dx; } } } else if(this._visibleState == VisibleState.Descending) { TimeSpan t = System.DateTime.Now.Subtract(this._lastVisibleChange); if(t.Milliseconds < hideTimeMilliseconds) { double percent = (double)t.Milliseconds / hideTimeMilliseconds; int dx = (int)((percent * (MenuButton.NormalSize + 5))); if(m_anchor == MenuAnchor.Left) { x -= dx; } else if(m_anchor == MenuAnchor.Right) { x += dx; } else if(m_anchor == MenuAnchor.Top) { y -= dx; } else if(m_anchor == MenuAnchor.Bottom) { y += dx; } } } lock(m_toolsMenuButtons.SyncRoot) { MenuButton selectedButton = null; if(_curSelection>=0 & _curSelection < totalNumberButtons) { if(_curSelection < m_toolsMenuButtons.Count) selectedButton = (MenuButton)m_toolsMenuButtons[_curSelection]; else selectedButton = (MenuButton)m_layersMenuButtons[_curSelection - m_toolsMenuButtons.Count]; } _outerPadding = MenuButton.NormalSize*padRatio; float menuWidth = (MenuButton.NormalSize+_outerPadding)*totalNumberButtons+_outerPadding; if(menuWidth>drawArgs.screenWidth) { //MessageBox.Show(drawArgs.screenWidth.ToString()); MenuButton.NormalSize = (drawArgs.screenWidth)/((padRatio+1)*totalNumberButtons+padRatio); //MessageBox.Show(MenuButton.NormalSize.ToString()); _outerPadding = MenuButton.NormalSize*padRatio; } if(this._visibleState != VisibleState.NotVisible) { MenuUtils.DrawBox(0, 0, drawArgs.screenWidth, (int)(MenuButton.NormalSize + 2* _outerPadding), 0.0f, World.Settings.toolBarBackColor, drawArgs.device); } float total = 0; float extra = 0; for(int i = 0; i < totalNumberButtons; i++) { MenuButton button; if(i < m_toolsMenuButtons.Count) button = (MenuButton)m_toolsMenuButtons[i]; else button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count]; total += button.CurrentSize; extra += button.CurrentSize-MenuButton.NormalSize; } float pad = ((float)_outerPadding*(totalNumberButtons+1) - extra)/(totalNumberButtons+1); float buttonX = pad; m_sprite.Begin(SpriteFlags.AlphaBlend); for(int i = 0; i < totalNumberButtons; i++) { MenuButton button; if(i < m_toolsMenuButtons.Count) button = (MenuButton)m_toolsMenuButtons[i]; else button = (MenuButton)m_layersMenuButtons[i - m_toolsMenuButtons.Count]; if(button.IconTexture == null) button.InitializeTexture(drawArgs.device); if(this._visibleState != VisibleState.NotVisible) { int centerX = (int)(buttonX+button.CurrentSize*0.5f); buttonX += button.CurrentSize + pad; float buttonTopY = y + _outerPadding; if(button.IsPushed()) { // Draw the chevron float chevronSize = button.CurrentSize*padRatio; enabledChevron[0].Color = chevronColor; enabledChevron[1].Color = chevronColor; enabledChevron[2].Color = chevronColor; enabledChevron[2].X = centerX - chevronSize; enabledChevron[2].Y = y + 2; enabledChevron[2].Z = 0.0f; enabledChevron[0].X = centerX; enabledChevron[0].Y = y + 2 + chevronSize; enabledChevron[0].Z = 0.0f; enabledChevron[1].X = centerX + chevronSize; enabledChevron[1].Y = y + 2; enabledChevron[1].Z = 0.0f; drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable; drawArgs.device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, enabledChevron); drawArgs.device.TextureState[0].ColorOperation = TextureOperation.SelectArg1; } button.RenderEnabledIcon( m_sprite, drawArgs, centerX, buttonTopY, i == this._curSelection); } } m_sprite.End(); } }
public LineInfo(int startY) { cutOffPositions = null; VisibleState = EagleIslandStudio.Controls.VisibleState.Visible; this.startY = startY; }
public UserAction NextStep(VisibleState state) => UserAction.None;
public VisibleState visibleState; // cant be mixed. if read as mixed, will override to visible public CategorySubType(Product.type_ type) { // Startup constructor, default settings productType = type; visibleState = VisibleState.notVisible; }