public virtual void ShowStars() { if (LabelObject != null) { LabelObject.SetActive(true); } if (!IsLocked) { if (UnlockedObject != null) { UnlockedObject.SetActive(true); } if (LockedObject != null) { LockedObject.SetActive(false); } } else { if (UnlockedObject != null) { UnlockedObject.SetActive(false); } if (LockedObject != null) { LockedObject.SetActive(true); } } }
protected override void FillCanvas() { LabelObject l; int i = 0, w, h; w = StyleConf.TimelineLabelsWidth; h = StyleConf.TimelineCategoryHeight; l = new LabelObject (w, h, i * h); l.Name = Catalog.GetString ("Periods"); AddLabel (l, null); i++; foreach (Timer t in project.Timers) { l = new TimerLabelObject (t, w, h, i * h); AddLabel (l, t); i++; } foreach (EventType eventType in project.EventTypes) { /* Add the category label */ l = new EventTypeLabelObject (eventType, w, h, i * h); AddLabel (l, eventType); i++; } double width = labelToObject.Keys.Max (la => la.RequiredWidth); foreach (LabelObject lo in labelToObject.Keys) { lo.Width = width; } WidthRequest = (int)width; }
private void AddNewLabel() { if (!CheckLicense()) { return; } List <string> labelNames = new List <string>(); foreach (var view in LabelViewList) { labelNames.Add((view.DataContext as LabelViewModel).Label.Name); } var newLabel = new LabelObject(); var olViewModel = new OptionLabelViewModel(newLabel, true); var olView = new OptionLabelView(); olView.DataContext = olViewModel; if (DialogService.ShowSelectDialog(Application.Current.MainWindow, olView, "Create New Label") == true) { var newLVM = new LabelViewModel(RegionManager); newLVM.Label = newLabel; AddLabel(newLVM); } }
public void Relayout() { if (m_label == null) { m_label = new LabelObject(this, m_font, string.Empty, LabelAlign.Start, LabelAlign.Start, m_richText); } m_label.Color = base.Color; m_label.Alpha = Alpha; m_label.Scale = m_fontSize; m_label.Text = m_text; Vector2 minSize = m_label.Size * m_fontSize; if (minSize.X < Size.X) { minSize.X = Size.X; } if (minSize.Y < Size.Y) { minSize.Y = Size.Y; } Size = minSize; RelayoutText(); m_needLayout = false; }
public void CreateNewLabelObject_Name_ReturnPropertyName() { LabelObject lo = new LabelObject("Text static_1"); var actual = lo.ObjectName; string expected = "Text static_1"; Assert.Equal(expected, actual); }
public IEnumerator GetLabelObject_Passes() { var gameObject = new GameObject("obj"); var label = gameObject.AddComponent <LabelObject>(); Assert.AreSame(label, LabelObject.GetLabelObject(gameObject)); Assert.AreSame(label, LabelObject.GetLabelObject(gameObject.transform)); Assert.AreSame(label, LabelObject.GetLabelObject(label)); Assert.IsNull(LabelObject.GetLabelObject(100)); Assert.IsNull(LabelObject.GetLabelObject("")); yield break; }
/// <summary> /// Восстановление объекта из xml /// </summary> public LabelViewModel(LabelObject storedObj, DataProvider dataProvider) { if (storedObj == null || dataProvider?.CommonSettings == null) { return; } Properties = new ObjectBaseProperties(storedObj.Id, storedObj.Name, dataProvider.CommonSettings.AppMode, dataProvider.ObjectsRepository); Properties.FontSettings.Update(storedObj.FontSettings); TextProperties = new ObjectTextProperties(dataProvider.VariablesRepository) { Text = storedObj.Text }; }
private void btnDraw_Click(object sender, System.EventArgs e) { IDataManager idm = new DBDataManager(); FormulaChart fc = FormulaChart.CreateChart(idm["MSFT"]); fc.EndTime = new DateTime(2004, 1, 9); fc.StartTime = fc.EndTime.AddMonths(-8); ObjectManager om = ObjectManager.FromChart(fc); if (cbPriceLabel.Checked) { LabelObject lo = new LabelObject(); lo.InitPriceDateLabel(); lo.ControlPoints[0] = GetObjectPoint(tbPriceDate.Text, tbLablePrice.Text); om.AddObject(lo); } ; if (cbArrowLine.Checked) { LineObject lo = new LineObject(); lo.LinePen.Width = 5; lo.LinePen.Color = Color.Red; lo.LinePen.Alpha = 100; lo.LinePen.DashStyle = DashStyle.DashDotDot; lo.InitArrowCap(); lo.ControlPoints[0] = GetObjectPoint(tbArrowStartDate.Text, tbArrowStartPrice.Text); lo.ControlPoints[1] = GetObjectPoint(tbArrowStopDate.Text, tbArrowStopPrice.Text); om.AddObject(lo); } if (cbRegression.Checked) { LinearRegressionObject lro = new LinearRegressionObject(); lro.InitChannel(); lro.ControlPoints[0] = GetObjectPoint(tbRegStartDate.Text, "10"); lro.ControlPoints[1] = GetObjectPoint(tbRegStopDate.Text, "10"); lro.ShowAuxLine = true; om.AddObject(lro); } ibChart.ImageUrl = fc.SaveToWeb(800, 600); }
public void Relayout() { if (m_label != null && m_needRecreate) { m_label.Remove(); m_label = null; } if (m_label == null) { m_label = new LabelObject(this, Font, string.Empty, LabelAlign.Start, LabelAlign.Start, RichText); } m_label.Color = Color; m_label.Alpha = Alpha; m_label.Scale = FontSize; if (!string.IsNullOrEmpty(m_text)) { m_label.Text = m_text; } Vector2 minSize = m_label.Size * FontSize; if (minSize.X < Size.X) { minSize.X = Size.X; } if (minSize.Y < Size.Y) { minSize.Y = Size.Y; } Size = minSize; RelayoutText(); m_needLayout = false; }
private void Relayout() { if (m_label == null) { m_label = new LabelObject(this, m_font, string.Empty, LabelAlign.Start, LabelAlign.Start); m_label.Position = m_padding.TopLeft; } m_label.Scale = m_fontSize; if (m_cursor == null) { m_cursor = m_font.GetSprites(m_cursorChar.ToString(), Vector2.Zero)[0]; m_cursor.Color = m_cursorColor; m_cursor.Scale = m_fontSize; //m_cursor.Blink(2000); m_cursor.Transform.Parent = Transform; } Vector2 minSize = m_label.Size * m_fontSize + m_padding.Size; if (minSize.X < Size.X) { minSize.X = Size.X; } if (minSize.Y < Size.Y) { minSize.Y = Size.Y; } Size = minSize; m_needLayout = false; UpdateCursor(0); UpdateColor(); }
void FillCanvas() { LabelObject l; int i = 0, w, h; double requiredWidth; w = StyleConf.TimelineLabelsWidth; h = StyleConf.TimelineCategoryHeight; widget.Width = w; l = new LabelObject(w, h, i * h); l.Name = Catalog.GetString("Periods"); AddLabel(l, null); i++; foreach (Timer t in project.Timers) { l = new TimerLabelObject(t, w, h, i * h); AddLabel(l, t); i++; } foreach (EventType eventType in project.EventTypes) { /* Add the category label */ l = new EventTypeLabelObject(eventType, w, h, i * h); AddLabel(l, eventType); i++; } requiredWidth = labelToObject.Keys.Max(la => la.RequiredWidth); foreach (LabelObject lo in labelToObject.Keys) { lo.Width = requiredWidth; } widget.Width = requiredWidth; }
private void Relayout() { if (m_label == null) { m_label = new LabelObject(this, Font, MaskText(m_text, MaskChar), LabelAlign.Start, LabelAlign.Start); m_label.Position = TextPadding.TopLeft; } else { m_label.Text = MaskText(m_text, MaskChar); } m_label.Color = TextColor; m_label.Scale = FontSize; m_label.Alpha = Alpha; if (m_cursor == null) { m_cursor = new ImageObject(this, Font.GetSprites(CursorChar, Vector2.Zero)[0]); m_cursor.Sprite.Color = CursorColor; m_cursor.Scale = FontSize; m_cursor.Transform.Parent = Transform; } /* // Nomad: I'm not sure it is normal to resize text edit depending on it's content. It looks like leftovers from WidgetLabel copy-paste * Vector2 minSize = m_label.Size * FontSize + TextPadding.Size; * if (minSize.X < Size.X) * minSize.X = Size.X; * if (minSize.Y < Size.Y) * minSize.Y = Size.Y; * * Size = minSize;*/ m_needLayout = false; UpdateCursor(0); }
private void UpdateTextPosition() { float y = 0; for (int i = 0; i < m_labels.Length; i++) { LabelObject label = m_labels[i]; float x; //if ((TextAlign & WidgetAlign.HorizontalCenter) == WidgetAlign.HorizontalCenter) //x = (m_contentSize.X - label.Size.X) / 2; //else if ((TextAlign & WidgetAlign.Right) == WidgetAlign.Right) //x = m_contentSize.X - label.Size.X; //else x = 0; label.Position = TextPadding.TopLeft + m_contentOffset + new Vector2(x, y); m_labels[i] = label; y += m_lineHeight; } }
private static LabelFile_1 LabelToFile_1(LabelObject lo) { return(new LabelFile_1() { Name = lo.Name, Width = lo.Width, Height = lo.Height, Margin = lo.Margin, Radius = lo.Radius, SelectedPrinter = lo.SelectedPrinter, SelectedDpi = lo.SelectedDpi, OffsetX = lo.OffsetX, OffsetY = lo.OffsetY, NumberOfCopies = lo.NumberOfCopies, RepeatOfInputs = lo.RepeatOfInputs, EnableSequentialInputs = lo.EnableSequentialInputs, SerialNumberStartIndex = lo.SerialNumberStartIndex, SerialNumberLength = lo.SerialNumberLength, LastSerialNumber = lo.LastSerialNumber }); }
public override bool Touch(float x, float y, bool press, bool unpress, int pointer) { if (press) { bool wasFocused = IsFocused; SetFocused(true); LabelObject label = null; for (int i = 0; i < m_labels.Length; i++) { if (m_labels[i].HitTest(x, y)) { label = m_labels[i]; m_cursorLine = i; break; } } Vector2 local = Transform.GetClientPoint(new Vector2(x, y)) - m_contentOffset; if (label == null) { m_cursorLine = (int)Math.Floor(local.Y / m_lineHeight); m_contentOffset.X = 0; if (m_cursorLine < 0) { m_cursorLine = 0; m_cursorLinePosition = 0; } else { if (m_cursorLine > m_lines.Length - 1) { m_cursorLine = m_lines.Length - 1; } m_cursorLinePosition = m_lines[m_cursorLine].Length; } UpdateCursor(0, 0); } else { bool spriteFound = false; float lx = local.X / FontSize; ISprite[] sprites = label.InternalGetSprites(); for (int i = 0; i < sprites.Length; i++) { if (lx < sprites[i].Position.X + sprites[i].FrameSize.X / 2) { m_cursorLinePosition = i; spriteFound = true; break; } } if (!spriteFound) { if (local.X < label.Position.X) { m_cursorLinePosition = 0; } else if (local.X > label.Position.X + label.Size.X) { m_cursorLinePosition = m_lines[m_cursorLine].Length; } } UpdateCursor(0, 0); } } if (!press && !unpress && !Hovered) { Hovered = true; WindowController.Instance.OnTouch += UnHoverTouch; } return(true); }
private void Relayout() { m_lines = m_text.Split(new string[] { "\r", "\n" }, StringSplitOptions.None); if (m_lines.Length == 0) { m_lines = new string[] { "" } } ; else if (m_lines.Length > 1) { m_text = string.Join("\n", m_lines); // we need it to avoid multi-char line feeds } m_lineHeight = (int)((Font.Height + LineSpacing) * FontSize + 0.5f); Vector2 maxSize = new Vector2(Size.X, 0); Vector2[] sizes = new Vector2[m_lines.Length]; for (int i = 0; i < m_lines.Length; i++) { string line = m_lines[i]; Vector2 size = Font.MeasureString(line); size = new Vector2(size.X * FontSize, m_lineHeight); maxSize = new Vector2(Math.Max(size.X, maxSize.X), size.Y + maxSize.Y); sizes[i] = size; m_lines[i] = line; } m_contentSize = maxSize + TextPadding.Size; if (m_labels == null || m_lines.Length != m_labels.Length) { m_labels = new LabelObject[m_lines.Length]; } for (int i = 0; i < m_lines.Length; i++) { if (m_labels[i] == null) { m_labels[i] = new LabelObject(this, Font, string.Empty, LabelAlign.Start, LabelAlign.Start, false); } m_labels[i].Color = TextColor; m_labels[i].Scale = FontSize; m_labels[i].Alpha = Alpha; m_labels[i].Text = m_lines[i]; m_labels[i].Size = sizes[i] / FontSize; } if (m_cursor == null) { m_cursor = new ImageObject(this, Font.GetSprites(CursorChar, Vector2.Zero)[0]); m_cursor.Sprite.Color = CursorColor; m_cursor.Scale = FontSize; m_cursor.Transform.Parent = Transform; } m_needLayout = false; UpdateCursor(0, 0); }
public static void RemoveLabel(LabelObject obj) { _objects[(int)LAYER_ORDER.LABELS].Remove(obj); }
void AddLabel(LabelObject label) { Objects.Add (label); }
public void Relayout() { string[] lines = m_text.Split(new string[] { "\r", "\n", "|n", "\\n" }, StringSplitOptions.None); float lineHeight = (m_font.Height + m_lineSpacing) * m_fontSize; // TODO: spacing Vector2 maxSize = Vector2.Zero; Vector2[] sizes = new Vector2[lines.Length]; LabelObject.TextSpan[][] colors = null; if (m_richText) { colors = new LabelObject.TextSpan[lines.Length][]; } for (int i = 0; i < lines.Length; i++) { string line = lines[i]; if (m_richText) { line = LabelObject.ParseRichText(line, Color, out colors[i], m_font.SpaceWidth + m_font.Spacing); } Vector2 size = m_font.MeasureString(line); size = new Vector2(size.X * m_fontSize, lineHeight); maxSize = new Vector2(Math.Max(size.X, maxSize.X), size.Y + maxSize.Y); sizes[i] = size; lines[i] = line; } if (m_maxWidth == 0 || m_maxWidth > maxSize.X) { Size = new Vector2(Math.Max(maxSize.X, Size.X), Math.Max(Size.Y, maxSize.Y)); } else { // Perform text wrapping List <string> newLines = new List <string>(); List <Vector2> newSizes = new List <Vector2>(); List <ArraySegment <LabelObject.TextSpan> > newColors = new List <ArraySegment <LabelObject.TextSpan> >(); for (int i = 0; i < lines.Length; i++) { if (sizes[i].X > m_maxWidth) { float[] charSizes = m_font.MeasureChars(lines[i]); float width = 0; int lastSeparator = -1; int start = 0; for (int j = 0; j < charSizes.Length; j++) { if (Array.IndexOf(s_separatorChars, lines[i][j]) != -1) { lastSeparator = j; } width += charSizes[j] * m_fontSize; if (width > m_maxWidth) { if (lastSeparator == -1) { lastSeparator = j; } string line = lines[i].Substring(start, lastSeparator - start); newLines.Add(line); width = 0; for (int k = start; k < lastSeparator; k++) { width += charSizes[k] * m_fontSize; } newSizes.Add(new Vector2(width, lineHeight)); if (m_richText) { newColors.Add(new ArraySegment <LabelObject.TextSpan>(colors[i], start, lastSeparator - start)); } if (lines[i][lastSeparator] == ' ') // skip line start space { lastSeparator++; } start = lastSeparator; width = 0; for (int k = lastSeparator; k <= j; k++) { width += charSizes[k] * m_fontSize; } lastSeparator = -1; } } if (start != charSizes.Length - 1) { newLines.Add(lines[i].Substring(start)); newSizes.Add(new Vector2(width, lineHeight)); if (m_richText) { newColors.Add(new ArraySegment <LabelObject.TextSpan>(colors[i], start, colors[i].Length - start)); } } } else { newLines.Add(lines[i]); newSizes.Add(sizes[i]); if (m_richText) { newColors.Add(new ArraySegment <LabelObject.TextSpan>(colors[i])); } } } lines = newLines.ToArray(); sizes = newSizes.ToArray(); if (m_richText) { LabelObject.TextSpan[][] newColorsArray = new LabelObject.TextSpan[newColors.Count][]; for (int i = 0; i < newColors.Count; i++) { ArraySegment <LabelObject.TextSpan> segment = newColors[i]; newColorsArray[i] = new LabelObject.TextSpan[segment.Count]; Array.Copy(segment.Array, segment.Offset, newColorsArray[i], 0, segment.Count); } colors = newColorsArray; } float height = sizes.Length * lineHeight; Size = new Vector2(Math.Max(Size.X, m_maxWidth), Math.Max(Size.Y, height)); } m_labels = new LabelObject[lines.Length]; float y = 0; for (int i = 0; i < lines.Length; i++) { LabelObject label = new LabelObject(this, m_font, string.Empty, LabelAlign.Start, LabelAlign.Start, false); label.Color = Color; label.Scale = m_fontSize; label.Alpha = Alpha; label.Text = lines[i]; if (m_richText) { label.SetColors(colors[i]); } float x = 0; if ((m_textAlign & WidgetAlign.HorizontalCenter) == WidgetAlign.HorizontalCenter) { x = (Size.X - sizes[i].X) / 2; } else if ((m_textAlign & WidgetAlign.Right) == WidgetAlign.Right) { x = Size.X - sizes[i].X; } label.Position = new Vector2(x, y); m_labels[i] = label; y += lineHeight; } m_needLayout = false; }
public static void AddLabel(LabelObject obj) { _objects[(int)LAYER_ORDER.LABELS].Add(obj); }
void AddLabel(LabelObject label) { Objects.Add(label); }
private void InitializeNetworkWindow() { /*Нахожу поднятые интерфейсы*/ networkInterfaces = new List <NetworkInterface>(); NetworkInterface[] allInterfaces = NetworkInterface.GetAllNetworkInterfaces(); for (int i = 0; i < allInterfaces.Length; ++i) { if (allInterfaces[i].OperationalStatus == OperationalStatus.Up) { networkInterfaces.Add(allInterfaces[i]); } } currentInterface = 0; networkWindow = new Window(2, 14, 70, 24, "Сетевая статистика", false, 3, ref app); networkWindow.TimerTick += NetworkWindow_TimerTick; networkWindow.BackgroundColor = ConsoleColor.Blue; ButtonObject btnExitNetwork = new ButtonObject(networkWindow.Left + networkWindow.Width - 12 , networkWindow.Top + networkWindow.Height - 2, 9, 1, true, false, "Закрыть"); btnExitNetwork.BackgroundColor = ConsoleColor.DarkGray; btnExitNetwork.ButtonClicked += BtnExit_ButtonClicked1; LabelObject labelName = new LabelObject(networkWindow.Left + 2, networkWindow.Top + 2, 40, 1, false, false, "Интерфейсы"); labelName.BackgroundColor = ConsoleColor.Gray; labelName.TextColor = ConsoleColor.Black; ListObject listInterfaces = new ListObject(networkWindow.Left + 2, networkWindow.Top + 3, 66, 2, false, false); listInterfaces.ButtonClicked += ListInterfaces_ButtonClicked; listInterfaces.BackgroundColor = ConsoleColor.Blue; listInterfaces.BackgroundActiveColor = ConsoleColor.White; listInterfaces.TextColor = ConsoleColor.White; listInterfaces.List = new List <string>(); for (int i = 0; i < networkInterfaces.Count; ++i) { listInterfaces.List.Add(networkInterfaces[i].Name); } /////////////////////////////////////////Заголовки подписей///////////////// LabelObject labelTitle = new LabelObject(listInterfaces.Left, listInterfaces.Top + 3, 9, 1, false, false, "Название: "); labelTitle.BackgroundColor = ConsoleColor.Blue; labelTitle.TextColor = ConsoleColor.White; LabelObject labelDescription = new LabelObject(listInterfaces.Left, labelTitle.Top + 1, 9, 1, false, false, "Описание: "); labelDescription.BackgroundColor = ConsoleColor.Blue; labelDescription.TextColor = ConsoleColor.White; LabelObject labelMAC = new LabelObject(listInterfaces.Left, labelTitle.Top + 2, 10, 1, false, false, "MAC-адрес: "); labelMAC.BackgroundColor = ConsoleColor.Blue; labelMAC.TextColor = ConsoleColor.White; LabelObject labelStatistics = new LabelObject(labelMAC.Left, labelMAC.Top + 2, 40, 1, false, false, "Статистика"); labelStatistics.BackgroundColor = ConsoleColor.Gray; labelStatistics.TextColor = ConsoleColor.Black; LabelObject labelDownload = new LabelObject(listInterfaces.Left, labelStatistics.Top + 1, 34, 1, false, false, "Пакетов принято(входящий трафик): "); labelDownload.BackgroundColor = ConsoleColor.Blue; labelDownload.TextColor = ConsoleColor.White; LabelObject labelUpload = new LabelObject(listInterfaces.Left, labelDownload.Top + 1, 39, 1, false, false, "Пакетов отправлено(исходящий трафик): "); labelUpload.BackgroundColor = ConsoleColor.Blue; labelUpload.TextColor = ConsoleColor.White; LabelObject labelDownloadSpeed = new LabelObject(listInterfaces.Left, labelUpload.Top + 2, 40, 1, false, false, "Скорость получения:"); labelDownloadSpeed.BackgroundColor = ConsoleColor.Blue; labelDownloadSpeed.TextColor = ConsoleColor.White; LabelObject labelUploadSpeed = new LabelObject(listInterfaces.Left, labelDownloadSpeed.Top + 4, 40, 1, false, false, "Скорость отдачи:"); labelUploadSpeed.BackgroundColor = ConsoleColor.Blue; labelUploadSpeed.TextColor = ConsoleColor.White; ///////////////////////////////////////////Вставляемая информация///////////////// LabelObject labelTitleinfo = new LabelObject(labelTitle.Left + labelTitle.Width + 1, labelTitle.Top, 40, 1, false, false, networkInterfaces[listInterfaces.ActiveLine].Name); labelTitleinfo.BackgroundColor = ConsoleColor.Blue; labelTitleinfo.TextColor = ConsoleColor.White; LabelObject labelDescriptioninfo = new LabelObject(labelDescription.Left + labelTitle.Width + 1, labelTitle.Top + 1, 55, 1, false, false, networkInterfaces[listInterfaces.ActiveLine].Description); labelDescriptioninfo.BackgroundColor = ConsoleColor.Blue; labelDescriptioninfo.TextColor = ConsoleColor.White; LabelObject labelMACinfo = new LabelObject(labelMAC.Left + labelTitle.Width + 2, labelMAC.Top, 55, 1, false, false, networkInterfaces[listInterfaces.ActiveLine].GetPhysicalAddress().ToString()); labelMACinfo.BackgroundColor = ConsoleColor.Blue; labelMACinfo.TextColor = ConsoleColor.White; var ipstat = networkInterfaces[currentInterface].GetIPv4Statistics(); oldBytesRecived = ipstat.BytesReceived; oldBytesSent = ipstat.BytesSent; LabelObject labelDownloadinfo = new LabelObject(labelDownload.Left + labelDownload.Width, labelDownload.Top, 20, 1, false, false, ipstat.UnicastPacketsReceived.ToString() + "/" + (ipstat.BytesReceived / 1024 / 1024).ToString() + " Мбайт"); labelDownloadinfo.BackgroundColor = ConsoleColor.Blue; labelDownloadinfo.TextColor = ConsoleColor.White; LabelObject labelUploadinfo = new LabelObject(labelUpload.Left + labelUpload.Width, labelUpload.Top, 20, 1, false, false, ipstat.UnicastPacketsSent.ToString() + "/" + (ipstat.BytesSent / 1024 / 1024).ToString() + " Мбайт"); labelUploadinfo.BackgroundColor = ConsoleColor.Blue; labelUploadinfo.TextColor = ConsoleColor.White; MaxSpeed = 100; ProgressObject progressInput = new ProgressObject(labelStatistics.Left, labelDownloadSpeed.Top + 1, 50, 2, false, false); progressInput.TextColor = ConsoleColor.White; progressInput.BackgroundTextColor = ConsoleColor.Blue; progressInput.BackgroundColor = ConsoleColor.DarkCyan; progressInput.PercentColor = ConsoleColor.Yellow; progressInput.Min = "0"; progressInput.Max = MaxSpeed.ToString() + " Мбит/c"; ProgressObject progressOutput = new ProgressObject(labelStatistics.Left, labelUploadSpeed.Top + 1, 50, 2, false, false); progressOutput.TextColor = ConsoleColor.White; progressOutput.BackgroundTextColor = ConsoleColor.Blue; progressOutput.BackgroundColor = ConsoleColor.DarkCyan; progressOutput.PercentColor = ConsoleColor.Yellow; progressOutput.Min = "0"; progressOutput.Max = MaxSpeed.ToString() + " Мбит/c"; networkWindow.AddChildren(btnExitNetwork); networkWindow.AddChildren(labelName); networkWindow.AddChildren(listInterfaces); networkWindow.AddChildren(labelTitle); networkWindow.AddChildren(labelDescription); networkWindow.AddChildren(labelMAC); networkWindow.AddChildren(labelStatistics); networkWindow.AddChildren(labelDownload); networkWindow.AddChildren(labelUpload); networkWindow.AddChildren(labelDownloadSpeed); networkWindow.AddChildren(labelUploadSpeed); networkWindow.AddChildren(labelTitleinfo); networkWindow.AddChildren(labelDescriptioninfo); networkWindow.AddChildren(labelMACinfo); networkWindow.AddChildren(labelDownloadinfo); networkWindow.AddChildren(labelUploadinfo); networkWindow.AddChildren(progressOutput); networkWindow.AddChildren(progressInput); }
private void InitializeProcessWindow() { processWindow = new Window(74, 20, 70, 18, "Информация о процессах", false, 2, ref app); processWindow.BackgroundColor = ConsoleColor.Blue; processWindow.TextColor = ConsoleColor.White; ButtonObject btnExitProcessWindow = new ButtonObject(processWindow.Left + processWindow.Width - 11, processWindow.Top + processWindow.Height - 2, 9, 1, false, false, "Закрыть"); btnExitProcessWindow.ButtonClicked += BtnExitProcessWindow_ButtonClicked; btnExitProcessWindow.BackgroundColor = ConsoleColor.DarkGray; ButtonObject btnUpdateProcess = new ButtonObject(processWindow.Left + processWindow.Width - 31, processWindow.Top + processWindow.Height - 2, 19, 1, false, false, "Обновить процессы"); btnUpdateProcess.ButtonClicked += BtnUpdateProcess_ButtonClicked; btnUpdateProcess.BackgroundColor = ConsoleColor.DarkGray; #region Заголовок "Процессы" LabelObject labelProcess = new LabelObject(processWindow.Left + 2, processWindow.Top + 2, 20, 1, false, false, "Процессы"); labelProcess.BackgroundColor = ConsoleColor.Gray; labelProcess.TextColor = ConsoleColor.Black; #endregion #region Список процессов ListObject listProcess = new ListObject(processWindow.Left + 2, labelProcess.Top + 2, 20, 10, true, false); listProcess.BackgroundColor = ConsoleColor.Blue; listProcess.BackgroundActiveColor = ConsoleColor.White; listProcess.ButtonClicked += ListProcess_ButtonClicked; listProcess.List = new List <string>(); Process[] allprocess = Process.GetProcesses(); processModule = new List <ProcessModuleCollection>(); process = new List <Process>(); for (int i = 0; i < allprocess.Length; i++) { try { processModule.Add(allprocess[i].Modules); process.Add(allprocess[i]); } catch { continue; } } for (int i = 0; i < process.Count; ++i) { listProcess.List.Add(process[i].ProcessName); } #endregion #region Список модулей для выбранного процесса LabelObject labelModule = new LabelObject(labelProcess.Left + labelProcess.Width + 1, labelProcess.Top, 45, 1, false, false, "Список модулей для " + process[listProcess.ActiveLine].ProcessName); labelModule.BackgroundColor = ConsoleColor.Gray; labelModule.TextColor = ConsoleColor.Black; #endregion #region Список модулей ListObject listModule = new ListObject(labelModule.Left, labelModule.Top + 2, 45, 10, false, false); listModule.BackgroundColor = ConsoleColor.Blue; listModule.BackgroundActiveColor = ConsoleColor.White; listModule.List = new List <string>(); ProcessModuleCollection pm = processModule[listProcess.ActiveLine]; for (int i = 0; i < pm.Count; ++i) { listModule.List.Add(pm[i].FileName); } #endregion processWindow.AddChildren(labelProcess); processWindow.AddChildren(labelModule); processWindow.AddChildren(listProcess); processWindow.AddChildren(listModule); processWindow.AddChildren(btnExitProcessWindow); processWindow.AddChildren(btnUpdateProcess); }
private void InitializeCharacterWindow() { characterWindow = new Window(74, 2, 70, 16, "Информация о системе", false, 1, ref app); characterWindow.BackgroundColor = ConsoleColor.Blue; characterWindow.TextColor = ConsoleColor.White; characterWindow.TimerTick += CharacterWindow_TimerTick; #region Операционная система LabelObject labelOS = new LabelObject(characterWindow.Left + 2, characterWindow.Top + 2, 21, 1, false, false, "Операционная система:"); labelOS.BackgroundColor = ConsoleColor.Blue; labelOS.TextColor = ConsoleColor.White; LabelObject labelOSinfo = new LabelObject(characterWindow.Left + 2 + 24, characterWindow.Top + 2, 40, 2, false, false, Environment.OSVersion.VersionString + " " + Environment.OSVersion.Platform.ToString()); labelOSinfo.BackgroundColor = ConsoleColor.Blue; labelOSinfo.TextColor = ConsoleColor.White; #endregion #region азрядность LabelObject labelBit = new LabelObject(labelOS.Left, labelOSinfo.Top + 2, 21, 1, false, false, "Разрядность:"); labelBit.BackgroundColor = ConsoleColor.Blue; labelBit.TextColor = ConsoleColor.White; bool Is64 = Environment.Is64BitOperatingSystem; string bit; if (Is64) { bit = "x64"; } else { bit = "x86"; } LabelObject labelBitinfo = new LabelObject(labelOSinfo.Left, labelOSinfo.Top + 2, 40, 2, false, false, bit); labelBitinfo.BackgroundColor = ConsoleColor.Blue; labelBitinfo.TextColor = ConsoleColor.White; #endregion #region Число ядер процессора LabelObject labelCore = new LabelObject(labelOS.Left, labelBitinfo.Top + 2, 21, 1, false, false, "Число ядер:"); labelCore.BackgroundColor = ConsoleColor.Blue; labelCore.TextColor = ConsoleColor.White; LabelObject labelCoreinfo = new LabelObject(labelOSinfo.Left, labelBitinfo.Top + 2, 40, 2, false, false, Environment.ProcessorCount.ToString()); labelCoreinfo.BackgroundColor = ConsoleColor.Blue; labelCoreinfo.TextColor = ConsoleColor.White; #endregion #region Имя компьютера LabelObject labelMachineName = new LabelObject(labelOS.Left, labelCoreinfo.Top + 2, 21, 1, false, false, "Имя компьютера:"); labelMachineName.BackgroundColor = ConsoleColor.Blue; labelMachineName.TextColor = ConsoleColor.White; LabelObject labelMachineNameinfo = new LabelObject(labelOSinfo.Left, labelCoreinfo.Top + 2, 40, 2, false, false, Environment.MachineName); labelMachineNameinfo.BackgroundColor = ConsoleColor.Blue; labelMachineNameinfo.TextColor = ConsoleColor.White; #endregion #region Имя пользователя LabelObject labelUserName = new LabelObject(labelOS.Left, labelMachineName.Top + 2, 21, 1, false, false, "Имя пользователя:"); labelUserName.BackgroundColor = ConsoleColor.Blue; labelUserName.TextColor = ConsoleColor.White; LabelObject labelUserNameinfo = new LabelObject(labelOSinfo.Left, labelMachineName.Top + 2, 40, 2, false, false, Environment.UserName); labelUserNameinfo.BackgroundColor = ConsoleColor.Blue; labelUserNameinfo.TextColor = ConsoleColor.White; #endregion #region Системное время LabelObject labelTime = new LabelObject(labelOS.Left, labelUserNameinfo.Top + 2, 21, 1, false, false, "Системное время:"); labelTime.BackgroundColor = ConsoleColor.Blue; labelTime.TextColor = ConsoleColor.White; LabelObject labelTimeinfo = new LabelObject(labelOSinfo.Left, labelUserNameinfo.Top + 2, 40, 2, false, false, DateTime.Now.ToLongTimeString()); labelTimeinfo.BackgroundColor = ConsoleColor.Blue; labelTimeinfo.TextColor = ConsoleColor.White; #endregion ButtonObject btnExitCharacterWindow = new ButtonObject(characterWindow.Left + characterWindow.Width - 11, characterWindow.Top + characterWindow.Height - 2, 9, 1, true, false, "Закрыть"); btnExitCharacterWindow.TextColor = ConsoleColor.Black; btnExitCharacterWindow.BackgroundColor = ConsoleColor.DarkGray; btnExitCharacterWindow.ButtonClicked += BtnExitCharacterWindow_ButtonClicked; characterWindow.AddChildren(labelOS); characterWindow.AddChildren(labelOSinfo); characterWindow.AddChildren(labelBit); characterWindow.AddChildren(labelBitinfo); characterWindow.AddChildren(labelCore); characterWindow.AddChildren(labelCoreinfo); characterWindow.AddChildren(labelMachineName); characterWindow.AddChildren(labelMachineNameinfo); characterWindow.AddChildren(labelUserName); characterWindow.AddChildren(labelUserNameinfo); characterWindow.AddChildren(labelTime); characterWindow.AddChildren(labelTimeinfo); characterWindow.AddChildren(btnExitCharacterWindow); }
void AddLabel(LabelObject label, object obj) { Objects.Add(label); labelToObject [label] = obj; }