public GraphicsEditor() { InitializeComponent(); CompositeTable = ProjectController.GraphicsManager.BuildPatternTable(0); CmbPalettes.DisplayMember = "Name"; foreach (var p in ProjectController.PaletteManager.Palettes) { CmbPalettes.Items.Add(p); } CmbGraphics1.DisplayMember = CmbGraphics2.DisplayMember = CmbGraphics3.DisplayMember = CmbGraphics4.DisplayMember = "Name"; foreach (var g in ProjectController.GraphicsManager.GraphicsInfo) { CmbGraphics1.Items.Add(g); CmbGraphics2.Items.Add(g); CmbGraphics3.Items.Add(g); CmbGraphics4.Items.Add(g); } CmbGraphics1.SelectedIndex = 0; CmbGraphics2.SelectedIndex = 1; CmbGraphics3.SelectedIndex = 2; CmbGraphics4.SelectedIndex = 3; CmbPalettes.SelectedIndex = 0; PtvTileSelector.CurrentTable= CompositeTable; SelectionMode = SelectionMode.Quarter; PslView.SelectedIndexChanged += new EventHandler(PslView_SelectedIndexChanged); PslView.SelectedOffsetChanged += new EventHandler(PslView_SelectedOffsetChanged); PtvTileSelector.SelectionChanged += new EventHandler(PtvTileSelector_SelectionChanged); PtvTileSelector.UpdateSelection(); }
void OnWizardCreate() { if(includeChildren || excludePrefabs) modePrefs=(SelectionMode.ExcludePrefab | SelectionMode.Editable | SelectionMode.Deep); else modePrefs=(SelectionMode.Editable); Object[] objs = Selection.GetFiltered(typeof(GameObject), modePrefs); foreach (GameObject go in objs) { go.renderer.material = material; } /* if you replace the above foreach with my version below, it seems to work well for cases where some children parts don't have a renderer: foreach (GameObject go in objs) { if (go.renderer) go.renderer.material = material; } */ }
/// <summary> /// Represents a <see cref="Model"/> that executes the appropriate selection logic requested by different commands. /// </summary> public SelectionModel() : base(NAME) { this.items = new List<object>(0); this.SelectedItems = new SelectedItemsCollection(); this.selectionMode = SelectionMode.Extended; this.ranges = new RangeCollection(); }
public Selection (DocumentLocation anchor, DocumentLocation lead, SelectionMode selectionMode = SelectionMode.Normal) { if (anchor.Line < DocumentLocation.MinLine || anchor.Column < DocumentLocation.MinColumn) throw new ArgumentOutOfRangeException ("anchor", anchor + " is out of range."); if (lead.Line < DocumentLocation.MinLine || lead.Column < DocumentLocation.MinColumn) throw new ArgumentOutOfRangeException ("lead", lead + " is out of range."); this.Anchor = anchor; this.Lead = lead; this.SelectionMode = selectionMode; }
public Selection (DocumentLocation anchor, DocumentLocation lead, SelectionMode selectionMode) { if (anchor.Line < DocumentLocation.MinLine || anchor.Column < DocumentLocation.MinColumn) throw new ArgumentException ("anchor"); if (lead.Line < DocumentLocation.MinLine || lead.Column < DocumentLocation.MinColumn) throw new ArgumentException ("lead"); this.Anchor = anchor; this.Lead = lead; this.SelectionMode = selectionMode; }
/// <summary> /// Creates a default implementation of ListSelectionModel interface. /// </summary> public DefaultListSelectionModel() { selectedIndices = new List<int>(); anchorIndex = -1; leadIndex = -1; maxIndex = -1; minIndex = -1; mode = SelectionMode.Single; isAdjusting = false; }
public GeneticAlgorithm(int populationSize, int chromosomeLength, int numberOfGenerations, double crossoverRate, double mutationRate, EvaluationDelegate fitnessFunction, BoundPair[] genesDomain , int elitismFactor = 0, SelectionMode Selection = SelectionMode.RouletteWheel, bool PrintLogMode = false) { this.populationSize = populationSize; this.chromosomeLength = chromosomeLength; this.numberOfGenerations = numberOfGenerations; this.crossoverRate = crossoverRate; this.mutationRate = mutationRate; this.fitnessFunction = fitnessFunction; this.genesDomain = genesDomain; this.elitismFactor = elitismFactor; this.PrintLogMode = PrintLogMode; }
// Public constructor public RadioListBox() { this.DrawMode = DrawMode.OwnerDrawFixed; this.SelectionMode = SelectionMode.One; this.ItemHeight = this.FontHeight; this.Align = new StringFormat(StringFormat.GenericDefault); this.Align.LineAlignment = StringAlignment.Center; // Force transparent analisys this.BackColor = this.BackColor; }
/// <summary> /// ���������� /// </summary> /// <param name="regionForm"></param> /// <param name="e"></param> public override void OnMouseDown(RegionForm regionForm, MouseEventArgs e) { wasMove = false; selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); int handleNumber = regionForm.DrawRectangle.HitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; resizedObject = regionForm.DrawRectangle; resizedObjectHandle = handleNumber; } if (selectMode == SelectionMode.None) { DrawRectangle o = null; if (regionForm.DrawRectangle.HitTest(point) == 0) { o = regionForm.DrawRectangle; } if (o != null) { selectMode = SelectionMode.Move; regionForm.Cursor = Cursors.SizeAll; } } lastPoint.X = e.X; lastPoint.Y = e.Y; startPoint.X = e.X; startPoint.Y = e.Y; regionForm.Capture = true; regionForm.Refresh(); }
//public tooltipForm tpform = new tooltipForm(); public override void OnMouseDoubleClick(DrawArea drawArea, MouseEventArgs e) { commandChangeState = null; wasMove = false; selectMode = SelectionMode.None; Point point = drawArea.BackTrackMouse(new Point(e.X, e.Y)); // Test for resizing (only if control is selected, cursor is on the handle) int al = drawArea.TheLayers.ActiveLayerIndex; int n = drawArea.TheLayers[al].Graphics.SelectionCount; // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { int n1 = drawArea.TheLayers[al].Graphics.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.TheLayers[al].Graphics[i].HitTest(point) == 0) { o = drawArea.TheLayers[al].Graphics[i]; break; } } if (o != null) { //if (drawArea.IsPainting) //{ // o.editProperties(); //} //else //{ // o.showProperties(); //} o.ShowPropertiesDialog(); drawArea.Refresh(); } } }
public void Click(BaseEventData data) { var pData = (PointerEventData)data; if (pData.dragging) return; var pos = Camera.main.ScreenToWorldPoint(pData.position); pos.z = Camera.main.transform.position.z; var dir = new Vector3 (0, 0, 1); var hit = Physics2D.Raycast (pos, dir, 100f, CellLayer); if (hit) { var cell = hit.transform.GetComponent<GridCell>(); if(!cell) return; if(mSelectionMode == SelectionMode.CellInfo) { if(cell == SelectedCell) SelectedCell = null; else SelectedCell = cell; } else if(mSelectionMode == SelectionMode.DeployBomb) { mBombToDeploy.Deploy(cell); mSelectionMode = SelectionMode.CellInfo; } } }
void OnWizardCreate() { if (includeChildren || excludePrefabs) modePrefs = (SelectionMode.ExcludePrefab | SelectionMode.Editable | SelectionMode.Deep); else modePrefs = (SelectionMode.Editable); Object[] objs = Selection.GetFiltered(typeof(GameObject), modePrefs); foreach (GameObject go in objs) { GameObject clone = PrefabUtility.InstantiatePrefab(prefab) as GameObject; clone.name = prefab.name; clone.transform.parent = go.transform.parent; if (copyPosition) { clone.transform.localPosition = go.transform.localPosition; } if (copyRotation) { clone.transform.localRotation = go.transform.localRotation; } if (copyScale) { clone.transform.localScale = go.transform.localScale; } } if (deleteSelectedObjects) { foreach (GameObject go in objs) { DestroyImmediate(go.gameObject); } } }
/// <summary> /// <para>Returns the current selection filtered by type and mode.</para> /// </summary> /// <param name="type">Only objects of this type will be retrieved.</param> /// <param name="mode">Further options to refine the selection.</param> public static Object[] GetFiltered(Type type, SelectionMode mode) { ArrayList list = new ArrayList(); if ((type == typeof(Component)) || type.IsSubclassOf(typeof(Component))) { Transform[] transforms = GetTransforms(mode); foreach (Transform transform in transforms) { Component component = transform.GetComponent(type); if (component != null) { list.Add(component); } } } else if ((type == typeof(GameObject)) || type.IsSubclassOf(typeof(GameObject))) { Transform[] transformArray3 = GetTransforms(mode); foreach (Transform transform2 in transformArray3) { list.Add(transform2.gameObject); } } else { Object[] objectsMode = GetObjectsMode(mode); foreach (Object obj2 in objectsMode) { if ((obj2 != null) && ((obj2.GetType() == type) || obj2.GetType().IsSubclassOf(type))) { list.Add(obj2); } } } return (Object[]) list.ToArray(typeof(Object)); }
private void Create(SelectionMode mode, params string[] lines) { _view = EditorUtil.CreateView(lines); _tracker = new SelectionTracker(_view, mode); _tracker.Start(); }
/// <summary> /// Set the selection mode for all three list boxes /// </summary> /// <param name="selectionMode"></param> private void SetSelectionMode(SelectionMode selectionMode) { // workaround for the CollectionViewSource wrappers that are used for the different ListBox sorts // setting SelectionMode to Multiple removes the issue where the SelectionChanged event handler gets // invoked every time the list is changed (which triggers a resort). The SelectionMode gets reset back // to Single when the SelectionChanged events handler gets called (for a valid reason - i.e. user action) // mitigate the recursive behavior of setting the SelectionMode re-invoking the SelectionChanged event handler bool disableState = disableListBoxSelectionChanged; disableListBoxSelectionChanged = true; ByNameListBox.SelectionMode = selectionMode; ByDueListBox.SelectionMode = selectionMode; ByPriListBox.SelectionMode = selectionMode; // reset the disable state disableListBoxSelectionChanged = disableState; }
private void ResetMode() { Mode = SelectionMode.Stream; }
/// <summary> /// Right mouse button is released /// </summary> /// <param name="drawArea"> </param> /// <param name="e"> </param> public override void OnMouseUp(TransparentCanvas drawArea, MouseEventArgs e) { if (_selectMode == SelectionMode.NetSelection) { // Remove old selection rectangle ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)), Color.Black, FrameStyle.Dashed); // Make group selection drawArea.GraphicsList.SelectInRectangle( DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)); _selectMode = SelectionMode.None; } if (_resizedObject != null) { // after resizing _resizedObject.Normalize(); _resizedObject = null; } drawArea.Capture = false; drawArea.Refresh(); if (_commandChangeState != null && _wasMove) { // Keep state after moving/resizing and add command to history _commandChangeState.NewState(drawArea.GraphicsList); drawArea.AddCommandToHistory(_commandChangeState); _commandChangeState = null; } }
public override void OnInspectorGUI () { script = (MapMagic)target; if (MapMagic.instance == null) MapMagic.instance = script; script.terrains.CheckEmpty(); if (layout == null) layout = new Layout(); layout.margin = 0; layout.field = Layout.GetInspectorRect(); layout.cursor = new Rect(); layout.undoObject = script; layout.undoName = "MapMagic settings change"; layout.Par(20); bool modeNailing = layout.CheckButton(selectionMode == SelectionMode.nailing, "Pin Terrain", rect:layout.Inset(0.5f), icon:"MapMagic_PinIcon"); if (layout.lastChange && modeNailing) selectionMode = SelectionMode.nailing; if (layout.lastChange && !modeNailing) selectionMode = SelectionMode.none; bool modeLocking = layout.CheckButton(selectionMode == SelectionMode.locking, "Lock Terrain", rect:layout.Inset(0.5f), icon:"MapMagic_LockIcon"); if (layout.lastChange && modeLocking) selectionMode = SelectionMode.locking; if (layout.lastChange && !modeLocking) selectionMode = SelectionMode.none; layout.Par(4); layout.Par(24); if (layout.Button("Show Editor", rect:layout.Inset(), icon:"MapMagic_EditorIcon")) { MapMagicWindow window = (MapMagicWindow)EditorWindow.GetWindow (typeof (MapMagicWindow)); //SceneMagicWindow window = EditorWindow.GetWindow<VoxelandCreate>(); //window.script = script; window.Show(); // window.FocusOnOutput(); } // layout.ComplexField(ref MapMagic.instance.seed, "Seed"); // layout.ComplexSlider(script.terrains.terrainSize, "Terrain Size", max:2048, quadratic:true); // layout.ComplexSlider(ref script.terrainHeight, "Terrain Height", max:2048, quadratic:true); // layout.Par(); // layout.Par(); if (layout.Button("Generate")) { MapMagic.instance.terrains.start = true; script.ProcessThreads(); } // layout.Par(); if (layout.Button("Clear")) MapMagic.instance.generators.ClearGenerators(); // Undo.RecordObject (script, "MapMagic settings change"); layout.margin =10; layout.fieldSize = 0.4f; layout.Par(5); layout.Foldout(ref script.guiSettings, "General Settings"); if (script.guiSettings) { MapMagic.instance.resolution = (int)layout.Field((Pots)MapMagic.instance.resolution, "Resolution"); if (layout.lastChange && MapMagic.instance.instantGenerate) MapMagic.instance.ForceGenerate(); layout.Field(ref MapMagic.instance.terrainSize, "Terrain Size"); if (layout.lastChange) MapMagic.instance.terrains.Reset(); layout.Field(ref MapMagic.instance.terrainHeight, "Terrain Height"); if (layout.lastChange) MapMagic.instance.terrains.Reset(); layout.Par(5); layout.Field(ref MapMagic.instance.generateInfinite, "Generate Infinite Terrain"); if (MapMagic.instance.generateInfinite) { layout.Field(ref MapMagic.instance.generateRange, "Generate Range"); layout.Field(ref MapMagic.instance.removeRange, "Remove Range", min:MapMagic.instance.generateRange); layout.Field(ref MapMagic.instance.enableRange, "Enable Range"); //layout.Field(ref MapMagic.instance.terrains.enableRange, "Low Detail Range"); //layout.Field(ref MapMagic.instance.terrains.detailRange, "Full Detail Range"); } layout.Par(5); layout.Field(ref script.multiThreaded, "Multithreaded"); if (script.multiThreaded) layout.Field(ref script.maxThreads, "Max Threads"); layout.Field(ref script.instantGenerate, "Instant Generate"); layout.Field(ref script.saveIntermediate, "Save Intermediate Results"); layout.Par(5); layout.Field(ref script.heightWeldMargins, "Height Weld Margins", max:100); layout.Field(ref script.splatsWeldMargins, "Splats Weld Margins", max:100); //layout.ComplexField(ref script.hideWireframe, "Hide Wireframe"); layout.Par(5); layout.Toggle(ref script.hideFarTerrains, "Hide Out-of-Range Terrains"); //layout.Toggle(ref script.useAllCameras, "Generate around All Cameras"); layout.Toggle(ref script.copyLayersTags, "Copy Layers and Tags to Terrains"); layout.Toggle(ref script.copyComponents, "Copy Components to Terrains"); layout.Par(5); layout.Label("Generate Terrain Markers:"); layout.Field(ref script.genAroundMainCam, "Around Main Camera"); layout.Par(); layout.Field(ref script.genAroundObjsTag, "Around Objects Tagged", rect:layout.Inset()); int tagFieldWidth = (int)(layout.field.width*layout.fieldSize - 25); layout.cursor.x -= tagFieldWidth; script.genAroundTag = EditorGUI.TagField(layout.Inset(tagFieldWidth), script.genAroundTag); layout.Par(10); layout.Par(); layout.Label("Data", layout.Inset(0.2f)); GeneratorsAsset newGens = layout.Field<GeneratorsAsset>(script.gens, rect:layout.Inset(0.5f)); if (newGens != script.gens) { script.gens = newGens; script.guiGens = newGens; } if (layout.lastChange) script.gens.OnAfterDeserialize(); if (script.gens == null) { if (layout.Button("Create", layout.Inset(0.3f))) { MapMagic.instance.gens = GeneratorsAsset.Default(); MapMagic.instance.guiGens = MapMagic.instance.gens; EditorUtility.SetDirty(MapMagic.instance); } } else if (!AssetDatabase.Contains(script.gens)) { if (layout.Button("Save", layout.Inset(0.3f))) { MapMagic.instance.gens.SaveAsset(); EditorUtility.SetDirty(MapMagic.instance); } } else { if (layout.Button("Release", layout.Inset(0.3f))) { MapMagic.instance.gens = MapMagic.instance.gens.ReleaseAsset(); MapMagic.instance.guiGens = MapMagic.instance.gens; EditorUtility.SetDirty(MapMagic.instance); } } layout.Par(5); //layout.Field(ref script.guiGeneratorWidth, "Node Width"); layout.Toggle(ref script.guiDebug, "Debug"); } layout.fieldSize = 0.5f; layout.sliderSize = 0.6f; layout.Par(5); layout.Foldout(ref script.guiTerrainSettings, "Terrain Settings"); if (script.guiTerrainSettings) { layout.Field(ref script.pixelError, "Pixel Error", min:0, max:200, slider:true); layout.Field(ref script.baseMapDist, "Base Map Dist.", min:0, max:2000, slider:true); layout.Field(ref script.castShadows, "Cast Shadows"); layout.Field(ref script.terrainMaterialType, "Material Type", disabled:script.previewGenerator!=null); layout.Field(ref script.customTerrainMaterial, "Custom Material", disabled:script.terrainMaterialType!=MapMagic.TerrainMaterialType.Custom); if (script.previewGenerator!=null) layout.Label("Terrain Material is disabled in preview mode", helpbox: true); layout.Field(ref script.applyColliders, "Apply Terrain Colliders"); } layout.Par(5); layout.Foldout(ref script.guiTreesGrassSettings, "Trees, Details and Grass Settings"); if (script.guiTreesGrassSettings) { layout.Field(ref script.detailDraw, "Draw"); layout.Field(ref script.detailDistance, "Detail Distance", min:0, max:250, slider:true); layout.Field(ref script.detailDensity, "Detail Density", min:0, max:1, slider:true); layout.Field(ref script.treeDistance, "Tree Distance", min:0, max:5000, slider:true); layout.Field(ref script.treeBillboardStart, "Billboard Start", min:0, max:2000, slider:true); layout.Field(ref script.treeFadeLength, "Fade Length", min:0, max:200, slider:true); layout.Field(ref script.treeFullLod, "Max Full LOD Trees", min:0, max:10000, slider:true); layout.Par(5); layout.Field(ref script.windSpeed, "Wind Amount", min:0, max:1, slider:true); layout.Field(ref script.windSize, "Wind Bending", min:0, max:1, slider:true); layout.Field(ref script.windBending, "Wind Speed", min:0, max:1, slider:true); //there's no mistake here. Variable names are swapped in unity layout.Field(ref script.grassTint, "Grass Tint"); } if (layout.change) foreach (Chunk tw in MapMagic.instance.terrains.Objects()) tw.SetSettings(); #region About layout.Par(5); layout.Foldout(ref script.guiAbout, "About"); if (script.guiAbout) { Rect savedCursor = layout.cursor; layout.Par(100, padding:0); layout.Icon("MapMagicAbout", layout.Inset(100,padding:0)); layout.cursor = savedCursor; layout.margin = 115; layout.Label("MapMagic " + (int)(MapMagic.version/10f) + "." + (MapMagic.version - (int)(MapMagic.version/10f)*10)); layout.Label("by Denis Pahunov"); layout.Par(10); layout.Label(" - Online Documentation", url:"https://docs.google.com/document/d/1OX7zYOrPz9qOFNAfO0qawhB7T3M6tLG9VgZSEntRJTA/edit?usp=sharing"); layout.Label(" - Video Tutorials", url:"https://www.youtube.com/playlist?list=PL8fjbXLqBxvZb5yqXwp_bn4keyzyg5e0R"); layout.Label(" - Forum Thread", url:"http://forum.unity3d.com/threads/map-magic-a-node-based-procedural-and-infinite-map-generator-for-asset-store.344440/"); //layout.Par(10); //layout.Par(); layout.Label("Review or rating vote on"); //layout.Par(); layout.Label("Asset Store", url:"--"); //layout.Par(); layout.Label("would be appreciated."); layout.Par(10); layout.Label("On any issues related"); layout.Label("with plugin functioning "); layout.Label("you can contact the"); layout.Label("author by mail:"); layout.Label("*****@*****.**", url:"mailto:[email protected]"); } #endregion Layout.SetInspectorRect(layout.field); }
/// <summary> /// 按下鼠标左键 /// </summary> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { _selectMode = SelectionMode.None; PointF point = new Point(e.X, e.Y); // 调整大小的测试(仅当选择了控件时,光标位于句柄上) int n = drawArea.GraphicsList.SelectionCount; for (int i = 0; i < n; i++) { DrawObject o = drawArea.GraphicsList.GetSelectedObject(i); int handleNumber = o.HitTest(point); bool hitOnOutline = o.HitOnCircumferance; if (handleNumber > 0) { _selectMode = SelectionMode.Size; #region LineConnect if (o is DrawConnectLine && handleNumber != 2) { ((DrawConnectLine)o).SetFollowObjectNull(handleNumber); } if (o is DrawConnectObject connect) { connect.SetFollowDrawObject(handleNumber, null, -1); } //if (o is WireConnectLineDrawObject && handleNumber != 2) //{ // ((WireConnectLineDrawObject)o).SetFollowObjectNull(handleNumber); //} #endregion //if ( o is SingleDisConnectorDrawObject && handleNumber == 9) //{ // float state = ((SingleDisConnectorDrawObject)o).Switch; // ((SingleDisConnectorDrawObject)o).Switch = state == 0 ? 1 : 0; //} // 在类成员中保留调整大小的对象 _resizedObject = o; _resizedObjectHandle = handleNumber; // 因为我们只想调整一个对象的大小,所以取消选择所有其他对象。 drawArea.GraphicsList.UnselectAll(); o.Selected = true; o.MouseClickOnHandle(handleNumber); break; } if (hitOnOutline && (n == 1)) { _selectMode = SelectionMode.Size; o.MouseClickOnBorder(); o.Selected = true; } } // 移动测试(光标在对象上) if (_selectMode == SelectionMode.None) { int n1 = drawArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.GraphicsList[i].HitTest(point) == 0) { o = drawArea.GraphicsList[i]; break; } } if (o != null) { _selectMode = SelectionMode.Move; // 如果未按ctrl且尚未选择单击的对象,则取消全选 if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.GraphicsList.UnselectAll(); } // 选择单击的对象 o.Selected = true; drawArea.Cursor = Cursors.SizeAll; } } //判断是否点击到旋钮 if (_selectMode == SelectionMode.None) { for (int i = 0; i < n; i++) { DrawObject o = drawArea.GraphicsList.GetSelectedObject(i); bool hitonknob = o.HitKnobTest(point); if (hitonknob) { _selectMode = SelectionMode.Rotate; // 在类成员中保留调整角度的对象 _rerotateObject = o; // 因为我们只想调整一个对象的大小,所以取消选择所有其他对象。 drawArea.GraphicsList.UnselectAll(); o.Selected = true; break; } } } // 净选择 if (_selectMode == SelectionMode.None) { // 点击背景 if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } _selectMode = SelectionMode.NetSelection; drawArea.DrawNetRectangle = true; } //保存一次最近操作 _lastPoint.X = e.X; _lastPoint.Y = e.Y; _startPoint.X = e.X; _startPoint.Y = e.Y; drawArea.Capture = true; drawArea.NetRectangle = DrawRectangleObject.GetNormalizedRectangle(_startPoint, _lastPoint); drawArea.Refresh(); }
private void LoadSettings() { XDocument doc = null; if (File.Exists(SettingsFile)) { doc = XMLExtensions.TryLoadXml(SettingsFile); } if (doc == null || doc.Root == null) { doc = new XDocument(new XElement("serversettings")); } SerializableProperties = SerializableProperty.DeserializeProperties(this, doc.Root); AutoRestart = doc.Root.GetAttributeBool("autorestart", false); #if CLIENT if (autoRestart) { GameMain.NetLobbyScreen.SetAutoRestart(autoRestart, AutoRestartInterval); } #endif subSelectionMode = SelectionMode.Manual; Enum.TryParse <SelectionMode>(doc.Root.GetAttributeString("SubSelection", "Manual"), out subSelectionMode); Voting.AllowSubVoting = subSelectionMode == SelectionMode.Vote; modeSelectionMode = SelectionMode.Manual; Enum.TryParse <SelectionMode>(doc.Root.GetAttributeString("ModeSelection", "Manual"), out modeSelectionMode); Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote; var traitorsEnabled = TraitorsEnabled; Enum.TryParse <YesNoMaybe>(doc.Root.GetAttributeString("TraitorsEnabled", "No"), out traitorsEnabled); TraitorsEnabled = traitorsEnabled; GameMain.NetLobbyScreen.SetTraitorsEnabled(traitorsEnabled); if (GameMain.NetLobbyScreen != null #if CLIENT && GameMain.NetLobbyScreen.ServerMessage != null #endif ) { #if SERVER GameMain.NetLobbyScreen.ServerName = doc.Root.GetAttributeString("name", ""); GameMain.NetLobbyScreen.SelectedModeName = GameMode; GameMain.NetLobbyScreen.MissionTypeName = MissionType; #endif GameMain.NetLobbyScreen.ServerMessageText = doc.Root.GetAttributeString("ServerMessage", ""); } #if CLIENT showLogButton.Visible = SaveServerLogs; #endif List <string> monsterNames = Directory.GetDirectories("Content/Characters").ToList(); for (int i = 0; i < monsterNames.Count; i++) { monsterNames[i] = monsterNames[i].Replace("Content/Characters", "").Replace("/", "").Replace("\\", ""); } monsterEnabled = new Dictionary <string, bool>(); foreach (string s in monsterNames) { monsterEnabled.Add(s, true); } extraCargo = new Dictionary <ItemPrefab, int>(); }
public void SetSelectionMode(SelectionMode mode) { Table.AllowsMultipleSelection = mode == SelectionMode.Multiple; }
private void ValidateSelectionMode(SelectionMode mode) { CanSelectMultiple = (mode != SelectionMode.Single); }
// common code for all constructors private void Initialize() { SelectionMode mode = (SelectionMode)SelectionModeProperty.GetDefaultValue(DependencyObjectType); ValidateSelectionMode(mode); }
public static IntPtr Box_SelectionMode(SelectionMode val) { IntPtr ret = NoesisGUI_PINVOKE.Box_SelectionMode((int)val); return(ret); }
public static SelectionMode Unbox_SelectionMode(IntPtr val) { SelectionMode ret = (SelectionMode)NoesisGUI_PINVOKE.Unbox_SelectionMode(val); return(ret); }
/// <inheritdoc /> protected override void SetIndexValue(int idx, ReadOnlySpan <char> val) { switch (idx) { case 0: SelectionMode = GetSelectionMode(val); break; case 1: Mode = GetFixMode(val); break; case 2: Sat1Id = GetInteger(val); break; case 3: Sat2Id = GetInteger(val); break; case 4: Sat3Id = GetInteger(val); break; case 5: Sat4Id = GetInteger(val); break; case 6: Sat5Id = GetInteger(val); break; case 7: Sat6Id = GetInteger(val); break; case 8: Sat7Id = GetInteger(val); break; case 9: Sat8Id = GetInteger(val); break; case 10: Sat9Id = GetInteger(val); break; case 11: Sat10Id = GetInteger(val); break; case 12: Sat11Id = GetInteger(val); break; case 13: Sat12Id = GetInteger(val); break; case 14: PDOPMeters = GetDouble(val); break; case 15: HDOPMeters = GetDouble(val); break; case 16: VDOPMeters = GetDouble(val); break; } }
public Selection () { SelectionMode = SelectionMode.Normal; }
/// <summary> /// 释放鼠标右键 /// </summary> public override void OnMouseUp(DrawArea drawArea, MouseEventArgs e) { if (_selectMode == SelectionMode.NetSelection) { // 分组选择 drawArea.GraphicsList.SelectInRectangle(drawArea.NetRectangle); _selectMode = SelectionMode.None; drawArea.DrawNetRectangle = false; } if (_resizedObject != null) { //if(_resizedObject is DeviceDrawObject) //{ // var device = (DeviceDrawObject)_resizedObject; // for (int i = 0; i < drawArea.GraphicsList.Count; i++) // { // if (!(drawArea.GraphicsList[i] is DeviceDrawObject)) continue; // int hithandle = drawArea.GraphicsList[i].HitTest(device.GetHandle(_resizedObjectHandle)); // if ( hithandle>= 0) // { // device.SetConnect(hithandle, (DeviceDrawObject) drawArea.GraphicsList[i]); // ((DeviceDrawObject) drawArea.GraphicsList[i]).SetConnect(hithandle, device); // } // } //} #region LineConnect if (_resizedObjectHandle != 2 && _resizedObject is DrawConnectLine) { var line = (DrawConnectLine)_resizedObject; for (int i = 0; i < drawArea.GraphicsList.Count; i++) { if (drawArea.GraphicsList[i] is DrawConnectLine) { continue; } if (drawArea.GraphicsList[i] is DrawLineObject) { continue; } if (drawArea.GraphicsList[i].HitTest(line.GetHandle(_resizedObjectHandle)) >= 0) { line.SetFollowObject(_resizedObjectHandle, drawArea.GraphicsList[i]); } } } if (_resizedObject is DrawConnectObject connect) { for (int i = 0; i < drawArea.GraphicsList.Count; i++) { if (drawArea.GraphicsList[i] is DeviceDrawObjectBase device) { if (device.HitTest(connect.GetHandle(_resizedObjectHandle)) >= 0) { connect.SetFollowDrawObject(_resizedObjectHandle, device, device.GetNearestPort(connect.GetHandle(_resizedObjectHandle))); } } } } //if (_resizedObjectHandle != 2 && _resizedObject is WireConnectLineDrawObject line1) //{ // for (int i = 0; i < drawArea.GraphicsList.Count; i++) // { // //if (drawArea.GraphicsList[i] is WireConnectLineDrawObject) continue; // //if (drawArea.GraphicsList[i] is WireConnectLineDrawObject) continue; // int hit = drawArea.GraphicsList[i].HitTest(line1.GetHandle(_resizedObjectHandle)); // if (hit >= 0) // { // if (hit == 0) // { // float mins = 99999; // int hits = 0; // for (int j = 0; j < drawArea.GraphicsList[i].HandleCount; j++) // { // var point = drawArea.GraphicsList[i].GetHandle(j); // var dis = (point.X - e.X) * (point.X - e.X) + (point.Y - e.Y) * (point.Y - e.Y); // if ( dis < mins) // { // mins = dis; // hits = j; // } // } // hit = hits; // } // //if (drawArea.GraphicsList[i] is DeviceDrawObject // // && !(drawArea.GraphicsList[i] is WireConnectLineDrawObject)) // //{ // // PortDrawObject port = null; // // foreach (var portDrawObject in ((DeviceDrawObject)drawArea.GraphicsList[i]).PortDrawObjects) // // { // // if(portDrawObject.OwnerDevice != drawArea.GraphicsList[i]) break; // // if (portDrawObject.OwnerDeviceHandle != hit) continue; // // port = portDrawObject; // // break; // // } // // if (port == null) // // { // // port = new PortDrawObject(e.X, e.Y) // // { // // ConnectDevice = _resizedObject as DeviceDrawObject, // // //OwnerDeviceHandle = hit, // // OwnerDevice = drawArea.GraphicsList[i] as DeviceDrawObject // // }; // // port.OwnerDeviceHandle = hit; // // ((DeviceDrawObject)drawArea.GraphicsList[i]).PortDrawObjects.Add(port); // // drawArea.GraphicsList.Add(port); // // } // //line1.SetFollowObject(_resizedObjectHandle, port, 9); // //break; // } // else // { // line1.SetFollowObject(_resizedObjectHandle, drawArea.GraphicsList[i]); // break; // } // } //} //} #endregion // 调整大小后 _resizedObject.MouseClickOnHandleUp(_resizedObjectHandle); _resizedObject.Normalize(); _resizedObject = null; drawArea.ResizeCommand(drawArea.GraphicsList.GetFirstSelected(), new PointF(_startPoint.X, _startPoint.Y), new PointF(e.X, e.Y), _resizedObjectHandle); } if (_rerotateObject != null) { _rerotateObject.Normalize(); _rerotateObject = null; drawArea.RerotateCommand(drawArea.GraphicsList.GetFirstSelected(), new PointF(_startPoint.X, _startPoint.Y), new PointF(e.X, e.Y)); } drawArea.Capture = false; drawArea.Refresh(); //立即按命令撤消/重做列表 if (_selectMode == SelectionMode.Move) { var movedItemsList = new ArrayList(); for (int i = 0; i < drawArea.GraphicsList.SelectionCount; i++) { movedItemsList.Add(drawArea.GraphicsList.GetSelectedObject(i)); } var delta = new PointF { X = e.X - _startPoint.X, Y = e.Y - _startPoint.Y }; drawArea.MoveCommand(movedItemsList, delta); } IsComplete = true; }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { CmbGraphics1.Enabled = true; TxtGName2.Enabled = BtnRename2.Enabled = TxtGName3.Enabled = BtnRename3.Enabled = TxtGName4.Enabled = BtnRename4.Enabled = CmbGraphics2.Enabled = CmbGraphics3.Enabled = CmbGraphics4.Enabled = false; SelectionMode = SelectionMode.Full; }
public void SetSelectionMode(SelectionMode mode) { Tree.SelectionMode = (mode == SelectionMode.Single) ? SWC.SelectionMode.Single : SWC.SelectionMode.Extended; }
public Selection() { SelectionMode = SelectionMode.Normal; }
public override void OnInspectorGUI () { script = (MapMagic)target; if (MapMagic.instance == null) MapMagic.instance = script; //checking removed terrains foreach (Chunk chunk in script.chunks.All()) if (chunk.terrain == null) script.chunks.Remove(chunk.coord); //assigning mapmagic to mapmagic window if (MapMagicWindow.instance != null && MapMagicWindow.instance.mapMagic != (IMapMagic)script) MapMagicWindow.Show(script.gens, script, forceOpen:false); if (layout == null) layout = new Layout(); layout.margin = 0; layout.field = Layout.GetInspectorRect(); layout.cursor = new Rect(); layout.undoObject = script; layout.undoName = "MapMagic settings change"; layout.Par(20); bool modeNailing = layout.CheckButton(selectionMode == SelectionMode.nailing, "Pin", rect:layout.Inset(0.3333f), icon:"MapMagic_PinIcon"); if (layout.lastChange && modeNailing) selectionMode = SelectionMode.nailing; if (layout.lastChange && !modeNailing) selectionMode = SelectionMode.none; bool modeLocking = layout.CheckButton(selectionMode == SelectionMode.locking, "Lock", rect:layout.Inset(0.3333f), icon:"MapMagic_LockIcon"); if (layout.lastChange && modeLocking) selectionMode = SelectionMode.locking; if (layout.lastChange && !modeLocking) selectionMode = SelectionMode.none; bool modeExporting = layout.CheckButton(selectionMode == SelectionMode.exporting, "Save", rect:layout.Inset(0.3333f), icon:"MapMagic_ExportIcon"); if (layout.lastChange && modeExporting) selectionMode = SelectionMode.exporting; if (layout.lastChange && !modeExporting) selectionMode = SelectionMode.none; layout.Par(4); layout.Par(24); if (layout.Button("Show Editor", rect:layout.Inset(), icon:"MapMagic_EditorIcon")) MapMagicWindow.Show(script.gens, script, forceOpen:true); // layout.ComplexField(ref MapMagic.instance.seed, "Seed"); // layout.ComplexSlider(script.terrains.terrainSize, "Terrain Size", max:2048, quadratic:true); // layout.ComplexSlider(ref script.terrainHeight, "Terrain Height", max:2048, quadratic:true); // layout.Par(); // layout.Par(); if (layout.Button("Generate")) { MapMagic.instance.terrains.start = true; script.ProcessThreads(); } // layout.Par(); if (layout.Button("Clear")) MapMagic.instance.generators.ClearGenerators(); // Undo.RecordObject (script, "MapMagic settings change"); layout.margin =10; layout.fieldSize = 0.4f; layout.Par(5); layout.Foldout(ref script.guiSettings, "General Settings"); if (script.guiSettings) { //layout.Field(ref MapMagic.instance.voxelandMode, "Voxeland Mode"); layout.Field(ref MapMagic.instance.seed, "Seed"); layout.Toggle(ref MapMagic.instance.changeSeed, "Change Seed on Playmode Start"); MapMagic.instance.resolution = (int)layout.Field((Pots)MapMagic.instance.resolution, "Resolution"); if (layout.lastChange) { MapMagic.instance.ClearResults(); MapMagic.instance.Generate(); } layout.Field(ref MapMagic.instance.terrainSize, "Terrain Size"); if (layout.lastChange) MapMagic.instance.ResetChunks(); layout.Field(ref MapMagic.instance.terrainHeight, "Terrain Height"); if (layout.lastChange) MapMagic.instance.ResetChunks(); layout.Par(5); layout.Field(ref MapMagic.instance.generateInfinite, "Generate Infinite Terrain"); if (MapMagic.instance.generateInfinite) { layout.Field(ref MapMagic.instance.generateRange, "Generate Range"); layout.Field(ref MapMagic.instance.removeRange, "Remove Range", min:MapMagic.instance.generateRange); layout.Field(ref MapMagic.instance.enableRange, "Enable Range"); //layout.Field(ref MapMagic.instance.terrains.enableRange, "Low Detail Range"); //layout.Field(ref MapMagic.instance.terrains.detailRange, "Full Detail Range"); } //threads layout.Par(5); layout.Field(ref ThreadWorker.multithreading, "Multithreading"); if (ThreadWorker.multithreading) { layout.Par(); layout.Field(ref ThreadWorker.maxThreads, "Max Threads", rect:layout.Inset(0.75f), fieldSize:0.2f, disabled:ThreadWorker.autoMaxThreads); layout.Toggle(ref ThreadWorker.autoMaxThreads, "Auto",rect:layout.Inset(0.25f)); } else layout.Field(ref ThreadWorker.maxThreads, "Max Coroutines"); layout.Field(ref ThreadWorker.maxApplyTime, "Max Apply Time"); layout.Par(5); script.instantGenerate = layout.Field(script.instantGenerate, "Instant Generate"); layout.Field(ref script.saveIntermediate, "Save Intermediate Results"); layout.Field(ref script.guiHideWireframe, "Hide Frame"); if (layout.lastChange) script.transform.ToggleDisplayWireframe(!script.guiHideWireframe); layout.Par(5); layout.Field(ref script.heightWeldMargins, "Height Weld Margins", max:100); layout.Field(ref script.splatsWeldMargins, "Splats Weld Margins", max:100); //layout.ComplexField(ref script.hideWireframe, "Hide Wireframe"); layout.Par(5); layout.Toggle(ref script.hideFarTerrains, "Hide Out-of-Range Terrains"); //layout.Toggle(ref script.useAllCameras, "Generate around All Cameras"); layout.Toggle(ref script.copyLayersTags, "Copy Layers and Tags to Terrains"); layout.Toggle(ref script.copyComponents, "Copy Components to Terrains"); layout.Par(5); layout.Label("Generate Terrain Markers:"); layout.Field(ref script.genAroundMainCam, "Around Main Camera"); layout.Par(); layout.Field(ref script.genAroundObjsTag, "Around Objects Tagged", rect:layout.Inset()); int tagFieldWidth = (int)(layout.field.width*layout.fieldSize - 25); layout.cursor.x -= tagFieldWidth; script.genAroundTag = EditorGUI.TagField(layout.Inset(tagFieldWidth), script.genAroundTag); layout.Par(5); layout.Label("Floating Point Origin Solution:"); layout.Toggle(ref script.shift, "Shift World"); layout.Field(ref script.shiftThreshold, "Shift Threshold", disabled:!script.shift); //data layout.Par(5); layout.fieldSize = 0.7f; script.gens = layout.ScriptableAssetField(script.gens, construct:GeneratorsAsset.Default, savePath: null); if (layout.lastChange) MapMagicWindow.Show(script.gens, script, forceOpen:false, asBiome:false); //debug BuildTargetGroup buildGroup = EditorUserBuildSettings.selectedBuildTargetGroup; string defineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildGroup); bool debug = false; if (defineSymbols.Contains("WDEBUG;") || defineSymbols.EndsWith("WDEBUG")) debug = true; layout.Par(7); layout.Toggle(ref debug, "Debug (Requires re-compile)"); if (layout.lastChange) { if (debug) { defineSymbols += (defineSymbols.Length!=0? ";" : "") + "WDEBUG"; } else { defineSymbols = defineSymbols.Replace("WDEBUG",""); defineSymbols = defineSymbols.Replace(";;", ";"); } PlayerSettings.SetScriptingDefineSymbolsForGroup(buildGroup, defineSymbols); } } layout.fieldSize = 0.5f; layout.sliderSize = 0.6f; layout.Par(5); layout.Foldout(ref script.guiTerrainSettings, "Terrain Settings"); if (script.guiTerrainSettings) { layout.Field(ref script.pixelError, "Pixel Error", min:0, max:200, slider:true); layout.Field(ref script.baseMapDist, "Base Map Dist.", min:0, max:2000, slider:true, disabled:!script.showBaseMap); layout.Field(ref script.showBaseMap, "Show Base Map"); layout.Field(ref script.castShadows, "Cast Shadows"); layout.Field(ref script.applyColliders, "Apply Terrain Colliders"); layout.Par(5); layout.Field(ref script.terrainMaterialType, "Material Type"); layout.Field(ref script.customTerrainMaterial, "Custom Material", disabled:script.terrainMaterialType!=Terrain.MaterialType.Custom); layout.Toggle(ref script.assignCustomTerrainMaterial, "Assign Material (disable for MegaSplat/RTP)", disabled:script.terrainMaterialType!=Terrain.MaterialType.Custom); //layout.Toggle(ref script.materialTemplateMode, "Material Template Mode (MegaSplat/RTP)"); if (Preview.enabled) layout.Label("Terrain Material is disabled in preview mode", helpbox: true); } layout.Par(5); layout.Foldout(ref script.guiTreesGrassSettings, "Trees, Details and Grass Settings"); if (script.guiTreesGrassSettings) { layout.Field(ref script.detailDraw, "Draw"); layout.Field(ref script.detailDistance, "Detail Distance", min:0, max:250, slider:true); layout.Field(ref script.detailDensity, "Detail Density", min:0, max:1, slider:true); layout.Field(ref script.treeDistance, "Tree Distance", min:0, max:5000, slider:true); layout.Field(ref script.treeBillboardStart, "Billboard Start", min:0, max:2000, slider:true); layout.Field(ref script.treeFadeLength, "Fade Length", min:0, max:200, slider:true); layout.Field(ref script.treeFullLod, "Max Full LOD Trees", min:0, max:10000, slider:true); layout.Field(ref script.bakeLightProbesForTrees, "Bake Light Probes For Trees"); layout.Par(5); layout.Field(ref script.windSpeed, "Wind Amount", min:0, max:1, slider:true); layout.Field(ref script.windSize, "Wind Bending", min:0, max:1, slider:true); layout.Field(ref script.windBending, "Wind Speed", min:0, max:1, slider:true); //there's no mistake here. Variable names are swapped in unity layout.Field(ref script.grassTint, "Grass Tint"); } if (layout.change) foreach (Chunk tw in MapMagic.instance.chunks.All()) tw.SetSettings(); #region Mass Pin layout.Par(5); layout.Foldout(ref script.guiMassPin, "Mass Pin/Lock"); if (script.guiMassPin) { layout.Par(52); layout.Label("This feature is designed to be used with streaming plugins. Using it in all other purposes is not recommended because of performance reasons", layout.Inset(), helpbox:true); layout.Par(); layout.Label("Offset (chunks):", layout.Inset(0.5f)); layout.Field(ref script.guiPinRect.offset.x, "X", layout.Inset(0.25f), fieldSize:0.7f); layout.Field(ref script.guiPinRect.offset.z, "Z", layout.Inset(0.25f), fieldSize:0.7f); layout.Par(); layout.Label("Area Size (chunks):", layout.Inset(0.5f)); layout.Field(ref script.guiPinRect.size.x, "X", layout.Inset(0.25f), fieldSize:0.7f); layout.Field(ref script.guiPinRect.size.z, "Z", layout.Inset(0.25f), fieldSize:0.7f); layout.Par(); if (layout.Button("Pin", layout.Inset(0.333f))) { Undo.RegisterFullObjectHierarchyUndo(MapMagic.instance, "MapMagic Mass Pin Terrain"); Coord min = script.guiPinRect.Min; Coord max = script.guiPinRect.Max; for (int x=min.x; x<max.x; x++) for (int z=min.z; z<max.z; z++) MapMagic.instance.chunks.Create(new Coord(x,z), script, pin:true); } if (layout.Button("Lock All", layout.Inset(0.333f))) { Undo.RegisterFullObjectHierarchyUndo(MapMagic.instance, "MapMagic Mass Lock Terrain"); foreach (Chunk chunk in MapMagic.instance.chunks.All(pinnedOnly:true)) chunk.locked = true; } if (layout.Button("Unpin All", layout.Inset(0.333f))) { Undo.RegisterFullObjectHierarchyUndo(MapMagic.instance, "MapMagic Mass Pin Terrain"); MapMagic.instance.chunks.Clear(); } } #endregion #region About layout.Par(5); layout.Foldout(ref script.guiAbout, "About"); if (script.guiAbout) { Rect savedCursor = layout.cursor; layout.Par(100, padding:0); layout.Icon("MapMagicAbout", layout.Inset(100,padding:0)); layout.cursor = savedCursor; layout.margin = 115; layout.Label("MapMagic " + MapMagic.version.ToVersionString() + " " + MapMagic.versionState.ToVersionString()); layout.Label("by Denis Pahunov"); layout.Par(10); layout.Label(" - Online Documentation", url:"https://gitlab.com/denispahunov/mapmagic/wikis/home"); layout.Label(" - Video Tutorials", url:"https://www.youtube.com/playlist?list=PL8fjbXLqBxvZb5yqXwp_bn4keyzyg5e0R"); layout.Label(" - Forum Thread", url:"http://forum.unity3d.com/threads/map-magic-a-node-based-procedural-and-infinite-map-generator-for-asset-store.344440/"); layout.Label(" - Issues / Ideas", url:"https://gitlab.com/denispahunov/mapmagic/issues"); } #endregion Layout.SetInspectorRect(layout.field); }
/// <summary> /// Sets the current selectionMode. SINGLE, MULTI or SIMPLE. /// </summary> /// <param name="mode">'SINGLE', 'MULTI' or 'SIMPLE'.</param> public void SetSelectionMode(SelectionMode mode) { this.Call("setSelectionMode", mode.ToString().ToLowerInvariant()); }
/// <summary> /// Prepare the ArchiveFileInfo list needed for this archive. This method scans for all files /// to be included in the archive and prepares their keynames, file paths and base prefixes. /// If the user selection doesn't include any files or if the user selection has a total size /// more than the remaining free Deepfreeze Storage, this method throws an exception. /// </summary> /// <param name="paths"></param> /// <returns></returns> private async Task PrepareArchivePathsAndSizeAsync(IEnumerable <string> paths, SelectionMode selectionMode) { // Clear list with archive files info. this._archiveInfo.Clear(); // Clear errors ErrorSelectingFiles = null; IsReset = false; IsBusy = true; BusyMessageText = Properties.Resources.CalculatingTotalArchiveSizeText; try { long size = 0; // split paths to files and folders. var files = new List <string>(); var directories = new List <string>(); bool isDirectoryRestricted; foreach (var p in paths) { FileAttributes attr = File.GetAttributes(p); // if the selected folder is indeed a directory and not a junction point // add it for archiving. if ((attr & FileAttributes.Directory) == FileAttributes.Directory && (attr & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) { isDirectoryRestricted = CheckIfDirectoryIsRestricted(p); if (!isDirectoryRestricted) { if (directories.Contains(p)) { continue; } directories.Add(p); } else { this._excludedFiles.Add(p, Enumerations.FileCategory.RestrictedDirectory); } } else { if (files.Contains(p)) { continue; } files.Add(p); } } // If the initial selection includes just one folder, // then set the archive's title to its name. (step 1) if (directories.Count == 1 && files.Count == 0) { this.ArchiveTitle = new DirectoryInfo(directories.First()).Name; } // The directories list may contain subdirectories of some of its elements. // We need to remove them because we need to add them later on in the subDirectories dictionary // so we can get the correct grandparent value. var dirsToRemove = new List <string>(); foreach (var dir in directories) { var dirInfo = new DirectoryInfo(dir); var subDirs = dirInfo.GetDirectories().Select(x => x.FullName); foreach (var sub in subDirs) { if (directories.Contains(sub) && !dirsToRemove.Contains(sub)) { dirsToRemove.Add(sub); } } dirInfo = null; subDirs = null; } foreach (var dirToRemove in dirsToRemove) { directories.Remove(dirToRemove); } dirsToRemove.Clear(); dirsToRemove = null; var subDirectories = new Dictionary <string, string>(); // Okay now find all the subdirectories to include respecting restrictions. foreach (var dir in directories) { var subsWithoutJunctions = await IgnoreJunctionsUnderPath(dir); foreach (var sub in subsWithoutJunctions.OrderBy(x => x)) { if (subDirectories.Keys.Contains(sub)) { continue; } // for each subdirectory to include we create a key with the dir's parent as a value. // we will need this to find the prefix to remove for the key names. subDirectories.Add(sub, Directory.GetParent(dir).FullName + "\\"); } subsWithoutJunctions.Clear(); subsWithoutJunctions = null; } // add all found subdirectories in the directories list // which will be scanned for files at the top level for each directory. if (subDirectories.Count > 0) { foreach (var sub in subDirectories.Keys) { if (directories.Contains(sub)) { continue; } directories.Add(sub); } } // REMARK // We want to handle directories first. The main reason behind this is that in search results // one file may be contained more than one time. If a descendant directory of this file is contained // in the results, then we want the file to be included with a key name indicating this hierarchy. // The "clean" selection of the file from the search results, will have to be ignored. // // Example: C:\test\test.txt // Searching for 'test' will return two results, the test folder and the test.txt file. // Selecting both, will add the same path two times. But the folder result will get included // first in the _archiveInfo list, and when the code tries to add the 'clean // for all directories selected for archiving, add all files in _archiveFileInfo. foreach (var dir in directories) { // Fetch all files in directory, only those on the top level. var dirFiles = Directory.GetFiles(dir, "*", SearchOption.TopDirectoryOnly); if (dirFiles.Count() > 0) { await Task.Run(() => { foreach (var f in dirFiles) { if (this._archiveInfo.Select(x => x.FilePath).Contains(f)) { continue; } var fileCategory = Utilities.CheckFileApiRestrictions(f); if (fileCategory != Enumerations.FileCategory.Normal) { this.HasInvalidFiles = true; this._excludedFiles.Add(f, fileCategory); continue; } var info = new FileInfo(f); // Check that the archive size does not exceed the maximum allowed file size. // S3 supports multipart uploads with up to 10000 parts and 5 TB max size. // Since DF supports part size of 5 MB, archive size must not exceed 5 MB * 10000 if (info.Length > MAX_ALLOWED_FILE_SIZE) { throw new Exception("The file " + f + " exceeds the maximum allowed archive size of " + LongToSizeString.ConvertToString((double)MAX_ALLOWED_FILE_SIZE) + "."); } var baseToRemove = (!subDirectories.Keys.Contains(dir)) ? Directory.GetParent(dir).FullName + "\\" : subDirectories[dir]; var archiveFileInfo = new ArchiveFileInfo() { FileName = info.Name, KeyName = f.Replace(baseToRemove, "").Replace('\\', '/'), FilePath = f, Size = info.Length, LastModified = info.LastWriteTimeUtc, MD5 = Utilities.GetMD5Hash(f), IsUploaded = false }; this._archiveInfo.Add(archiveFileInfo); size += archiveFileInfo.Size; } } ); } } // Remove the subdirectories from the directories list, so only the initially selected // directory(ies) is left. We need to keep clean the directories list, so the code below // suggesting an upload name gets the corrent amount of initially selected directories. foreach (string subDir in subDirectories.Values) { directories.Remove(subDir); } subDirectories.Clear(); subDirectories = null; // do the same for each individually selected files. foreach (var f in files) { if (this._archiveInfo.Select(x => x.FilePath).Contains(f)) { continue; } var fileCategory = Utilities.CheckFileApiRestrictions(f); if (fileCategory != Enumerations.FileCategory.Normal) { this.HasInvalidFiles = true; this._excludedFiles.Add(f, fileCategory); continue; } var info = new FileInfo(f); // Check that the archive size does not exceed the maximum allowed file size. // S3 supports multipart uploads with up to 10000 parts and 5 TB max size. // Since DF supports part size of 5 MB, archive size must not exceed 5 MB * 10000 if (info.Length > MAX_ALLOWED_FILE_SIZE) { throw new Exception("The file " + info + " exceeds the maximum allowed archive size of " + LongToSizeString.ConvertToString((double)MAX_ALLOWED_FILE_SIZE) + "."); } var archiveFileInfo = new ArchiveFileInfo() { FileName = info.Name, KeyName = info.Name, FilePath = f, Size = info.Length, LastModified = info.LastWriteTimeUtc, MD5 = Utilities.GetMD5Hash(f), IsUploaded = false }; this._archiveInfo.Add(archiveFileInfo); size += archiveFileInfo.Size; } var result = await ShowRestrictedWarningMessage(); // if the user clicked cancel in the warning message box because of a restricted folder // then cancel the new archive archive creation and reset the ViewModel. if (result == MessageBoxResult.Cancel) { this._isUserCancel = true; throw new Exception("User cancelled because of a restricted folder"); } if (this._archiveInfo.Count == 0) { throw new Exception("Your selection doesn't contain any files. Nothing to upload."); } // check that the archive size fits in user's DF storage. if (size > (this._deepfreezeClient.Settings.ActiveUser.Quota.Size - this._deepfreezeClient.Settings.ActiveUser.Quota.Used)) { // get the userviewmodel to refresh stats. // we could use the messaging service, but we actually need to wait until the stats are refreshed // before checking the sizes again. Sending a message is a fire and forget style, so that couldn't work here. var userVM = IoC.Get <IUserViewModel>() as UserViewModel; await userVM.RefreshUser(); if (size > (this._deepfreezeClient.Settings.ActiveUser.Quota.Size - this._deepfreezeClient.Settings.ActiveUser.Quota.Used)) { throw new Exception(Properties.Resources.ErrorNotEnoughSpaceGenericText); } } // suggest an archive title step 2 // if the title wasn't set in the previous step, suggest one. if (String.IsNullOrEmpty(this.ArchiveTitle)) { if (this._archiveInfo.Count == 1) { this.ArchiveTitle = this._archiveInfo.First().FileName; } else { this.ArchiveTitle = "upload-" + String.Format("{0:yyyy-MM-dd}", DateTime.Now); } } this._archiveSize = size; this.SetTotalsTexts(); this.HasChosenFiles = true; return; } catch (Exception e) { _log.Error(Utilities.GetCallerName() + " threw " + e.GetType().ToString() + " with message \"" + e.Message + "\"", e); if (!this._isUserCancel) { this.ErrorSelectingFiles = Properties.Resources.ErrorAddingFilesGenericText; } if (e is UnauthorizedAccessException || e is DirectoryNotFoundException || e is FileNotFoundException) { this.ErrorSelectingFiles += " " + e.Message; } else { if (e.Message == Properties.Resources.ErrorNotEnoughSpaceGenericText) { this.ErrorSelectingFiles = e.Message; } // if the selection includes no files and a restricted folder WASN'T in the selection // then show the no files to upload error message. if (this._archiveInfo.Count == 0 && !this._isUserCancel) { this.ErrorSelectingFiles = e.Message; } } this.IsReset = true; if (this._isUserCancel) { this.Reset(); } } finally { IsBusy = false; } }
/// <summary> /// Initializes a new instance of the <see cref="PagingItemListViewModel{TItem,TModel}.WithSelection"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="source">The source.</param> /// <param name="selectionMode">The selection mode.</param> protected WithSelection(object parent, IList <TModel> source, SelectionMode selectionMode = DefaultSelectionMode) : base(parent, source) { _selectionMode = selectionMode; _selectedItems.CollectionChanged += (a, b) => OnSelectionChanged(); }
public Selection WithSelectionMode(SelectionMode newSelectionMode) { return(new Selection(Anchor, Lead, newSelectionMode)); }
Selection(bool empty) { anchor = lead = DocumentLocation.Empty; selectionMode = SelectionMode.Normal; }
public Selection(int anchorLine, int anchorColumn, int leadLine, int leadColumn, SelectionMode mode = SelectionMode.Normal) : this(new DocumentLocation(anchorLine, anchorColumn), new DocumentLocation(leadLine, leadColumn), mode) { }
public static ObjectIdCollection GetSelection(Database database, LayoutHelperDevice layoutHelperDevice, Point location, SelectionMode selectionMode) { ObjectIdCollection objectIdCollection = new ObjectIdCollection(); if (database != null && layoutHelperDevice != null) { int buffer = 5; using (Selector selector = new Selector(objectIdCollection, database.CurrentSpaceId)) { using (Point2dCollection point2DCollection = new Point2dCollection(new Point2d[] { new Point2d(location.X - buffer, location.Y - buffer), new Point2d(location.X + buffer, location.Y + buffer) })) { using (View pView = layoutHelperDevice.ActiveView) { pView.Select(point2DCollection, selector, selectionMode); } } } } return(objectIdCollection); }
/// <summary> /// Handle mouse down. /// Start moving, resizing or group selection. /// </summary> public override void OnMouseDown(DrawingCanvas drawingCanvas, MouseButtonEventArgs e) { commandChangeState = null; wasMove = false; Point point = e.GetPosition(drawingCanvas); selectMode = SelectionMode.None; GraphicsBase o; GraphicsBase movedObject = null; int handleNumber; // Test for resizing (only if control is selected, cursor is on the handle) for (int i = drawingCanvas.GraphicsList.Count - 1; i >= 0; i--) { o = drawingCanvas[i]; if (o.IsSelected) { handleNumber = o.MakeHitTest(point); if (handleNumber > 0) { selectMode = SelectionMode.Size; // keep resized object in class member resizedObject = o; resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects HelperFunctions.UnselectAll(drawingCanvas); o.IsSelected = true; commandChangeState = new CommandChangeState(drawingCanvas); break; } } } // Test for move (cursor is on the object) if (selectMode == SelectionMode.None) { for (int i = drawingCanvas.GraphicsList.Count - 1; i >= 0; i--) { o = drawingCanvas[i]; if (o.MakeHitTest(point) == 0) { movedObject = o; break; } } if (movedObject != null) { selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if (Keyboard.Modifiers != ModifierKeys.Control && !movedObject.IsSelected) { HelperFunctions.UnselectAll(drawingCanvas); } // Select clicked object movedObject.IsSelected = true; // Set move cursor drawingCanvas.Cursor = Cursors.SizeAll; commandChangeState = new CommandChangeState(drawingCanvas); } } // Click on background if (selectMode == SelectionMode.None) { // Unselect all if Ctrl is not pressed if (Keyboard.Modifiers != ModifierKeys.Control) { HelperFunctions.UnselectAll(drawingCanvas); } // Group selection. Create selection rectangle. GraphicsSelectionRectangle r = new GraphicsSelectionRectangle( point.X, point.Y, point.X + 1, point.Y + 1, drawingCanvas.ActualScale); r.Clip = new RectangleGeometry(new Rect(0, 0, drawingCanvas.ActualWidth, drawingCanvas.ActualHeight)); drawingCanvas.GraphicsList.Add(r); selectMode = SelectionMode.GroupSelection; } lastPoint = point; // Capture mouse until MouseUp event is received drawingCanvas.CaptureMouse(); }
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_DragEnter(object sender, DragEventArgs e) //{ // try { // e.Effects = GetEffect(e); // textArea.Caret.Show(); // } catch (Exception ex) { // OnDragException(ex); // } //} //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_DragOver(object sender, DragEventArgs e) //{ // try { // e.Effects = GetEffect(e); // } catch (Exception ex) { // OnDragException(ex); // } //} //DragDropEffects GetEffect(DragEventArgs e) //{ // if (e.Data.GetDataPresent(DataFormats.UnicodeText, true)) { // e.Handled = true; // int visualColumn; // bool isAtEndOfLine; // int offset = GetOffsetFromMousePosition(e.GetPosition(textArea.TextView), out visualColumn, out isAtEndOfLine); // if (offset >= 0) { // textArea.Caret.Position = new TextViewPosition(textArea.Document.GetLocation(offset), visualColumn) { IsAtEndOfLine = isAtEndOfLine }; // textArea.Caret.DesiredXPos = double.NaN; // if (textArea.ReadOnlySectionProvider.CanInsert(offset)) { // if ((e.AllowedEffects & DragDropEffects.Move) == DragDropEffects.Move // && (e.KeyStates & DragDropKeyStates.ControlKey) != DragDropKeyStates.ControlKey) // { // return DragDropEffects.Move; // } else { // return e.AllowedEffects & DragDropEffects.Copy; // } // } // } // } // return DragDropEffects.None; //} //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_DragLeave(object sender, DragEventArgs e) //{ // try { // e.Handled = true; // if (!textArea.IsKeyboardFocusWithin) // textArea.Caret.Hide(); // } catch (Exception ex) { // OnDragException(ex); // } //} //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_Drop(object sender, DragEventArgs e) //{ // try { // DragDropEffects effect = GetEffect(e); // e.Effects = effect; // if (effect != DragDropEffects.None) { // int start = textArea.Caret.Offset; // if (mode == SelectionMode.Drag && textArea.Selection.Contains(start)) { // Debug.WriteLine("Drop: did not drop: drop target is inside selection"); // e.Effects = DragDropEffects.None; // } else { // Debug.WriteLine("Drop: insert at " + start); // var pastingEventArgs = new DataObjectPastingEventArgs(e.Data, true, DataFormats.UnicodeText); // textArea.RaiseEvent(pastingEventArgs); // if (pastingEventArgs.CommandCancelled) // return; // string text = EditingCommandHandler.GetTextToPaste(pastingEventArgs, textArea); // if (text == null) // return; // bool rectangular = pastingEventArgs.DataObject.GetDataPresent(RectangleSelection.RectangularSelectionDataType); // // Mark the undo group with the currentDragDescriptor, if the drag // // is originating from the same control. This allows combining // // the undo groups when text is moved. // textArea.Document.UndoStack.StartUndoGroup(this.currentDragDescriptor); // try { // if (rectangular && RectangleSelection.PerformRectangularPaste(textArea, textArea.Caret.Position, text, true)) { // } else { // textArea.Document.Insert(start, text); // textArea.Selection = Selection.Create(textArea, start, start + text.Length); // } // } finally { // textArea.Document.UndoStack.EndUndoGroup(); // } // } // e.Handled = true; // } // } catch (Exception ex) { // OnDragException(ex); // } //} //void OnDragException(Exception ex) //{ // // swallows exceptions during drag'n'drop or reports them incorrectly, so // // we re-throw them later to allow the application's unhandled exception handler // // to catch them // textArea.Dispatcher.BeginInvoke( // DispatcherPriority.Send, // new Action(delegate { // throw new DragDropException("Exception during drag'n'drop", ex); // })); //} //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_GiveFeedback(object sender, GiveFeedbackEventArgs e) //{ // try { // e.UseDefaultCursors = true; // e.Handled = true; // } catch (Exception ex) { // OnDragException(ex); // } //} //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] //void textArea_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) //{ // try { // if (e.EscapePressed) { // e.Action = DragAction.Cancel; // } else if ((e.KeyStates & DragDropKeyStates.LeftMouseButton) != DragDropKeyStates.LeftMouseButton) { // e.Action = DragAction.Drop; // } else { // e.Action = DragAction.Continue; // } // e.Handled = true; // } catch (Exception ex) { // OnDragException(ex); // } //} #endregion #region Start Drag //object currentDragDescriptor; //void StartDrag() //{ // // prevent nested StartDrag calls // mode = SelectionMode.Drag; // // mouse capture and Drag'n'Drop doesn't mix // textArea.ReleaseMouseCapture(); // DataObject dataObject = textArea.Selection.CreateDataObject(textArea); // DragDropEffects allowedEffects = DragDropEffects.All; // var deleteOnMove = textArea.Selection.Segments.Select(s => new AnchorSegment(textArea.Document, s)).ToList(); // foreach (ISegment s in deleteOnMove) { // ISegment[] result = textArea.GetDeletableSegments(s); // if (result.Length != 1 || result[0].Offset != s.Offset || result[0].EndOffset != s.EndOffset) { // allowedEffects &= ~DragDropEffects.Move; // } // } // var copyingEventArgs = new DataObjectCopyingEventArgs(dataObject, true); // textArea.RaiseEvent(copyingEventArgs); // if (copyingEventArgs.CommandCancelled) // return; // object dragDescriptor = new object(); // this.currentDragDescriptor = dragDescriptor; // DragDropEffects resultEffect; // using (textArea.AllowCaretOutsideSelection()) { // var oldCaretPosition = textArea.Caret.Position; // try { // Debug.WriteLine("DoDragDrop with allowedEffects=" + allowedEffects); // resultEffect = DragDrop.DoDragDrop(textArea, dataObject, allowedEffects); // Debug.WriteLine("DoDragDrop done, resultEffect=" + resultEffect); // } catch (COMException ex) { // // ignore COM errors - don't crash on badly implemented drop targets // Debug.WriteLine("DoDragDrop failed: " + ex.ToString()); // return; // } // if (resultEffect == DragDropEffects.None) { // // reset caret if drag was aborted // textArea.Caret.Position = oldCaretPosition; // } // } // this.currentDragDescriptor = null; // if (deleteOnMove != null && resultEffect == DragDropEffects.Move && (allowedEffects & DragDropEffects.Move) == DragDropEffects.Move) { // bool draggedInsideSingleDocument = (dragDescriptor == textArea.Document.UndoStack.LastGroupDescriptor); // if (draggedInsideSingleDocument) // textArea.Document.UndoStack.StartContinuedUndoGroup(null); // textArea.Document.BeginUpdate(); // try { // foreach (ISegment s in deleteOnMove) { // textArea.Document.Remove(s.Offset, s.Length); // } // } finally { // textArea.Document.EndUpdate(); // if (draggedInsideSingleDocument) // textArea.Document.UndoStack.EndUndoGroup(); // } // } //} #endregion #region QueryCursor // provide the IBeam Cursor for the text area //void textArea_QueryCursor(object sender, QueryCursorEventArgs e) //{ // if (!e.Handled) { // if (mode != SelectionMode.None) { // // during selection, use IBeam cursor even outside the text area // e.Cursor = Cursors.IBeam; // e.Handled = true; // } else if (textArea.TextView.VisualLinesValid) { // // Only query the cursor if the visual lines are valid. // // If they are invalid, the cursor will get re-queried when the visual lines // // get refreshed. // Point p = e.GetPosition(textArea.TextView); // if (p.X >= 0 && p.Y >= 0 && p.X <= textArea.TextView.ActualWidth && p.Y <= textArea.TextView.ActualHeight) { // int visualColumn; // bool isAtEndOfLine; // int offset = GetOffsetFromMousePosition(e, out visualColumn, out isAtEndOfLine); // if (enableTextDragDrop && textArea.Selection.Contains(offset)) // e.Cursor = Cursors.Arrow; // else // e.Cursor = Cursors.IBeam; // e.Handled = true; // } // } // } //} #endregion #region LeftButtonDown private void TextArea_MouseLeftButtonDown(object sender, PointerPressedEventArgs e) { if (e.GetCurrentPoint(TextArea).Properties.IsLeftButtonPressed == false) { if (TextArea.RightClickMovesCaret == true && e.Handled == false) { SetCaretOffsetToMousePosition(e); } } else { TextArea.Cursor = Cursor.Parse("IBeam"); var pointer = e.GetCurrentPoint(TextArea); _mode = SelectionMode.None; if (!e.Handled) { var modifiers = e.KeyModifiers; var shift = modifiers.HasFlag(KeyModifiers.Shift); if (_enableTextDragDrop && e.ClickCount == 1 && !shift) { var offset = GetOffsetFromMousePosition(e, out _, out _); if (TextArea.Selection.Contains(offset)) { if (TextArea.CapturePointer(e.Pointer)) { _mode = SelectionMode.PossibleDragStart; _possibleDragStartMousePos = e.GetPosition(TextArea); } e.Handled = true; return; } } var oldPosition = TextArea.Caret.Position; SetCaretOffsetToMousePosition(e); if (!shift) { TextArea.ClearSelection(); } if (TextArea.CapturePointer(e.Pointer)) { if (modifiers.HasFlag(KeyModifiers.Alt) && TextArea.Options.EnableRectangularSelection) { _mode = SelectionMode.Rectangular; if (shift && TextArea.Selection is RectangleSelection) { TextArea.Selection = TextArea.Selection.StartSelectionOrSetEndpoint(oldPosition, TextArea.Caret.Position); } } else if (modifiers.HasFlag(KeyModifiers.Control) && e.ClickCount == 1) // e.ClickCount == 1 { _mode = SelectionMode.WholeWord; if (shift && !(TextArea.Selection is RectangleSelection)) { TextArea.Selection = TextArea.Selection.StartSelectionOrSetEndpoint(oldPosition, TextArea.Caret.Position); } } else if (pointer.Properties.IsLeftButtonPressed && e.ClickCount == 1) // e.ClickCount == 1 { _mode = SelectionMode.Normal; if (shift && !(TextArea.Selection is RectangleSelection)) { TextArea.Selection = TextArea.Selection.StartSelectionOrSetEndpoint(oldPosition, TextArea.Caret.Position); } } else { SimpleSegment startWord; _mode = SelectionMode.WholeWord; startWord = GetWordAtMousePosition(e); if (e.ClickCount == 3) { _mode = SelectionMode.WholeLine; startWord = GetLineAtMousePosition(e); } else { _mode = SelectionMode.WholeWord; startWord = GetWordAtMousePosition(e); } if (startWord == SimpleSegment.Invalid) { _mode = SelectionMode.None; TextArea.ReleasePointerCapture(e.Pointer); return; } if (shift && !TextArea.Selection.IsEmpty) { if (startWord.Offset < TextArea.Selection.SurroundingSegment.Offset) { TextArea.Selection = TextArea.Selection.SetEndpoint(new TextViewPosition(TextArea.Document.GetLocation(startWord.Offset))); } else if (startWord.EndOffset > TextArea.Selection.SurroundingSegment.EndOffset) { TextArea.Selection = TextArea.Selection.SetEndpoint(new TextViewPosition(TextArea.Document.GetLocation(startWord.EndOffset))); } _startWord = new AnchorSegment(TextArea.Document, TextArea.Selection.SurroundingSegment); } else { TextArea.Selection = Selection.Create(TextArea, startWord.Offset, startWord.EndOffset); _startWord = new AnchorSegment(TextArea.Document, startWord.Offset, startWord.Length); } } } e.Handled = true; } } }
/// <summary> /// This is overriden in sub-classes. /// </summary> /// <param name="tolerant">The geographic envelope in cases like cliking near points where tolerance is allowed.</param> /// <param name="strict">The geographic region when working with absolutes, without a tolerance.</param> /// <param name="mode">The selection mode.</param> /// <param name="affectedArea">The affected area.</param> /// <param name="clear">Indicates whether prior selected features should be cleared.</param> /// <returns>False.</returns> public virtual bool Select(Envelope tolerant, Envelope strict, SelectionMode mode, out Envelope affectedArea, ClearStates clear) { affectedArea = null; return(false); }
public void SetSelectionMode(SelectionMode mode) { switch (mode) { case SelectionMode.Single: ListView.SelectionMode = SWC.SelectionMode.Single; break; case SelectionMode.Multiple: ListView.SelectionMode = SWC.SelectionMode.Extended; break; } }
public void Detach() { mode = SelectionMode.None; textArea.MouseLeftButtonDown -= textArea_MouseLeftButtonDown; textArea.MouseMove -= textArea_MouseMove; textArea.MouseLeftButtonUp -= textArea_MouseLeftButtonUp; textArea.QueryCursor -= textArea_QueryCursor; textArea.OptionChanged -= textArea_OptionChanged; if (enableTextDragDrop) { DetachDragDrop(); } }
/// <summary> /// Left mouse button is pressed /// </summary> /// <param name="drawArea"> </param> /// <param name="e"> </param> public override void OnMouseDown(TransparentCanvas drawArea, MouseEventArgs e) { _commandChangeState = null; _wasMove = false; _selectMode = SelectionMode.None; Point point = new Point(e.X, e.Y); // Test for resizing (only if control is selected, cursor is on the handle) foreach (DrawObject o in drawArea.GraphicsList.Selection) { int handleNumber = o.HitTest(point); if (handleNumber > 0) { _selectMode = SelectionMode.Size; // keep resized object in class member _resizedObject = o; _resizedObjectHandle = handleNumber; // Since we want to resize only one object, unselect all other objects drawArea.GraphicsList.UnselectAll(); o.Selected = true; _commandChangeState = new CommandChangeState(drawArea.GraphicsList); break; } } // Test for move (cursor is on the object) if (_selectMode == SelectionMode.None) { int n1 = drawArea.GraphicsList.Count; DrawObject o = null; for (int i = 0; i < n1; i++) { if (drawArea.GraphicsList[i].HitTest(point) == 0) { o = drawArea.GraphicsList[i]; break; } } if (o != null) { _selectMode = SelectionMode.Move; // Unselect all if Ctrl is not pressed and clicked object is not selected yet if ((Control.ModifierKeys & Keys.Control) == 0 && !o.Selected) { drawArea.GraphicsList.UnselectAll(); } // Select clicked object o.Selected = true; _commandChangeState = new CommandChangeState(drawArea.GraphicsList); drawArea.Cursor = Cursors.SizeAll; } } // Net selection if (_selectMode == SelectionMode.None) { // click on background if ((Control.ModifierKeys & Keys.Control) == 0) { drawArea.GraphicsList.UnselectAll(); } _selectMode = SelectionMode.NetSelection; } _lastPoint.X = e.X; _lastPoint.Y = e.Y; _startPoint.X = e.X; _startPoint.Y = e.Y; drawArea.Capture = true; drawArea.Refresh(); if (_selectMode == SelectionMode.NetSelection) { // Draw selection rectangle in initial position ControlPaint.DrawReversibleFrame( drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(_startPoint, _lastPoint)), Color.Black, FrameStyle.Dashed); } }
void textArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { mode = SelectionMode.None; if (!e.Handled && e.ChangedButton == MouseButton.Left) { ModifierKeys modifiers = Keyboard.Modifiers; bool shift = (modifiers & ModifierKeys.Shift) == ModifierKeys.Shift; if (enableTextDragDrop && e.ClickCount == 1 && !shift) { int visualColumn; bool isAtEndOfLine; int offset = GetOffsetFromMousePosition(e, out visualColumn, out isAtEndOfLine); if (textArea.Selection.Contains(offset)) { if (textArea.CaptureMouse()) { mode = SelectionMode.PossibleDragStart; possibleDragStartMousePos = e.GetPosition(textArea); } e.Handled = true; return; } } var oldPosition = textArea.Caret.Position; SetCaretOffsetToMousePosition(e); if (!shift) { textArea.ClearSelection(); } if (textArea.CaptureMouse()) { if ((modifiers & ModifierKeys.Alt) == ModifierKeys.Alt && textArea.Options.EnableRectangularSelection) { mode = SelectionMode.Rectangular; if (shift && textArea.Selection is RectangleSelection) { textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position); } } else if (e.ClickCount == 1 && ((modifiers & ModifierKeys.Control) == 0)) { mode = SelectionMode.Normal; if (shift && !(textArea.Selection is RectangleSelection)) { textArea.Selection = textArea.Selection.StartSelectionOrSetEndpoint(oldPosition, textArea.Caret.Position); } } else { SimpleSegment startWord; if (e.ClickCount == 3) { mode = SelectionMode.WholeLine; startWord = GetLineAtMousePosition(e); } else { mode = SelectionMode.WholeWord; startWord = GetWordAtMousePosition(e); } if (startWord == SimpleSegment.Invalid) { mode = SelectionMode.None; textArea.ReleaseMouseCapture(); return; } if (shift && !textArea.Selection.IsEmpty) { if (startWord.Offset < textArea.Selection.SurroundingSegment.Offset) { textArea.Selection = textArea.Selection.SetEndpoint(new TextViewPosition(textArea.Document.GetLocation(startWord.Offset))); } else if (startWord.EndOffset > textArea.Selection.SurroundingSegment.EndOffset) { textArea.Selection = textArea.Selection.SetEndpoint(new TextViewPosition(textArea.Document.GetLocation(startWord.EndOffset))); } this.startWord = new AnchorSegment(textArea.Document, textArea.Selection.SurroundingSegment); } else { textArea.Selection = Selection.Create(textArea, startWord.Offset, startWord.EndOffset); this.startWord = new AnchorSegment(textArea.Document, startWord.Offset, startWord.Length); } } } } e.Handled = true; }
public void SetSelectionMode(SelectionMode mode) { switch (mode) { case SelectionMode.Single: Widget.Selection.Mode = Gtk.SelectionMode.Single; break; case SelectionMode.Multiple: Widget.Selection.Mode = Gtk.SelectionMode.Multiple; break; } }
/// <summary> /// When implemented by a class, defines the <see cref="T:System.Web.UI.Control" /> object that child controls and templates belong to. These child controls are in turn defined within an inline template. /// </summary> /// <param name="container">The <see cref="T:System.Web.UI.Control" /> object to contain the instances of controls from the inline template.</param> public void InstantiateIn( Control container ) { var cell = container as DataControlFieldCell; if (cell != null) { var selectField = cell.ContainingField as SelectField; if ( selectField != null ) { SelectionMode = selectField.SelectionMode; DataVisibleField = selectField.DataVisibleField; DataSelectedField = selectField.DataSelectedField; DataTextField = selectField.DataTextField; ColumnIndex = selectField.ColumnIndex; CheckBox cb = null; if ( SelectionMode == SelectionMode.Multiple ) { cb = new CheckBox(); } else { cb = new RockRadioButton(); } cb.ID = "cbSelect_" + ColumnIndex.ToString(); cb.DataBinding += cb_DataBinding; cell.Controls.Add( cb ); } } }
private void OnSelectionModeChanged(SelectionMode newValue) { // Show/Hide the multiple selection mode summary text block or the items presenter depending on which selection mode chosen if (newValue == SelectionMode.Multiple || newValue == SelectionMode.Extended) { if (_multipleSelectionModeSummary != null && _itemsPresenterHostPart != null) { _multipleSelectionModeSummary.Visibility = Visibility.Visible; _itemsPresenterHostPart.Visibility = Visibility.Collapsed; } } else { if (_multipleSelectionModeSummary != null && _itemsPresenterHostPart != null) { _multipleSelectionModeSummary.Visibility = Visibility.Collapsed; _itemsPresenterHostPart.Visibility = Visibility.Visible; } } }
/// <summary> /// This is overriden in sub-classes. /// </summary> /// <param name="tolerant">The geographic envelope in cases like cliking near points where tolerance is allowed.</param> /// <param name="strict">The geographic region when working with absolutes, without a tolerance.</param> /// <param name="mode">The selection mode.</param> /// <param name="affectedArea">The affected area.</param> /// <returns>False.</returns> public virtual bool UnSelect(Envelope tolerant, Envelope strict, SelectionMode mode, out Envelope affectedArea) { affectedArea = null; return(false); }
private void RdoHalf_CheckedChanged(object sender, EventArgs e) { TxtGName1.Enabled = BtnRename1.Enabled = TxtGName3.Enabled = BtnRename3.Enabled = CmbGraphics1.Enabled = CmbGraphics3.Enabled = true; TxtGName2.Enabled = BtnRename2.Enabled = TxtGName4.Enabled = BtnRename4.Enabled = CmbGraphics2.Enabled = CmbGraphics4.Enabled = false; SelectionMode = SelectionMode.Half; }
void StartDrag() { // prevent nested StartDrag calls mode = SelectionMode.Drag; // mouse capture and Drag'n'Drop doesn't mix textArea.ReleaseMouseCapture(); DataObject dataObject = textArea.Selection.CreateDataObject(textArea); DragDropEffects allowedEffects = DragDropEffects.All; var deleteOnMove = textArea.Selection.Segments.Select(s => new AnchorSegment(textArea.Document, s)).ToList(); foreach (ISegment s in deleteOnMove) { ISegment[] result = textArea.GetDeletableSegments(s); if (result.Length != 1 || result[0].Offset != s.Offset || result[0].EndOffset != s.EndOffset) { allowedEffects &= ~DragDropEffects.Move; } } var copyingEventArgs = new DataObjectCopyingEventArgs(dataObject, true); textArea.RaiseEvent(copyingEventArgs); if (copyingEventArgs.CommandCancelled) return; object dragDescriptor = new object(); this.currentDragDescriptor = dragDescriptor; DragDropEffects resultEffect; using (textArea.AllowCaretOutsideSelection()) { var oldCaretPosition = textArea.Caret.Position; try { Debug.WriteLine("DoDragDrop with allowedEffects=" + allowedEffects); resultEffect = DragDrop.DoDragDrop(textArea, dataObject, allowedEffects); Debug.WriteLine("DoDragDrop done, resultEffect=" + resultEffect); } catch (COMException ex) { // ignore COM errors - don't crash on badly implemented drop targets Debug.WriteLine("DoDragDrop failed: " + ex.ToString()); return; } if (resultEffect == DragDropEffects.None) { // reset caret if drag was aborted textArea.Caret.Position = oldCaretPosition; } } this.currentDragDescriptor = null; if (deleteOnMove != null && resultEffect == DragDropEffects.Move && (allowedEffects & DragDropEffects.Move) == DragDropEffects.Move) { bool draggedInsideSingleDocument = (dragDescriptor == textArea.Document.UndoStack.LastGroupDescriptor); if (draggedInsideSingleDocument) textArea.Document.UndoStack.StartContinuedUndoGroup(null); textArea.Document.BeginUpdate(); try { foreach (ISegment s in deleteOnMove) { textArea.Document.Remove(s.Offset, s.Length); } } finally { textArea.Document.EndUpdate(); if (draggedInsideSingleDocument) textArea.Document.UndoStack.EndUndoGroup(); } } }
public static T[] GetFiltered <T>(SelectionMode mode) // no generic constraint because we also want to allow interfaces { return(GetFilteredInternal(typeof(T), mode).Cast <T>().ToArray()); }
void textArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (mode == SelectionMode.None || e.Handled) return; e.Handled = true; if (mode == SelectionMode.PossibleDragStart) { // -> this was not a drag start (mouse didn't move after mousedown) SetCaretOffsetToMousePosition(e); textArea.ClearSelection(); } else if (mode == SelectionMode.Normal || mode == SelectionMode.WholeWord || mode == SelectionMode.WholeLine || mode == SelectionMode.Rectangular) { ExtendSelectionToMouse(e); } mode = SelectionMode.None; textArea.ReleaseMouseCapture(); }
public static Object[] GetFiltered(System.Type type, SelectionMode mode) { return(GetFilteredInternal(type, mode).Cast <Object>().ToArray()); }
/// <summary> /// Highlights the values in the specified region, and returns the affected area from the selection, /// which should allow for slightly faster drawing in cases where only a small area is changed. /// This will also specify the method by which members should be selected. /// </summary> /// <param name="tolerant"> /// The envelope to change. /// </param> /// <param name="strict"> /// The envelope to use in cases like polygons where the geometry has no tolerance. /// </param> /// <param name="selectionMode"> /// The selection mode that clarifies the rules to use for selection. /// </param> /// <param name="affectedArea"> /// The geographic envelope of the region impacted by the selection. /// </param> /// <returns> /// Boolean, true if items were selected. /// </returns> public override bool Select(IEnvelope tolerant, IEnvelope strict, SelectionMode selectionMode, out IEnvelope affectedArea) { if (!_drawnStatesNeeded && !_editMode) { AssignFastDrawnStates(); } IEnvelope region = tolerant; if (DataSet.FeatureType == FeatureType.Polygon) { region = strict; } affectedArea = _selection.Envelope; bool changed = false; if (IsWithinLegendSelection() || _scheme.IsWithinLegendSelection()) { _selection.SelectionMode = selectionMode; changed = _selection.AddRegion(region, out affectedArea); } else { if (!_drawnStatesNeeded) { AssignFastDrawnStates(); } SuspendChangeEvent(); _selection.ProgressHandler = ProgressHandler; _selection.SuspendChanges(); List<IFeatureCategory> categories = _scheme.GetCategories().ToList(); foreach (IFeatureCategory category in categories) { if (!category.IsSelected) { continue; } _selection.RegionCategory = category; _selection.AddRegion(region, out affectedArea); _selection.RegionCategory = null; } _selection.ResumeChanges(); ResumeChangeEvent(); } return changed; }
void StartDrag() { // prevent nested StartDrag calls mode = SelectionMode.Drag; // mouse capture and Drag'n'Drop doesn't mix textArea.ReleaseMouseCapture(); DataObject dataObject = textArea.Selection.CreateDataObject(textArea); DragDropEffects allowedEffects = DragDropEffects.All; var deleteOnMove = textArea.Selection.Segments.Select(s => new AnchorSegment(textArea.Document, s)).ToList(); foreach (ISegment s in deleteOnMove) { ISegment[] result = textArea.GetDeletableSegments(s); if (result.Length != 1 || result[0].Offset != s.Offset || result[0].EndOffset != s.EndOffset) { allowedEffects &= ~DragDropEffects.Move; } } var copyingEventArgs = new DataObjectCopyingEventArgs(dataObject, true); textArea.RaiseEvent(copyingEventArgs); if (copyingEventArgs.CommandCancelled) { return; } object dragDescriptor = new object(); this.currentDragDescriptor = dragDescriptor; DragDropEffects resultEffect; using (textArea.AllowCaretOutsideSelection()) { var oldCaretPosition = textArea.Caret.Position; try { Debug.WriteLine("DoDragDrop with allowedEffects=" + allowedEffects); resultEffect = DragDrop.DoDragDrop(textArea, dataObject, allowedEffects); Debug.WriteLine("DoDragDrop done, resultEffect=" + resultEffect); } catch (COMException ex) { // ignore COM errors - don't crash on badly implemented drop targets Debug.WriteLine("DoDragDrop failed: " + ex.ToString()); return; } if (resultEffect == DragDropEffects.None) { // reset caret if drag was aborted textArea.Caret.Position = oldCaretPosition; } } this.currentDragDescriptor = null; if (deleteOnMove != null && resultEffect == DragDropEffects.Move && (allowedEffects & DragDropEffects.Move) == DragDropEffects.Move) { bool draggedInsideSingleDocument = (dragDescriptor == textArea.Document.UndoStack.LastGroupDescriptor); if (draggedInsideSingleDocument) { textArea.Document.UndoStack.StartContinuedUndoGroup(null); } textArea.Document.BeginUpdate(); try { foreach (ISegment s in deleteOnMove) { textArea.Document.Remove(s.Offset, s.Length); } } finally { textArea.Document.EndUpdate(); if (draggedInsideSingleDocument) { textArea.Document.UndoStack.EndUndoGroup(); } } } }
/// <summary> /// This is overriden in sub-classes /// </summary> /// <param name="tolerant">The geographic envelope in cases like cliking near points where tolerance is allowed</param> /// <param name="strict">The geographic region when working with absolutes, without a tolerance</param> /// <param name="mode"></param> /// <param name="affectedArea"></param> /// <returns></returns> public virtual bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionMode mode, out IEnvelope affectedArea) { affectedArea = null; return false; }