public virtual void UpdateStat() { RetailSum = Lines.Sum(x => x.RetailSum); SupplierSumWithoutNds = Lines.Sum(x => x.SupplierSumWithoutNds); SupplierSum = Lines.Sum(x => x.SupplierSum); PosCount = Lines.Count(); }
public void Calculate() { Total = Lines.Sum(l => l.TotalExpense); Average = Total / Lines.Count(); foreach (SharingLine line in Lines) { line.CalculateDebt(Average); } }
private void HandleControlKeyDown(object sender, KeyEventArgs e) { e.Handled = true; if (Keys.V == e.KeyCode) { VerifySelectionForTextInsert(); string input = Clipboard.GetText(TextDataFormat.Text); InsertUserInput(input); } else if (Keys.C == e.KeyCode) { Copy(); } else if (Keys.X == e.KeyCode) { Cut(); if ((SelectionStart + SelectionLength) > _promptPosition) { FlushInputBuffer(); } } else if (Keys.Home == e.KeyCode) { SelectionStart = 0; ScrollToCaret(); } else if (Keys.End == e.KeyCode) { SelectionStart = EndOfLinePosition; ScrollToCaret(); } else if (Keys.Up == e.KeyCode) { int lineIndex = GetLineFromCharIndex(SelectionStart); lineIndex = Math.Max(0, lineIndex - 1); int charIndex = GetFirstCharIndexFromLine(lineIndex); Select(charIndex, 0); ScrollToCaret(); } else if (Keys.Down == e.KeyCode) { int lineIndex = GetLineFromCharIndex(SelectionStart); lineIndex = Math.Min(Lines.Count() - 1, lineIndex + 1); int charIndex = GetFirstCharIndexFromLine(lineIndex); Select(charIndex, 0); ScrollToCaret(); } else { e.Handled = false; } }
public bool NextLine() { if (Lines.Count() <= lineCount + 1) { lineCount++; return(true); } else { return(false); } }
public void SelectLastLine() { if (Lines.Any()) { var line = Lines.Count() - 1; var s1 = GetFirstCharIndexOfCurrentLine(); var s2 = line < Lines.Count() - 1 ? GetFirstCharIndexFromLine(line + 1) - 1 : Text.Length; Select(s1, s2 - s1); } }
public MarkupString ToMarkupString() { List <string> retInfo = new List <string>(); retInfo.Add($"Scene Key: {SceneKey}"); retInfo.Add($"Scene Line Count: {Lines.Count()}"); retInfo.Add($"Scene Action Count: {Actions.Count()}"); foreach (var action in Actions) { retInfo.Add(action.ToString()); } return((MarkupString)string.Join("<br />", retInfo)); }
/// <summary> /// Processes all lines in the text box /// </summary> /// <param name="force">Forces the recoloring of all lines. /// Otherwise, already colored lines are not processed again</param> public void ProcessAllLines(bool force = false) { if (ApplyPatterns) { CanPaint = false; if (Lines.Count() < 300) { if (force) { _processedLines.Clear(); } int lineNumber = 0; int start = 0; foreach (string line in Lines) { lineNumber = lineNumber + 1; if (!_processedLines.Contains(lineNumber)) { ProcessLine(start, line); _processedLines.Add(lineNumber); } start = start + line.Length + 1; } } else { // For longer text, it takes too much time to apply to coloring algorithm. // Don't color anything in that case int savedSelectionStart = SelectionStart; int savedSelectionLength = SelectionLength; Color savedSelectionColor = SelectionBackColor; SelectionStart = 0; SelectionLength = TextLength; SelectionColor = Color.Black; SelectionFont = RegularFont; SelectionStart = savedSelectionStart; SelectionLength = savedSelectionLength; SelectionColor = savedSelectionColor; } CanPaint = true; } }
public void ApplyQuantityDiscounts() { //Assumption here - one discount per order line, and only the best one gets counted. foreach (var orderLine in Lines) { var validDiscount = Discounts.FirstOrDefault(d => Lines.Count() >= d.QuantityRequired && orderLine.BaseLinePrice >= d.QualifyingPrice); if (validDiscount != null) { orderLine.AdjustedLinePrice = orderLine.BaseLinePrice * validDiscount.Multiplier; } else { orderLine.AdjustedLinePrice = orderLine.BaseLinePrice; } } }
public Location GetChoppingBoardLocation() { for (int i = 0; i < Lines.Count(); i++) { for (int j = 0; j < Lines[i].Count(); j++) { if (Lines[i][j].Equals('C')) { return(new Location { X = j, Y = i }); } } } return(null); }
public Location GetStrawberriesLocation() { for (int i = 0; i < Lines.Count(); i++) { for (int j = 0; j < Lines[i].Count(); j++) { if (Lines[i][j].Equals('S')) { return(new Location { X = j, Y = i }); } } } return(null); }
public Location GetIcecreamLocation() { for (int i = 0; i < Lines.Count(); i++) { for (int j = 0; j < Lines[i].Count(); j++) { if (Lines[i][j].Equals('I')) { return(new Location { X = j, Y = i }); } } } return(null); }
void SelectCurrentLine() { if (Lines == null || !Lines.Any()) { return; } for (int i = 0; i < Lines.Count(); i++) { if (Lines.ElementAt(i).LineNumber == LineNumber) { RTB.Document.Blocks.ElementAt(i).Background = _currentMatchedLineBackgroundBrush; break; } else { RTB.Document.Blocks.ElementAt(i).Background = null; } } }
public override string Solve() { List <int[][]> puzzles = new List <int[][]>(); for (int i = 1; i < Lines.Count(); i += 10) // 9 lines for puzzle + 1 for header { // take 9 lines of puzzle, for each line get each column and convert to digit int[][] puzzle = Lines.Skip(i).Take(9).Select(x => x.Trim().Select(c => c - '0').ToArray()).ToArray(); puzzles.Add(puzzle); } int counter = 0; foreach (int[][] puzzle in puzzles) { SudokuSolver.SudokuSolver.Solve(puzzle); counter += puzzle[0][0] * 100 + puzzle[0][1] * 10 + puzzle[0][2]; } return(counter.ToString(CultureInfo.InvariantCulture)); }
public void BeginGetAll(Func <IMarkGeometry, bool> callback) { Parallel.For(0, Points.Count(), index => { callback(Points[index]); } ); Parallel.For(0, Lines.Count(), index => { callback(Lines[index]); } ); Parallel.For(0, Arcs.Count(), index => { callback(Arcs[index]); } ); Parallel.For(0, Circles.Count(), index => { callback(Circles[index]); } ); Parallel.For(0, Paths.Count(), index => { callback(Paths[index]); } ); }
/// <summary> /// Applies function to all geometries /// </summary> /// <param name="function">The function apply to all geometries</param> public void MapFunc(Func <IMarkGeometry, IMarkGeometry> function) { Parallel.For(0, Points.Count(), index => { Points[index] = function(Points[index]) as MarkGeometryPoint; } ); Parallel.For(0, Lines.Count(), index => { Lines[index] = function(Lines[index]) as MarkGeometryLine; } ); Parallel.For(0, Arcs.Count(), index => { Arcs[index] = function(Arcs[index]) as MarkGeometryArc; } ); Parallel.For(0, Circles.Count(), index => { Circles[index] = function(Circles[index]) as MarkGeometryCircle; } ); Parallel.For(0, Paths.Count(), index => { Paths[index] = function(Paths[index]) as MarkGeometryPath; } ); }
public virtual void UpdateStat() { SupplierSum = Lines.Sum(x => x.SupplierSum); PosCount = Lines.Count(); }
/// <summary> /// Check if operation is same as previous operation /// If previous operation is move node (by arrow forexample) is better group operation like one big move instead of many small moves. /// </summary> public bool isSame(string type, Nodes nodes, Lines lines) { if (operations.Count()>0) { UndoOperation operation = operations.First(); if (operation.type == type) { if (operation.nodes.Count() == 0 && nodes == null) { } else if ((operation.nodes == null && nodes != null) || (operation.nodes != null && nodes == null)) { return false; } else if (operation.nodes.Count() == nodes.Count()) { for (int i = 0; i < nodes.Count(); i++) { if (operation.nodes[i].id != nodes[i].id) { return false; } } } else { return false; } if (operation.lines.Count() == 0 && lines == null) { } else if ((operation.lines == null && lines != null) || (operation.lines != null && lines == null)) { return false; } else if (operation.lines.Count() == lines.Count()) { for (int i = 0; i < lines.Count(); i++) { if (operation.lines[i].start != lines[i].start || operation.lines[i].end != lines[i].end) { return false; } } } else { return false; } return true; } } return false; }
public override void SetExtents() { Extents.MinX = double.MaxValue; Extents.MaxX = double.MinValue; Extents.MinY = double.MaxValue; Extents.MaxY = double.MinValue; Extents.MinZ = double.MaxValue; Extents.MaxZ = double.MinValue; int[] ns = { Points.Count(), Arcs.Count(), Circles.Count(), Lines.Count(), Paths.Count() }; int n = GeometricArithmeticModule.Max <int>(ns); for (int i = 0; i < n; i++) { if (i < Points.Count()) { Extents.MaxX = Math.Max(Extents.MaxX, Points[i].Extents.MaxX); Extents.MaxY = Math.Max(Extents.MaxY, Points[i].Extents.MaxY); Extents.MaxZ = Math.Max(Extents.MaxZ, Points[i].Extents.MaxZ); Extents.MinX = Math.Min(Extents.MinX, Points[i].Extents.MinX); Extents.MinY = Math.Min(Extents.MinY, Points[i].Extents.MinY); Extents.MinZ = Math.Min(Extents.MinZ, Points[i].Extents.MinZ); } if (i < Arcs.Count()) { Extents.MaxX = Math.Max(Extents.MaxX, Arcs[i].Extents.MaxX); Extents.MaxY = Math.Max(Extents.MaxY, Arcs[i].Extents.MaxY); Extents.MaxZ = Math.Max(Extents.MaxZ, Arcs[i].Extents.MaxZ); Extents.MinX = Math.Min(Extents.MinX, Arcs[i].Extents.MinX); Extents.MinY = Math.Min(Extents.MinY, Arcs[i].Extents.MinY); Extents.MinZ = Math.Min(Extents.MinZ, Arcs[i].Extents.MinZ); } if (i < Circles.Count()) { Extents.MaxX = Math.Max(Extents.MaxX, Circles[i].Extents.MaxX); Extents.MaxY = Math.Max(Extents.MaxY, Circles[i].Extents.MaxY); Extents.MaxZ = Math.Max(Extents.MaxZ, Circles[i].Extents.MaxZ); Extents.MinX = Math.Min(Extents.MinX, Circles[i].Extents.MinX); Extents.MinY = Math.Min(Extents.MinY, Circles[i].Extents.MinY); Extents.MinZ = Math.Min(Extents.MinZ, Circles[i].Extents.MinZ); } if (i < Lines.Count()) { Extents.MaxX = Math.Max(Extents.MaxX, Lines[i].Extents.MaxX); Extents.MaxY = Math.Max(Extents.MaxY, Lines[i].Extents.MaxY); Extents.MaxZ = Math.Max(Extents.MaxZ, Lines[i].Extents.MaxZ); Extents.MinX = Math.Min(Extents.MinX, Lines[i].Extents.MinX); Extents.MinY = Math.Min(Extents.MinY, Lines[i].Extents.MinY); Extents.MinZ = Math.Min(Extents.MinZ, Lines[i].Extents.MinZ); } if (i < Paths.Count()) { Extents.MaxX = Math.Max(Extents.MaxX, Paths[i].Extents.MaxX); Extents.MaxY = Math.Max(Extents.MaxY, Paths[i].Extents.MaxY); Extents.MaxZ = Math.Max(Extents.MaxZ, Paths[i].Extents.MaxZ); Extents.MinX = Math.Min(Extents.MinX, Paths[i].Extents.MinX); Extents.MinY = Math.Min(Extents.MinY, Paths[i].Extents.MinY); Extents.MinZ = Math.Min(Extents.MinZ, Paths[i].Extents.MinZ); } } GridWidth = Extents.MaxX - Extents.MinX; GridHeight = Extents.MaxY - Extents.MinY; GridDepth = Extents.MaxZ - Extents.MinZ; Origin = new MarkGeometryPoint( Extents.MinX + (0.5 * GridWidth), Extents.MinY + (0.5 * GridHeight), Extents.MinZ + (0.5 * GridDepth) ); }
// EVENT Mouse Up // [MOUSE] [UP] [EVENT] public void DiagramApp_MouseUp(object sender, MouseEventArgs e) { #if DEBUG this.logEvent("MouseUp"); #endif this.actualMousePos.set(e.X, e.Y); Position mouseTranslation = new Position(this.actualMousePos).subtract(this.startMousePos); // States bool mousemove = ((this.actualMousePos.x != this.startMousePos.x) || (this.actualMousePos.y != this.startMousePos.y)); // mouse change position bool buttonleft = e.Button == MouseButtons.Left; bool buttonright = e.Button == MouseButtons.Right; bool buttonmiddle = e.Button == MouseButtons.Middle; bool isreadonly = this.diagram.options.readOnly; bool keyalt = this.keyalt; bool keyctrl = this.keyctrl; bool keyshift = this.keyshift; bool dblclick = this.stateDblclick; bool finishdraging = this.stateDragSelection; bool finishadding = this.stateAddingNode; bool finishselecting = mousemove && this.stateSelectingNodes; MoveTimer.Enabled = false; if(dblclick) { this.stateSelectingNodes = false; } else // KEY DRAG if (finishdraging) // drag node { if (!this.diagram.options.readOnly) { if (this.sourceNode != null && !keyctrl) // return node to starting position after connection is created { Position translation = new Position(this.startNodePos) .subtract(sourceNode.position); if (this.selectedNodes.Count > 0) { foreach (Node node in this.selectedNodes) { node.position.add(translation); } } this.diagram.InvalidateDiagram(); } } } else // KEY DRAG-MMIDDLE if (finishadding) { this.diagram.InvalidateDiagram(); } else // KEY DRAG+MLEFT select nodes with selection rectangle if (finishselecting) { if (mousemove) { Position a = new Position(this.startMousePos) .scale(this.scale) .add(this.shift) .subtract(this.startShift); Position b = new Position(this.actualMousePos) .scale(this.scale); int temp; if (b.x < a.x) { temp = a.x; a.x = b.x; b.x = temp; } if (b.y < a.y) { temp = b.y; b.y = a.y; a.y = temp; } if (!this.keyshift) this.ClearSelection(); foreach (Node rec in this.currentLayer.nodes) { if ( (rec.layer == this.currentLayer.id || rec.id == this.currentLayer.id) && -this.shift.x + a.x <= rec.position.x && rec.position.x + rec.width <= -this.shift.x + b.x && -this.shift.y + a.y <= rec.position.y && rec.position.y + rec.height <= -this.shift.y + b.y) // get all nodes in selection rectangle { if (keyshift && !keyctrl && !keyalt) // KEY SHIFT+MLEFT Invert selection { if (rec.selected) { this.RemoveNodeFromSelection(rec); } else { this.SelectNode(rec); } } if (!keyshift && !keyctrl && !keyalt) // KEY MLEFT select nodes { this.SelectNode(rec); } } } this.diagram.InvalidateDiagram(); } } Node TargetNode = this.findNodeInMousePosition(new Position(e.X, e.Y)); if (buttonleft) // MLEFT { if (!keyalt && keyctrl && !keyshift && TargetNode != null && TargetNode.selected) // CTRL+CLICK add node to selection { this.RemoveNodeFromSelection(TargetNode); this.diagram.InvalidateDiagram(); } else if (!keyalt && keyctrl && !keyshift && TargetNode != null && !TargetNode.selected) // CTRL+CLICK remove node from selection { this.SelectNode(TargetNode); this.diagram.InvalidateDiagram(); } else if (this.stateCoping && mousemove) // CTRL+DRAG copy part of diagram { this.stateCoping = false; DiagramBlock newBlock = this.diagram.duplicatePartOfDiagram(this.selectedNodes, this.currentLayer.id); Position vector = new Position(this.actualMousePos) .scale(this.scale) .subtract(this.vmouse) .subtract(this.shift) .subtract(this.sourceNode.position); // filter only top nodes fromm all new created nodes. NewNodes containing sublayer nodes. Nodes topNodes = new Nodes(); foreach (Node node in newBlock.nodes) { if (node.layer == this.currentLayer.id) { topNodes.Add(node); } } foreach (Node node in topNodes) { node.position.add(vector); } this.diagram.unsave("create", newBlock.nodes, newBlock.lines); this.SelectNodes(topNodes); this.diagram.unsave(); this.diagram.InvalidateDiagram(); } else if (bottomScrollBar != null && rightScrollBar != null && (bottomScrollBar.MouseUp() || rightScrollBar.MouseUp())) { this.diagram.InvalidateDiagram(); } else // KEY MLEFT clear selection if (!mousemove && TargetNode == null && this.sourceNode == null && this.selectedNodes.Count() > 0 && !keyalt && !keyctrl && !keyshift) { this.ClearSelection(); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create node and conect with existing node if (!isreadonly && !keyshift && keyctrl && keyalt && TargetNode == null && this.sourceNode != null) { var s = this.sourceNode; var node = this.CreateNode(new Position(e.X, e.Y)); node.shortcut = s.id; this.diagram.Connect(s, node); this.diagram.unsave("create", node, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create shortcut beetwen objects if (!isreadonly && !keyshift && keyctrl && keyalt && TargetNode != null && this.sourceNode != null && TargetNode != this.sourceNode) { this.diagram.unsave("edit", this.sourceNode, this.shift, this.currentLayer.id); this.sourceNode.link = "#" + TargetNode.id.ToString(); this.diagram.unsave(); this.diagram.InvalidateDiagram(); } else // KEY DRAG move node if ( !isreadonly && ( (TargetNode == null && this.sourceNode != null) || ( TargetNode != null && this.sourceNode != TargetNode && TargetNode.selected ) || (TargetNode != null && this.sourceNode == TargetNode) ) && Math.Sqrt(mouseTranslation.x * mouseTranslation.x + mouseTranslation.y * mouseTranslation.y) > 5 ) { Position vector = new Position(this.actualMousePos) .scale(this.scale) .subtract(this.vmouse) .subtract(this.shift) .subtract(this.sourceNode.position); if (this.selectedNodes.Count > 0) { this.diagram.undoOperations.add("edit", this.selectedNodes, null, this.shift, this.currentLayer.id); foreach (Node node in this.selectedNodes) { node.position.add(vector); } this.diagram.unsave(); } this.diagram.InvalidateDiagram(); } else // KEY DRAG+CTRL create node and conect with existing node if (!isreadonly && !keyshift && !keyctrl && keyalt && TargetNode != null && this.sourceNode == null) { Node node = this.CreateNode( new Position( +this.shift.x - startShift.x + this.startMousePos.x, +this.shift.y - startShift.y + this.startMousePos.y ) ); Line line = this.diagram.Connect( node, TargetNode ); this.diagram.unsave("create", node, line, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY CTRL+ALT+DRAG create node and make shortcut to target node if (!isreadonly && keyalt && keyctrl && !keyshift && TargetNode != null && this.sourceNode == null) { Node newrec = this.CreateNode( new Position(this.shift).subtract(startShift).add(this.startMousePos) ); newrec.link = "#" + TargetNode.id; this.diagram.unsave("create", newrec, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DBLCLICK open link or edit window after double click on node [dblclick] [open] [edit] if (dblclick && this.sourceNode != null && !keyctrl && !keyalt && !keyshift) { this.resetStates(); this.OpenLinkAsync(this.sourceNode); } else // KEY SHIFT+DBLCLICK open node edit form if (dblclick && this.sourceNode != null && !keyctrl && !keyalt && keyshift) { this.diagram.EditNode(this.sourceNode); } else // KEY CTRL+DBLCLICK open link in node if (dblclick && this.sourceNode != null && keyctrl && !keyalt && !keyshift) { if (this.sourceNode.link != "") { Os.openPathInSystem(this.sourceNode.link); } } else // KEY DBLCLICK+SPACE change position in zoom view mode if (this.stateZooming && dblclick && !keyctrl && !keyalt && !keyshift) { this.shift .subtract( this.actualMousePos .clone() .scale(this.scale) ) .add( (this.ClientSize.Width * this.scale) / 2, (this.ClientSize.Height * this.scale) / 2 ); this.diagram.InvalidateDiagram(); } else // KEY CTRL+SHIFT+MLEFT conect with selected nodes new node or selected node if (!isreadonly && keyshift && keyctrl && this.selectedNodes.Count() > 0 && e.X == this.startMousePos.x && e.Y == this.startMousePos.y) { // TODO Still working this? Node newrec = TargetNode; Nodes newNodes = new Nodes(); if (newrec == null) { newrec = this.CreateNode(this.actualMousePos.clone().subtract(10), false); newNodes.Add(newrec); } Lines newLines = new Lines(); foreach (Node rec in this.selectedNodes) { Line line = this.diagram.Connect(rec, newrec); newLines.Add(line); } this.SelectOnlyOneNode(newrec); this.diagram.unsave("create", newNodes, newLines, this.shift, this.currentLayer.id); } else // KEY ALT+MLEFT // KEY DBLCLICK create new node if (!isreadonly && (dblclick || keyalt) && !keyshift && !keyctrl && TargetNode == null && this.sourceNode == null && e.X == this.startMousePos.x && e.Y == this.startMousePos.y) { Node newNode = this.CreateNode(this.actualMousePos.clone().subtract(10), false); this.diagram.unsave("create", newNode, this.shift, this.currentLayer.id); } else // KEY DRAG+ALT copy style from node to other node if (!isreadonly && !keyshift && !keyctrl && keyalt && TargetNode != null && this.sourceNode != null && this.sourceNode != TargetNode) { if (this.selectedNodes.Count() > 1) { this.diagram.undoOperations.add("edit", this.selectedNodes, null, this.shift, this.currentLayer.id); foreach (Node rec in this.selectedNodes) { rec.copyNodeStyle(TargetNode); } this.diagram.unsave(); } if (this.selectedNodes.Count() == 1 || (this.selectedNodes.Count() == 0 && this.sourceNode != null)) { this.diagram.undoOperations.add("edit", TargetNode, this.shift, this.currentLayer.id); TargetNode.copyNodeStyle(this.sourceNode); if (this.selectedNodes.Count() == 1 && this.selectedNodes[0] != this.sourceNode) { this.ClearSelection(); this.SelectNode(this.sourceNode); } this.diagram.unsave(); } } else // KEY DRAG make link between two nodes if (!isreadonly && !keyctrl && !keyalt && TargetNode != null && this.sourceNode != null && this.sourceNode != TargetNode) { bool arrow = false; if (keyshift) { arrow = true; } Lines newLines = new Lines(); Lines removeLines = new Lines(); if (this.selectedNodes.Count() > 0) { foreach (Node rec in this.selectedNodes) { if (rec != TargetNode) { if (this.diagram.hasConnection(rec, TargetNode)) { Line removeLine = this.diagram.getLine(rec, TargetNode); removeLines.Add(removeLine); this.diagram.Disconnect(rec, TargetNode); } else { Line newLine = this.diagram.Connect(rec, TargetNode, arrow, null); newLines.Add(newLine); } } } } if (newLines.Count() > 0 && removeLines.Count() > 0) { this.diagram.undoOperations.startGroup(); this.diagram.undoOperations.add("create", null, newLines, this.shift, this.currentLayer.id); this.diagram.undoOperations.add("delete", null, removeLines, this.shift, this.currentLayer.id); this.diagram.undoOperations.endGroup(); this.diagram.unsave(); } else if (newLines.Count() > 0) { this.diagram.undoOperations.add("create", null, newLines, this.shift, this.currentLayer.id); } else if (removeLines.Count() > 0) { this.diagram.undoOperations.add("delete", null, removeLines, this.shift, this.currentLayer.id); } this.diagram.InvalidateDiagram(); } // KEY SHIFT+MLEFT add node to selected nodes else if (!keyctrl && keyshift && !keyalt && this.sourceNode == TargetNode && TargetNode != null && !TargetNode.selected) { this.SelectNode(TargetNode); this.diagram.InvalidateDiagram(); } // KEY SHIFT+MLEFT remove node from selected nodes else if (!keyctrl && keyshift && !keyalt && TargetNode != null && (this.sourceNode == TargetNode || TargetNode.selected)) { this.RemoveNodeFromSelection(TargetNode); this.diagram.InvalidateDiagram(); } else if (this.sourceNode == TargetNode && this.stateSourceNodeAlreadySelected) { this.rename(); } } else if (buttonright) // KEY MRIGHT { this.stateMoveView = false; // show popup menu if (e.X == this.startMousePos.x && e.Y == this.startMousePos.y && this.startShift.x == this.shift.x && this.startShift.y == this.shift.y) { Node temp = this.findNodeInMousePosition(new Position(e.X, e.Y)); if (temp == null || (this.sourceNode != temp && !temp.selected)) { this.ClearSelection(); this.SelectOnlyOneNode(temp); } this.diagram.InvalidateDiagram(); PopupMenu.Show(this.Left + e.X, this.Top + e.Y); // [POPUP] show popup } else { // KEY DRAG+MRIGHT move view this.shift.x = (int)(this.startShift.x + (e.X - this.startMousePos.x) * this.scale); this.shift.y = (int)(this.startShift.y + (e.Y - this.startMousePos.y) * this.scale); this.diagram.InvalidateDiagram(); } } else if (buttonmiddle) // MMIDDLE { // KEY DRAG+MMIDDLE conect two existing nodes if (this.sourceNode != null && TargetNode != null) { Line newLine = this.diagram.Connect( sourceNode, TargetNode ); if (newLine != null) { this.diagram.unsave("create", newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } } else // KEY DRAG+MMIDDLE connect exixting node with new node if (this.sourceNode != null && TargetNode == null) { Node newNode = this.CreateNode(this.actualMousePos.clone().subtract(10)); Line newLine = this.diagram.Connect( sourceNode, newNode ); this.diagram.unsave("create", newNode, newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DRAG+MMIDDLE create new node and conect id with existing node if (!isreadonly && TargetNode != null) { Node newNode = this.CreateNode( (new Position(this.shift)).subtract(this.startShift).add(this.startMousePos) ); Line newLine = this.diagram.Connect( newNode, TargetNode ); this.diagram.unsave("create", newNode, newLine, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } else // KEY DRAG+MMIDDLE create new node and conect with new node (create line) if (!isreadonly && TargetNode == null) { Nodes nodes = new Nodes(); Lines lines = new Lines(); Node node1 = this.CreateNode( (new Position(this.shift)).subtract(this.startShift).add(this.startMousePos), false ); nodes.Add(node1); Node node2 = this.CreateNode( this.actualMousePos.clone().subtract(10) ); nodes.Add(node2); lines.Add(this.diagram.Connect( node1, node2 )); this.diagram.unsave("create", nodes, lines, this.shift, this.currentLayer.id); this.diagram.InvalidateDiagram(); } } this.resetStates(); }
private void FConsole_KeyDown(object sender, KeyEventArgs e) { if (State == ConsoleState.Closing) { e.SuppressKeyPress = true; return; } if ((e.KeyCode == Keys.Up || e.KeyCode == Keys.Down) && State == ConsoleState.ReadLine) { if (recentlist.Count != 0) { var recentText = string.Empty; if (e.KeyCode == Keys.Up) { recentText = RecentUndo(); } else if (e.KeyCode == Keys.Down) { recentText = RecentRedo(); } SelectLastLine(); SelectedText = recentText; } e.SuppressKeyPress = true; return; } else { Select(TextLength, 0); if (e.KeyData == (Keys.Control | Keys.V)) { MultiplePaste(); e.SuppressKeyPress = true; } else if ((int)e.KeyCode == (int)Keys.Enter && InputEnable == true && State == ConsoleState.ReadLine) { Cursor = Cursors.WaitCursor; ReadOnly = true; CurrentLine = Lines[Lines.Count() - 1]; recentlist.Add(CurrentLine); WriteLine(""); InputEnable = false; e.SuppressKeyPress = true; } else if (InputEnable == true && State == ConsoleState.ReadKey) { ReadOnly = true; CurrentKey = (char)e.KeyCode; InputEnable = false; } else if ((int)e.KeyCode == (int)Keys.Escape && InputEnable == false)//esc exit { Pause = false; } else if ((int)e.KeyCode == (int)Keys.Space && InputEnable == false)//space pause { Pause = !Pause; } else if ((int)e.KeyCode == (int)Keys.Back && InputEnable == true && ReadPoint + 1 > TextLength) { e.SuppressKeyPress = true; } } }