private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { InnerDiameter = agg_basics.Clamp(InnerDiameter, 0, OuterDiameter - .1, ref changed); Sides = agg_basics.Clamp(Sides, 3, 360, ref changed); var aabb = this.GetAxisAlignedBoundingBox(); var startingAngle = StartingAngle; var endingAngle = EndingAngle; if (!Advanced) { startingAngle = 0; endingAngle = 360; } var innerDiameter = Math.Min(OuterDiameter - .1, InnerDiameter); var path = new VertexStorage(); path.MoveTo(OuterDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, Height / 2); path.LineTo(innerDiameter / 2, -Height / 2); path.LineTo(OuterDiameter / 2, -Height / 2); var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle)); Mesh = VertexSourceToMesh.Revolve(path, Sides, startAngle, endAngle); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); if (changed) { base.OnInvalidate(new InvalidateArgs(this, InvalidateType.Properties)); } }
IEnumerator LoadTrackCoroutine() { Consts.MissingTilesNames.Clear(); yield return(null); if (Isloading) { // load track PopulateTilePlacementArray(); InitializeHeightArrays(Consts.TRACK.Height, Consts.TRACK.Width); LoadTerrain(Consts.LoadMirrored); } else { // generate track Consts.TRACK = new TrackSavable((ushort)TrackSize.value[0], (ushort)TrackSize.value[1]); InitializeHeightArrays(Consts.TRACK.Height, Consts.TRACK.Width); InitializeTilePlacementArray(TrackSize.value[1], TrackSize.value[0]); Consts.Trackname = "Untitled"; } Build.Reset(); UndoBuffer.Reset(); if (Consts.LoadMirrored) { Consts.Trackname += " (mirrored)"; } MainCanvas.GetComponent <EditorMenu>().nazwa_toru.text = Consts.Trackname; MainCanvas.GetComponent <EditorMenu>().NameOfTrack.text = Consts.Trackname; CreateScatteredMeshColliders(); if (Isloading) { StartCoroutine(PlaceLoadedTilesOnMap()); } else { DisableLoadingScreen(); MainCamera.SetActive(true); } CreateTilesetMenu(); editorPanel.GetComponent <SliderCase>().SwitchToTileset(Consts.CHKPOINTS_STR); }
/// <summary> /// Reset all tracking variables. /// </summary> public void Reset() { VotesWithSupporters.Clear(); VoterMessageId.Clear(); RankedVotesWithSupporters.Clear(); RankedVoterMessageId.Clear(); PlanNames.Clear(); ReferenceVoters.Clear(); ReferenceVoterPosts.Clear(); ReferencePlanNames.Clear(); ReferencePlans.Clear(); FutureReferences.Clear(); UndoBuffer.Clear(); OrderedTaskList.Clear(); cleanVoteLookup.Clear(); cleanedKeys.Clear(); if (VotesWithSupporters.Comparer != Agnostic.StringComparer) { VotesWithSupporters = new Dictionary <string, HashSet <string> >(Agnostic.StringComparer); } if (RankedVotesWithSupporters.Comparer != Agnostic.StringComparer) { RankedVotesWithSupporters = new Dictionary <string, HashSet <string> >(Agnostic.StringComparer); } if (ReferencePlans.Comparer != Agnostic.StringComparer) { ReferencePlans = new Dictionary <string, List <string> >(Agnostic.StringComparer); } if (ReferencePlanNames.Comparer != Agnostic.StringComparer) { ReferencePlanNames = new HashSet <string>(Agnostic.StringComparer); } if (PlanNames.Comparer != Agnostic.StringComparer) { PlanNames = new HashSet <string>(Agnostic.StringComparer); } OnPropertyChanged("VoteCounter"); OnPropertyChanged("Tasks"); }
public override void Flatten(UndoBuffer undoBuffer) { // we want to end up with just a group of all the visible mesh objects using (RebuildLock()) { var newChildren = new List <IObject3D>(); // push our matrix into a copy of our visible children foreach (var child in this.VisibleMeshes()) { var meshOnlyItem = new Object3D { Matrix = child.WorldMatrix(this), Color = child.WorldColor(this), MaterialIndex = child.WorldMaterialIndex(this), OutputType = child.WorldOutputType(this), Mesh = child.Mesh, Name = "Mesh".Localize() }; newChildren.Add(meshOnlyItem); } if (newChildren.Count > 1) { var group = new GroupObject3D { Name = this.Name }; group.Children.Modify(list => { list.AddRange(newChildren); }); newChildren.Clear(); newChildren.Add(group); } else if (newChildren.Count == 1) { newChildren[0].Name = this.Name; } // and replace us with the children undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, newChildren)); } Invalidate(InvalidateType.Children); }
public virtual void WrapItems(IEnumerable <IObject3D> items, UndoBuffer undoBuffer = null) { var parent = items.First().Parent; RebuildLocks parentLock = (parent == null) ? null : parent.RebuilLockAll(); var firstChild = new Object3D(); this.Children.Add(firstChild); // if the items we are replacing are already in a list if (parent != null) { if (undoBuffer != null) { foreach (var item in items) { firstChild.Children.Add(item.Clone()); } var replace = new ReplaceCommand(items, new[] { this }); undoBuffer.AddAndDo(replace); } else { parent.Children.Modify(list => { foreach (var item in items) { list.Remove(item); firstChild.Children.Add(item); } list.Add(this); }); } } else // just add them { firstChild.Children.Modify(list => { list.AddRange(items); }); } parentLock?.Dispose(); parent?.Invalidate(new InvalidateArgs(parent, InvalidateType.Children)); }
public void Dispose() { Extras.Clear(); leaves.Clear(); ListCheck.Clear(); listCheckExists.Clear(); ListUpdate.Clear(); listUpdateExists.Clear(); UndoBuffer.Clear(); BlockDB.Cache.Clear(); Zones.Clear(); lock (queueLock) blockqueue.Clear(); lock (saveLock) { blocks = null; CustomBlocks = null; } }
/// <summary> /// Merges voter support. /// All of the list of provided voters are adjusted to support the same votes /// as those supported by the voterToJoin. /// </summary> /// <param name="voters">List of voters that are being adjusted.</param> /// <param name="voterToJoin">Voter that all specified voters will be joining.</param> /// <param name="voteType">The type of vote being manipulated.</param> /// <returns>Returns true if adjustments were made.</returns> public bool Join(List <string> voters, string voterToJoin, VoteType voteType) { if (voters == null) { throw new ArgumentNullException(nameof(voters)); } if (string.IsNullOrEmpty(voterToJoin)) { throw new ArgumentNullException(nameof(voterToJoin)); } if (voters.Count == 0) { return(false); } var votes = GetVotesCollection(voteType); var joinVotersVotes = votes.Where(v => v.Value.Contains(voterToJoin)); int count = 0; var priorVotes = votes.Where(v => v.Value.Any(u => voters.Contains(u))); var voterIDList = GetVotersCollection(voteType); UndoBuffer.Push(new UndoAction(UndoActionType.Join, voteType, voterIDList, voters, priorVotes)); foreach (string voter in voters) { if (voter != voterToJoin) { count++; RemoveSupport(voter, voteType); foreach (var vote in joinVotersVotes) { vote.Value.Add(voter); } } } CleanupEmptyVotes(voteType); OnPropertyChanged("VoteCounter"); return(count > 0); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); bool changed = false; using (RebuildLock()) { Sides = agg_basics.Clamp(Sides, 3, 360, ref changed); var aabb = this.GetAxisAlignedBoundingBox(); if (!Advanced) { var path = new VertexStorage(); path.MoveTo(0, -Height / 2); path.LineTo(Diameter / 2, -Height / 2); path.LineTo(Diameter / 2, Height / 2); path.LineTo(0, Height / 2); Mesh = VertexSourceToMesh.Revolve(path, Sides); } else { var path = new VertexStorage(); path.MoveTo(0, -Height / 2); path.LineTo(Diameter / 2, -Height / 2); path.LineTo(DiameterTop / 2, Height / 2); path.LineTo(0, Height / 2); Mesh = VertexSourceToMesh.Revolve(path, Sides, MathHelper.DegreesToRadians(StartingAngle), MathHelper.DegreesToRadians(EndingAngle)); } if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); if (changed) { base.OnInvalidate(new InvalidateArgs(this, InvalidateType.Properties)); } }
/// <summary> /// Delete a vote from the vote list specified. /// </summary> /// <param name="vote">The vote to remove.</param> /// <param name="voteType">The type of vote to remove.</param> /// <returns>Returns true if a vote was removed.</returns> public bool Delete(string vote, VoteType voteType, bool suppressUndo = false) { if (string.IsNullOrEmpty(vote)) { return(false); } bool removed = false; var votes = GetVotesCollection(voteType); Dictionary <string, HashSet <string> > deletedVotes = new Dictionary <string, HashSet <string> >(); foreach (var v in votes) { if (v.Key == vote || (voteType == VoteType.Rank && VoteString.CondenseVote(v.Key) == vote)) { deletedVotes.Add(v.Key, v.Value); } } if (deletedVotes.Count > 0) { if (!suppressUndo) { UndoBuffer.Push(new UndoAction(UndoActionType.Delete, voteType, GetVotersCollection(voteType), deletedVotes)); } foreach (var del in deletedVotes) { removed = votes.Remove(del.Key) || removed; } } foreach (var v in deletedVotes) { foreach (var voter in v.Value) { TrimVoter(voter, voteType); } } OnPropertyChanged("VoteCounter"); return(removed); }
public override void Flatten(UndoBuffer undoBuffer) { // change this from a text object to a group var newContainer = new GroupObject3D(); newContainer.CopyProperties(this, Object3DPropertyFlags.All); int index = 0; foreach (var child in this.Children) { var clone = child.Clone(); var newName = index < NameToWrite.Length ? NameToWrite[index++].ToString() : "Letter".Localize(); clone.Name = MapIfSymbol(newName); newContainer.Children.Add(clone); } undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, new[] { newContainer })); newContainer.Name = this.Name + " - " + "Flattened".Localize(); }
public void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); AdjustChildSize(null, null); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } base.Invalidate(new InvalidateArgs(this, InvalidateType.Matrix)); }
public override void Flatten(UndoBuffer undoBuffer) { // only keep the mesh and get rid of everything else using (RebuildLock()) { var meshOnlyItem = new Object3D() { Mesh = this.Mesh.Copy(CancellationToken.None) }; meshOnlyItem.CopyProperties(this, Object3DPropertyFlags.All); // and replace us with the children undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, new[] { meshOnlyItem })); } Invalidate(InvalidateType.Children); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); Mesh = PlatonicSolids.CreateCube(Width, Depth, Height); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); }
public void Undo_NextCommandAtEnd_Undo() { var str = new StringBuilder(); var buffer = new UndoBuffer(); var cmd1 = new TestCommand(str, "", "A"); buffer.Execute(cmd1); Assert.Equal("A", str.ToString()); Assert.Equal(1, buffer.NextCommandIndex); Assert.Equal(0, buffer.PreviousCommandIndex); Assert.True(buffer.IsModified); buffer.Undo(); Assert.Equal("", str.ToString()); Assert.Equal(0, buffer.NextCommandIndex); Assert.Equal(-1, buffer.PreviousCommandIndex); Assert.False(buffer.IsModified); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); var startingAngle = StartingAngle; var endingAngle = EndingAngle; var latitudeSides = LatitudeSides; if (!Advanced) { startingAngle = 0; endingAngle = 360; latitudeSides = Sides; } var path = new VertexStorage(); var angleDelta = MathHelper.Tau / 2 / latitudeSides; var angle = -MathHelper.Tau / 4; var radius = Diameter / 2; path.MoveTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); for (int i = 0; i < latitudeSides; i++) { angle += angleDelta; path.LineTo(new Vector2(radius * Math.Cos(angle), radius * Math.Sin(angle))); } var startAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(startingAngle)); var endAngle = MathHelper.Range0ToTau(MathHelper.DegreesToRadians(endingAngle)); var steps = Math.Max(1, (int)(Sides * MathHelper.Tau / Math.Abs(MathHelper.GetDeltaAngle(startAngle, endAngle)) + .5)); Mesh = VertexSourceToMesh.Revolve(path, steps, startAngle, endAngle); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Mesh)); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { ResetMeshWrapperMeshes(Object3DPropertyFlags.All, CancellationToken.None); var oldMatrix = this.Matrix; this.Matrix = Matrix4X4.Identity; var mirrorMatrix = Matrix4X4.Identity; switch (MirrorOn) { case MirrorAxis.X_Axis: mirrorMatrix = this.ApplyAtBoundsCenter(Matrix4X4.CreateScale(-1, 1, 1)); break; case MirrorAxis.Y_Axis: mirrorMatrix = this.ApplyAtBoundsCenter(Matrix4X4.CreateScale(1, -1, 1)); break; case MirrorAxis.Z_Axis: mirrorMatrix = this.ApplyAtBoundsCenter(Matrix4X4.CreateScale(1, 1, -1)); break; } foreach (var item in this.WrappedObjects()) { var meshCopyToThis = item.meshCopy.WorldMatrix(this); // move it to us then mirror then move it back item.meshCopy.Mesh.Transform(meshCopyToThis * mirrorMatrix * meshCopyToThis.Inverted); item.meshCopy.Mesh.ReverseFaceEdges(); item.meshCopy.Mesh.CalculateNormals(); item.meshCopy.Mesh.MarkAsChanged(); } this.Matrix = oldMatrix; } base.Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }
public void Redo_NextCommandInMiddle_Redo() { var str = new StringBuilder(); var buffer = new UndoBuffer(); var cmd1 = new TestCommand(str, "", "A"); var cmd2 = new TestCommand(str, "A", "B"); buffer.Execute(cmd1); buffer.Execute(cmd2); buffer.Execute(cmd1); buffer.Undo(); buffer.Undo(); buffer.Redo(); Assert.Equal("B", str.ToString()); Assert.Equal(2, buffer.NextCommandIndex); Assert.Equal(1, buffer.PreviousCommandIndex); Assert.True(buffer.IsModified); }
public void SetWidthDepthUndo(IObject3D selectedItem, UndoBuffer undoBuffer, Vector2 doWidthDepth, Matrix4X4 doMatrix, Vector2 undoWidthDepth, Matrix4X4 undoMatrix) { undoBuffer.AddAndDo(new UndoRedoActions(async() => { setWidth(undoWidthDepth.X); setDepth(undoWidthDepth.Y); await selectedItem.Rebuild(); selectedItem.Matrix = undoMatrix; selectedItem?.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues)); }, async() => { setWidth(doWidthDepth.X); setDepth(doWidthDepth.Y); await selectedItem.Rebuild(); selectedItem.Matrix = doMatrix; selectedItem?.Invalidate(new InvalidateArgs(selectedItem, InvalidateType.DisplayValues)); })); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); using (RebuildLock()) { var aabb = this.GetAxisAlignedBoundingBox(); this.Children.Modify((list) => { list.Clear(); var offest = 0.0; double pointsToMm = 0.352778; foreach (var letter in NameToWrite.ToCharArray()) { var letterPrinter = new TypeFacePrinter(letter.ToString(), new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize)) { ResolutionScale = 10 }; var scalledLetterPrinter = new VertexSourceApplyTransform(letterPrinter, Affine.NewScaling(pointsToMm)); IObject3D letterObject = new Object3D() { Mesh = VertexSourceToMesh.Extrude(scalledLetterPrinter, Height) }; letterObject.Matrix = Matrix4X4.CreateTranslation(offest, 0, 0); list.Add(letterObject); offest += letterPrinter.GetSize(letter.ToString()).X *pointsToMm; } }); if (aabb.ZSize > 0) { // If the part was already created and at a height, maintain the height. PlatingHelper.PlaceMeshAtHeight(this, aabb.minXYZ.Z); } } Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { // push our matrix into inner children foreach (var child in ScaleItem.Children) { child.Matrix *= this.Matrix; } // add inner children to our parent and remove from parent this.Parent.Children.Modify(list => { list.Remove(this); list.AddRange(ScaleItem.Children); }); } Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { using (new CenterAndHeightMaintainer(this)) { var firstChild = this.Children.FirstOrDefault(); // only keep the first object this.Children.Modify(list => { list.Clear(); // add back in the sourceContainer list.Add(firstChild); }); } } base.Remove(undoBuffer); }
public void Undo_NextCommandAtBeginning_NoChange() { var str = new StringBuilder(); var buffer = new UndoBuffer(); var cmd1 = new TestCommand(str, "", "A"); buffer.Execute(cmd1); buffer.Undo(); Assert.Equal("", str.ToString()); Assert.Equal(0, buffer.NextCommandIndex); Assert.Equal(-1, buffer.PreviousCommandIndex); Assert.False(buffer.IsModified); // Try to undo again - should be no change since nothing to undo buffer.Undo(); Assert.Equal("", str.ToString()); Assert.Equal(0, buffer.NextCommandIndex); Assert.Equal(-1, buffer.PreviousCommandIndex); Assert.False(buffer.IsModified); }
/// <summary> /// Merge the vote supporters from one vote into several other votes. /// </summary> /// <param name="fromVote">The originating vote.</param> /// <param name="toVotes">The destination votes.</param> /// <returns>Returns true if successfully completed.</returns> public bool Split(VoteLineBlock fromVote, List <VoteLineBlock> toVotes) { UndoBuffer.Push(new UndoAction(UndoActionType.Split, VoteStorage)); UserMerges.AddMergeRecord(fromVote, toVotes, UndoActionType.Split, Quest !.PartitionMode); bool merged = SplitImplWrapper(fromVote, toVotes); if (merged) { OnPropertyChanged("Votes"); OnPropertyChanged("Voters"); OnPropertyChanged(nameof(HasUndoActions)); } else { UndoBuffer.Pop(); } return(merged); }
private async void AutoArrangePartsInBackground() { if (MeshGroups.Count > 0) { string progressArrangeParts = LocalizedString.Get("Arranging Parts"); string progressArrangePartsFull = string.Format("{0}:", progressArrangeParts); processingProgressControl.ProcessType = progressArrangePartsFull; processingProgressControl.Visible = true; processingProgressControl.PercentComplete = 0; LockEditControls(); List <Matrix4X4> preArrangeTarnsforms = new List <Matrix4X4>(MeshGroupTransforms); await Task.Run(() => { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; PushMeshGroupDataToAsynchLists(TraceInfoOpperation.DONT_COPY); PlatingHelper.ArrangeMeshGroups(asyncMeshGroups, asyncMeshGroupTransforms, asyncPlatingDatas, ReportProgressChanged); }); if (HasBeenClosed) { return; } // offset them to the center of the bed for (int i = 0; i < asyncMeshGroups.Count; i++) { asyncMeshGroupTransforms[i] *= Matrix4X4.CreateTranslation(new Vector3(ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.print_center), 0)); } PartHasBeenChanged(); PullMeshGroupDataFromAsynchLists(); List <Matrix4X4> postArrangeTarnsforms = new List <Matrix4X4>(MeshGroupTransforms); UndoBuffer.Add(new ArangeUndoCommand(this, preArrangeTarnsforms, postArrangeTarnsforms)); UnlockEditControls(); } }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { var thisClone = this.Clone(); using (thisClone.RebuildLock()) { // remove all the mesh wrappers that we own var meshWrappers = thisClone.Descendants().Where(o => o.OwnerID == thisClone.ID).ToArray(); foreach (var meshWrapper in meshWrappers) { meshWrapper.Remove(null); } foreach (var child in thisClone.Children) { child.OutputType = PrintOutputTypes.Default; // push our matrix into a copy of our children (so they don't jump away) using (child.RebuildLock()) { child.Matrix *= thisClone.Matrix; } } // collapse our children into our parent // and replace us with the children var replaceCommand = new ReplaceCommand(new[] { this }, thisClone.Children.ToList(), false); if (undoBuffer != null) { undoBuffer.AddAndDo(replaceCommand); } else { replaceCommand.Do(); } } } Invalidate(InvalidateType.Children); }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { List <IObject3D> newChildren = new List <IObject3D>(); // push our matrix into a copy of our children foreach (var child in this.SourceContainer.Children) { var newChild = child.Clone(); newChildren.Add(newChild); newChild.Matrix *= this.Matrix; var flags = Object3DPropertyFlags.Visible; if (this.Color.alpha != 0) { flags |= Object3DPropertyFlags.Color; } if (this.OutputType != PrintOutputTypes.Default) { flags |= Object3DPropertyFlags.OutputType; } if (this.MaterialIndex != -1) { flags |= Object3DPropertyFlags.MaterialIndex; } newChild.CopyProperties(this, flags); } // and replace us with the children var replaceCommand = new ReplaceCommand(new[] { this }, newChildren, false); if (undoBuffer != null) { undoBuffer.AddAndDo(replaceCommand); } else { replaceCommand.Do(); } } Invalidate(InvalidateType.Children); }
private void Rebuild(UndoBuffer undoBuffer) { this.DebugDepth("Rebuild"); var rebuildLock = RebuildLock(); ResetMeshWrapperMeshes(Object3DPropertyFlags.All, CancellationToken.None); // spin up a task to remove holes from the objects in the group ApplicationController.Instance.Tasks.Execute( "Subtract".Localize(), (reporter, cancellationToken) => { var progressStatus = new ProgressStatus(); reporter.Report(progressStatus); var removeObjects = this.Children .Where((i) => ItemsToSubtract.Contains(i.ID)) .SelectMany((h) => h.DescendantsAndSelf()) .Where((c) => c.OwnerID == this.ID).ToList(); var keepObjects = this.Children .Where((i) => !ItemsToSubtract.Contains(i.ID)) .SelectMany((h) => h.DescendantsAndSelf()) .Where((c) => c.OwnerID == this.ID).ToList(); try { Subtract(keepObjects, removeObjects, cancellationToken, reporter); } catch { } UiThread.RunOnIdle(() => { rebuildLock.Dispose(); base.Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }); return(Task.CompletedTask); }); }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { // remove all the mesh wrappers that we own var meshWrappers = this.Descendants().Where(o => o.OwnerID == this.ID).ToList(); foreach (var meshWrapper in meshWrappers) { meshWrapper.Remove(null); } foreach (var child in Children) { child.OutputType = PrintOutputTypes.Default; } // collapse our children into our parent base.Remove(null); } Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }
public override void Remove(UndoBuffer undoBuffer) { using (RebuildLock()) { // put everything back to where it was before the arrange started if (OriginalChildrenBounds.Count == Children.Count) { int i = 0; foreach (var child in Children) { // Where you are minus where you started to get back to where you started child.Translate(-(child.GetAxisAlignedBoundingBox().minXYZ - OriginalChildrenBounds[i].minXYZ)); i++; } } base.Remove(undoBuffer); } Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }
public override void Apply(UndoBuffer undoBuffer) { using (RebuildLock()) { // push our matrix into our children foreach (var child in this.Children) { child.Matrix *= this.Matrix; } // push child into children SourceItem.Matrix *= TransformItem.Matrix; // add our children to our parent and remove from parent this.Parent.Children.Modify(list => { list.Remove(this); list.AddRange(TransformItem.Children); }); } Invalidate(new InvalidateArgs(this, InvalidateType.Content)); }
private void dgvChars_DragDrop(object sender, DragEventArgs e) { //MessageBox.Show("ドロップイベント"); // ドラッグされているデーターが行番号(int型)で、かつ、 // ドラッグ ソースのデータは、ドロップ先に複写するよう指示さ // れている場合(すなわち、移動等の別の指示ではない場合) /*if (e.Data.GetDataPresent(typeof(int)) && (e.Effect == DragDropEffects.Move)) { // DragDropイベント発生時の (x,y)座標を取得 System.Drawing.Point clientPoint = dgvChars.PointToClient(new System.Drawing.Point(e.X, e.Y)); DataGridView.HitTestInfo hit = dgvChars.HitTest(clientPoint.X, clientPoint.Y); try { dgvChars.Rows[hit.RowIndex].Selected = true; // 該当行を選択状態に } catch { slideChar(dragPrevIndex, dragStartIndex); dragPrevIndex = dragStartIndex = -1; return; // 下過ぎた場合 } // ドラッグ ソースの行番号(int)を取得 int ind = (int)e.Data.GetData(typeof(int)); // ドロップ先としての指定位置が、有効な場合 // (x,y座標値の取得に成功している場合) if (hit.RowIndex != -1 && hit.RowIndex != ind) { int ind2 = hit.RowIndex; //slideChar(ind, ind2); slideChar(dragPrevIndex, ind2); dragPrevIndex = dragStartIndex = -1; } // ドロップ先としての指定位置が、有効でない場合 // (x,y座標値の取得に失敗した場合) else { //元に戻す slideChar(dragPrevIndex, dragStartIndex); dragPrevIndex = dragStartIndex = -1; } } else */ if (e.Data.GetDataPresent(DataFormats.FileDrop) && (e.Effect == DragDropEffects.Copy)) { //コントロール内にドロップされたとき実行される //ドロップされたすべてのファイル名を取得する string[] fileName = (string[])e.Data.GetData(DataFormats.FileDrop, false); if (fileName.Length <= 0) // 世の中何があるかわからないものです。 { return; } int charCount; try { charCount = dlcData.Chars.Count; } catch { charCount = 0; } var subu = StopUndoBufferUpdate; StopUndoBufferUpdate = true; if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift || !newDlc) { undoBuffer = new UndoBuffer<DLCData>(); // シフトが押されてなければ過去の履歴は忘れる。BCM 読み込みモードでも忘れる。 } int index = 0; if (charCount > 0) { // Shift の押し下げで追加かどうかを切り替え //(ここで MessageBox を表示する場合別スレッドでやらないとエクスプローラーが止まっtえ鬱陶しいので注意) if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift) { OpenStateFile(fileName[index++]); // シフトが押されてなければ新規読み込み } } else { OpenStateFile(fileName[index++]); } //dgvChars.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.None; //dgvChars.Columns[1].HeaderCell.SortGlyphDirection = SortOrder.None; for (int i = 0; i < dgvChars.Columns.Count; i++) { dgvChars.Columns[i].HeaderCell.SortGlyphDirection = SortOrder.None; } setEgvCharsSlotColor(); setEgvCharsNameColor(); setEgvCharsTextsColor(); if (dgvChars.Rows.Count <= 0) { btnCharsDelete.Enabled = false; } // 色付けを何度も行って無駄だが、 // コードを簡単にすることでバグのリスクを減らすほうが有益だと判断 while (index < fileName.Length) { AddStateFile(fileName[index++]); } StopUndoBufferUpdate = subu; undoBufferUpdate(); } else { // 特に処理はなし } }
public void SetUp() { _undoBuffer = new UndoBuffer(); _textBuffer = new StringBuilder(); }
private void btnNewDLC_Click(object sender, EventArgs e) { var pt = LoadIniString("InitialDirectory", "BCM"); if (pt != "") saveFileDialog.InitialDirectory = GetOwnOFolderrExistingParent(Path.GetDirectoryName(pt)); saveFileDialog.FileName = Path.GetFileName(openFileDialog.FileName); if (ConformScrap() && saveFileDialog.ShowDialog() == DialogResult.OK) { //MessageBox.Show("a"); System.Text.RegularExpressions.Regex regex_doa = new System.Text.RegularExpressions.Regex(@"^(.*\\([^\\]+))\\\2\.bcm$", System.Text.RegularExpressions.RegexOptions.IgnoreCase); if (regex_doa.IsMatch(saveFileDialog.FileName)) { tbSavePath.Text = regex_doa.Replace(saveFileDialog.FileName, "$1"); SaveIniString("InitialDirectory", "BCM", Path.GetDirectoryName(saveFileDialog.FileName)); } else { tbSavePath.Text = saveFileDialog.FileName; SaveIniString("InitialDirectory", "BCM", saveFileDialog.FileName); } newDlc = true; ClearMainUI(); //tbSavePath.Text = saveFileDialog.FileName; dlcData = new DLCData(); //btnSave.Text = Program.dicLanguage["SaveDLC"]; setBtnSave(); btnCmpSave.Enabled = btnSave.Enabled = true; btnSaveState.Enabled = true; btnCharsAdd.Enabled = true; //clmCos.ReadOnly = false; clmInner.ReadOnly = false; dlcData.BcmVer = 9; tbBCMVer.Text = "9"; //dlcData.SavePath = saveFileDialog.FileName; cbSaveListInDLC.Enabled = true; cbSaveListInDLC.Checked = true; undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } }
private void btnOpenBCM_Click(object sender, EventArgs e) { var pt = GetOwnOFolderrExistingParent(LoadIniString("InitialDirectory", "BCM")); if (pt != "") openFileDialogBCM.InitialDirectory = pt; openFileDialogBCM.FileName = Path.GetFileName(saveFileDialogBCM.FileName); if (ConformScrap() && openFileDialogBCM.ShowDialog() == DialogResult.OK) { OpenFile(openFileDialogBCM.FileName); btnSaveState.Enabled = true; //btnCmpSave.Enabled = false; //btnCmpSave.Enabled = true; //btnCmpSave.Text = Program.dicLanguage["ExtractFiles"]; SaveIniString("InitialDirectory", "BCM", Path.GetDirectoryName(openFileDialogBCM.FileName)); undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } }
private void btnOpenState_Click(object sender, EventArgs e) { try { var pt = GetOwnOFolderrExistingParent(LoadIniString("InitialDirectory", "LST")); if (pt != "") openFileDialogState.InitialDirectory = pt; openFileDialogState.FileName = Path.GetFileName(saveFileDialogState.FileName); if (ConformScrap() && openFileDialogState.ShowDialog() == DialogResult.OK) { SaveIniString("InitialDirectory", "LST", Path.GetDirectoryName(openFileDialogState.FileName)); //dgvChars.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.None; //dgvChars.Columns[1].HeaderCell.SortGlyphDirection = SortOrder.None; for (int i = 0; i < dgvChars.Columns.Count; i++) { dgvChars.Columns[i].HeaderCell.SortGlyphDirection = SortOrder.None; } if (openFileDialogState.FilterIndex == 1) { string orgpath = openFileDialogState.FileName; string ext = Path.GetExtension(orgpath).ToLower(); //newDlc = true; // OpenStateFile で行われるけど tbListPath.Text 編集イベントの前にかえておかないといけない OpenStateFile(openFileDialogState.FileName); } else { var bf = new BinaryFormatter(); using (var fs = new FileStream(openFileDialogState.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { dlcData = (DLCData)bf.Deserialize(fs); } newDlc = true; tbListPath.Text = "";// newDLC より後で。 ClearMainUI(); MakeColumnsFromDLCData(dlcData); tbSavePath.Text = dlcData.SavePath; btnSave.Text = Program.dicLanguage["SaveDLC"]; ; btnCmpSave.Enabled = btnSave.Enabled = true; btnSaveState.Enabled = true; btnCharsAdd.Enabled = true; //clmCos.ReadOnly = false; clmInner.ReadOnly = false; tbBCMVer.Text = dlcData.BcmVer.ToString(); for (int i = 0; i < dlcData.Chars.Count; i++) { dgvChars.Rows.Add(); dgvChars.Rows[i].Cells[0].Value = GetCharNamesJpn(dlcData.Chars[i].ID);// Program.CharNamesJpn[dlcData.Chars[i].ID]; dgvChars.Rows[i].Cells[1].Value = dlcData.Chars[i].CostumeSlot.ToString(); dgvChars.Rows[i].Cells[2].Value = dlcData.Chars[i].AddTexsCount.ToString(); dlcData.Chars[i].Comment = "";// GetComment()"; //dgvChars.Rows[i].Cells[3].Value = dlcData.Chars[i].Comment; showComment(i); } if (dlcData.Chars.Count > 0) { dgvChars.Rows[0].Selected = true; } } saveFileDialogState.FileName = openFileDialogState.FileName; setEgvCharsSlotColor(); setEgvCharsNameColor(); setEgvCharsTextsColor(); if (dgvChars.Rows.Count <= 0) { btnCharsDelete.Enabled = false; } undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public MainForm() { InitializeComponent(); setVersion(); SetDATList(); //SetCharNames(); // SetDatList → DAT リスト変更イベントで勝手に呼ばれる TranslateInitialUI(true); //SetDATList(); //dgvChars.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; string[] cmds = Environment.GetCommandLineArgs(); if (cmds.Length > 1 && System.Text.RegularExpressions.Regex.IsMatch(cmds[1], @"\.[lr]st$", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { OpenStateFile(cmds[1]); } else { string curList = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"current.lst"); #if !DEBUG try #endif { if (File.Exists(curList)) { var tbListPathText = LoadIniString("Text", "tbListPath"); OpenStateFile(curList, tbListPathText + ".lst"); tbListPath.Text = tbListPathText; tbListPath.Select(tbListPath.Text.Length, 0); tbListPath.ScrollToCaret(); string bcmName = LoadIniString("Text", "BCMName"); if (bcmName != "") { OpenFile(Path.Combine(tbSavePath.Text, bcmName)); } setEgvCharsSlotColor(); setEgvCharsNameColor(); setEgvCharsTextsColor(); } } #if !DEBUG catch { try { File.Delete(curList); } catch { } } #endif } undoBuffer = new UndoBuffer<DLCData>(); undoBufferUpdate(); undoBuffer.SetSaved(); // 終了時のイベントハンドラを登録 //ApplicationExitイベントハンドラを追加 Application.ApplicationExit += new EventHandler(Application_ApplicationExit); // 異常終了時は単にタイマーを止める Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // タイマー開始 TimerForSave = new FormsTimerTest(); TimerForSave.Run(); }
public RichTextBoxEx() { HideSelection = false; // do NOT execute this in OnCreateControl() !! DetectUrls = false; mi_UndoBuf = new UndoBuffer(this); }