public int Clear() { int count = Panels.Count(); Panels.Clear(); return(count); }
private void CreateGridCells() { var rows = _collectionProperties["Rows"].Items.ToArray(); PropertiesNodes.Clear(); var rowsContainer = new GridPanelRowConstructor(rows); for (var i = 0; i < rowsContainer.GetRowCount(); i++) { Panels.Add(CreatePanel()); //регистрируем строку грида в инспекторе объектов //создаем контейнер объектов RegisterGridPanelRowInInspector(i); } for (var i = 0; i < Panels.Count(); i++) { _memento.BeginUpdate(); ObjectInspector.FocusedPropertiesNode = PropertiesNodes[i]; var cells = rowsContainer.GetCells(i); //DesignerExtensions.GetCollection(rows[i], "Cells").ToList(); //устанавливаем количество столбцов, соответствующее суммарном количеству столбцов в строке var columnSpan = cells.Select(s => Convert.ToInt32(s.ColumnSpan)).Cast <int>().ToList(); //устанавливаем для строки количество столбцов Panels[i].SetColumnSpan(columnSpan); _memento.EndUpdate(); } }
public BoardStats GetStats() { BoardStats stats = new BoardStats(); stats.Mines = Panels.Count(x => x.IsMine); stats.FlaggedMinePanels = Panels.Count(x => x.IsMine && x.IsFlagged); stats.PercentMinesFlagged = Math.Round((double)(stats.FlaggedMinePanels / stats.Mines) * 100, 2); stats.TotalPanels = Panels.Count; stats.PanelsRevealed = Panels.Count(x => x.IsFlagged || x.IsRevealed); stats.PercentPanelsRevealed = Math.Round((double)(stats.PanelsRevealed / stats.TotalPanels) * 100, 2); return(stats); }
private void AddManyTo <T>(List <T> ListToAdd, params T[] Panels) where T : Panel { for (int PanelIndex = 0; PanelIndex <= Panels.Count() - 1; ++PanelIndex) { ListToAdd.Add(Panels[PanelIndex]); } }
/// <summary> /// Add /// </summary> /// <param name="obj"></param> /// <returns></returns> public PanelItem AddPanel(int id, string name, UserControl obj) { if (Panels == null) { Panels = new ObservableCollection <PanelItem>(); } PanelItem panel = new PanelItem(id, name, obj); Panels.Add(panel); SelectIndex = Panels.Count(); return(panel); }
private void generateAndUploadToolStripMenuItem_Click(object sender, EventArgs e) { if (Panels.Count(pnl => !pnl.GetModel().IsMenu) <= 0) { ShowError("There is no code to upload", "Check error"); return; } if (JoyInfos.Count == 0) { ShowError("Joystick infromation is absent!", "Check error"); return; } toolStripCompileLabel.Text = CommonResources.fmMain_generateProjectToolStripMenuItem_Click_Generating____; if (!ExecuteStep(() => JoyInfos.ForEach(j => j.Check()))) { return; } if (string.IsNullOrEmpty(Settings.OutputPath)) { ShowError("Output path is not set"); return; } var gen = new CodeGenerator(__Settings, __JoyInfos, Panels.ToArray(), ExecuteStep); if (!gen.GenerateProject()) { return; } toolStripCompileLabel.Text = CommonResources.fmMain_generateProjectToolStripMenuItem_Click_Generation_successed; SetChangedState(); var fUpload = new FlashBoardDialog429(); fUpload.ProgramCode = gen.ByteCode; fUpload.ShowDialog(this); }
private void generateAndUploadToolStripMenuItem_Click(object sender, EventArgs e) { if (Panels.Count(pnl => !pnl.GetModel().IsMenu) > 0) { if (JoyInfo == null) { ShowError("Joystick infromation is absent!", "Check error"); return; } toolStripCompileLabel.Text = "Generating ..."; if (!ExecuteStep(() => JoyInfo.Check())) { return; } if (string.IsNullOrEmpty(Settings.OutputPath)) { ShowError("Output path is not set"); return; } var gen = new CodeGenerator(__Settings, __JoyInfo, Panels.ToArray(), ExecuteStep); if (!gen.GenerateProject()) { return; } toolStripCompileLabel.Text = "Generation successed"; SetChangedState(); var fUpload = new FlashBoardDialog(); fUpload.ProgramCode = gen.ByteCode; fUpload.ShowDialog(this); } else { var fUpload = new FlashBoardDialog(); fUpload.ProgramCode = null; fUpload.ShowDialog(this); } }
protected virtual void ResizePanels(int deltaWidth, bool fit = false) { if (Splits.Count == 0) { return; } var currentSplit = 0; var oldSplit = 0; //var oldWidth = Splits[Splits.Count - 1]; var oldWidth = 0; for (var i = 0; i < Panels.Count; i++) { if (Panels[i].StaticWidth == 0) { oldWidth += Splits[i] - (i == 0 ? 0 : Splits[i - 1]); } } for (var i = 0; i < Panels.Count; i++) { var splitWidth = Splits[i] - oldSplit; var panelDelta = Panels[i].StaticWidth > 0 ? 0 : (oldWidth > 0 ? ((float)splitWidth / oldWidth) : (1f / Panels.Count(p => p.StaticWidth == 0))) * deltaWidth; oldSplit = Splits[i]; currentSplit = Splits[i] = (int)(currentSplit + splitWidth + panelDelta); } if (fit) { Splits[Splits.Count - 1] = FullSize; } AdjustPanels(); }