public void AllOneColor(Color Color) { pixelColors = new List<Color>(); for (int i = 0; i < spi.PixelCount; i++) { pixelColors.Add(Color.FromArgb(255, Color.R,Color.G,Color.B)); } SPIclass.SendPixels(pixelColors); }
public ColorPickerMenuItem(Color color) { Color = color; _fillBrush = new SolidBrush(Color); _borderPen = new Pen( Color.FromArgb( (int)(color.R / 1.5f), (int)(color.G / 1.5f), (int)(color.B / 1.5f) ) ); }
private Color ChangeOpacity(Color c, float opacity) { return(Color.FromArgb((int)(opacity * c.A), c)); }
private void m_btnUpload_Click(object sender, RoutedEventArgs e) { //文件名 if (m_tbProjectName.Text.Equals("") || m_tbProjectName.Text.Length > 32) { m_tbProjectNameHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 90, 90)); return; } else { m_tbProjectNameHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); } //文件路径 if (!m_tbProjectName.Text.Equals("") || !File.Exists(m_tbProjectName.Text)) { m_tbProjectNameHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 90, 90)); } else { m_tbProjectNameHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); return; } //文件类型 if (m_rbUploadTypeMy.IsChecked == false && m_rbUploadTypeOther.IsChecked == false) { m_tbUploadTypeOtherHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 90, 90)); return; } else { m_tbUploadTypeOtherHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); } //文件简介 if (m_tbProjectRemarks.Text.Length > 256) { m_tbProjectRemarksHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 90, 90)); return; } else { m_tbProjectRemarksHelp.Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); } FileInfo fileInfo = new System.IO.FileInfo(m_tbProjectPath.Text); //KB为单位 if (System.Math.Ceiling(fileInfo.Length / 1024.0) > 4096) { //大于1M new MessageDialog(mw, "TheFileIsTooLarge").ShowDialog(); return; } //扩展名 ".mid" if (!System.IO.Path.GetExtension(m_tbProjectPath.Text).Equals(".lightScript")) { new MessageDialog(mw, "NonLightScriptFile").ShowDialog(); return; } //上传文件 var url = "http://www.launchpadlight.com/sharer/UploadProject"; var formDatas = new List <FormItemModel>(); //添加文本 formDatas.Add(new FormItemModel() { Key = "UserName", Value = mw.strUserName }); formDatas.Add(new FormItemModel() { Key = "UserPassword", Value = mw.strUserPassword }); formDatas.Add(new FormItemModel() { Key = "UserId", Value = mw.mUser.UserId.ToString() }); formDatas.Add(new FormItemModel() { Key = "ProjectName", Value = m_tbProjectName.Text }); int type = 0; if (m_rbUploadTypeOther.IsChecked == true) { type = 1; } formDatas.Add(new FormItemModel() { Key = "ProjectType", Value = type.ToString() }); formDatas.Add(new FormItemModel() { Key = "ProjectRemarks", Value = m_tbProjectRemarks.Text }); formDatas.Add(new FormItemModel() { Key = "UploadTime", Value = DateTime.Now.ToString() }); //添加文件 formDatas.Add(new FormItemModel() { Key = "ScriptFile", Value = "", FileName = "my.lightScript", FileContent = File.OpenRead(m_tbProjectPath.Text) }); //提交表单 var result = Util.PostForm(url, formDatas); if (result.Equals("success")) { mw.tbUploadCount.Text = (int.Parse(mw.tbUploadCount.Text) + 1).ToString(); System.Windows.Forms.MessageBox.Show("上传成功"); } else { System.Windows.Forms.MessageBox.Show(result.Substring(5)); } }
/// <summary> /// Shows a timetable for user /// </summary> /// <param name="t">Timetable to show</param> /// <param name="quietChangedOfTimeTable">Changed timetable without showing it</param> /// <returns>Task for await</returns> private async Task ShowTimeTableAsync(Timetable t, bool quietChangedOfTimeTable = false, bool addPage = true) { if (InfoCenterStackPanel.Visibility == Visibility.Visible) InfoCenterStackPanel.Visibility = Visibility.Collapsed; // if we want to show timetable, without checking if eg settings page is opened if (!quietChangedOfTimeTable && SplitViewContentScrollViewer.Visibility == Visibility.Collapsed) { SplitViewContentScrollViewer.Visibility = Visibility.Visible; SplitViewContentFrame.Visibility = Visibility.Collapsed; } var splitViewContentGrid = MenuSplitViewContentGrid; //absolute id of timetable var idOfTimeTable = Timetable.GetIdOfTimetable(t, TimeTable); //t.type == Lesson.LessonType.Class ? TimeTable.TimetablesOfClasses.IndexOf(t) : //TimeTable.TimetablesOfClasses.Count + TimeTable.TimetableOfTeachers.IndexOf(t); //if table which we want to show is actually opened var headerGrid = splitViewContentGrid.Parent as Grid; if (addPage) PagesManager.AddPage(t, PagesManager.ePagesType.Timetable); if ((!quietChangedOfTimeTable && idOfTimeTable == TimeTable.IdOfLastOpenedTimeTable && splitViewContentGrid.Children.Any()) || headerGrid == null) { if (!TitleText.Text.Contains("Plan lekcji")) TitleText.Text = "Plan lekcji - " + t.name; return; } var timeNow = DateTime.Now.TimeOfDay; var actualHour = timeNow.Hours; var actualMinute = timeNow.Minutes; //checks checking actual hour and minute which lesson actually is var actualLesson = actualHour == 7 ? 1 : (actualHour == 8 && actualMinute < 55) ? 2 : ((actualHour == 8 && actualMinute >= 55) || actualHour == 9 && actualMinute < 45) ? 3 : ((actualHour == 9 && actualMinute >= 45) || actualHour == 10 && actualMinute < 45) ? 4 : ((actualHour == 10 && actualMinute >= 45) || actualHour == 11 && actualMinute < 35) ? 5 : ((actualHour == 11 && actualMinute >= 35) || actualHour == 12 && actualMinute < 30) ? 6 : ((actualHour == 12 && actualMinute >= 30) || actualHour == 13 && actualMinute < 20) ? 7 : ((actualHour == 13 && actualMinute >= 20) || actualHour == 14 && actualMinute < 10) ? 8 : ((actualHour == 14 && actualMinute >= 10)) ? 9 : ((actualHour == 15 && actualMinute >= 0) || actualHour == 15 && actualMinute < 50) ? 10 : ((actualHour == 15 && actualMinute >= 50) || actualHour >= 16) ? 11 : 0; if (!quietChangedOfTimeTable) TitleText.Text = "Plan lekcji - " + t.name; var actualTheme = Application.Current.RequestedTheme; //checks if we dont have title TextBlock created if (headerGrid.Children.FirstOrDefault(p => p is TextBlock && p != InfoCenterText) == null) { headerGrid.Children.Add(new TextBlock() { Text = t.name, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(10.0), Padding = new Thickness(10.0), FontSize = 36 }); } else ((TextBlock)headerGrid.Children.First(p => p is TextBlock && p != InfoCenterText)).Text = t.name; //if we didnt created before a struct of grids //if we, then we have to delete it, lefts first row with //dayNames (poniedzialek,etc) if (!splitViewContentGrid.Children.Any()) { for (var i = 0; i < 7; i++) { splitViewContentGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); var tx = new TextBlock() { Text = _dayNames[i], HorizontalAlignment = HorizontalAlignment.Center, Padding = new Thickness(5.0) }; var grid = new Grid(); grid.Children.Add(tx); Grid.SetColumn(grid, i); grid.BorderBrush = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Black : Colors.White); grid.BorderThickness = new Thickness(1.0); grid.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightCyan : Color.FromArgb(127, 0, 150, 0)); splitViewContentGrid.Children.Add(grid); } } else { splitViewContentGrid.RowDefinitions.Clear(); var listOfObjects = splitViewContentGrid.Children.Select(p => (((Grid)p).Children[0] as TextBlock)).ToList(); foreach (TextBlock tb in listOfObjects) { if (!string.IsNullOrEmpty(_dayNames.FirstOrDefault(p => p.Contains(tb.Text)))) continue; splitViewContentGrid.Children.Remove((tb.Parent as Grid)); } } var numOfLessonsOnThisTimetable = t.days.Max(day => day.LessonsNum); //scans by rows for (var i = 0; i < numOfLessonsOnThisTimetable + 1; i++) { splitViewContentGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); // i=0 is a dayName eg Nr,Godz,Poniedzialek etc..., //we dont want to show there lessons if (i == 0) continue; //scans on every column for (var j = 0; j < 7; j++) { var tx = new TextBlock(); var grid = new Grid { IsTapEnabled = true }; //infoTextBlock provides a info about position lesson in a table //for flyout lesson instance looking var text = string.Empty; //j=0 is a number of lesson //j=1 is a hours of this lessons //j>1 is a lesson if (j == 0 || j == 1) { tx.HorizontalAlignment = HorizontalAlignment.Center; tx.VerticalAlignment = VerticalAlignment.Center; } switch (j) { case 0: text = i.ToString(); // number of lesson grid.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightCyan : Color.FromArgb(127, 0, 150, 0)); break; case 1: text = _lessonTimes[i - 1]; // hour of lessons grid.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightGreen : Color.FromArgb(127, 204, 0, 0)); break; default: var infoTextBlock = new TextBlock { Visibility = Visibility.Collapsed, Text = $"[] {j} {i} {Timetable.GetIdOfTimetable(t, TimeTable)}" }; grid.Children.Add(infoTextBlock); //j is column, i is a row //j - 2 because we have 2 added columns (Nr, Godz) //i - 1 because i=0 is a row with dayNames (Nr,Godz,Poniedzialek)etc.. var lesson = t.days[j - 2].Lessons[i - 1]; if (t.type == Lesson.LessonType.Teacher && !string.IsNullOrEmpty(lesson.lesson2Name)) { tx.Inlines.Add(new Run() { Text = $"{lesson.lesson2Name} ", FontWeight = FontWeights.Light }); } tx.Inlines.Add(new Run() { Text = lesson.lesson1Name ?? "", FontWeight = FontWeights.Bold }); //if lesson1Tag (is a Teachertag) is not available, then //skip it, else show full format if (string.IsNullOrEmpty(lesson.lesson1Tag)) { tx.Inlines.Add(new Run() { Text = $" {lesson.lesson1Place}", Foreground = new SolidColorBrush(Colors.Red) }); } else { tx.Inlines.Add(new Run { Text = $" {lesson.lesson1Tag}", Foreground = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Purple : Colors.LightCyan) }); tx.Inlines.Add(new Run { Text = $" {lesson.lesson1Place}", Foreground = new SolidColorBrush(Colors.Red) }); } //if this is a class timetable and //at one time, we have two lessons then show //seccond one at bottom in grid if (!string.IsNullOrEmpty(lesson.lesson2Name) && t.type == Lesson.LessonType.Class) { tx.Inlines.Add(new Run { Text = $"{Environment.NewLine}{lesson.lesson2Name}", FontWeight = FontWeights.Bold }); tx.Inlines.Add(new Run { Text = $" {lesson.lesson2Tag}" ?? " ", Foreground = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Purple : Colors.LightCyan) }); tx.Inlines.Add(new Run { Text = $" {lesson.lesson2Place}" ?? " ", Foreground = new SolidColorBrush(Colors.Red) }); } break; } tx.Padding = new Thickness(10.0); //if actually operated record //was a lesson (then text was not added, and is empty) if (text != "") tx.Text = text; if (tx.Text.Trim() != "" && j > 1) { grid.Tapped += (s, e) => { var lesson = Lesson.GetLessonFromLessonGrid(s as Grid, TimeTable); FlyoutHelper.SetTimetable(TimeTable); //if lesson has two lesson, show flyout with choose which lesson if (!string.IsNullOrEmpty(lesson.lesson2Tag)) FlyoutHelper.ShowFlyOutMenuForTwoLessons(grid, lesson); else //clicked lesson has only one lesson FlyoutHelper.ShowFlyOutMenuForLesson(grid); }; } grid.Children.Add(tx); Grid.SetColumn(grid, j); Grid.SetRow(grid, i); grid.BorderBrush = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Black : Colors.White); grid.BorderThickness = new Thickness(1.0); if (SettingsPage.IsShowActiveLessonsToogleSwitchOn() && i == actualLesson) { grid.BorderThickness = new Thickness(2); grid.BorderBrush = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Red : Colors.Yellow); } splitViewContentGrid.Children.Add(grid); } } /* Saving lastOpenedTimeTable */ if (await DataServices.SaveLastOpenedTimeTableToFile(idOfTimeTable, TimeTable) == false) { //If Plan is not saved ResetView(); InfoCenterStackPanel.Visibility = Visibility.Visible; InfoCenterText.Visibility = Visibility.Visible; InfoCenterButton.Visibility = Visibility.Collapsed; InfoCenterText.Text = "Wystąpił błąd podczas zapisu danych. Prawdopodobnie masz za mało pamięci na telefonie," + " bądź inny błąd uniemożliwia zapis. Spróbuj uruchomić aplikację ponownie!"; _isLoaded = false; } }
public ColorTable() { this.SuspendLayout(); // Set yellow as default highlight color. selectedColor = Color.Yellow; this.LayoutStyle = ToolStripLayoutStyle.Table; TableLayoutSettings layout = (TableLayoutSettings)this.LayoutSettings; layout.ColumnCount = 5; layout.RowCount = 3; // Highlight color values used here have been shamelessly // copied from microsoft word's Highlight color values. Color[] colors = new Color[] { Color.FromArgb(255, 255, 0), Color.FromArgb(0, 255, 0), Color.FromArgb(0, 255, 255), Color.FromArgb(255, 0, 255), Color.FromArgb(0, 0, 255), Color.FromArgb(255, 0, 0), Color.FromArgb(0, 0, 128), Color.FromArgb(0, 128, 128), Color.FromArgb(0, 128, 0), Color.FromArgb(128, 0, 128), Color.FromArgb(128, 0, 0), Color.FromArgb(128, 128, 0), Color.FromArgb(128, 128, 128), Color.FromArgb(192, 192, 192), Color.FromArgb(0, 0, 0) }; // ToolTipText used. Same text as MS Word, what a coincidence! string[] colorNames = new string[] { "Yellow", "Bright Green", "Turquoise", "Pink", "Blue", "Red", "Dark Blue", "Teal", "Green", "Violet", "Dark Red", "Dark Yellow", "Gray-50%", "Gray-25%", "Black" }; // Set rectangle and padding values so that // when an item is selected the selection // frame highlights the color "square" with // even spacing around it. Rectangle rc = new Rectangle(1, 1, 11, 11); Padding itemPadding = new Padding(2, 1, 2, 1); // To get selection frame perfectly centered // The size of the bitmap image to draw on is // 13 pixels wide and 12 pixels high. int bmWidth = 13; int bmHeight = 12; // Add the Fourteen colors to the dropdown. for (int i = 0; i < 15; i++) { Bitmap bm = new Bitmap(bmWidth, bmHeight); using (Graphics g = Graphics.FromImage(bm)) { // g.Clear(colors[i]); g.FillRectangle(new SolidBrush(colors[i]), rc); g.DrawRectangle(Pens.Gray, 1, 0, 11, 11); } ToolStripMenuItem item = (new ToolStripMenuItem(bm)); this.Items.Add(item); item.Padding = itemPadding; item.ImageScaling = ToolStripItemImageScaling.None; item.ImageAlign = ContentAlignment.MiddleCenter; item.DisplayStyle = ToolStripItemDisplayStyle.Image; item.ToolTipText = colorNames[i]; item.MouseDown += color_MouseDown; item.Tag = colors[i]; this.Opening += ColorTable_Opening; } // Select yellow item as default selected color. this.Items[0].Select(); // Also add an option to clear existing highlighting // back to default/no highlighting. ToolStripMenuItem noColor = new ToolStripMenuItem("None"); this.Items.Add(noColor); layout.SetCellPosition(noColor, new TableLayoutPanelCellPosition(0, 0)); layout.SetColumnSpan(noColor, 5); // The color white is used to indicate "No Highlight". Bitmap bmp = new Bitmap(1, 1); using (Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.White); } noColor.Image = bmp; noColor.Tag = Color.White; noColor.DisplayStyle = ToolStripItemDisplayStyle.Text; noColor.Dock = DockStyle.Fill; noColor.ToolTipText = "No Highlight"; noColor.MouseDown += color_MouseDown; this.ResumeLayout(); }
public static DlmMap ReadFromStream(IDataReader givenReader, DlmReader dlmReader) { DlmMap map = null; try { var reader = givenReader; map = new DlmMap { Version = reader.ReadByte(), Id = reader.ReadInt() }; if (map.Version > DlmReader.VERSION) { throw new Exception(string.Format("Reader outdated for this map (old version:{0} new version:{1})", DlmReader.VERSION, map.Version)); } if (map.Version >= 7) { map.Encrypted = reader.ReadBoolean(); map.EncryptionVersion = reader.ReadByte(); var len = reader.ReadInt(); if (map.Encrypted) { var key = dlmReader.DecryptionKey; if (key == null && dlmReader.DecryptionKeyProvider != null) { key = dlmReader.DecryptionKeyProvider(map.Id); } if (key == null) { throw new InvalidOperationException(string.Format("Cannot decrypt the map {0} without decryption key", map.Id)); } var data = reader.ReadBytes(len); var encodedKey = Encoding.Default.GetBytes(key); if (key.Length > 0) { for (var i = 0; i < data.Length; i++) { data[i] = (byte)(data[i] ^ encodedKey[i % key.Length]); } reader = new FastBigEndianReader(data); } } } map.RelativeId = reader.ReadUInt(); map.MapType = reader.ReadByte(); // temp, just to know if the result is coherent if (map.MapType < 0 || map.MapType > 1) { throw new Exception("Invalid decryption key"); } map.SubAreaId = reader.ReadInt(); map.TopNeighbourId = reader.ReadInt(); map.BottomNeighbourId = reader.ReadInt(); map.LeftNeighbourId = reader.ReadInt(); map.RightNeighbourId = reader.ReadInt(); map.ShadowBonusOnEntities = reader.ReadInt(); if (map.Version >= 9) { map.BackgroundColor = Color.FromArgb(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); map.GridColor = Color.FromArgb(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); } else if (map.Version >= 3) { map.BackgroundColor = Color.FromArgb(reader.ReadByte(), reader.ReadByte(), reader.ReadByte()); } if (map.Version >= 4) { map.ZoomScale = reader.ReadUShort(); map.ZoomOffsetX = reader.ReadShort(); map.ZoomOffsetY = reader.ReadShort(); } map.UseLowPassFilter = reader.ReadByte() == 1; map.UseReverb = reader.ReadByte() == 1; if (map.UseReverb) { map.PresetId = reader.ReadInt(); } { map.PresetId = -1; } map.BackgroudFixtures = new DlmFixture[reader.ReadByte()]; for (var i = 0; i < map.BackgroudFixtures.Length; i++) { map.BackgroudFixtures[i] = DlmFixture.ReadFromStream(map, reader); } map.ForegroundFixtures = new DlmFixture[reader.ReadByte()]; for (var i = 0; i < map.ForegroundFixtures.Length; i++) { map.ForegroundFixtures[i] = DlmFixture.ReadFromStream(map, reader); } reader.ReadInt(); map.GroundCRC = reader.ReadInt(); map.Layers = new DlmLayer[reader.ReadByte()]; for (var i = 0; i < map.Layers.Length; i++) { map.Layers[i] = DlmLayer.ReadFromStream(map, reader); } map.Cells = new DlmCellData[CellCount]; int?lastMoveZone = null; for (short i = 0; i < map.Cells.Length; i++) { map.Cells[i] = DlmCellData.ReadFromStream(i, map.Version, reader); if (!lastMoveZone.HasValue) { lastMoveZone = map.Cells[i].MoveZone; } else if (lastMoveZone != map.Cells[i].MoveZone) // if a cell is different the new system is used { map.UsingNewMovementSystem = true; } } return(map); } catch (Exception ex) { throw new BadEncodedMapException(ex, map); } }
private void Glassify(Rectangle Rectangle, PaintEventArgs e, Color Color, bool Pressed) { using (var gp = CreateRoundRectangle(Rectangle, 2)) { var opacity = 0x7f; using (Brush brush = new SolidBrush(Color.FromArgb(opacity, Color))) { e.Graphics.FillPath(brush, gp); } } using (var clip = CreateRoundRectangle(Rectangle, 2)) { e.Graphics.SetClip(clip, CombineMode.Intersect); using (var gp = CreateBottomRadialPath(Rectangle)) { using (var brush = new PathGradientBrush(gp)) { var opacity = (int) (0xB2*.99f + .5f); var bounds = gp.GetBounds(); brush.CenterPoint = new PointF((bounds.Left + bounds.Right)/2f, (bounds.Top + bounds.Bottom)/2f); brush.CenterColor = Color.FromArgb(opacity, Color.White); brush.SurroundColors = new[] {Color.FromArgb(0, Color.White)}; e.Graphics.FillPath(brush, gp); } } e.Graphics.ResetClip(); } var newRect = Rectangle; newRect.Height >>= 1; if (newRect.Width > 0 && newRect.Height > 0) { newRect.Height++; using (var gp = CreateTopRoundRectangle(newRect, 2)) { var opacity = Pressed ? (int) (.4f*0x9 + .5f) : 0x99; newRect.Height++; using ( var brush = new LinearGradientBrush(newRect, Color.FromArgb(opacity, Color.White), Color.FromArgb(opacity/3, Color.White), LinearGradientMode.Vertical)) { e.Graphics.FillPath(brush, gp); } } } var Y = Rectangle.Y + Rectangle.Height - 1; // e.Graphics.DrawLine(new Pen(Color.Black), Rectangle.Left, Y, Rectangle.Right, Y); }
public static void DrawFilledBox(float x, float y, float w, float h, Color Color, int alpha = 255) { Vector2[] vertexList = new Vector2[2]; DXLine.GLLines = true; DXLine.Antialias = false; DXLine.Width = w; vertexList[0].X = x + (w / 2f); vertexList[0].Y = y; vertexList[1].X = x + (w / 2f); vertexList[1].Y = y + h; DXLine.Begin(); DXLine.Draw(vertexList, Color.FromArgb(alpha, Color.R, Color.G, Color.B)); DXLine.End(); }
public void Update() { switch (Order.Status) { case OrderStatus.New: Color = Color.FromArgb(255, 255, 230); break; case OrderStatus.PartiallyFilled: Color = Color.SkyBlue; break; case OrderStatus.Filled: Color = Color.FromArgb(220, 255, 220); break; case OrderStatus.Cancelled: Color = Color.FromArgb(255, 230, 230); break; } }
private void ColorSlide(object sender, MouseEventArgs e, ColorComponents colorComponent) { Control control = (sender as Control); int xLocation = e.X.Clamp(0, control.ClientRectangle.Width); if (e.Button == System.Windows.Forms.MouseButtons.Left) { byte newValue = (byte)ScaleRange(xLocation, 0, control.ClientRectangle.Width, 0, 255); switch (colorComponent) { case ColorComponents.Red: Color = Color.FromArgb(color.A, newValue, color.G, color.B); break; case ColorComponents.Green: Color = Color.FromArgb(color.A, color.R, newValue, color.B); break; case ColorComponents.Blue: Color = Color.FromArgb(color.A, color.R, color.G, newValue); break; case ColorComponents.Alpha: Color = Color.FromArgb(newValue, color.R, color.G, color.B); break; } } }
public override void LoadDetails(XmlNode node, KmlRoot owner) { base.LoadDetails(node, owner); Color = GetColor(node); ColorMode = GetColorMode(node); if (ColorMode == KmlColorModes.Random) { byte red = (Byte)(Color.R * rnd.NextDouble()); byte green = (Byte)(Color.G * rnd.NextDouble()); byte blue = (Byte)(Color.B * rnd.NextDouble()); byte alpha = (Byte)(Color.A * rnd.NextDouble()); Color = Color.FromArgb(alpha, red, green, blue); } }
/// <summary> /// Load the label from a github api json representation. /// </summary> /// <param name="json">The github api json representation</param> public override void LoadFromJson(JObject json) { Name = json["name"].Value<string>(); Color = Color.Empty; var c = json["color"]; int ic; if (Int32.TryParse(json["color"].Value<string>(), NumberStyles.HexNumber, null, out ic)) Color = Color.FromArgb(ic); }
public static Color EcuacionPhong(Foco3D[] Focos, PhongShader Constantes, Vector3D NormalSUR, Punto3D PuntoSUR, Color Color, Camara3D Camara) { Vector3D Rayo = null; Vector3D Salida = null; Vector3D Vista = null; byte r = 0; byte g = 0; byte b = 0; long rr = 0; long gg = 0; long bb = 0; long trr = 0; long tgg = 0; long tbb = 0; double Escalar = 0; double Ambiente = 0; double Difusa = 0; double Especular = 0; double AmbienteR = 0; double DifusaR = 0; double EspecularR = 0; double AmbienteG = 0; double DifusaG = 0; double EspecularG = 0; double AmbienteB = 0; double DifusaB = 0; double EspecularB = 0; trr = 0; tgg = 0; tbb = 0; Vista = new Vector3D(Camara.Posicion, PuntoSUR); Vista.Normalizar(); Ambiente = Constantes.Ambiente; NormalSUR.Normalizar(); for (long i = 0; i <= Focos.GetUpperBound(0); i++) { Rayo = new Vector3D(Focos[i].Coordenadas, PuntoSUR); Rayo = !Rayo.VectorUnitario; Salida = (((2 * (NormalSUR * Rayo)) * NormalSUR) - Rayo).VectorUnitario; Difusa = Focos[i].Intensidad * (Constantes.Difusa * (NormalSUR * Rayo)); Escalar = (Salida * Vista); if (Escalar < 0) { Especular = Math.Abs((Constantes.Especular * Math.Pow(Escalar, Constantes.ExponenteEspecular))); } else { Especular = 0; } AmbienteR = Ambiente * (Focos[i].Color.R / 255); DifusaR = Difusa * (Focos[i].Color.R / 255); EspecularR = Especular * (Focos[i].Color.R / 255); AmbienteG = Ambiente * (Focos[i].Color.G / 255); DifusaG = Difusa * (Focos[i].Color.G / 255); EspecularG = Especular * (Focos[i].Color.G / 255); AmbienteB = Ambiente * (Focos[i].Color.B / 255); DifusaB = Difusa * (Focos[i].Color.B / 255); EspecularB = Especular * (Focos[i].Color.B / 255); rr = Color.R * (AmbienteR + DifusaR); rr = rr + ((Focos[i].Color.R - rr) * EspecularR); gg = Color.G * (AmbienteG + DifusaG); gg = gg + ((Focos[i].Color.G - gg) * EspecularG); bb = Color.B * (AmbienteB + DifusaB); bb = bb + ((Focos[i].Color.B - bb) * EspecularB); if (rr < 0) rr = 0; if (gg < 0) gg = 0; if (bb < 0) bb = 0; trr += rr; tgg += gg; tbb += bb; } if (trr > 255) trr = 255; if (trr < 0) trr = 0; if (tgg > 255) tgg = 255; if (tgg < 0) tgg = 0; if (tbb > 255) tbb = 255; if (tbb < 0) tbb = 0; r = trr; g = tgg; b = tbb; return Color.FromArgb(255, r, g, b); }
/// <summary> /// Process RAW!!!! bytes /// </summary> /// <param name="bytesOrig">RAW BYTES!!!!! NOT(!) Bitmap.Save() bytes!!!!</param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="gamma"></param> /// <param name="minQuality"></param> /// <param name="maxQuality"></param> /// <param name="speed">1: slowest-beast quality, 10: fastest and rough</param> /// <returns>PNG bytes!!!!!</returns> public static byte[] Compress( byte[] bytesOrig , int width , int height , double gamma = 0.0d , int minQuality = 50 , int maxQuality = 90 , int speed = 1 ) { IntPtr ptrAttr = IntPtr.Zero; IntPtr ptrImgSrc = IntPtr.Zero; IntPtr ptrImgResult = IntPtr.Zero; try { ptrAttr = imagequant.liq_attr_create(); if (ptrAttr == IntPtr.Zero) { Console.WriteLine("can't create attr"); return(null); } ptrImgSrc = imagequant.liq_image_create_rgba(ptrAttr, bytesOrig, width, height, gamma); if (ptrImgSrc == IntPtr.Zero) { Console.WriteLine("can't create image"); return(null); } var errQual = imagequant.liq_set_quality(ptrAttr, minQuality, maxQuality); if (liq_error.LIQ_OK != errQual) { Console.WriteLine("can't set quality"); return(null); } var errSpeed = imagequant.liq_set_speed(ptrAttr, speed); if (liq_error.LIQ_OK != errSpeed) { Console.WriteLine("can't set speed"); return(null); } ptrImgResult = imagequant.liq_quantize_image(ptrAttr, ptrImgSrc); if (ptrImgResult == IntPtr.Zero) { Console.WriteLine("can't quantize image"); return(null); } //var buffer_size = width * height; /// !!!!! 4x for ARGB //var buffer_size = width * height * 4; var buffer_size = bytesOrig.Length; var bytesRemapped = new byte[buffer_size]; var err = imagequant.liq_write_remapped_image(ptrImgResult, ptrImgSrc, bytesRemapped, (UIntPtr)buffer_size); if (err != liq_error.LIQ_OK) { Console.WriteLine("remapping error"); return(null); } // APPLY PALETTE liq_palette liqPal = (liq_palette)Marshal.PtrToStructure(imagequant.liq_get_palette(ptrImgResult), typeof(liq_palette)); byte[] bytesOut = null; using (Bitmap bmpOut = new Bitmap(width, height, PixelFormat.Format8bppIndexed)) { ColorPalette pal = bmpOut.Palette; //make sure that we only use as many entries as we have available int liqPalCnt = liqPal.count; int bmpPalCnt = pal.Entries.Length; int palCnt = liqPalCnt < bmpPalCnt ? liqPalCnt : bmpPalCnt; for (int i = 0; i < palCnt; i++) { liq_color liqCol = liqPal.entries[i]; pal.Entries[i] = Color.FromArgb(liqCol.a, liqCol.r, liqCol.g, liqCol.b); } // if there are more bmp entries than liq entries, set to invisible if (liqPalCnt < bmpPalCnt) { for (int i = liqPalCnt; i < bmpPalCnt; i++) { pal.Entries[i] = Color.FromArgb(0, 0, 0, 0); } } //!!!!! // Palette IS NOT A REFERENCE!!! HAS TO BE SET AGAIN!!!!! bmpOut.Palette = pal; BitmapData bmpData = bmpOut.LockBits( new Rectangle(0, 0, bmpOut.Width, bmpOut.Height) , ImageLockMode.WriteOnly //, bmpOut.PixelFormat //, PixelFormat.Format32bppArgb //, PixelFormat.Format32bppRgb //, PixelFormat.Format32bppPArgb , PixelFormat.Format8bppIndexed ); int bmpDataLength = bmpData.Stride * bmpData.Height; Marshal.Copy(bytesRemapped, 0, bmpData.Scan0, bmpDataLength /* compressed.Length*/); // !!!!! JUST FOR TESTING, write orignal data //Marshal.Copy(orig, 0, bmpData.Scan0, bmpDataLength /* compressed.Length*/); bmpOut.UnlockBits(bmpData); using (MemoryStream msOut = new MemoryStream()) { bmpOut.Save(msOut, ImageFormat.Png); bytesOut = msOut.GetBuffer(); } } return(bytesOut); } catch (Exception ex) { Console.WriteLine($"unexpected error {ex}"); return(null); } finally { imagequant.liq_image_destroy(ptrImgSrc); imagequant.liq_result_destroy(ptrImgResult); imagequant.liq_attr_destroy(ptrAttr); } }
private void DrawRedGreenBlue(int red, int green, int blue) { Color color = Color.FromArgb(red, green, blue); SetBackColor(color); }
/// <summary> /// 初始化主题色彩方案 /// </summary> /// User:Ryan CreateTime:2012-8-7 22:11. /// User:Ryan CreateTime:2012-8-7 22:18. public override void IniSkinTheme() { this.ThemeStyle = EnumTheme.BlueSea; this.ThemeName = "面朝大海,春暖花开"; this.BackGroundImage = Properties.Resources.bg06; this.BackGroundImageEnable = false; this.BackGroundImageOpacity = 0.8F; this.BaseColor = Color.FromArgb(238, 247, 252); this.BorderColor = Color.Gainsboro; this.InnerBorderColor = Color.FromArgb(196, 214, 230); this.OuterBorderColor = Color.FromArgb(30, 111, 201); this.DefaultControlColor = new GradientColor(Color.FromArgb(248, 245, 251), Color.FromArgb(227, 226, 227), new float[] { 0.0f, 0.15f, 0.05f, 0.2f, 0.6f, 0.8f, 0.85f }, new float[] { 0f, 0.2f, 0.4f, 0.6f, 0.8f, 0.9f, 1.0f }); this.HeightLightControlColor = new GradientColor(Color.FromArgb(1, 185, 246), Color.FromArgb(31, 112, 202), new float[] { 0.0F, 0.7F, 1.5F }, new float[] { 0.0F, 0.6F, 1F }); this.FocusedControlColor = new GradientColor(Color.FromArgb(30, 111, 201), Color.FromArgb(60, 206, 238), new float[] { 0.2F, 0.6F, 0.8F, 0.4F, 0.2F }, new float[] { 0.0F, 0.3F, 0.6F, 0.8F, 1F }); this.UselessColor = Color.FromArgb(159, 159, 159); this.CaptionColor = new GradientColor(Color.FromArgb(240, 0, 151, 230), Color.FromArgb(1, 30, 111, 201), new float[] { 0.0f, 0.15f, 0.05f, 0.2f, 0.6f, 0.8f, 0.85f }, new float[] { 0f, 0.2f, 0.4f, 0.6f, 0.8f, 0.9f, 1.0f }); this.ThemeColor = Color.FromArgb(238, 247, 252); this.CaptionFontColor = Color.FromArgb(31, 31, 31); ////control color this.ControlBoxDefaultColor = new GradientColor(Color.FromArgb(110, 195, 226), Color.FromArgb(0, 110, 195, 226), new float[] { 0f, .1f, .7f, 1f }, new float[] { 0f, .3f, .6f, 1f }); this.ControlBoxHeightLightColor = new GradientColor(Color.FromArgb(40, 183, 236), Color.FromArgb(0, 40, 183, 236), new float[] { 0f, .1f, .7f, 1f }, new float[] { 0f, .3f, .6f, 1f }); this.ControlBoxPressedColor = new GradientColor(Color.FromArgb(33, 154, 202), Color.FromArgb(0, 33, 154, 202), new float[] { 0f, .7f, .2f, 0f }, new float[] { 0f, .3f, .6f, 1f }); this.CloseBoxHeightLightColor = new GradientColor(Color.FromArgb(219, 85, 55), Color.FromArgb(0, 219, 85, 55), new float[] { 0f, .1f, .7f, 1f }, new float[] { 0f, .3f, .6f, 1f }); this.CloseBoxPressedColor = new GradientColor(Color.FromArgb(167, 78, 58), Color.FromArgb(0, 167, 78, 58), new float[] { 0f, .7f, .2f, 0f }, new float[] { 0f, .3f, .6f, 1f }); this.ControlBoxFlagColor = Color.White; }
private void waitinglistbtn_MouseLeave(object sender, EventArgs e) { waitinglistbtn.BackColor = Color.FromArgb(64, 64, 64); panel2.Size = new Size(91, 569); }
private void CreateLightGrayPen() { _lightGrayPen = new Pen(Color.FromArgb(247, 247, 247)); _lightGrayPen.Width = GetScaledSize(1, false); }
private void ucSystemSettingsBookings_Load(object sender, EventArgs e) { _clsSystemSettings.theData.ConnectionString = TConnections.GetConnectionString(theSystemDBTag, UserCurrentInfo.Connection); dtSysset = _clsSystemSettings.getSysset(); dtSysset = _clsSystemSettings.getSysset(); try { if (dtSysset.Rows.Count > 0) { chkBookFaceLength.Checked = false; chkDisableBookingCyclePlan.Checked = false; chkUseNewValidationMethod.Checked = false; chkForceOwnNotes.Checked = false; chkForceProblemGroup.Checked = false; chkForceProblemType.Checked = false; chkNewProblemBookingMethod.Checked = false; chkAllowBookingofSwCw.Checked = false; chkSamplingUseLatestForPlan.Checked = false; if (dtSysset.Rows[0]["AllowSWCWBook"].ToString() == "Y") { chkAllowBookingofSwCw.Checked = true; txtPlanSW.Text = dtSysset.Rows[0]["SWCheck"].ToString(); txtPlanCW.Text = dtSysset.Rows[0]["CWCheck"].ToString(); txtPlanSW.Enabled = true; txtPlanCW.Enabled = true; } else { txtPlanSW.Text = "0"; txtPlanCW.Text = "0"; txtPlanSW.Enabled = false; txtPlanCW.Enabled = false; } if (dtSysset.Rows[0]["BookFL"].ToString() == "Y") chkBookFaceLength.Checked = true; if (dtSysset.Rows[0]["DisableBookingCyclePlan"].ToString() == "Y") chkDisableBookingCyclePlan.Checked = true; if (dtSysset.Rows[0]["ProblemNew"].ToString() == "Y") chkUseNewValidationMethod.Checked = true; if (dtSysset.Rows[0]["Problem_ProblemTypeLink"].ToString() == "Y") chkForceProblemType.Checked = true; if (dtSysset.Rows[0]["ProblemGroup_ProblemTypeLink"].ToString() == "Y") chkForceProblemGroup.Checked = true; if (dtSysset.Rows[0]["ProblemForceNote"].ToString() == "Y") chkForceOwnNotes.Checked = true; if (dtSysset.Rows[0]["ProblemNewValidation"].ToString() == "Y") chkNewProblemBookingMethod.Checked = true; if (dtSysset.Rows[0]["SamplingValue"].ToString() == "K") { rdgrpGradeBookingsSettings.SelectedIndex = 0; } else if (dtSysset.Rows[0]["SamplingValue"].ToString() == "S") { rdgrpGradeBookingsSettings.SelectedIndex = 1; } else if (dtSysset.Rows[0]["SamplingValue"].ToString() == "B") { rdgrpGradeBookingsSettings.SelectedIndex = 2; } if (dtSysset.Rows[0]["SamplingUseLatestForPlan"].ToString() == "Y") chkSamplingUseLatestForPlan.Checked = true; string _colorA = dtSysset.Rows[0]["A_Color"].ToString(); string _colorB = dtSysset.Rows[0]["B_Color"].ToString(); string _colorS = dtSysset.Rows[0]["S_Color"].ToString(); txtColorA.Color = Color.FromArgb(Convert.ToInt32(_colorA)); txtColorB.Color = Color.FromArgb(Convert.ToInt32(_colorB)); txtColorS.Color = Color.FromArgb(Convert.ToInt32(_colorS)); if (dtSysset.Rows[0]["CheckMeas"].ToString() != "None") { cmbCheckMeas.Text = dtSysset.Rows[0]["CheckMeas"].ToString(); if (dtSysset.Rows[0]["CheckMeasLvl"].ToString() == "MO") rdgrpCheckMeasType.SelectedIndex = 1; else { if (dtSysset.Rows[0]["CheckMeasLvl"].ToString() == "SB") rdgrpCheckMeasType.SelectedIndex = 2; else rdgrpCheckMeasType.SelectedIndex = 0; } rdgrpCheckMeasType.Enabled = true; } else { rdgrpCheckMeasType.SelectedIndex = 0; rdgrpCheckMeasType.Enabled = false; } txtPercBlastQual.Text = dtSysset.Rows[0]["PERCBLASTQUALIFICATION"].ToString(); } } catch (Exception _exception) { MessageBox.Show(_exception.ToString()); } }
public override void Draw(Graphics Canvas, Pen DrawingPen, SolidBrush DrawingBrush) { DrawingPen.Color = Color.FromArgb(this.Parameters[1]); DrawingPen.Width = this.Parameters[2]; Canvas.DrawLine(DrawingPen, this.Parameters[4], this.Parameters[5], this.Parameters[6], this.Parameters[7]); }
public override void ExecuteResult(ControllerContext context) { //-- ایجاد یک تصویر نقشه بیتی 32 بیتی Bitmap bitmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb); //-- ایجاد یک شیء گرافیکی برای عملیات ترسیم روی تصویر امنیتی Graphics gfxCaptchaImage = Graphics.FromImage(bitmap); gfxCaptchaImage.PageUnit = GraphicsUnit.Pixel; gfxCaptchaImage.SmoothingMode = SmoothingMode.HighQuality; //-- پاک کردن پس زمینه تصویر امنیتی با یک رنگ سفید gfxCaptchaImage.Clear(_backGroundColor); //-- ایجاد یک عدد اتفاقی بین 1000 و 9999 int salt = CaptchaHelpers.CreateSalt(); //-- تاریخ فعلی (فقط روز فعلی) باید به کلید رمزنگاری اطلاعات اضافه شود //-- این کار به این هدف متفاوت بودن کلید رمزنگاری اطلاعات در هر روز صورت گرفته است string encryptionSaltKey = EncryptionKey + DateTime.Now.Date.ToString(); //-- چسباندن عدد اتفاقی تولید شده به تاریخ و زمان فعلی با یک جدا کننده //-- توضیح: تاریخ و زمان فعلی باید در کورکی ذخیره شود تا هنگام رمزگشایی //-- اطلاعات، اختلاف زمانی فی ما بین زمان ارسال فرم به مرورگر کاربر و زمان //-- ارسال فرم به سرور توسط کاربر محاسبه شود string plainText = salt.ToString() + "," + DateTime.Now.ToString(); //-- رمزنگاری مقدار متغیر بالا جهت ذخیره در کوکی string encryptedValue = (plainText).Encrypt(encryptionSaltKey); //-- ذخیره کردن رشته رمزنگاری شده در کوکی HttpCookie cookie = new HttpCookie("captchastring"); cookie.Value = encryptedValue; HttpContext.Current.Response.Cookies.Add(cookie); //-- تبدیل عدد اتفاقی تولید شده به حروف معادل string randomString = (salt).NumberToText(Language.Persian); //-- تنظیمات فرمت متن تصویر امنیتی var format = new StringFormat(); int faLCID = new System.Globalization.CultureInfo("fa-IR").LCID; format.SetDigitSubstitution(faLCID, StringDigitSubstitute.National); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; format.FormatFlags = StringFormatFlags.DirectionRightToLeft; //-- نوع و اندازه قلم تصویر امنیتی Font font = new Font(CaptchaFontFamily, CaptchaFontSize); //-- ایجاد یک مسیر گرافیکی در تصویر امنیتی GraphicsPath path = new GraphicsPath(); path.AddString(randomString, font.FontFamily, (int)font.Style, (gfxCaptchaImage.DpiY * font.SizeInPoints / 72), new Rectangle(0, 0, Width, Height), format); Random random = new Random(); //-- ایجاد رنگ متن تصویر امنیتی به صورت اتفاقی Pen pen = new Pen(Color.FromArgb(random.Next(0, 100), random.Next(0, 100), random.Next(0, 100))); gfxCaptchaImage.DrawPath(pen, path); //-- ایجاد یک موج سینوسی و کسینوسی اتفاقی برای نوشتن حروف کد امنیتی در آن int distortion = random.Next(-10, 10); using (Bitmap copy = (Bitmap)bitmap.Clone()) { for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { int newX = (int)(x + (distortion * Math.Sin(Math.PI * y / 64.0))); int newY = (int)(y + (distortion * Math.Cos(Math.PI * x / 64.0))); if (newX < 0 || newX >= Width) { newX = 0; } if (newY < 0 || newY >= Height) { newY = 0; } bitmap.SetPixel(x, y, copy.GetPixel(newX, newY)); } } } //-- اضافه کردن نویز به تصویر امنیتی int i, r, xx, yy, u, v; for (i = 1; i < 10; i++) { pen.Color = Color.FromArgb((random.Next(0, 255)), (random.Next(0, 255)), (random.Next(0, 255))); r = random.Next(0, (Width / 3)); xx = random.Next(0, Width); yy = random.Next(0, Height); u = xx - r; v = yy - r; gfxCaptchaImage.DrawEllipse(pen, u, v, r, r); } //-- رسم تصویر امنیتی gfxCaptchaImage.DrawImage(bitmap, new Point(0, 0)); gfxCaptchaImage.Flush(); //-- خروجی به عنوان یک تصویر jpeg و به صورت جریان به مرورگر کاربر فرستاده می شود HttpResponseBase response = context.HttpContext.Response; response.ContentType = "image/jpeg"; bitmap.Save(response.OutputStream, ImageFormat.Jpeg); //-- آزاد سازی حافظه های اشغال شده font.Dispose(); gfxCaptchaImage.Dispose(); bitmap.Dispose(); }
public void ModeIndexChange(int _Index) { MainFormClass.FadeLEDPanel.Enabled = false; MainFormClass.VisualizerPanel.Visible = false; MainFormClass.IndividualLEDPanel.Visible = false; MainFormClass.InstructionsPanel.Visible = false; MainFormClass.ConfigureSetupPanel.Visible = false; MainFormClass.AmbiLightModePanel.Visible = false; MainFormClass.ServerSettingsPanel.Visible = false; MainFormClass.AnimationModePanel.Visible = false; MainFormClass.GeneralSettingsPanel.Visible = false; MainFormClass.VisualizerEnabled = false; MainFormClass.VisualizerSectionClass.EnableBASS(false); MainFormClass.AnimationModeSectionClass.AutoSave(); MainFormClass.InstructionsSectionClass.AutoSave(); MainFormClass.ConfigureSetupSectionClass.AutoSave(); if (_Index == 0) { MainFormClass.FadeLEDPanel.Enabled = true; MainFormClass.FadeLEDPanel.BringToFront(); if (!MainFormClass.InstructionsSectionClass.ContinueInstructionsLoop) { MainFormClass.FadeColorsSectionClass.FadeColorsSendData( true, (int)MainFormClass.FadeLEDPanelFromIDNumericUpDown.Value, (int)MainFormClass.FadeLEDPanelToIDNumericUpDown.Value, Color.FromArgb(MainFormClass.FadeColorsRedTrackBar.Value, MainFormClass.FadeColorsGreenTrackBar.Value, MainFormClass.FadeColorsBlueTrackBar.Value), (int)MainFormClass.FadeColorsFadeSpeedNumericUpDown.Value, (double)MainFormClass.FadeColorsFadeFactorNumericUpDown.Value ); } } if (_Index == 1) { MainFormClass.AmbiLightSectionClass.StopAmbilight(); if (MainFormClass.MenuPanel.Visible) { MainFormClass.VisualizerPanel.Visible = true; } MainFormClass.VisualizerPanel.BringToFront(); if (!MainFormClass.InstructionsSectionClass.ContinueInstructionsLoop) { MainFormClass.VisualizerEnabled = true; MainFormClass.VisualizerSectionClass.EnableBASS(true); } } if (_Index == 2) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.IndividualLEDPanel.Visible = true; } MainFormClass.IndividualLEDPanel.BringToFront(); if (!MainFormClass.InstructionsSectionClass.ContinueInstructionsLoop) { MainFormClass.FadeColorsSectionClass.FadeColorsSendData( false, (int)MainFormClass.FadeLEDPanelFromIDNumericUpDown.Value, (int)MainFormClass.FadeLEDPanelToIDNumericUpDown.Value, Color.FromArgb(MainFormClass.FadeColorsRedTrackBar.Value, MainFormClass.FadeColorsGreenTrackBar.Value, MainFormClass.FadeColorsBlueTrackBar.Value), (int)MainFormClass.FadeColorsFadeSpeedNumericUpDown.Value, (double)MainFormClass.FadeColorsFadeFactorNumericUpDown.Value ); } } if (_Index == 3) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.InstructionsPanel.Visible = true; } MainFormClass.InstructionsPanel.BringToFront(); if (!MainFormClass.InstructionsSectionClass.ContinueInstructionsLoop) { MainFormClass.FadeColorsSectionClass.FadeColorsSendData( false, (int)MainFormClass.FadeLEDPanelFromIDNumericUpDown.Value, (int)MainFormClass.FadeLEDPanelToIDNumericUpDown.Value, Color.FromArgb(MainFormClass.FadeColorsRedTrackBar.Value, MainFormClass.FadeColorsGreenTrackBar.Value, MainFormClass.FadeColorsBlueTrackBar.Value), (int)MainFormClass.FadeColorsFadeSpeedNumericUpDown.Value, (double)MainFormClass.FadeColorsFadeFactorNumericUpDown.Value ); } } if (_Index == 4) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.AmbiLightModePanel.Visible = true; } MainFormClass.AmbiLightModePanel.BringToFront(); } if (_Index == 5) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.ServerSettingsPanel.Visible = true; } MainFormClass.ServerSettingsPanel.BringToFront(); } if (_Index == 6) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.AnimationModePanel.Visible = true; } MainFormClass.AnimationModePanel.BringToFront(); } if (_Index == 7) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.ConfigureSetupPanel.Visible = true; } MainFormClass.ConfigureSetupPanel.BringToFront(); } if (_Index == 8) { if (MainFormClass.MenuPanel.Visible) { MainFormClass.GeneralSettingsPanel.Visible = true; } MainFormClass.GeneralSettingsPanel.BringToFront(); } }
private void drawGraph(DataSet dsGrid, string[] arrDay) { DundasCharts.DundasChartBase(Chart1, ChartImageType.Flash, 800, 300 , BorderSkinStyle.Emboss, Color.FromArgb(181, 64, 1), 2 , Color.FromArgb(0xFF, 0xFF, 0xFE) , Color.FromArgb(0xFF, 0xFF, 0xFE), Color.FromArgb(0x20, 0x80, 0xD0), ChartDashStyle.Solid , -1 , ChartHatchStyle.None, GradientType.TopBottom, AntiAliasing.None); Series[] oasrType = new Series[dsGrid.Tables[0].Rows.Count]; int intLP = 0; foreach (DataRow row in dsGrid.Tables[0].Rows) { // For each Row add a new series oasrType[intLP] = DundasCharts.CreateSeries(Chart1, "Series" + intLP.ToString(), Chart1.ChartAreas[0].Name, row["SNM"].ToString(), null, SeriesChartType.Line, 3, GetChartColor(intLP), GetChartColor(intLP), Color.FromArgb(64, 0, 0, 0), 1, 9, Color.FromArgb(64, 64, 64)); for (int colIndex = 1; colIndex < dsGrid.Tables[0].Columns.Count; colIndex++) { // For each column (column 1 and onward) add the value as a point string columnName = dsGrid.Tables[0].Columns[colIndex].ColumnName; double YVal = double.Parse(row[columnName].ToString()); Chart1.Series[oasrType[intLP].Name].Points.AddXY(arrDay[colIndex-1], YVal); } intLP += 1; } DundasAnimations.DundasChartBase(Chart1, AnimationTheme.None, -1, -1, false, 1); for (int i = 0; i < oasrType.Length; i++) { if (i == 0) DundasAnimations.GrowingAnimation(Chart1, oasrType[i], 0.5, 1.0, true); else DundasAnimations.GrowingAnimation(Chart1, oasrType[i], i + 0.1, 1.0, true); oasrType[i].MarkerStyle = GetMarkerStyle(i); oasrType[i].MarkerColor = GetChartColor(i); oasrType[i].MarkerBorderColor = GetChartColor(i); } Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "#,###"; Chart1.DataSource = dsGrid; Chart1.DataBind(); }
private void backgroundFetch_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { IDictionary<string, string> Reals = (IDictionary<string, string>)e.Result; if (!mustReload) mustReload = (Reals.ContainsKey("Version") && Reals.ContainsKey("BaseVersion")) ? DateTime.Parse(Reals["Version"]) > DateTime.Parse(Reals["BaseVersion"]) : false; lbPV.Text = (Reals.ContainsKey("PVText")) ? Reals["PVText"] : "------"; lbRaw.Text = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------"; lbPVCalc.Text = (Reals.ContainsKey("PV")) ? Reals["PV"] : "------"; string alarms = (Reals.ContainsKey("Alarms")) ? Reals["Alarms"] : String.Empty; lbPVEUHI.BackColor = (alarms.IndexOf("HE=") < 0) ? this.BackColor : Color.Magenta; lbPVEULO.BackColor = (alarms.IndexOf("LE=") < 0) ? this.BackColor : Color.Magenta; lbPVHHTP.BackColor = (alarms.IndexOf("HH=") < 0) ? this.BackColor : Color.Red; lbPVHITP.BackColor = (alarms.IndexOf("HI=") < 0) ? this.BackColor : Color.Yellow; lbPVHITP.ForeColor = (alarms.IndexOf("HI=") < 0) ? Color.White : Color.Black; lbPVLOTP.BackColor = (alarms.IndexOf("LO=") < 0) ? this.BackColor : Color.Yellow; lbPVLOTP.ForeColor = (alarms.IndexOf("LO=") < 0) ? Color.White : Color.Black; lbPVLLTP.BackColor = (alarms.IndexOf("LL=") < 0) ? this.BackColor : Color.Red; lastcent = percent; percent = 0; if (Decimal.TryParse((Reals.ContainsKey("PVPercent")) ? (string)Reals["PVPercent"] : "0", out percent)) percent = percent / 100m; lbPVPercent.Text = percent.ToString("0.000 %"); lbPV.BackColor = (Reals.ContainsKey("BackColor")) ? Color.FromArgb(int.Parse(Reals["BackColor"])) : Color.Black; lbPV.ForeColor = (Reals.ContainsKey("ForeColor")) ? Color.FromArgb(int.Parse(Reals["ForeColor"])) : Color.White; bool quit = (Reals.ContainsKey("QuitAlarms")) ? bool.Parse(Reals["QuitAlarms"]) : true; bool alarm = (Reals.ContainsKey("HasAlarms")) ? bool.Parse(Reals["HasAlarms"]) : false; bool lostalarm = (Reals.ContainsKey("HasLostAlarms")) ? bool.Parse(Reals["HasLostAlarms"]) : false; if (!quit && blink) { lbPV.BackColor = Color.Transparent; lbPV.ForeColor = Color.White; if (alarms.IndexOf("HE=True") < 0) lbPVEUHI.BackColor = Color.Transparent; if (alarms.IndexOf("HH=True") < 0) lbPVHHTP.BackColor = Color.Transparent; if (alarms.IndexOf("HI=True") < 0) { lbPVHITP.BackColor = Color.Transparent; lbPVHITP.ForeColor = Color.White; } if (alarms.IndexOf("LO=True") < 0) { lbPVLOTP.BackColor = Color.Transparent; lbPVLOTP.ForeColor = Color.White; } if (alarms.IndexOf("LL=True") < 0) lbPVLLTP.BackColor = Color.Transparent; if (alarms.IndexOf("LE=True") < 0) lbPVEULO.BackColor = Color.Transparent; } if (Reals.ContainsKey("UserLevel")) { string slevel = Reals["UserLevel"]; UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel)); UserLevel level = UserLevel.Диспетчер; foreach (UserLevel item in levels) if (item.ToString().Equals(slevel)) { level = item; break; } if (level >= UserLevel.Оператор) btnQuit.Enabled = !quit; else btnQuit.Enabled = false; } else btnQuit.Enabled = false; pbBar.Invalidate(); blink = !blink; }
private void ShowPlaceTimetable(List<Lesson> listOfLessonsInThisPlace, string place, bool addTimetable = true) { if(addTimetable) PagesManager.AddPage(new Tuple<List<Lesson>, string>(listOfLessonsInThisPlace, place), PagesManager.ePagesType.TimeTable_Place); var gird = MenuSplitViewContentGrid; var actualTheme = Application.Current.RequestedTheme; if (!gird.Children.Any()) { for (var j = 0; j < 7; j++) { gird.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); var tx = new TextBlock() { Text = _dayNames[j], HorizontalAlignment = HorizontalAlignment.Center, Padding = new Thickness(5.0) }; var grid = new Grid(); grid.Children.Add(tx); Grid.SetColumn(grid, j); grid.BorderBrush = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Black : Colors.White); grid.BorderThickness = new Thickness(1.0); grid.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightCyan : Color.FromArgb(127, 0, 150, 0)); gird.Children.Add(grid); } } else { gird.RowDefinitions.Clear(); var listOfObjects = gird.Children.Select(p => (((Grid)p).Children[0] as TextBlock)).ToList(); foreach (TextBlock tb in listOfObjects) { if (!string.IsNullOrEmpty(_dayNames.FirstOrDefault(p => p.Contains(tb.Text)))) continue; gird.Children.Remove((tb.Parent as Grid)); } } SetTitleText($"Plan lekcji - Sala: {place}"); var placeTimetable = new Timetable() { type = Lesson.LessonType.Class, name = place, days = new List<Day>() }; var numOfLessonsOnThisPlace = listOfLessonsInThisPlace.Max(p => p.lessonDayPosition.lessonId)+1; placeTimetable.days.AddRange(Enumerable.Range(0, 5).Select( day => new Day() { Lessons = Enumerable.Range(0, numOfLessonsOnThisPlace).Select( lessonId => listOfLessonsInThisPlace.FirstOrDefault(lesson => lesson.lessonDayPosition.dayId == day && lesson.lessonDayPosition.lessonId == lessonId) ?? new Lesson() {lesson1Name = "", lessonDayPosition = new Lesson.dayCoordiantes() { dayId = day, lessonId = lessonId, timetableId = -1 } } ).ToList()}).ToList()); var headerGrid = gird.Parent as Grid; //checks if we dont have title TextBlock created if (headerGrid.Children.FirstOrDefault(p => p is TextBlock && p != InfoCenterText) == null) { headerGrid.Children.Add(new TextBlock() { Text = placeTimetable.name, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(10.0), Padding = new Thickness(10.0), FontSize = 36 }); } else ((TextBlock)headerGrid.Children.First(p => p is TextBlock && p != InfoCenterText)).Text = placeTimetable.name; //scans by rows for (var i = 0; i < numOfLessonsOnThisPlace+1; i++) { gird.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); // i=0 is a dayName eg Nr,Godz,Poniedzialek etc..., //we dont want to show there lessons if (i == 0) continue; //scans on every column for (var j = 0; j < 7; j++) { var tx = new TextBlock(); var gridlesson = new Grid { IsTapEnabled = true }; //infoTextBlock provides a info about position lesson in a table //for flyout lesson instance looking var text = string.Empty; //j=0 is a number of lesson //j=1 is a hours of this lessons //j>1 is a lesson if (j == 0 || j == 1) { tx.HorizontalAlignment = HorizontalAlignment.Center; tx.VerticalAlignment = VerticalAlignment.Center; } switch (j) { case 0: text = i.ToString(); // number of lesson gridlesson.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightCyan : Color.FromArgb(127, 0, 150, 0)); break; case 1: text = _lessonTimes[i - 1]; // hour of lessons gridlesson.Background = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.LightGreen : Color.FromArgb(127, 204, 0, 0)); break; default: var infoTextBlock = new TextBlock { Visibility = Visibility.Collapsed, Text = $"[] {j} {i} {Timetable.GetIdOfTimetable(placeTimetable.days[j - 2].Lessons[i - 1].lesson1Name == "" ? null : Timetable.GetTimetableById(placeTimetable.days[j - 2].Lessons[i - 1].lessonDayPosition.timetableId, TimeTable), TimeTable)}" }; gridlesson.Children.Add(infoTextBlock); var lesson = placeTimetable.days[j - 2].Lessons[i - 1]; var timetableId = lesson.lessonDayPosition.timetableId; var timetableType = timetableId == -1 ? Lesson.LessonType.Class : Timetable.GetTimetableById(timetableId, TimeTable).type; var timetable = timetableId == -1 ? null : Timetable.GetTimetableById(timetableId, TimeTable); tx.Inlines.Add(new Run { Text = timetable == null ? "" : timetable.name , Foreground = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Purple : Colors.LightCyan) }); tx.Inlines.Add(new Run { Text = place == lesson.lesson1Place ? $" {lesson.lesson1Name}" : $" {lesson.lesson2Name}", Foreground = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Black : Colors.White), FontWeight = FontWeights.Bold }); tx.Inlines.Add(new Run { Text = place == lesson.lesson1Place ? $" {lesson.lesson1Tag}" : $" {lesson.lesson2Tag}", Foreground = new SolidColorBrush(Colors.Red) }); break; } tx.Padding = new Thickness(10.0); //if actually operated record //was a lesson (then text was not added, and is empty) if (text != "") tx.Text = text; if (tx.Text.Trim() != "" && j > 1) { gridlesson.Tapped += (f, m) => { var lesson = Lesson.GetLessonFromLessonGrid(f as Grid, TimeTable); FlyoutHelper.SetTimetable(TimeTable); FlyoutHelper.ShowFlyOutMenuForLesson(gridlesson,place==lesson.lesson1Place?0:1,true); }; } gridlesson.Children.Add(tx); Grid.SetColumn(gridlesson, j); Grid.SetRow(gridlesson, i); gridlesson.BorderBrush = new SolidColorBrush(actualTheme == ApplicationTheme.Light ? Colors.Black : Colors.White); gridlesson.BorderThickness = new Thickness(1.0); gird.Children.Add(gridlesson); } } }
private static void LoadObjectDbXml(string file) { var xmlSettings = XElement.Load(file); // Load Colors foreach (var xElement in xmlSettings.Elements("GlobalColors").Elements("GlobalColor")) { string name = (string)xElement.Attribute("Name"); XNA.Color color = XnaColorFromString((string)xElement.Attribute("Color")); GlobalColors.Add(name, color); } foreach (var xElement in xmlSettings.Elements("Tiles").Elements("Tile")) { var curTile = new TileProperty(); // Read XML attributes curTile.Color = ColorFromString((string)xElement.Attribute("Color")); curTile.Name = (string)xElement.Attribute("Name"); curTile.Id = (int?)xElement.Attribute("Id") ?? 0; curTile.IsFramed = (bool?)xElement.Attribute("Framed") ?? false; curTile.IsSolid = (bool?)xElement.Attribute("Solid") ?? false; curTile.IsSolidTop = (bool?)xElement.Attribute("SolidTop") ?? false; curTile.IsLight = (bool?)xElement.Attribute("Light") ?? false; curTile.FrameSize = StringToVector2Short((string)xElement.Attribute("Size"), 1, 1); curTile.Placement = InLineEnumTryParse <FramePlacement>((string)xElement.Attribute("Placement")); curTile.TextureGrid = StringToVector2Short((string)xElement.Attribute("TextureGrid"), 16, 16); curTile.IsGrass = "Grass".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsPlatform = "Platform".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsCactus = "Cactus".Equals((string)xElement.Attribute("Special")); /* Heathtech */ curTile.IsStone = (bool?)xElement.Attribute("Stone") ?? false; /* Heathtech */ curTile.CanBlend = (bool?)xElement.Attribute("Blends") ?? false; /* Heathtech */ curTile.MergeWith = (int?)xElement.Attribute("MergeWith") ?? null; /* Heathtech */ foreach (var elementFrame in xElement.Elements("Frames").Elements("Frame")) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = (string)elementFrame.Attribute("Name"); curFrame.Variety = (string)elementFrame.Attribute("Variety"); curFrame.UV = StringToVector2Short((string)elementFrame.Attribute("UV"), 0, 0); curFrame.Anchor = InLineEnumTryParse <FrameAnchor>((string)elementFrame.Attribute("Anchor")); // Assign a default name if none existed if (string.IsNullOrWhiteSpace(curFrame.Name)) { curFrame.Name = curTile.Name; } curTile.Frames.Add(curFrame); Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = curFrame.Name + ", " + curFrame.Variety, Origin = curFrame.UV, Size = curTile.FrameSize, Tile = (ushort)curTile.Id, /* SBlogic */ TileName = curTile.Name }); } if (curTile.Frames.Count == 0 && curTile.IsFramed) { var curFrame = new FrameProperty(); // Read XML attributes curFrame.Name = curTile.Name; curFrame.Variety = string.Empty; curFrame.UV = new Vector2Short(0, 0); //curFrame.Anchor = InLineEnumTryParse<FrameAnchor>((string)xElement.Attribute("Anchor")); // Assign a default name if none existed if (string.IsNullOrWhiteSpace(curFrame.Name)) { curFrame.Name = curTile.Name; } curTile.Frames.Add(curFrame); Sprites.Add(new Sprite { Anchor = curFrame.Anchor, IsPreviewTexture = false, Name = curFrame.Name + ", " + curFrame.Variety, Origin = curFrame.UV, Size = curTile.FrameSize, Tile = (ushort)curTile.Id, TileName = curTile.Name }); } TileProperties.Add(curTile); if (!curTile.IsFramed) { TileBricks.Add(curTile); } } for (int i = TileProperties.Count; i < 255; i++) { TileProperties.Add(new TileProperty(i, "UNKNOWN", Color.FromArgb(255, 255, 0, 255), true)); } foreach (var xElement in xmlSettings.Elements("Walls").Elements("Wall")) { var curWall = new WallProperty(); curWall.Color = ColorFromString((string)xElement.Attribute("Color")); curWall.Name = (string)xElement.Attribute("Name"); curWall.Id = (int?)xElement.Attribute("Id") ?? -1; curWall.IsHouse = (bool?)xElement.Attribute("IsHouse") ?? false; WallProperties.Add(curWall); } foreach (var xElement in xmlSettings.Elements("Items").Elements("Item")) { var curItem = new ItemProperty(); curItem.Id = (int?)xElement.Attribute("Id") ?? -1; curItem.Name = (string)xElement.Attribute("Name"); ItemProperties.Add(curItem); _itemLookup.Add(curItem.Id, curItem); } foreach (var xElement in xmlSettings.Elements("Npcs").Elements("Npc")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); NpcIds.Add(name, id); NpcNames.Add(id, name); int frames = (int?)xElement.Attribute("Frames") ?? 16; NpcFrames.Add(id, frames); } foreach (var xElement in xmlSettings.Elements("ItemPrefix").Elements("Prefix")) { int id = (int?)xElement.Attribute("Id") ?? -1; string name = (string)xElement.Attribute("Name"); ItemPrefix.Add((byte)id, name); } foreach (var xElement in xmlSettings.Elements("ShortCutKeys").Elements("Shortcut")) { var key = InLineEnumTryParse <Key>((string)xElement.Attribute("Key")); var tool = (string)xElement.Attribute("Tool"); ShortcutKeys.Add(key, tool); } XElement appSettings = xmlSettings.Element("App"); int appWidth = (int?)appSettings.Attribute("Width") ?? 800; int appHeight = (int?)appSettings.Attribute("Height") ?? 600; int clipboardSize = (int)XNA.MathHelper.Clamp((int?)appSettings.Attribute("ClipboardRenderSize") ?? 512, 64, 4096); _appSize = new Vector2(appWidth, appHeight); ClipboardBuffer.ClipboardRenderSize = clipboardSize; ToolDefaultData.LoadSettings(xmlSettings.Elements("Tools")); AltC = (string)xmlSettings.Element("AltC"); }
public void GetAllCard() { bool isError = false; List<Card> allCards = null; App.ProxyMutex.WaitOne(); try { allCards = ServiceProxy.Proxy.GetAllCard(App.UserName, curr_page); } catch (CommunicationException exc) { App.OnException(); isError = true; } App.ProxyMutex.ReleaseMutex(); if (isError) { App.OnConnectionError(); return; } if (allCards != null) { this.Dispatcher.Invoke(new Action(delegate { //clear foreach (CardPlace item in AllCardsGrid.Children) { item.ContainsCard = false; item.ToolTip = null; item.sellBtn.IsEnabled = false; //item.CardContextMenu.Visibility = Visibility.Hidden; } foreach (CardPlace item in SlotGrid.Children) { item.ContainsCard = false; item.ToolTip = null; } //fill foreach (var item in allCards) { CardPlace cp; if (item.slot >= 10) { int index = curr_page == 1 ? item.slot - 10 : item.slot - ((curr_page - 1) * 24) - 10; cp = AllCardsGrid.Children[index] as CardPlace; cp.ThisCard = item; CardInfo ci = new CardInfo(); ci.CardName.Content = item.card_name; ci.Rarity.Content = App.rarityDictionary[item.cardRarity].RarityName; ci.Rarity.Foreground = App.rarityDictionary[item.cardRarity].RarityColor; ci.Dmg.Content = "Атака: " + item.dmg; ci.Def.Content = "Защита: " + item.def; ci.Hp.Content = "Здоровье: " + item.hp; ci.Level.Content = "Уровень: " + item.min_level; cp.ToolTip = new ToolTip() { Background = new SolidColorBrush(Color.FromArgb(230, 0, 0,0)), BorderThickness = new Thickness(0), Content = ci }; cp.sellBtn.IsEnabled = true; //cp.CardContextMenu.Visibility = Visibility.Visible; //cp.CardContextMenuSellBtn.Click += new RoutedEventHandler(CardContextMenuSellBtn_Click); } else { cp = SlotGrid.Children[item.slot - 1] as CardPlace; cp.ThisCard = item; CardInfo ci = new CardInfo(); ci.CardName.Content = item.card_name; ci.Rarity.Content = App.rarityDictionary[item.cardRarity].RarityName; ci.Rarity.Foreground = App.rarityDictionary[item.cardRarity].RarityColor; ci.Dmg.Content = "Атака: " + item.dmg; ci.Def.Content = "Защита: " + item.def; ci.Hp.Content = "Здоровье: " + item.hp; ci.Level.Content = "Уровень: " + item.min_level; cp.ToolTip = new ToolTip() { Background = new SolidColorBrush(Color.FromArgb(230, 0, 0, 0)), BorderThickness = new Thickness(0), Content = ci }; } } })); } }
private void ReloadPage() { try { ControlHelper.FreezeControl(tableLayoutPanel1, true); List<int> lst = new List<int>(); if (PageCount <= 9) { for (var i = 1; i <= PageCount; i++) { lst.Add(i); } } else { if (this.PageIndex <= 6) { for (var i = 1; i <= 7; i++) { lst.Add(i); } lst.Add(-1); lst.Add(PageCount); } else if (this.PageIndex > PageCount - 6) { lst.Add(1); lst.Add(-1); for (var i = PageCount - 6; i <= PageCount; i++) { lst.Add(i); } } else { lst.Add(1); lst.Add(-1); var begin = PageIndex - 2; var end = PageIndex + 2; if (end > PageCount) { end = PageCount; begin = end - 4; if (PageIndex - begin < 2) { begin = begin - 1; } } else if (end + 1 == PageCount) { end = PageCount; } for (var i = begin; i <= end; i++) { lst.Add(i); } if (end != PageCount) { lst.Add(-1); lst.Add(PageCount); } } } for (int i = 0; i < 9; i++) { UCBtnExt c = (UCBtnExt)this.tableLayoutPanel1.Controls.Find("p" + (i + 1), false)[0]; if (i >= lst.Count) { c.Visible = false; } else { if (lst[i] == -1) { c.BtnText = "..."; c.Enabled = false; } else { c.BtnText = lst[i].ToString(); c.Enabled = true; } c.Visible = true; if (lst[i] == PageIndex) { c.RectColor = Color.FromArgb(255, 77, 59); } else { c.RectColor = Color.FromArgb(223, 223, 223); } } } ShowBtn(PageIndex > 1, PageIndex < PageCount); } finally { ControlHelper.FreezeControl(tableLayoutPanel1, false); } }
private void Form1_Load(object sender, EventArgs e) { label11.BackColor = Color.FromArgb(161, 242, 235); SuaXin(); GetHealth(); }
private void LoadColor() { this.BackColor = Color.FromArgb(int.Parse(DataBase.CaiDat.MAIN_BACKCOLOR)); //m_btnThem.BackColor = m_btnLuu.BackColor = m_btnSua.BackColor = m_btnTaoTK.BackColor = m_btnXoa.BackColor = Color.FromArgb(int.Parse(DataBase.CaiDat.TABBUTTONCOLOR)); //m_btHide.BackColor = m_btclose.BackColor = Color.FromArgb(int.Parse(DataBase.CaiDat.TOPBUTTONCOLOR)); }
private void DrawBlackWhite(int value) { Color color = Color.FromArgb(value, value, value); SetBackColor(color); }
/* * embedText * string text, Bitmap bmp * text를 bmp에 숨김 * payload text * carrier bmp */ public static Bitmap embedText(string text, Bitmap bmp) { State state = State.Hiding; //상태를 숨김 모드로 설정 int charIndex = 0; //숨긴 문자 갯수를 저장하는 변수 int charValue = 0; //숨길 대상의 문자를 저장하는 변수 long pixelElementIndex = 0; //R=0, G=1, B=2 int zeros = 0; //문자 하나의 비트 수 int R = 0, G = 0, B = 0; //R,G,B값을 모두 0으로 초기화 for (int i = 0; i < bmp.Height; i++) //Bitmap 객체의 세로 길이(높이)부터 1비트씩 확인 { for (int j = 0; j < bmp.Width; j++) //Bitmap 객체의 가로 길이(너비)부터 1비트씩 확인 { Color pixel = bmp.GetPixel(j, i); //가로 세로 위치를 이용해 색 정보(픽셀)를 리턴 R = pixel.R - pixel.R % 2; G = pixel.G - pixel.G % 2; B = pixel.B - pixel.B % 2; //해당 픽셀의 R,G,B 각각의 LSB비트를 0으로 초기화 for (int n = 0; n < 3; n++) //3번 반복 (R,G,B) { if (pixelElementIndex % 8 == 0) //만약 pixelElementIndex가 0이나 8인 경우 { if (state == State.Filling_With_Zeros && zeros == 8) //만약 해당 상태가 숨김 완료 모드이고 8비트(한 문자) 모두 확인했다면 { if ((pixelElementIndex - 1) % 3 < 2) //R,G,B 모두 처리한 경우 { bmp.SetPixel(j, i, Color.FromArgb(R, G, B)); //해당 R,B,B값으로 픽셀 설정 } return(bmp); //text가 숨겨져 있는 Bitmap bmp 반환 } if (charIndex >= text.Length) //숨겨야 할 text를 모두 저장한 경우 { state = State.Filling_With_Zeros; //상태를 숨김 완료 모드로 설정 } else { //숨겨야 할 text를 모두 저장하지 못한 경우 charValue = text[charIndex++]; //숨길 대상의 문자를 저장하고 charIndex(숨긴 문자 갯수) 1 증가 } } //pixelElementIndex % 3에 따라 수행 switch (pixelElementIndex % 3) { case 0: //0일때 : R { if (state == State.Hiding) //상태가 숨김 모드이면 { R += charValue % 2; //R에 LSB값 저장(0 또는 1) } charValue /= 2; //charValue를 2로 나눔(LSB 0으로 만듬) } break; case 1: //1일때 : G { if (state == State.Hiding) //상태가 숨김 모드면 { G += charValue % 2; //G에 LSB값 저장(0 또는 1) charValue /= 2; //charValue를 2로 나눔(LSB 0으로 만듬) } } break; case 2: //2일때 : B { if (state == State.Hiding) //상태가 숨김 모드면 { B += charValue % 2; //B에 LSB값 저장(0 또는 1) charValue /= 2; //charValue를 2로 나눔(LSB 0으로 만듬) } bmp.SetPixel(j, i, Color.FromArgb(R, G, B)); //해당 RGB에 해당하는 픽셀 세팅 } break; } pixelElementIndex++; //pixelElementIndex 1 증가 if (state == State.Filling_With_Zeros) //상태가 숨김 완료 모드이면 { zeros++; //zero 1 증가 } } } } return(bmp); //Bitmap bmp 반환 }
private void consolebutton_MouseHover(object sender, EventArgs e) { consolebutton.FlatAppearance.MouseOverBackColor = Color.FromArgb(37, 255, 203, 0); }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); Graphics G = e.Graphics; G.SmoothingMode = SmoothingMode.HighQuality; G.Clear(Parent.BackColor); int SwitchXLoc = 3; Rectangle ControlRectangle = new Rectangle(0, 0, Width - 1, Height - 1); GraphicsPath ControlPath = RoundRectangle.RoundRect(ControlRectangle, 4); LinearGradientBrush BackgroundLGB = default(LinearGradientBrush); if (_Toggled) { SwitchXLoc = 37; BackgroundLGB = new LinearGradientBrush(ControlRectangle, Color.FromArgb(231, 108, 58), Color.FromArgb(236, 113, 63), 90.0F); } else { SwitchXLoc = 0; BackgroundLGB = new LinearGradientBrush(ControlRectangle, Color.FromArgb(208, 208, 208), Color.FromArgb(226, 226, 226), 90.0F); } // Fill inside background gradient G.FillPath(BackgroundLGB, ControlPath); // Draw string switch (ToggleType) { case _Type.OnOff: if (Toggled) { G.DrawString("ON", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("OFF", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; case _Type.YesNo: if (Toggled) { G.DrawString("YES", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("NO", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; case _Type.IO: if (Toggled) { G.DrawString("I", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.WhiteSmoke, Bar.X + 18, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } else { G.DrawString("O", new Font("Segoe UI", 12, FontStyle.Regular), Brushes.DimGray, Bar.X + 59, (float)(Bar.Y + 13.5), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } break; } Rectangle SwitchRectangle = new Rectangle(SwitchXLoc, 0, Width - 38, Height); GraphicsPath SwitchPath = RoundRectangle.RoundRect(SwitchRectangle, 4); LinearGradientBrush SwitchButtonLGB = new LinearGradientBrush(SwitchRectangle, Color.FromArgb(253, 253, 253), Color.FromArgb(240, 238, 237), LinearGradientMode.Vertical); // Fill switch background gradient G.FillPath(SwitchButtonLGB, SwitchPath); // Draw borders if (_Toggled == true) { G.DrawPath(new Pen(Color.FromArgb(185, 89, 55)), SwitchPath); G.DrawPath(new Pen(Color.FromArgb(185, 89, 55)), ControlPath); } else { G.DrawPath(new Pen(Color.FromArgb(181, 181, 181)), SwitchPath); G.DrawPath(new Pen(Color.FromArgb(181, 181, 181)), ControlPath); } }
public void polowienia() { //p1 i p2 to przedziały ( początkowy i końcowy ) Number p1 = new Number(1.0, 2.0); Number p2 = new Number(3.0, 2.0); // Random rnd = new Random(); Number epsilon = new Number(rnd.Next(2, 7), 100.0); polowienieBox.AppendText("epsilon wynosi " + epsilon.value + "\nkolejne podziały: \n"); Function f_p1 = new Function(p1.value); Function f_p2 = new Function(p2.value); if (f_p1.val * f_p2.val < 0.0) { PointPairList lista = new PointPairList(); Random random = new Random(); for (int i = 0; i < 15; i++) { // dodawanie przedzialow na wykresie lista.Add(f_p1.arg, 0); lista.Add(f_p1.arg, -20 + i * 2.5); lista.Add(f_p2.arg, -20 + i * 2.5); lista.Add(f_p2.arg, 0); System.Threading.Thread.Sleep(25); LineItem myCurve = zedGraphControl1.GraphPane.AddCurve("", lista, Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)), SymbolType.None); myCurve.Line.Width = 1.0f; zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); // polowienieBox.AppendText(i + 1 + ". " + f_p1.arg + " - " + f_p2.arg + "\n"); Function srodek = new Function((f_p1.arg + f_p2.arg) / 2.0); if (srodek.modulus() < epsilon.value) { polowienieBox.AppendText("\n\nMiejsce zerowe znalezione!\nPrzybliżone miejsce zerowe (" + srodek.val.ToString("0.###") + " < " + epsilon.value + ") znaleziono w x = " + srodek.arg.ToString("#.###")); //dodawanie strzalki na wykresie ArrowObj strzalka = new ArrowObj(Color.Black, 10.0f, srodek.arg, srodek.val + 45, srodek.arg, srodek.val + 5); zedGraphControl1.GraphPane.GraphObjList.Add(strzalka); zedGraphControl1.Refresh(); break; } else { if (f_p1.val * srodek.val < 0) { f_p2 = new Function(srodek.arg); } else { f_p1 = new Function(srodek.arg); } } } } else { MessageBox.Show("Kryczyny błąd", "wartosci funkcji dla tego przedziału są tego samego znaku - algorytm nie może kontynuować", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//=----------------------------------------------------------------------------------------------= protected void SetBackGroundColor(Control _cltr) { try { foreach (Control _cltrs in _cltr.Controls) { if (_cltrs is System.Windows.Forms.TabPage) { _cltr.BackColor = Global.ThemeColorLight; _cltrs.ForeColor = Color.Black; SetBackGroundColor(_cltrs); } if (_cltrs is System.Windows.Forms.TabControl) { _cltr.BackColor = Global.ThemeColorLight; _cltrs.ForeColor = Color.Black; SetBackGroundColor(_cltrs); } if (_cltrs is System.Windows.Forms.GroupBox) { _cltrs.ForeColor = Color.Black; SetBackGroundColor(_cltrs); } if (_cltrs is SplitterPanel) SetBackGroundColor(_cltrs); if (_cltrs is System.Windows.Forms.SplitContainer) SetBackGroundColor(_cltrs); if (_cltrs is CheckedListBox) _cltrs.BackColor = Global.ThemeColorLight; if (_cltrs is DateTimePicker) { ((DateTimePicker)_cltrs).CalendarTitleBackColor = Global.ThemeColorDark; ((DateTimePicker)_cltrs).CalendarMonthBackground = Global.ThemeColorLight; } if (_cltrs is LTPLGridView) { //((LTPLGridView)_cltrs).AlternatingRowsDefaultCellStyle.BackColor = Global.ThemeColorLight; //Color.FromArgb(230, 240, 250); //Color.FromArgb(214, 230, 246); if (Global.ThemeName == "SaitecSolutions") ((LTPLGridView)_cltrs).SetBgColor = Color.FromArgb(189, 171, 168); else ((LTPLGridView)_cltrs).SetBgColor = Global.ThemeColorLight; ((LTPLGridView)_cltrs).RowsDefaultCellStyle.SelectionForeColor = Color.White; ((LTPLGridView)_cltrs).RowsDefaultCellStyle.SelectionBackColor = Global.ThemeColorDark; ((LTPLGridView)_cltrs).AllowUserToResizeRows = false; ((LTPLGridView)_cltrs).SetReadOnlyColBgColor = Global.ThemeColorLight; ((LTPLGridView)_cltrs).EnableHeadersVisualStyles = false; ((LTPLGridView)_cltrs).ColumnHeadersDefaultCellStyle.BackColor = Global.ThemeColorLight; ((LTPLGridView)_cltrs).ColumnHeadersDefaultCellStyle.ForeColor = Color.Black; ((LTPLGridView)_cltrs).CellBorderStyle = DataGridViewCellBorderStyle.None; ((LTPLGridView)_cltrs).ColumnHeadersDefaultCellStyle.BackColor = Global.ThemeGridHeaderCell; //if (((LTPLGridView)_cltrs).TotalCol != null || ((LTPLGridView)_cltrs).SummaryCol != null) //{ // int _intHeight = (((LTPLGridView)_cltrs).Height - ((LTPLGridView)_cltrs).ColumnHeadersHeight) % (((LTPLGridView)_cltrs).RowTemplate.Height); // if (((LTPLGridView)_cltrs).Dock == DockStyle.Fill) // ((LTPLGridView)_cltrs).Parent.Height = ((LTPLGridView)_cltrs).Parent.Height - _intHeight - 2; // else // ((LTPLGridView)_cltrs).Height = ((LTPLGridView)_cltrs).Height - _intHeight - 2; //} ((LTPLGridView)_cltrs).AllowUserToResizeRows = false; ((LTPLGridView)_cltrs).EnableHeadersVisualStyles = false; ((LTPLGridView)_cltrs).ColumnHeadersDefaultCellStyle.ForeColor = Color.Black; ((LTPLGridView)_cltrs).CellBorderStyle = DataGridViewCellBorderStyle.None; } if (_cltrs is LTPLLOV) { ((LTPLLOV)_cltrs).BackColor = Global.ThemeColorDark;// Color.FromArgb(210, 202, 196); //Global.ThemeColorDark; ((LTPLLOV)_cltrs).BarColor = Global.ThemeColorLight; ((LTPLLOV)_cltrs).LOVGrid.ColumnHeadersDefaultCellStyle.BackColor = Global.ThemeGridHeaderCell; } if (_cltrs is LTPLButtonControl) { ((LTPLButtonControl)_cltrs).SetColor = Global.ThemeColorDark; ((LTPLButtonControl)_cltrs).SetLightColor = Global.ThemeColorLight; //((LTPLButtonControl)_cltrs).Height = 42; } if (_cltrs is LTPLReprotButtonControl) { ((LTPLReprotButtonControl)_cltrs).SetColor = Global.ThemeColorDark; ((LTPLReprotButtonControl)_cltrs).Height = 42; ((LTPLReprotButtonControl)_cltrs).SetLightColor = Global.ThemeColorLight; } if (_cltrs is LTPLGroupBox) { if (((LTPLGroupBox)_cltrs).BackgroundGradientMode != LTPLGroupBox.GroupBoxGradientMode.None) { ((LTPLGroupBox)_cltrs).BackgroundColor = Global.ThemeColorLight; ((LTPLGroupBox)_cltrs).BackgroundGradientColor = Global.ThemeColorDark; ((LTPLGroupBox)_cltrs).ShadowColor = Global.ThemeColorDark; ((LTPLGroupBox)_cltrs).BackgroundGradientMode = LTPLGroupBox.GroupBoxGradientMode.BackwardDiagonal; ((LTPLGroupBox)_cltrs).ShadowThickness = 3; } //((LTPLGroupBox)_cltrs).BorderColor = Global.ThemeColorLight; } if (_cltrs is Panel) { ((Panel)_cltrs).BackColor = Global.ThemeColorDark; } } } catch (Exception ex) { } }
private void honebtn_MouseLeave(object sender, EventArgs e) { honebtn.BackColor = Color.FromArgb(64, 64, 64); }
// Token: 0x060001BA RID: 442 RVA: 0x0000B66C File Offset: 0x0000986C protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Bitmap bitmap = new Bitmap(base.Width, base.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.Clear(Color.Transparent); graphics.FillPath(this.bj, this.il); graphics.DrawPath(this.bh, this.il); LinearGradientBrush linearGradientBrush = new LinearGradientBrush(new Rectangle(base.Width - 23, 4, 19, 19), Color.FromArgb(241, 241, 241), Color.FromArgb(241, 241, 241), 90f); graphics.FillRectangle(linearGradientBrush, linearGradientBrush.Rectangle); graphics.DrawRectangle(new Pen(Color.FromArgb(252, 252, 252)), new Rectangle(base.Width - 22, 5, 17, 17)); graphics.DrawRectangle(new Pen(Color.FromArgb(180, 180, 180)), new Rectangle(base.Width - 23, 4, 19, 19)); graphics.DrawLine(new Pen(Color.FromArgb(250, 252, 250)), new Point(base.Width - 22, base.Height - 16), new Point(base.Width - 5, base.Height - 16)); graphics.DrawLine(new Pen(Color.FromArgb(180, 180, 180)), new Point(base.Width - 22, base.Height - 15), new Point(base.Width - 5, base.Height - 15)); graphics.DrawLine(new Pen(Color.FromArgb(250, 250, 250)), new Point(base.Width - 22, base.Height - 14), new Point(base.Width - 5, base.Height - 14)); graphics.DrawString("+", new Font("Tahoma", 8f), Brushes.Gray, (float)(base.Width - 19), (float)(base.Height - 26)); graphics.DrawString("-", new Font("Tahoma", 12f), Brushes.Gray, (float)(base.Width - 19), (float)(base.Height - 20)); kI.NH nh = this.kN; if (nh != kI.NH.NI) { if (nh == kI.NH.NJ) { graphics.DrawString(Convert.ToString(this.bL), this.Font, new SolidBrush(this.ForeColor), new Rectangle(0, 0, base.Width - 1, base.Height - 1), new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } } else { graphics.DrawString(Convert.ToString(this.bL), this.Font, new SolidBrush(this.ForeColor), new Rectangle(5, 0, base.Width - 1, base.Height - 1), new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center }); } e.Graphics.DrawImage((Image)bitmap.Clone(), 0, 0); graphics.Dispose(); bitmap.Dispose(); }
/// <summary>Lights up the provided color and returns it</summary> private Color LightColor(Color Color) { int A = Color.A; int R = (Convert.ToInt32(Color.R) + 1024)/5; int G = (Convert.ToInt32(Color.G) + 1024)/5; int B = (Convert.ToInt32(Color.B) + 1024)/5; return Color.FromArgb(A, R, G, B); }
public Color Fusionar() { if (mHijos == null) { return mColor; } else { long r = 0; long g = 0; long b = 0; Color Color = default(Color); r = 0; g = 0; b = 0; for (int i = 0; i <= 7; i++) { Color = mHijos[i].Fusionar(); r += Color.R; g += Color.G; b += Color.B; } return Color.FromArgb(255, r / 8, g / 8, b / 8); } }