public VectorLayerList() { _updateHeight = false; _currentToolId = string.Empty; ModuleStreetSmart modulestreetSmart = ModuleStreetSmart.Current; _measurementList = modulestreetSmart.MeasurementList; _cycloMediaGroupLayer = modulestreetSmart.CycloMediaGroupLayer; EditTool = EditTools.NoEditTool; }
private async Task <List <Measurement> > ReloadSelectionAsync() { List <Measurement> result = new List <Measurement>(); bool thisMeasurement = false; if (Layer.SelectionCount >= 1) { await QueuedTask.Run(async() => { Selection selectionFeatures = Layer?.GetSelection(); using (RowCursor rowCursur = selectionFeatures?.Search()) { while (rowCursur?.MoveNext() ?? false) { Row row = rowCursur.Current; Feature feature = row as Feature; Geometry geometry = feature?.GetShape(); long objectId = feature?.GetObjectID() ?? -1; if ((geometry != null) && (objectId != -1)) { Measurement measurement = _measurementList.Get(objectId) ?? (await _measurementList.GetAsync(geometry)); thisMeasurement = true; _measurementList.DrawPoint = false; EditTools editTool = _vectorLayerList.EditTool; if ((editTool != EditTools.SketchLineTool) && (editTool != EditTools.SketchPointTool) && (editTool != EditTools.SketchPolygonTool)) { measurement = _measurementList.StartMeasurement(geometry, measurement, false, objectId, this); } _measurementList.DrawPoint = true; if (measurement != null) { await measurement.UpdateMeasurementPointsAsync(geometry); measurement.CloseMeasurement(); result.Add(measurement); } } } } }); } if (thisMeasurement && (_vectorLayerList.EditTool == EditTools.SketchPointTool)) { _vectorLayerList.SketchFinished(); await _vectorLayerList.StartSketchToolAsync(); } return(result); }
protected async void OnActiveToolChangedEvent(ToolEventArgs args) { if (_currentToolId != args.CurrentID) { _currentToolId = args.CurrentID; switch (_currentToolId) { case "esri_editing_ModifyFeatureImpl": EditTool = EditTools.ModifyFeatureImpl; break; case "esri_editing_ReshapeFeature": EditTool = EditTools.ReshapeFeature; break; case "esri_editing_SketchLineTool": EditTool = EditTools.SketchLineTool; SketchFinished(); await StartSketchToolAsync(); break; case "esri_editing_SketchPolygonTool": EditTool = EditTools.SketchPolygonTool; SketchFinished(); await StartSketchToolAsync(); break; case "esri_editing_SketchPointTool": EditTool = EditTools.SketchPointTool; SketchFinished(); await StartSketchToolAsync(); break; default: EditTool = EditTools.NoEditTool; SketchFinished(); break; } if (EditTool == EditTools.NoEditTool) { FrameworkApplication.State.Deactivate("globeSpotterArcGISPro_measurementState"); } else { FrameworkApplication.State.Activate("globeSpotterArcGISPro_measurementState"); } } }
protected async void OnDrawStarted(MapViewEventArgs args) { MapView mapView = args.MapView; Geometry geometry = await mapView.GetCurrentSketchAsync(); if ((geometry?.HasZ ?? false) && (EditTool == EditTools.SketchPointTool)) { await AddHeightToMeasurementAsync(geometry, mapView); } if (geometry != null && EditTool == EditTools.ModifyFeatureImpl) { EditTool = EditTools.Verticles; Measurement measurement = _measurementList.Sketch; measurement?.OpenMeasurement(); } else if (geometry == null && EditTool == EditTools.Verticles) { EditTool = EditTools.ModifyFeatureImpl; } }
// Do the painting operations with the given Graphics item // Enable useClearImage if it's rendering over all the control, set to false if only for the final result void DoPaint(Graphics g, EditTools tool, object info, bool useClearImage = true) { if (info == null) { return; } bool dispose = true; Bitmap bmp = null; List <Point> pts; switch (tool) { case EditTools.Image: // All images will have the same size, so we always use the size of the BaseLayer g.DrawImage((Bitmap)info, TopLeftCorner()); break; case EditTools.Pen: PaintPoints(ref g, new Pen(Settings.GetValue <SerializableColor>("penColor"), ToolSize), (List <Point>)info); break; case EditTools.Marker: if (g.SmoothingMode == SmoothingMode.AntiAlias) // Do it right. This could (and SHOULD) be optimized { bmp = GetFinalResult(); var newbmp = new Bitmap(bmp.Width, bmp.Height); var gr = Graphics.FromImage(newbmp); PaintPoints(ref gr, new Pen(Settings.GetValue <SerializableColor>("markerColor"), ToolSize), (List <Point>)info); gr.Dispose(); newbmp.MergeMultiply(bmp); g.DrawImage(newbmp, 0, 0); } else // Do it quick { PaintPoints(ref g, new Pen(Color.FromArgb(100, Settings.GetValue <SerializableColor>("markerColor")), ToolSize), (List <Point>)info); } break; case EditTools.Eraser: dispose = false; bmp = useClearImage ? clearImage : BaseBmp; if (bmp == null) { break; } var tb = new TextureBrush(bmp); var pn = new Pen(tb, ToolSize); PaintPoints(ref g, new Pen(new TextureBrush(bmp), ToolSize), (List <Point>)info, true); break; case EditTools.Blur: pts = (List <Point>)info; if (pts.Count < 2) { break; } if (g.SmoothingMode == SmoothingMode.AntiAlias) // Do it right { CursorShown = true; OnOperation("Aplicando desenfoque..."); bmp = GetFinalResult(); g.DrawImage(bmp.Blur(GetRectangle(pts[0], pts[1]), (int)ToolSize), 0, 0); OnOperation(""); CursorShown = false; } else // Do it quick { g.DrawRectangle(Pens.Black, GetRectangle(pts[0], pts[1])); } break; case EditTools.Pixelate: pts = (List <Point>)info; if (pts.Count < 2) { break; } if (g.SmoothingMode == SmoothingMode.AntiAlias) // Do it right { CursorShown = true; OnOperation("Aplicando pixelado..."); bmp = GetFinalResult(); g.DrawImage(bmp.Pixelate(GetRectangle(pts[0], pts[1]), (int)ToolSize), 0, 0); OnOperation(""); CursorShown = false; } else // Do it quick { g.DrawRectangle(Pens.Black, GetRectangle(pts[0], pts[1])); } break; case EditTools.Text: pts = (List <Point>)info; if (pts.Count < 2) { break; } var rct = GetRectangle(pts[0], pts[1]); g.TextRenderingHint = TextRenderingHint.AntiAlias; if (g.SmoothingMode != SmoothingMode.AntiAlias) { g.DrawRectangle(Pens.Black, rct); } g.DrawString( SelectedTextFontFamily.Text, GetBestFontSize(ref g, rct), new SolidBrush(Settings.GetValue <SerializableColor>("penColor")), rct); break; } if (dispose && bmp != null) { bmp.Dispose(); } }
static private void ApplyPrefab(GameObject prefab, Object targetPrefab, bool replace) { if (EditorUtility.DisplayDialog("注意!", "是否进行递归查找批量替换模板?", "ok", "cancel")) { GameObject replacePrefab; //int count = 0; if (replace) { PrefabUtility.ReplacePrefab(prefab, targetPrefab, ReplacePrefabOptions.ConnectToPrefab); Refresh(); replacePrefab = targetPrefab as GameObject; //count = prefab.GetComponentsInChildren<UITemplate>().Length; } else { replacePrefab = AssetDatabase.LoadAssetAtPath(AssetDatabase.GetAssetPath(targetPrefab), typeof(GameObject)) as GameObject;; //GameObject checkPrefab = PrefabUtility.InstantiatePrefab(replacePrefab) as GameObject; //count = checkPrefab.GetComponentsInChildren<UITemplate>().Length; //DestroyImmediate(checkPrefab); } //if (count != 1) //{ // EditorUtility.DisplayDialog("注意!", "无法批量替换,因为模板不支持嵌套。", "ok"); // return; //} UITemplate template = replacePrefab.GetComponent <UITemplate>(); if (template != null) { List <GameObject> references; if (TrySearchPrefab(template.m_GUID, out references)) { GameObject checkPrefab = PrefabUtility.InstantiatePrefab(replacePrefab) as GameObject; for (int i = 0; i < references.Count; i++) { GameObject reference = references[i]; GameObject go = PrefabUtility.InstantiatePrefab(reference) as GameObject; UITemplate[] instanceTemplates = go.GetComponentsInChildren <UITemplate>(); for (int j = 0; j < instanceTemplates.Length; j++) { UITemplate instance = instanceTemplates[j]; if (instance.m_GUID == template.m_GUID) { EditTools.CopyComponents(template.gameObject, instance.gameObject); UITemplateChild[] instanceTemplatesChild = go.GetComponentsInChildren <UITemplateChild>(); UITemplateChild[] templateTemplatesChild = checkPrefab.gameObject.GetComponentsInChildren <UITemplateChild>(); for (int x = 0; x < templateTemplatesChild.Length; x++) { UITemplateChild templateChild = templateTemplatesChild[x]; for (int y = 0; y < instanceTemplatesChild.Length; y++) { UITemplateChild instanceChild = instanceTemplatesChild[y]; if (instanceChild.m_GUID == templateChild.m_GUID) { EditTools.CopyComponents(templateChild.gameObject, instanceChild.gameObject); } } } } PrefabUtility.ReplacePrefab(go, PrefabUtility.GetPrefabParent(go), ReplacePrefabOptions.ConnectToPrefab); } DestroyImmediate(go); } DestroyImmediate(checkPrefab); } } ClearHierarchy(); Refresh(); } }
/// <summary> /// Draw the custom wizard. /// </summary> void OnGUI() { Event currentEvent = Event.current; EventType type = currentEvent.type; int x = cellPadding, y = cellPadding; int width = Screen.width - cellPadding; int spacingX = cellSize + cellPadding; int spacingY = spacingX; if (mMode == Mode.DetailedMode) { spacingY += 32; } GameObject dragged = draggedObject; bool isDragging = (dragged != null); int indexUnderMouse = GetCellUnderMouse(spacingX, spacingY); Item selection = isDragging ? FindItem(dragged) : null; string searchFilter = NGUISettings.searchField; int newTab = mTab; GUILayout.BeginHorizontal(); if (GUILayout.Toggle(newTab == 0, "按钮", "ButtonLeft")) { newTab = 0; } if (GUILayout.Toggle(newTab == 1, "字体", "ButtonMid")) { newTab = 1; } if (GUILayout.Toggle(newTab == 2, "公共控件", "ButtonMid")) { newTab = 2; } if (GUILayout.Toggle(newTab == 3, "界面", "ButtonMid")) { newTab = 3; } if (GUILayout.Toggle(newTab == 4, "其他", "ButtonRight")) { newTab = 4; } GUILayout.EndHorizontal(); if (mTab == 1) { EditorGUILayout.LabelField("选中要修改的label,然后点击对应的字体可直接应用样式"); } if (mTab != newTab) { Save(); mTab = newTab; mReset = true; NGUISettings.SetInt("NGUI Prefab Tab", mTab); Load(); } if (mReset && type == EventType.Repaint) { mReset = false; foreach (Item item in mItems) { GeneratePreview(item, null); } RectivateLights(); } // Search field GUILayout.BeginHorizontal(); { string after = EditorGUILayout.TextField("", searchFilter, "SearchTextField", GUILayout.Width(Screen.width - 20f)); if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f))) { after = ""; GUIUtility.keyboardControl = 0; } if (searchFilter != after) { NGUISettings.searchField = after; searchFilter = after; } } GUILayout.EndHorizontal(); bool eligibleToDrag = (currentEvent.mousePosition.y < Screen.height - 40); if (type == EventType.MouseDown) { mMouseIsInside = true; } else if (type == EventType.MouseDrag) { mMouseIsInside = true; if (indexUnderMouse != -1 && eligibleToDrag) { // Drag operation begins if (draggedObjectIsOurs) { DragAndDrop.StartDrag("Prefab Tool"); } currentEvent.Use(); } } else if (type == EventType.MouseUp) { DragAndDrop.PrepareStartDrag(); mMouseIsInside = false; Repaint(); } else if (type == EventType.DragUpdated) { // Something dragged into the window mMouseIsInside = true; UpdateVisual(); currentEvent.Use(); } else if (type == EventType.DragPerform) { // We've dropped a new object into the window if (dragged != null) { if (selection != null) { DestroyTexture(selection); mItems.Remove(selection); } AddItem(dragged, indexUnderMouse); draggedObject = null; } mMouseIsInside = false; currentEvent.Use(); } else if (type == EventType.DragExited || type == EventType.Ignore) { mMouseIsInside = false; } // If the mouse is not inside the window, clear the selection and dragged object if (!mMouseIsInside) { selection = null; dragged = null; } // Create a list of indices, inserting an entry of '-1' underneath the dragged object BetterList <int> indices = new BetterList <int>(); for (int i = 0; i < mItems.size;) { if (dragged != null && indices.size == indexUnderMouse) { indices.Add(-1); } if (mItems[i] != selection) { if (string.IsNullOrEmpty(searchFilter) || mItems[i].prefab.name.IndexOf(searchFilter, System.StringComparison.CurrentCultureIgnoreCase) != -1) { indices.Add(i); } } ++i; } // There must always be '-1' (Add/Move slot) present if (!indices.Contains(-1)) { indices.Add(-1); } // We want to start dragging something from within the window if (eligibleToDrag && type == EventType.MouseDown && indexUnderMouse > -1) { GUIUtility.keyboardControl = 0; if (currentEvent.button == 0 && indexUnderMouse < indices.size) { int index = indices[indexUnderMouse]; if (index != -1 && index < mItems.size) { selection = mItems[index]; draggedObject = selection.prefab; dragged = selection.prefab; currentEvent.Use(); if (mTab == 1) { EditTools.CopyTemplateLabelValue(selection.prefab); } } } } //else if (type == EventType.MouseUp && currentEvent.button == 1 && indexUnderMouse > mItems.size) //{ // NGUIContextMenu.AddItem("Reset", false, RemoveItem, index); // NGUIContextMenu.Show(); //} // Draw the scroll view with prefabs mPos = GUILayout.BeginScrollView(mPos); { Color normal = new Color(1f, 1f, 1f, 0.5f); for (int i = 0; i < indices.size; ++i) { int index = indices[i]; Item ent = (index != -1) ? mItems[index] : selection; if (ent != null && ent.prefab == null) { mItems.RemoveAt(index); continue; } Rect rect = new Rect(x, y, cellSize, cellSize); Rect inner = rect; inner.xMin += 2f; inner.xMax -= 2f; inner.yMin += 2f; inner.yMax -= 2f; rect.yMax -= 1f; // Button seems to be mis-shaped. It's height is larger than its width by a single pixel. if (!isDragging && (mMode == Mode.CompactMode || (ent == null || ent.tex != null))) { mContent.tooltip = (ent != null) ? ent.prefab.name : "Click to add"; } else { mContent.tooltip = ""; } //if (ent == selection) { GUI.color = normal; NGUIEditorTools.DrawTiledTexture(inner, NGUIEditorTools.backdropTexture); } GUI.color = Color.white; GUI.backgroundColor = normal; if (GUI.Button(rect, mContent, "Button")) { if (ent == null || currentEvent.button == 0) { string path = EditorUtility.OpenFilePanel("Add a prefab", NGUISettings.currentPath, "prefab"); if (!string.IsNullOrEmpty(path)) { NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path); Item newEnt = CreateItemByPath(path); if (newEnt != null) { mItems.Add(newEnt); Save(); } } } else if (currentEvent.button == 1) { NGUIContextMenu.AddItem("Delete", false, RemoveItem, index); NGUIContextMenu.Show(); } } string caption = (ent == null) ? "" : ent.prefab.name.Replace("Control - ", ""); if (ent != null) { if (ent.tex != null) { GUI.DrawTexture(inner, ent.tex); } else if (mMode != Mode.DetailedMode) { GUI.Label(inner, caption, mStyle); caption = ""; } } else { GUI.Label(inner, "Add", mStyle); } if (mMode == Mode.DetailedMode) { GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f); GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), caption, "ProgressBarBack"); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; } x += spacingX; if (x + spacingX > width) { y += spacingY; x = cellPadding; } } GUILayout.Space(y); } GUILayout.EndScrollView(); // Mode Mode modeAfter = (Mode)EditorGUILayout.EnumPopup(mMode); if (modeAfter != mMode) { mMode = modeAfter; mReset = true; NGUISettings.SetEnum("NGUI Prefab Mode", mMode); } }
private void Menu_Click(object sender, RoutedEventArgs e) { if (sender is MenuItem menu) { switch (menu.Header) { // ---Under File case "New": CheckIfStringIsEmpty(); if (didYouSave == true) { MainTextBox.Clear(); } else { AskForSaving(menu); } break; case "Exit": CheckIfStringIsEmpty(); if (didYouSave == true) { Application.Current.Shutdown(); } else { AskForSaving(menu); } break; case "Print": print = new Print(MainTextBox); break; case "New Window": MainWindow mainExtra = new MainWindow(); mainExtra.Show(); break; case "Save": sal.SaveFile(); break; case "Save As": sal.SaveFileAs(); break; case "Open": sal.LoadFile(); break; // ---Under Edit case "Undo": ur = new UndoAndRedo(MainTextBox); ur.UndoMethod(); break; case "Redo": ur = new UndoAndRedo(MainTextBox); ur.RedoMethod(); break; case "Cut": editTools = new EditTools(MainTextBox); editTools.CutMethod(); break; case "Copy": editTools = new EditTools(MainTextBox); editTools.CopyMethod(); break; case "Paste": editTools = new EditTools(MainTextBox); editTools.PasteMethod(); break; case "Select all": editTools = new EditTools(MainTextBox); editTools.SelectAllMethod(); break; case "Search": Search search = new Search(MainTextBox); search.Show(); break; case "Search web": if (MainTextBox.SelectionLength > 0) { SearchWebb SWebb = new SearchWebb(MainTextBox); SWebb.SearchWebbMethod(); } else { return; } break; case "Set read only": if (menu.IsChecked == true) { MainTextBox.IsReadOnly = true; } else { MainTextBox.IsReadOnly = false; } break; } } }
private void Start() { AddListeners(); _currentTool = EditTools.Cursor; }