public static IEnumerable<Spot> GetSpots(RandomPaint proper) { List<Spot> spots = new List<Spot>(); for (int i = 0; i < proper.TailCount; i++) { Spot spot = new Spot(proper); spots.Add(spot); } return spots; }
private Dictionary<string, RandomPaint> getAllProperPaints() { Dictionary<string, RandomPaint> propers = new Dictionary<string, RandomPaint>(); int numProper = 0; using (var t = _db.TransactionManager.StartTransaction()) { var lt = _db.LayerTableId.GetObject(OpenMode.ForRead) as LayerTable; foreach (ObjectId idLayer in lt) { var layer = idLayer.GetObject(OpenMode.ForRead) as LayerTableRecord; RandomPaint proper = new RandomPaint(layer.Name, numProper++, layer.Color.ColorValue, layer.Id); propers.Add(proper.LayerName, proper); } } return propers; }
private void AddControls(RandomPaint proper) { string tag = proper.LayerName; GroupBox groupBox = new GroupBox(); //CheckBox checkBox = new CheckBox(); // Lock/Ublock TextBox textBox = new TextBox(); // % Button buttonDel = new Button(); TrackBar trackBar = new TrackBar(); Label label = new Label(); groupBox.SuspendLayout(); ((ISupportInitialize)(trackBar)).BeginInit(); SuspendLayout(); // groupBox groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; groupBox.Tag = tag; groupBox.Name = "groupBox" + tag; groupBox.Size = new Size(378, 72); groupBox.TabStop = false; groupBox.Text = tag; groupBox.Controls.Add(textBox); groupBox.Controls.Add(buttonDel); groupBox.Controls.Add(trackBar); groupBox.Controls.Add(label); groupBox.Enabled = true; groupBox.Visible = true; groupBox.Location = _location; shiftLocation(DISTANCE_BETWEEN_GROUP); // textbox % textBox.Anchor = AnchorStyles.Right; textBox.Font = new Font("Microsoft Sans Serif", 11.25F, FontStyle.Regular, GraphicsUnit.Point, 204); textBox.Location = new Point(291, 28); textBox.Name = "textBox" + tag; textBox.Size = new Size(43, 24); textBox.Tag = tag; textBox.Text = proper.Percent.ToString(); // buttonDel buttonDel.Anchor = AnchorStyles.Right; buttonDel.BackgroundImage = Properties.Resources.delete; buttonDel.BackgroundImageLayout = ImageLayout.Stretch; buttonDel.Location = new Point(344, 27); buttonDel.Name = "buttonDel" + tag; buttonDel.Size = new Size(28, 28); buttonDel.Text = "-"; buttonDel.UseVisualStyleBackColor = true; buttonDel.Tag = tag; // trackBar trackBar.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; trackBar.BackColor = proper.Color; trackBar.Location = new Point(12, 19); trackBar.Name = "trackBar" + tag; trackBar.Size = new Size(273, 45); trackBar.TickStyle = TickStyle.Both; trackBar.Tag = tag; trackBar.Maximum = 100; trackBar.Value = proper.Percent; // Label label.AutoSize = true; label.Location = new Point(301, 12); label.Name = "labelTemp2"; label.Size = new Size(15, 13); label.TabIndex = 9; label.Text = "%"; this.Controls.Add(groupBox); // События textBox.TextChanged += TextBox_TextChanged; trackBar.ValueChanged += trackBar_ValueChanged; buttonDel.Click += buttonDel_Click; _groupBoxs.Add(proper.LayerName, groupBox); }
// Запись текущего значения процента в текстбокс private void setPercentToTextBox(RandomPaint proper) { GroupBox groupBox = _groupBoxs[proper.LayerName]; string tag = (string)groupBox.Tag; TextBox textBox = groupBox.Controls.Find("textBox" + tag, false).First() as TextBox; textBox.Text = proper.Percent.ToString(); }
// Получение корректного нового значения процента (чтобы не превышалось 100% распределения) private int getCorrectValue(RandomPaint proper, int newValue) { int delta = newValue - proper.Percent; int value = newValue; // Нельзя распределить больше 100% if (delta > 0) { int oldDistributedPercent = distributedPercent(); int newDistributedPercent = oldDistributedPercent + delta; if (newDistributedPercent >= 100) { value = 100 - oldDistributedPercent + proper.Percent; return value; } } return value; }
private void addTrackProper(RandomPaint proper) { // Проверка нет ли уже такого слоя в распределении if (!_trackPropers.ContainsKey(proper.LayerName)) { _trackPropers.Add(proper.LayerName, proper); AddControls(proper); } }
public Spot(RandomPaint proper) { _proper = proper; }