// open image when any of recent image clicked private void RecentImagesClick(object sender, EventArgs e) { if (drawLines.Any() || redoLines.Any()) { ShowUnsavedChangesWarning(sender, e); } var image = (ToolStripMenuItem)sender; Image img; if (!File.Exists(image.Text)) { MessageBox.Show("Could not open file: " + image.Text + ".\n\nNo such file exists!"); return; } using (var bmpTemp = new Bitmap(image.Text)) { img = new Bitmap(bmpTemp); } DrawPanel.BackgroundImage = img; drawLines.Clear(); Undo.Enabled = false; redoLines.Clear(); Redo.Enabled = false; DrawPanel.Invalidate(); fileName = image.Text; UpdateRecent(fileName); }
private void StartAnimation(AnimationType anim) { switch (anim) { case AnimationType.UpdateMap: animationTimer.Stop(); AnimationCount = 0; DrawPanel.Invalidate(); break; case AnimationType.UnitWaiting: animationTimer.Stop(); AnimationFrames = GetAnimationFrames.UnitWaiting(_main.ViewPieceMode); AnimationCount = 0; animationTimer.Interval = 200; // ms animationTimer.Start(); break; case AnimationType.UnitMoving: //AnimType = AnimationType.UnitMoving; AnimationFrames = GetAnimationFrames.UnitMoving(_main.ViewPieceMode); break; case AnimationType.ViewPiece: animationTimer.Stop(); AnimationCount = 0; animationTimer.Interval = 200; // ms animationTimer.Start(); break; } }
// When an option is clicked, update the bool array of options private void ClickPanels_Click(object sender, EventArgs e) { Control clickedControl = (Control)sender; // Sender gives you which control is clicked. int index = _clickPanels.FindIndex(a => a == clickedControl); // Get which control is clicked in a list _choiceOptions[index] = !_choiceOptions[index]; DrawPanel.Invalidate(); }
public void ZoomOUTclicked(Object sender, EventArgs e) { if (Game.Zoom != 8) { Game.Zoom--; MapViewChange(CentrXY); StartAnimation(AnimType); DrawPanel.Invalidate(); } }
private void MapViewChange(int[] newCenterCoords) { if (map != null) { map.Dispose(); } ReturnCoordsAtMapViewChange(newCenterCoords); map = Draw.MapPart(Game.ActiveCiv.Id, mapStartXY[0], mapStartXY[1], mapDrawSq[0], mapDrawSq[1], Game.Zoom, Game.Options.FlatEarth); DrawPanel.Invalidate(); }
private void MainForm_Load(object sender, EventArgs e) { DrawPanel.MouseWheel += DrawPanel_MouseWheel; (DrawPanel as Control).KeyUp += DrawPanel_KeyUp; (DrawPanel as Control).KeyDown += DrawPanel_KeyDown; SemanticNetwork = new SemanticNetwork(new List <Node>(), new List <Edge>(), "Семантическая сеть"); converter = new Converter(DrawPanel.Width, DrawPanel.Height, -5, 5, -5, 5); Test(); DrawPanel.Invalidate(); }
private void DrawPanel_MouseWheel(object sender, MouseEventArgs e) { double x = converter.IItoXX(e.X); double y = converter.JJtoYY(e.Y); coeff = e.Delta < 0 ? 1.03f : 0.97f; converter.Xmin = x - (x - converter.Xmin) * coeff; converter.Xmax = x + (converter.Xmax - x) * coeff; converter.Ymin = y - (y - converter.Ymin) * coeff; converter.Ymax = y + (converter.Ymax - y) * coeff; DrawPanel.Invalidate(); }
// add the last removed line when redo clicked private void RedoClick(object sender, EventArgs e) { var line = redoLines.Pop(); //pop line from redoLines drawLines.Push(line); //add line back to drawLines Undo.Enabled = true; //as soon as a line is redone we want to be able to undo it. if (!redoLines.Any()) { Redo.Enabled = false; //if redoLines is empty disable the redo button } DrawPanel.Invalidate(); //redraw the Draw Panel }
private void DrawPanel_MouseClick(object sender, MouseEventArgs e) { DrawPanel.Focus(); Drawing.Editing(e.Location, SemanticNetwork); if (e.Button == MouseButtons.Left) { SemanticNetwork.Deselect(); } if (AddingNewEdgeFlag) { for (int i = 0; i < SemanticNetwork.Nodes.Count; i++) { Node node = Drawing.CheckNode(e.X, e.Y, SemanticNetwork); if (node == null) { return; } if (selected1 == null) { selected1 = node; break; } if (selected2 == null) { selected2 = node; if (selected1 == null) { return; } EdgeForm addNewEdgeForm = new EdgeForm(); addNewEdgeForm.SetRelations = SemanticNetwork.Relations; addNewEdgeForm.Converter = converter; if (addNewEdgeForm.ShowDialog() == DialogResult.OK) { Relation relation = addNewEdgeForm.Relation; EdgeConfig ec = addNewEdgeForm.EdgeConfig; Edge edge = new Edge(relation, selected1, selected2, ec); //edge.EdgeConfig.SetDefaultValues(edge.NodeOne, edge.NodeTwo); SemanticNetwork.AddEdge(edge); AddingNewEdgeFlag = false; } DrawPanel.Invalidate(); selected1 = null; selected2 = null; break; } } } }
private void DrawPanel_MouseMove(object sender, MouseEventArgs e) { Drawing.Select(e.Location, SemanticNetwork); if (SemanticNetwork.SelectedNode != null) { SemanticNetwork.DeSelectEdges(); } if (e.Button == MouseButtons.Left) { if (SemanticNetwork.SelectedNode != null) { SemanticNetwork.SelectedNode.Position = converter.IJtoXY(e.Location); } if (SemanticNetwork.EditingEdge != null) { PointF mark = Drawing.CheckMark(e.Location, SemanticNetwork.EditingEdge); if (mark != PointF.Empty) { if (mark == SemanticNetwork.EditingEdge.EdgeConfig.Markers[Utils.MarkerType.Center]) { SemanticNetwork.EditingEdge.EdgeConfig.Y = converter.JJtoYY(e.Y); } else if (mark == SemanticNetwork.EditingEdge.EdgeConfig.Markers[Utils.MarkerType.CenterStart]) { SemanticNetwork.EditingEdge.EdgeConfig.XStart = (e.Location.X - (converter.XXtoII(SemanticNetwork.EditingEdge.NodeOne.X) - Drawing.GetSizeF(SemanticNetwork.EditingEdge.NodeOne).Width / 2)) / converter.Scale; } else if (mark == SemanticNetwork.EditingEdge.EdgeConfig.Markers[Utils.MarkerType.CenterEnd]) { SemanticNetwork.EditingEdge.EdgeConfig.XEnd = (e.Location.X - (converter.XXtoII(SemanticNetwork.EditingEdge.NodeTwo.X) - Drawing.GetSizeF(SemanticNetwork.EditingEdge.NodeTwo).Width / 2)) / converter.Scale; } } } } else if (e.Button == MouseButtons.Middle) { double dx = converter.IItoXX(e.X) - converter.IItoXX(e0.X); double dy = converter.JJtoYY(e.Y) - converter.JJtoYY(e0.Y); e0 = e; converter.Xmin -= dx; converter.Ymin -= dy; converter.Xmax -= dx; converter.Ymax -= dy; } else if (e.Button == MouseButtons.Right) { } DrawPanel.Invalidate(); }
private void DrawPanel_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { } else if (e.Button == MouseButtons.Middle) { e0 = e; } else if (e.Button == MouseButtons.Right) { } DrawPanel.Invalidate(); }
// call ShowUnsavedChangesWarning and reset everything private void NewImageClick(object sender, EventArgs e) { if (drawLines.Any() || redoLines.Any()) { ShowUnsavedChangesWarning(sender, e); } drawLines.Clear(); Undo.Enabled = false; redoLines.Clear(); Redo.Enabled = false; fileName = string.Empty; DrawPanel.BackgroundImage = null; DrawPanel.Invalidate(); }
/// <summary> /// Draws the graph on the DrawPanel's graphic surface. /// </summary> private void DrawGraph() { if (WindowState == FormWindowState.Minimized) { return; } if (Graph == null) { DrawPanel.Invalidate(); return; } using (var graphics = DrawPanel.CreateGraphics()) Graph.DrawAutomata(graphics, 0, 0, DrawPanel.Width, DrawPanel.Height); }
void timer_Tick(object sender, EventArgs e) { alpha += delta; if (alpha >= 255 || alpha <= 0) { alpha = delta > 0 ? 255 : 0; timer.Stop(); if (delta < 0) { BringToFront(); } else { SendToBack(); } Hidden = delta > 0; Layer.Size = delta > 0 ? ClientSize : Size.Empty; } Layer.Invalidate(); }
private void ResetButton_Click(object sender, EventArgs e) { //wipe panel of darts DrawPanel.Invalidate(); ApproxPiNum.Text = SimsLabelNum.Text = PercentDifferenceLabelNum.Text = "0"; SimBackgroundWorker.CancelAsync(); StartBtn.Enabled = true; StopBtn.Enabled = false; RunForeverCheckbox.Enabled = true; IterationsToRunTextBox.Enabled = true; IterationsToRunLabel.Enabled = true; //resets vars as to not effect future iterations _percentDifference = 0; _approximatedPi = 0; _insideUnitCircle = 0; _iterationsRan = 0; InsideCircleLabel.Text = OutsideCircleLabel.Text = "0"; }
// open file after openFile dialog private void OpenFileOk(object sender, CancelEventArgs e) { var openFileDialogue = (OpenFileDialog)sender; fileName = openFileDialogue.FileName; Image img; using (var bmpTemp = new Bitmap(fileName)) { img = new Bitmap(bmpTemp); } DrawPanel.BackgroundImage = img; drawLines.Clear(); Undo.Enabled = false; redoLines.Clear(); Redo.Enabled = false; UpdateRecent(fileName); DrawPanel.Invalidate(); }
// add line to drawLines container if Line is selected, set start & finish point emply, and call OnPaint private void MouseUp(object sender, MouseEventArgs e) { OnMouseUp(e); finish = e.Location; if (!start.IsEmpty && !finish.IsEmpty) { if (tool == Tool.Line) { var points = new List <Tuple <Point, Point> >(); points.Add(new Tuple <Point, Point>(start, finish)); drawLines.Push(new Line(new Pen(pen.Color, pen.Width), new List <Tuple <Point, Point> >(points))); } else { drawLines.Push(new Line(new Pen(pen.Color, pen.Width), new List <Tuple <Point, Point> >(points))); } } start = Point.Empty; finish = Point.Empty; Undo.Enabled = true; //as soon as a line exists we want to be able to undo it. DrawPanel.Invalidate(); }
// Once slider value changes --> redraw list private void VerticalBarValueChanged(object sender, EventArgs e) { _barValue = _verticalBar.Value; DrawPanel.Invalidate(); }
private void DrawPanel_MouseClick(object sender, MouseEventArgs e) { first_or_second = !first_or_second; if (first_or_second) { firstClick.X = e.X; firstClick.Y = e.Y; } else { secondClick.X = e.X; secondClick.Y = e.Y; } //what to call? if (first_or_second == false) { if (lineRadio.Checked) { shapes.Add(new line(firstClick.X, secondClick.X, firstClick.Y, secondClick.Y, pen)); } else if (rectRadio.Checked) { int tlX = getMin(firstClick.X, secondClick.X); int tlY = getMin(firstClick.Y, secondClick.Y); int rectWidth = Math.Abs((firstClick.X - secondClick.X)); int rectHeight = Math.Abs((firstClick.Y - secondClick.Y)); if (fill_chkbox.Checked) { shapes.Add(new rectangle(tlX, tlY, rectWidth, rectHeight, presentBrush)); } if (outline_chkbox.Checked) { shapes.Add(new rectangle(tlX, tlY, rectWidth, rectHeight, pen)); } } else if (ellipseRadio.Checked) { int tlX = getMin(firstClick.X, secondClick.X); int tlY = getMin(firstClick.Y, secondClick.Y); int ellWidth = Math.Abs((firstClick.X - secondClick.X)); int ellHeight = Math.Abs((firstClick.Y - secondClick.Y)); if (fill_chkbox.Checked) { shapes.Add(new ellipse(tlX, tlY, ellWidth, ellHeight, presentBrush)); } if (outline_chkbox.Checked) { shapes.Add(new ellipse(tlX, tlY, ellWidth, ellHeight, pen)); } } else if (textRadio.Checked) { int tlX = getMin(firstClick.X, secondClick.X); int tlY = getMin(firstClick.Y, secondClick.Y); int txtWidth = Math.Abs((firstClick.X - secondClick.X)); int txtHeight = Math.Abs((firstClick.Y - secondClick.Y)); Rectangle rect = new Rectangle(tlX, tlY, txtWidth, txtHeight); shapes.Add(new text(txt, textPen, rect)); } } DrawPanel.Invalidate(); }
private void DrawPanel_MouseDoubleClick(object sender, MouseEventArgs e) { Drawing.Select(e.Location, SemanticNetwork); if (SemanticNetwork.SelectedNode != null) { if (e.Button == MouseButtons.Left) { NodeForm nf = new NodeForm(); nf.Info = SemanticNetwork.SelectedNode.Concept; nf.Converter = converter; if (nf.ShowDialog() == DialogResult.OK) { NodeConfig nc = nf.NodeConfig; SemanticNetwork.SelectedNode.Concept = nf.Info; SemanticNetwork.SelectedNode.NodeConfig = nc; } } else if (e.Button == MouseButtons.Right) { if (MessageBox.Show("Вы уверены?", "Подтвердите действие", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SemanticNetwork.DeleteNode(SemanticNetwork.SelectedNode); } } } else if (SemanticNetwork.SelectedEdge != null) { if (e.Button == MouseButtons.Left) { EdgeForm addNewEdgeForm = new EdgeForm(); addNewEdgeForm.SetRelations = SemanticNetwork.Relations; addNewEdgeForm.Relation = SemanticNetwork.SelectedEdge.Relation; addNewEdgeForm.Converter = converter; addNewEdgeForm.EdgeConfig = SemanticNetwork.SelectedEdge.EdgeConfig; if (addNewEdgeForm.ShowDialog() == DialogResult.OK) { Relation relation = addNewEdgeForm.Relation; EdgeConfig ec = addNewEdgeForm.EdgeConfig; ec.Selected = true; SemanticNetwork.SelectedEdge.EdgeConfig = ec; SemanticNetwork.SelectedEdge.Relation = relation; SemanticNetwork.DeSelectEditing(); } } else if (e.Button == MouseButtons.Right) { if (MessageBox.Show("Вы уверены?", "Подтвердите действие", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SemanticNetwork.DeleteEdge(SemanticNetwork.SelectedEdge); } } } else { if (e.Button == MouseButtons.Left) { NodeForm nf = new NodeForm(); nf.Converter = converter; if (nf.ShowDialog() == DialogResult.OK) { NodeConfig nc = nf.NodeConfig; SemanticNetwork.AddNode(new Node(nf.Info, converter.IJtoXY(e.Location), nc)); } } } DrawPanel.Invalidate(); }
void OnGridEnableCheck(object sender, EventArgs e) { Game.GridEnabled = EnableGridCheckbox.Checked; DrawPanel?.Invalidate(); }
private void RefreshPanel(object sender, EventArgs e) { DrawPanel.Invalidate(); DrawPanel.Update(); }
private void MapEventHappened(object sender, MapEventArgs e) { switch (e.EventType) { case MapEventType.MapViewChanged: { MapViewChange(e.CentrXY); break; } case MapEventType.SwitchViewMovePiece: { if (_main.ViewPieceMode) { StartAnimation(AnimationType.ViewPiece); } else { StartAnimation(AnimationType.UnitWaiting); } break; } case MapEventType.ViewPieceMoved: { StartAnimation(AnimationType.ViewPiece); break; } case MapEventType.ToggleBetweenCurrentEntireMapView: { DrawPanel.Invalidate(new Rectangle(0, 0, DrawPanel.Width, DrawPanel.Height)); Update(); break; } case MapEventType.ZoomChanged: { MapViewChange(CentrXY); StartAnimation(AnimType); DrawPanel.Invalidate(); break; } case MapEventType.CenterView: { MapViewChange(Game.ActiveXY); DrawPanel.Invalidate(); break; } case MapEventType.ToggleGrid: { MapViewChange(CentrXY); StartAnimation(AnimType); DrawPanel.Invalidate(); break; } default: break; } }
private void Animation_Tick(object sender, EventArgs e) { switch (AnimType) { case AnimationType.UnitWaiting: { // At new unit turn initially re-draw the whole map if (AnimationCount == 0) { DrawPanel.Invalidate(new Rectangle(0, 0, DrawPanel.Width, DrawPanel.Height)); } else { DrawPanel.Invalidate(new Rectangle(ActiveOffsetPx.X, ActiveOffsetPx.Y - Game.Ypx, 2 * Game.Xpx, 3 * Game.Ypx)); } break; } case AnimationType.ViewPiece: { // At new unit turn initially re-draw the whole map if (AnimationCount == 0) { DrawPanel.Invalidate(new Rectangle(0, 0, DrawPanel.Width, DrawPanel.Height)); } else if (ActiveOffsetPx.X >= 0 && ActiveOffsetPx.X <= DrawPanel.Width && ActiveOffsetPx.Y >= 0 && ActiveOffsetPx.Y <= DrawPanel.Height) // Draw only if active piece is within the panel { DrawPanel.Invalidate(new Rectangle(ActiveOffsetPx.X, ActiveOffsetPx.Y, 2 * Game.Xpx, 2 * Game.Ypx)); } break; } case AnimationType.UnitMoving: { //DrawPanel.Invalidate(new Rectangle((Game.ActiveXY[0] - MapPanel_offset[0]) * 32 - 64, (Game.ActiveXY[1] - MapPanel_offset[1]) * 16 - 48, 3 * 64, (3 * 32) + 16)); Update(); if (AnimationCount == 7) // Unit has completed movement { // First update world map with new visible tiles Game.UpdateWorldMapAfterUnitHasMoved(); // Update the original world map image with image of new location of unit & redraw whole map IUnit unit = Game.Instance.ActiveUnit; // Game.CivsMap[Game.Instance.ActiveCiv.Id] = ModifyImage.MergedBitmaps(Game.CivsMap[Game.Instance.ActiveCiv.Id], AnimationFrames[TimerCounter], 32 * unit.LastXY[0] - 64, 16 * unit.LastXY[1] - 48); DrawPanel.Invalidate(new Rectangle(0, 0, DrawPanel.Width, DrawPanel.Height)); Update(); // Then stop animation StartAnimation(AnimationType.UpdateMap); // Check if unit moved outside map view -> map view needs to be updated if (UnitMovedOutsideMapView) { ReturnCoordsAtMapViewChange(Game.ActiveXY); DrawPanel.Invalidate(new Rectangle(0, 0, DrawPanel.Width, DrawPanel.Height)); Update(); } } break; } } AnimationCount++; }
private void clearToolStripMenuItem_Click(object sender, EventArgs e) { shapes.Clear(); DrawPanel.Invalidate(); }
private void NextCityButton_Click(object sender, EventArgs e) { _thisCity = Game.GetCities[1]; // TODO: search only in your civ's cities Invalidate(); DrawPanel.Invalidate(); }
// Once slider value changes --> redraw improvements list private void ImprovementsBarValueChanged(object sender, EventArgs e) { DrawPanel.Invalidate(); }
// Once slider value changes --> redraw list private void HorizontalBarValueChanged(object sender, EventArgs e) { _barValue = _horizontalBar.Value; DrawPanel.Invalidate(); }
public void recordWindowSwitch(Boolean makeNewFile) { String s = GetActiveProcessName(); Debug.WriteLine(DateTime.Now + " " + makeNewFile); // Update the amount of time spent on processes System.TimeSpan diff = DateTime.Now.Subtract(curr); if (dict.ContainsKey(currprocess)) { dict[currprocess] = dict[currprocess].Add(diff); } else { dict.Add(currprocess, diff); } String displayname = currprocess; if (mapping.ContainsKey(currprocess)) { displayname = mapping[currprocess]; } // Log.Text += "Successfully added duration " + diff + " to process " + displayname + "\r\n"; // If this is not a "midnight" change, only write data if ProcessClock works if (!makeNewFile) { // If one opens the ProcessClock window, the program will automatically write all data to the day's file if (s.Equals("ProcessClock")) { WriteData(); // Redraw static data graph DrawPanel.Invalidate(true); } } else { // Create a folder to store ProcessClock files if it doesn't already exist string subPath = path + "\\ProcessClock"; // Write all remaining data WriteDataPast(); // Clear current memory dict = new Dictionary <String, TimeSpan>(); mapping = new Dictionary <String, String>(); // Prepare subpath LoadOptions(subPath); // Schedule next action for next midnight Action switchFilesAtMidnight = () => recordWindowSwitch(true); DateTime nextMidnight = DateTime.Today.AddDays(1); ScheduleAction(switchFilesAtMidnight, nextMidnight); } currprocess = s; curr = DateTime.Now; }
private void undoToolStripMenuItem_Click(object sender, EventArgs e) { shapes.RemoveAt(shapes.Count - 1); DrawPanel.Invalidate(); }