void m_menuDegrouperActions_Click(object sender, EventArgs e) { if (Selection.Count == 1 && Selection[0] is CActionProcessFils) { CActionProcessFils action = Selection[0] as CActionProcessFils; CResultAErreur result = action.Degrouper(); if (!result) { CFormAfficheErreur.Show(result.Erreur); } else { Selection.Clear(); if (result.Data is IEnumerable <CAction> ) { List <I2iObjetGraphique> lstTmp = new List <I2iObjetGraphique>(); foreach (CAction actionTmp in (IEnumerable <CAction>)result.Data) { lstTmp.Add(actionTmp); } Selection.AddRange(lstTmp); Refresh(); } } } }
private void CreateCards() { Program.Log("开始洗牌"); cards = new Selection[3]; for (int i = 0; i <= 2; i++) { cards[i] = new Selection(); } baseCard = new Selection(); Selection Full = new Selection(); for (Card.Color i = Card.Color.Hongtao; i <= Card.Color.Meihua; i++) { for (Card.Value j = Card.Value.Three; j <= Card.Value.Two; j++) { Full.Add(new Card(i, j)); } } Full.Add(new Card(Card.Color.Joker, Card.Value.Grey)); Full.Add(new Card(Card.Color.Joker, Card.Value.Red)); Reshuffle(ref Full); cards[0].AddRange(Full.GetRange(0, CARDS_PER_PERSON)); cards[1].AddRange(Full.GetRange(CARDS_PER_PERSON, CARDS_PER_PERSON)); cards[2].AddRange(Full.GetRange(CARDS_PER_PERSON * 2, CARDS_PER_PERSON)); //Debug.Assert(cards[0] is Selection); baseCard.AddRange(Full.GetRange(CARDS_PER_PERSON * 3, 3)); Program.Log("洗牌结束"); }
public void ToFile([Required] string fileName) { var selection = Selection; SelectAll(); var bitmap = GetBitmapFromCollection(Selection); Selection.Clear(); Selection.AddRange(selection); bitmap.Save(fileName); }
public Bitmap ToBitmap() { var selection = Selection; SelectAll(); var result = GetBitmapFromCollection(Selection); Selection.Clear(); Selection.AddRange(selection); return(result); }
private void Selection_SelectionChange(object sender, SelectionChangedEventArgs e) { if (EnableRowColSpan) { if (e.EventType == SelectionChangedEventType.Add) { for (int r = e.Range.Start.Row; r <= e.Range.End.Row; r++) { for (int c = e.Range.Start.Column; c <= e.Range.End.Column; c++) { ICell l_Cell = this[r, c]; if (l_Cell != null) { Range l_Range = l_Cell.Range; if (l_Range != new Range(new Position(r, c))) { Selection.AddRange(l_Range); } } } } } else if (e.EventType == SelectionChangedEventType.Remove) { for (int r = e.Range.Start.Row; r <= e.Range.End.Row; r++) { if (Selection.SelectionMode != GridSelectionMode.Row) { for (int c = e.Range.Start.Column; c <= e.Range.End.Column; c++) { ICell l_Cell = this[r, c]; if (l_Cell != null) { Range l_Range = l_Cell.Range; if (l_Range != new Range(new Position(r, c))) { Selection.RemoveRange(l_Range); } } } } else if (Selection.ContainsRow(e.Range.Start.Row)) { Selection.RemoveRange(new Range(new Position(r, 0), new Position(r, ColumnsCount - 1))); } } } } }
public void ToClipboard() { var selection = Selection; SelectAll(); var bitmap = GetBitmapFromCollection(Selection); Selection.Clear(); Selection.AddRange(selection); DataObject dataObject = new DataObject(); dataObject.SetData(DataFormats.Bitmap, true, bitmap); Clipboard.SetDataObject(dataObject); }
/// <summary> /// Разгрупиране формите. /// </summary> public void UnGroup() { for (int i = 0; i < Selection.Count; i++) { if (Selection[i] is GroupShape) { var ungroupedShapes = (Selection[i] as GroupShape).SubItems; ShapeList.AddRange(ungroupedShapes); ShapeList.RemoveAt(ShapeList.IndexOf(Selection[i])); Selection.AddRange(ungroupedShapes); Selection.RemoveAt(i); i -= 1; } } }
public Metafile ToMetafile() { var selection = Selection; SelectAll(); RectangleF bounds = GoDocument.ComputeBounds(Selection, this); Graphics gbm = CreateGraphics(); IntPtr bufdc = gbm.GetHdc(); MemoryStream str = new MemoryStream(); Metafile mf = new Metafile(str, bufdc, bounds, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual); Graphics gmf = Graphics.FromImage(mf); gmf.PageUnit = GraphicsUnit.Pixel; gmf.SmoothingMode = this.SmoothingMode; gmf.TextRenderingHint = this.TextRenderingHint; gmf.InterpolationMode = this.InterpolationMode; gmf.CompositingQuality = this.CompositingQuality; gmf.PixelOffsetMode = this.PixelOffsetMode; RectangleF b = bounds; b.Inflate(1, 1); PaintPaperColor(gmf, b); foreach (GoObject obj in Selection) { if (!obj.CanView()) { continue; } obj.Paint(gmf, this); } gmf.Dispose(); gbm.ReleaseHdc(bufdc); gbm.Dispose(); mf.Dispose(); byte[] data = str.GetBuffer(); Selection.Clear(); Selection.AddRange(selection); return(new Metafile(new MemoryStream(data, false))); }
private void tvResults_SelectionChanged(object sender, EventArgs e) { Selection.Clear(); foreach (var node in tvResults.SelectedNodes) { if (node.Tag is BestPracticeRule rule) { Selection.AddRange(AnalyzerResultsTreeModel.ResultsByRule(rule)); } else if (node.Tag is AnalyzerResult result) { Selection.Add(result); } } BeginInvoke(new Action(UpdateUI)); }
private void SetSelection(List <ListViewItem> newSelection) { var changed = newSelection.Count != Selection.Count || !newSelection.All(Selection.Contains); if (changed) { Selection.Clear(); Selection.AddRange(newSelection); foreach (var item in Items) { var highlight = Selection.Contains(item); item.BackgroundColor = highlight ? highlightBackgroundColor : normalBackgroundColor; item.normalColor = highlight ? highlightColor : normalColor; } onSelectionChanged?.Invoke(); } }
internal void UnGroupSelectedShapes() { for (int i = 0; i < Selection.Count; i++) { if (Selection[i].GetType().Equals(typeof(GroupShape))) { GroupShape gs = (GroupShape)Selection[i]; ShapeList.AddRange(gs.Shapes); Selection.AddRange(gs.Shapes); gs.Shapes.Clear(); gs.Rectangle = new RectangleF(); Selection[i] = null; gs = null; ShapeList.Remove(Selection[i]); Selection.Remove(Selection[i]); } } }
public void SetSelection(List <I2iObjetGraphique> lst) { List <I2iObjetGraphique> listePourMoi = new List <I2iObjetGraphique>(); Selection.Clear(); if (ObjetEdite != null && lst != null) { lst = new List <I2iObjetGraphique>(lst); Size szRef = ObjetEdite.Size; foreach (I2iObjetGraphique obj in lst) { C2i3DEn2D c3D = obj as C2i3DEn2D; if (c3D != null) { listePourMoi.Add(c3D.Composant3D.Get2D(VueAffichee)); } } Selection.AddRange(listePourMoi); } }
/// ////////////////////////////////////////////////// protected override void Editeur_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (ObjetEdite == null) { return; } if (LockEdition) { return; } if (e.Data.GetDataPresent(typeof(CReferenceObjetDonnee))) { CReferenceObjetDonnee reference = e.Data.GetData(typeof(CReferenceObjetDonnee)) as CReferenceObjetDonnee; if (reference.TypeObjet == typeof(CModeleAffectationUtilisateurs)) { Point pt = PointToClient(new Point(e.X, e.Y)); Point ptLogique = GetLogicalPointFromDisplay(pt); CWorkflowEtapeDessin dessinEtape = ObjetEdite.SelectionnerElementDuDessus(ptLogique) as CWorkflowEtapeDessin; if (dessinEtape != null) { CModeleAffectationUtilisateurs modele = reference.GetObjet(CSc2iWin32DataClient.ContexteCourant) as CModeleAffectationUtilisateurs; if (modele != null) { CParametresAffectationEtape parametres = modele.ParametresAffectation; if (parametres != null) { CParametresInitialisationEtape parametre = dessinEtape.Initializations; CParametresAffectationEtape parAff = parametre.Affectations; if (parAff != null) { if (MessageBox.Show(I.T("Replace current assignments(Yes) or add new assignemnts(No) ?|20135"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { parAff = new CParametresAffectationEtape(); } parAff.AddFormules(parametres.Formules); parametre.Affectations = parAff; dessinEtape.Initializations = parametre; e.Effect = DragDropEffects.Link; Refresh(); return; } } } } } } List <CDonneeDragDropObjetGraphique> datas = GetDragDropData(e.Data); if (datas == null || datas.Count == 0) { return; } List <I2iObjetGraphique> candidats = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { candidats.Add(rct.ObjetGraphique); } Point ptLocal = GetLogicalPointFromDisplay(PointToClient(new Point(e.X, e.Y))); I2iObjetGraphique parent = ObjetEdite.SelectionnerElementConteneurDuDessus(ptLocal, candidats); parent = DessinWorkflow;; if (parent == null) { e.Effect = DragDropEffects.None; } else { List <I2iObjetGraphique> nouveaux = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { rct.RectangleDrag = rct.Datas.GetDragDropPosition(ptLocal); rct.RectangleDrag = GetRectangleSelonModesActives(rct.RectangleDrag, ptLocal); // rct.RectangleDrag.Offset((int)(AutoScrollPosition.X / Echelle), (int)(AutoScrollPosition.Y / Echelle)); //Si dummy de création (type de bloc), création d'une nouvelle étape I2iObjetGraphique objetGraphique = rct.Datas.ObjetDragDrop; CDummyObjetWorkflowPourCreation dummyCreation = objetGraphique as CDummyObjetWorkflowPourCreation; if (dummyCreation != null) { CTypeEtapeWorkflow typeEtape = dummyCreation.TypeEtape; if (typeEtape == null) { typeEtape = new CTypeEtapeWorkflow(DessinWorkflow.TypeWorkflow.ContexteDonnee); typeEtape.CreateNewInCurrentContexte(); typeEtape.Workflow = DessinWorkflow.TypeWorkflow; typeEtape.Bloc = Activator.CreateInstance(dummyCreation.TypeBloc, new object[] { typeEtape }) as CBlocWorkflow; } CWorkflowEtapeDessin graphEtape = new CWorkflowEtapeDessin(); graphEtape.TypeEtape = typeEtape; objetGraphique = graphEtape; objetGraphique.Size = dummyCreation.Size; } JusteBeforePositionneSurApresDragDrop(objetGraphique); bool bParentIsInSelec = objetGraphique.Parent != null && candidats.Contains(objetGraphique.Parent); bool bHasMove = false; if (e.Effect == DragDropEffects.Copy) { Dictionary <Type, object> dicObjetsPourCloner = new Dictionary <Type, object>(); AddObjectsForClonerSerializer(dicObjetsPourCloner); objetGraphique = (I2iObjetGraphique)objetGraphique.GetCloneAMettreDansParent(parent, dicObjetsPourCloner); if (objetGraphique == null || !parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; objetGraphique.CancelClone(); continue; } else { objetGraphique.Parent = parent; nouveaux.Add(objetGraphique); } bHasMove = true; } else { bHasMove = true; if (objetGraphique.Parent != parent) { if (objetGraphique.Parent != null) { if (!bParentIsInSelec) { objetGraphique.Parent.RemoveChild(objetGraphique); } } else { nouveaux.Add(objetGraphique); } if (!bParentIsInSelec) { if (!parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; continue; } else { objetGraphique.Parent = parent; } } } } if (!bParentIsInSelec && bHasMove) { Point ptDrop = new Point(rct.RectangleDrag.Left, rct.RectangleDrag.Top); objetGraphique.PositionAbsolue = ptDrop; } } if (nouveaux.Count > 0) { RefreshSelectionChanged = false; Selection.Clear(); Selection.AddRange(nouveaux); RefreshSelectionChanged = true; DeclencheAfterAddElements(nouveaux); Refresh(); } } ElementModifie(); EnDeplacement = false; Dessiner(true, true); }
/// ////////////////////////////////////////////////// protected override void Editeur_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (ObjetEdite == null) { return; } if (LockEdition) { return; } List <CDonneeDragDropObjetGraphique> datas = GetDragDropData(e.Data); if (datas == null || datas.Count == 0) { return; } List <I2iObjetGraphique> candidats = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { candidats.Add(rct.ObjetGraphique); } Point ptLocal = GetLogicalPointFromDisplay(PointToClient(new Point(e.X, e.Y))); I2iObjetGraphique parent = ObjetEdite.SelectionnerElementConteneurDuDessus(ptLocal, candidats); CRepresentationExpressionGraphique repForParametre = parent as CRepresentationExpressionGraphique; if (RectsDrags.Count() != 1) { repForParametre = null; } parent = ObjetEdite; List <I2iObjetGraphique> nouveaux = new List <I2iObjetGraphique>(); foreach (CRectangleDragForObjetGraphique rct in RectsDrags) { rct.RectangleDrag = rct.Datas.GetDragDropPosition(ptLocal); rct.RectangleDrag = GetRectangleSelonModesActives(rct.RectangleDrag, ptLocal); // rct.RectangleDrag.Offset((int)(AutoScrollPosition.X / Echelle), (int)(AutoScrollPosition.Y / Echelle)); I2iObjetGraphique objetGraphique = rct.Datas.ObjetDragDrop; JusteBeforePositionneSurApresDragDrop(objetGraphique); bool bParentIsInSelec = objetGraphique.Parent != null && candidats.Contains(objetGraphique.Parent); bool bHasMove = false; if (e.Effect == DragDropEffects.Copy) { Dictionary <Type, object> dicObjetsPourCloner = new Dictionary <Type, object>(); AddObjectsForClonerSerializer(dicObjetsPourCloner); objetGraphique = (I2iObjetGraphique)objetGraphique.GetCloneAMettreDansParent(parent, dicObjetsPourCloner); if (objetGraphique == null || !parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; objetGraphique.CancelClone(); continue; } else { objetGraphique.Parent = parent; nouveaux.Add(objetGraphique); } bHasMove = true; } else { if (repForParametre == null) { bHasMove = true; if (objetGraphique.Parent != parent) { if (objetGraphique.Parent != null) { if (!bParentIsInSelec) { objetGraphique.Parent.RemoveChild(objetGraphique); } } else { nouveaux.Add(objetGraphique); } if (!bParentIsInSelec) { if (!parent.AddChild(objetGraphique)) { e.Effect = DragDropEffects.None; continue; } else { objetGraphique.Parent = parent; } } } } } if (!bParentIsInSelec && bHasMove) { Point ptDrop = new Point(rct.RectangleDrag.Left, rct.RectangleDrag.Top); objetGraphique.PositionAbsolue = ptDrop; } } if (nouveaux.Count > 0) { RefreshSelectionChanged = false; Selection.Clear(); Selection.AddRange(nouveaux); RefreshSelectionChanged = true; DeclencheAfterAddElements(nouveaux); Refresh(); } ElementModifie(); EnDeplacement = false; Dessiner(true, true); if (repForParametre != null) { CRepresentationExpressionGraphique repParametre = RectsDrags[0].Datas.ObjetDragDrop as CRepresentationExpressionGraphique; if (repParametre != null) { ShowInterfaceLienParametre(repParametre, repForParametre); } } }
/// <summary> /// Fired when calling SortRangeRows method /// </summary> /// <param name="e">The <see cref="Fr.Medit.MedDataGrid.SortRangeRowsEventArgs"/> instance containing the event data.</param> /// <remarks> /// This could be optimised by removing the duplicated sorting. /// </remarks> protected override void OnSortingRangeRows(SortRangeRowsEventArgs e) { base.OnSortingRangeRows(e); if (CustomSort == false && EnableSort == true) { if (e.AbsoluteColumnIndexes > e.Range.End.Column && e.AbsoluteColumnIndexes < e.Range.Start.Column) { throw new ArgumentOutOfRangeException("e", "Invalid e.AbsoluteColKeys"); } Range range = e.Range; if (this.FixedRows > 1 && this.FixedRows > e.Range.Start.Row) { range = new Range(this.FixedRows - e.Range.Start.Row + 1, e.Range.Start.Column, e.Range.End.Row, e.Range.End.Column); } ICell[][] sortableRange = new ICell[range.End.Row - range.Start.Row + 1][]; ICell[] cellsKeys = new ICell[range.End.Row - range.Start.Row + 1]; ICell[] selectCellsKeys = new ICell[range.End.Row - range.Start.Row + 1]; bool[][] sortableSelection = new bool[range.End.Row - range.Start.Row + 1][]; List <Range> selectionRange = new List <Range>(); int sortableRow = 0; for (int row = range.Start.Row; row <= range.End.Row; row++) { int sortableColumn = 0; sortableRange[sortableRow] = new ICell[range.End.Column - range.Start.Column + 1]; cellsKeys[sortableRow] = this[row, e.AbsoluteColumnIndexes]; selectCellsKeys[sortableRow] = this[row, e.AbsoluteColumnIndexes]; sortableSelection[sortableRow] = new bool[range.End.Column - range.Start.Column + 1]; for (int column = range.Start.Column; column <= range.End.Column; column++) { sortableRange[sortableRow][sortableColumn] = this[row, column]; if (this.doKeepSelection == true && this[row, column] != null) { sortableSelection[sortableRow][sortableColumn] = this[row, column].Select; } sortableColumn++; } sortableRow++; } IComparer cellComparer = e.CellComparer; if (cellComparer == null) { cellComparer = new ValueCellComparer(); } // SAA TODO: This is inefficient - we don't want 2 identical sorts! Array.Sort(cellsKeys, sortableRange, cellComparer); if (this.doKeepSelection == true) { Array.Sort(selectCellsKeys, sortableSelection, cellComparer); } // Apply sort sortableRow = 0; for (int i = 0; i <= range.End.Row - range.Start.Row; i++) { int row; if (e.Ascending) { row = range.Start.Row + i; } else { row = range.End.Row - i; } int sortableColumn = 0; for (int column = range.Start.Column; column <= range.End.Column; column++) { ICell sortedCell = sortableRange[sortableRow][sortableColumn]; if (sortedCell != null && sortedCell.Grid != null && sortedCell.Range.Start.Row >= 0 && sortedCell.Range.Start.Column >= 0) { RemoveCell(sortedCell.Range.Start.Row, sortedCell.Range.Start.Column); } this[row, column] = sortedCell; sortableColumn++; } if (this.doKeepSelection == true && sortableSelection[sortableRow][1] == true) { Range ra = new Range(new Position(row, 0), new Position(row, range.End.Column)); selectionRange.Add(ra); } sortableRow++; } if (this.doKeepSelection == true) { // and now we restore the selection in the grid foreach (Range selectedRange in selectionRange) { Selection.AddRange(selectedRange); } } } this.OnSortedRangeRows(e); }
public static Selection SelectTiles(Map thisMap, Selection selection, int left, int top, int width, int height) { var result = new Selection(); result.AddRange(selection); for (int x = left; x < left + width; x++) for (int y = top; y < top + height; y++) { Tile t = thisMap.GetTileAcrossWrap(x, y); if (t != null && !selection.ContainsTile(t)) result.Add(t.GetCoordinate()); } return result; }