private async void Btn_Start_Click(object sender, EventArgs e) { if (Running || !UpdateFlowInfo()) { return; } Running = true; manualExit = false; List <Task> tasks = new List <Task>(); foreach (var item in Flow.Instance.MainFlows) { tasks.Add(Task.Run(() => { Result re; ToolBase tool = item.UserObject as ToolBase; do { re = tool.RunAll(); Thread.Sleep(10); } while (re.ErrorCode != (int)ErrorCode.fatalError && !manualExit); manualExit = true; })); } foreach (var item in tasks) { await item; } Running = false; }
/// <summary> /// 添加用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public async Task <ResponseModel> UserAdd(AddUser user) { var isusername = await Db.Queryable <sys_user>().AnyAsync(c => c.username == user.username); if (isusername) { return(new ResponseModel { code = 0, result = "已存在该用户~" }); } user.password = ToolBase.EncryptByMd5(user.password); var query = await Db.Insertable(user).ExecuteCommandAsync(); if (query >= 1) { return(new ResponseModel { code = 200, result = "添加成功~" }); } else { return(new ResponseModel { code = 0, result = "添加失败~" }); } }
protected virtual void onToolCurrentChanged(ToolBase tool) { if (toolCurrentChanged != null) { toolCurrentChanged(tool); } }
public static void OnToolChanged(ref ToolBase tool) { if (TouchThisTool.instance?.enabled == true && tool != TouchThisTool.instance && (TTTPanel.Instance?.MainPanel?.isVisible ?? false)) { TouchThisToolMod.Instance?.UnselectTab(); } }
public void Update() { var currentTool = ToolsModifierControl.GetCurrentTool<ToolBase>(); if (currentTool != _previousTool) { ToolBaseDetour.ResetForceMode(); } _previousTool = currentTool; if (currentTool is ResourceTool || currentTool is TreeTool) { ForceModeMethod.Invoke(currentTool, new object[] {InfoManager.InfoMode.NaturalResources, InfoManager.SubInfoMode.Default}); } else if (currentTool is DistrictTool) { ForceModeMethod.Invoke(currentTool, new object[] { InfoManager.InfoMode.Districts, InfoManager.SubInfoMode.Default }); } else if (currentTool is TransportTool) { Singleton<TransportManager>.instance.LinesVisible = true; Singleton<TransportManager>.instance.TunnelsVisible = true; } else { var nextInfoMode = Singleton<InfoManager>.instance.NextMode; Singleton<TransportManager>.instance.LinesVisible = (nextInfoMode == InfoManager.InfoMode.Transport); Singleton<TransportManager>.instance.TunnelsVisible = (nextInfoMode == InfoManager.InfoMode.Transport || nextInfoMode == InfoManager.InfoMode.Traffic); } }
/// <summary> /// We need to react to changes in current tool. /// If current tool is NOT <see cref="NetTool"/> then we must disable everything, while still remembering if the tool was enabled or not (so that we can restore this state once the tool becomes <see cref="NetTool"/> again). /// </summary> /// <param name="component"></param> /// <param name="value"></param> private void ToolBaseDetour_OnToolChanged(UIComponent component, ToolBase value) { if (value is NetTool) { // If we're in NetTool, we must restore our previous state + make the button visible _mainWindow.ToggleToolButton(true); _isToolActive = true; if (_isToolEnabled) { // This means we also need to restore detours and show our main window again ToggleDetours(true); _mainWindow.isVisible = true; } } else { // We're not anymore in NetTool, so we must hide all of our UI and disable detours _mainWindow.ToggleToolButton(false); _mainWindow.isVisible = false; _isToolActive = false; ToggleDetours(false); } Log._Debug($"[{nameof(ParallelRoadTool)}.{nameof(ToolBaseDetour_OnToolChanged)}] Changed tool to {value.GetType().Name} [{nameof(_isToolActive)}: {_isToolActive}, {nameof(_isToolEnabled)}: {_isToolEnabled}]"); }
void IUIElement.UpdateState(CommandStatus newStatus) { ToolBase tool = this.manager.Tools[this.key]; tool.SharedProps.Enabled = newStatus == CommandStatus.Enabled; tool.SharedProps.Visible = newStatus != CommandStatus.Unavailable; }
public void SetToolMode(TrafficManagerMode mode) { if (mode == ToolMode) { return; } //UI.toolMode = mode; ToolMode = mode; if (mode != TrafficManagerMode.None) { if (ToolsModifierControl.toolController.CurrentTool != TrafficLightTool) { _originalTool = ToolsModifierControl.toolController.CurrentTool; } DestroyTool(); EnableTool(); } else { ToolsModifierControl.toolController.CurrentTool = _originalTool; DestroyTool(); } }
public void TurnOn(ToolTypes tool) { TurnOffAll(); foreach (var tgo in tools) { if (tgo == null) { continue; } var toolBase = tgo.GetComponentInChildren <ToolBase>(true); if (toolBase == null) { continue; } if (toolBase.tool == tool) { toolBase.mystery = GameMgr.CurrentIsMystery(); activeTool = toolBase; tgo.SetActive(true); if (ToolText.instance != null) { ToolText.instance.Log(tgo.name); } if (GuideText.instance != null) { GuideText.instance.ResetForTool(tgo); } break; } } }
public static void AddToolStripElements(WorkItem workItem, IEnumerable <UICommandDefinition> menuEntryEnumerable, UICommandPlacement toolStripMode, Control host) { foreach (UICommandDefinition definition in menuEntryEnumerable) { if ((toolStripMode != UICommandPlacement.VerticalToolPanel) && !definition.IsCategory) { ToolBase toolStripItem = GetToolStripItem(toolStripMode, definition); toolStripItem.Tag = definition; toolStripItem.Key = definition.ContextName + definition.Name; if ((definition.Parent != null) && definition.Parent.IsCategory) { toolStripItem = workItem.UIExtensionSites[definition.Parent.Site].Add <ToolBase>(toolStripItem); } else { toolStripItem = workItem.UIExtensionSites[definition.Site].Add <ToolBase>(toolStripItem); } if (definition.IsFolder || definition.IsCategory) { if (toolStripItem is PopupMenuTool) { workItem.UIExtensionSites.RegisterSite(definition.Site + "." + definition.Name, ((PopupMenuTool)toolStripItem).Tools); } else { workItem.UIExtensionSites.RegisterSite(definition.Site + "." + definition.Name, toolStripItem); } } if (!definition.IsFolder && !definition.IsCategory) { ((workItem is LocalCommandWorkItem) ? AddShortcutCommand((LocalCommandWorkItem)workItem, host, definition) : AddCommand(workItem, host, definition)).AddInvoker(toolStripItem, "ToolClick"); } } } }
public override void OnFinishedAction(GameObject pObjectActioning = null) { var toolController = pObjectActioning.GetComponent <ToolController>(); ToolName pCurrentTool = toolController.GetCurrentToolName(); if (pCurrentTool == ToolName.NoTool && TableObject != null) // if player empty handed and table has tool { ToolBase pToolOnTable = TableObject.GetComponent <ToolBase>(); pToolOnTable.gameObject.GetComponent <Pickupable>().IsActionActive = true; toolController.SetTool(TableObject); ChangeObjectLayer(TableObject.transform, "Default"); TableObject = null; ActionFinishedSoundEvent = PickUpSound; PlayFinishedActionSFX(); } else if (pCurrentTool != ToolName.NoTool && TableObject == null) // if player holding tool & table empty { ToolBase pTool = toolController.GetToolBase(); TableObject = pTool.gameObject; pTool.gameObject.GetComponent <Pickupable>().IsActionActive = false; toolController.RemoveTool(); PlaceTool(); ActionFinishedSoundEvent = DropSound; PlayFinishedActionSFX(); } }
/// <summary> /// Restores a ToolbarManager using the provided byte-array. /// Prior to applying the settings the (shared) properties 'Caption' and 'ToolTip' /// of each element in the Tools-Collection /// saved and restored after applying the settings from the byte-array. /// This avoids that strings from a different login-language are restored. /// No Exceptions are catched by this method. /// </summary> /// <param name="toolbarManager">UltraToolbarsManager</param> /// <param name="stream">Stream</param> /// <param name="mediator">The mediator.</param> public static void LoadToolbarManager(UltraToolbarsManager toolbarManager, Stream stream, CommandMediator mediator) { //First remember original (current language) strings Hashtable oCaptions = new Hashtable(); for (int i = 0; i < toolbarManager.Tools.Count; i++) { ToolBase oTool = toolbarManager.Tools[i]; LocalizedProperties props = new LocalizedProperties(oTool); oCaptions.Add(oTool.Key, props); } //Now load the settings try { toolbarManager.LoadFromBinary(stream); } catch (Exception ex) { Trace.WriteLine("toolbarManager.LoadFrom...() failed: " + ex.Message); return; // use it as it was initialized on the original form } //The stream already has the captions stored, so overwrite them //with the current ones (could be different language) for (int i = 0; i < toolbarManager.Tools.Count; i++) { ToolBase oTool = toolbarManager.Tools[i]; if (oCaptions.Contains(oTool.Key)) { LocalizedProperties props = (LocalizedProperties)oCaptions[oTool.Key]; props.Apply(oTool); } mediator.ReRegisterCommand(oTool as ICommand); } }
public override void SimulationStep() { ToolBase.RaycastInput input = new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength); input.m_ignoreSegmentFlags = NetSegment.Flags.None; input.m_ignoreNodeFlags = NetNode.Flags.None; ulong[] collidingSegments; ulong[] collidingBuildings; this.m_toolController.BeginColliding(out collidingSegments, out collidingBuildings); try { ToolBase.RaycastOutput output; if (this.m_mouseRayValid && ToolBase.RayCast(input, out output)) { float terrainHeight = TerrainManager.instance.SampleDetailHeight(output.m_hitPos); output.m_hitPos.y = output.m_hitPos.y > terrainHeight ? output.m_hitPos.y : terrainHeight; Randomizer r = this.m_randomizer; ushort id = Singleton <PropManager> .instance.m_props.NextFreeItem(ref r); this.m_mousePosition = output.m_hitPos; this.m_placementErrors = ToolErrors.None; } else { this.m_placementErrors = ToolBase.ToolErrors.RaycastFailed; } } finally { this.m_toolController.EndColliding(); } }
private void SetParentVisibility(ToolBase item) { ToolbarsCollection.ToolbarEnumerator enumerator = item.ToolbarsManager.Toolbars.GetEnumerator(); while (enumerator.MoveNext()) { foreach (ToolBase base2 in enumerator.Current.Tools) { if (!(base2 is PopupMenuTool)) { continue; } bool flag = false; ToolEnumerator enumerator3 = ((PopupMenuTool)base2).Tools.GetEnumerator(); while (enumerator3.MoveNext()) { if (enumerator3.Current.SharedProps.Visible) { flag = true; goto Label_008D; } } Label_008D: if (!base2.IsRootTool) { base2.SharedProps.Visible = flag; } } } }
public async Task <ResponseModel> Repwd(UpdatePwd updatepwd, HttpContext context) { var id = context.Session.Get <sys_user>("yr_user").id; var user = await Db.Queryable <sys_user>().Where(c => c.id == id).SingleAsync(); if (user.password == ToolBase.EncryptByMd5(updatepwd.oldpwd)) { var query = await Db.Updateable <sys_user>().Where(c => c.id == id).UpdateColumns(c => new sys_user { password = ToolBase.EncryptByMd5(updatepwd.newpwd) }).ExecuteCommandAsync(); if (query >= 1) { return(new ResponseModel { code = 200, result = "修改成功~" }); } else { return(new ResponseModel { code = 0, result = "修改失败~" }); } } else { return(new ResponseModel { code = 0, result = "旧密码有误~" }); } }
/// <summary> /// Unity late update handling. /// Called by game every late update. /// </summary> protected override void OnToolLateUpdate() { base.OnToolLateUpdate(); // Force the info mode to none. ToolBase.ForceInfoMode(InfoManager.InfoMode.None, InfoManager.SubInfoMode.None); }
public override void SimulationStep() { ToolBase.RaycastInput input = new ToolBase.RaycastInput(this.m_mouseRay, this.m_mouseRayLength); ToolBase.RaycastOutput raycastOutput; if (this.m_undoRequest && !this.m_strokeInProgress) { this.ApplyUndo(); this.m_undoRequest = false; } else if (this.m_strokeEnded) { this.EndStroke(); this.m_strokeEnded = false; this.m_strokeInProgress = false; updateCash(); } else if (this.m_mouseRayValid && ToolBase.RayCast(input, out raycastOutput)) { this.m_mousePosition = raycastOutput.m_hitPos; if (this.m_mouseLeftDown != this.m_mouseRightDown) { this.m_strokeInProgress = true; this.ApplyBrush(); } } }
//private void tvwSqlObjects_MouseDown(object sender, MouseEventArgs e) //{ // // http://blog.lib.umn.edu/kuyp0005/think2/2007/05/c_dragdrop_and_doubleclick.html // if (e.Button == MouseButtons.Left && e.Clicks == 1) // { // var tn = _view.tvwPeople.GetNodeFromPoint(new Point(e.X, e.Y)) as TableNode; // if (tn != null) // { // var dbn = tn.Parent.Parent as DatabaseNode; // var sn = dbn.Parent.Parent as ServerNode; // var dt = new DraggableTable(sn.ServerObject, dbn.DatabaseObject, tn.TableObject); // _view.tvwPeople.DoDragDrop(dt, DragDropEffects.Copy | DragDropEffects.All); // } // } //} //private void tvwSqlObjects_DragOver(object sender, DragEventArgs e) //{ // var node = e.Data.GetData(typeof(DraggableTable)) as DraggableTable; // if (node != null) // { // Point clientPos = _view.tvwPeople.PointToClient(new Point(e.X, e.Y)); // UltraTreeNode nodeAtPoint = _view.tvwPeople.GetNodeFromPoint(clientPos); // if (nodeAtPoint is TablesNode) // { // e.Effect = DragDropEffects.Copy; // } // else // { // e.Effect = DragDropEffects.None; // } // } //} //private void tvwSqlObjects_DragDrop(object sender, DragEventArgs e) //{ // if (e.Data != null) // { // var node = e.Data.GetData(typeof(DraggableTable)) as DraggableTable; // if (node != null) // { // Point clientPos = _view.tvwPeople.PointToClient(new Point(e.X, e.Y)); // UltraTreeNode nodeAtPoint = _view.tvwPeople.GetNodeFromPoint(clientPos); // if (nodeAtPoint is TablesNode) // { // // todo implement // MessageBox.Show("Copy Table - Not Implemented!", DialogHelper.Instance.GetApplicationName()); // } // } // } //} private void tbManager_QuickAccessToolbarModified(object sender, QuickAccessToolbarModifiedEventArgs e) { if (e.QuickAccessToolbarChangeType == QuickAccessToolbarChangeType.ToolAdded) { ToolBase tb = _view.tbManager.Ribbon.QuickAccessToolbar.Tools[e.Tool.Key]; tb.Tag = e.Tool.Tag; } }
protected override void OnEnable() { prevTool = m_toolController.CurrentTool; m_toolController.CurrentTool = this; frames = 0; trackId = -1; builderLog = new StringBuilder(); }
private Vector3 RaycastMouseLocation(Ray mouseRay) { ToolBase.RayCast(new ToolBase.RaycastInput(mouseRay, Camera.main.farClipPlane) { m_ignoreTerrain = false }, out RaycastOutput raycastOutput); return(raycastOutput.m_hitPos); }
public ToolVisibilityChangedMessage(ToolBase tool) { if (tool == null) { throw new ArgumentNullException("tool"); } Sender = tool; }
public override void SimulationStep() { while (!Monitor.TryEnter(this.m_dataLock, SimulationManager.SYNCHRONIZE_TIMEOUT)) { } Ray mouseRay; Vector3 cameraDirection; bool mouseRayValid; try { mouseRay = this.m_mouseRay; cameraDirection = this.m_cameraDirection; mouseRayValid = this.m_mouseRayValid; } finally { Monitor.Exit(this.m_dataLock); } ToolBase.RaycastInput input = new ToolBase.RaycastInput(mouseRay, m_mouseRayLength); ToolBase.RaycastOutput raycastOutput; if (mouseRayValid && ToolBase.RayCast(input, out raycastOutput)) { if (!m_active) { while (!Monitor.TryEnter(this.m_dataLock, SimulationManager.SYNCHRONIZE_TIMEOUT)) { } try { this.m_mouseDirection = cameraDirection; this.m_mousePosition = raycastOutput.m_hitPos; } finally { Monitor.Exit(this.m_dataLock); } } else { while (!Monitor.TryEnter(this.m_dataLock, SimulationManager.SYNCHRONIZE_TIMEOUT)) { } try { if (checkMaxArea(raycastOutput.m_hitPos)) { this.m_mousePosition = raycastOutput.m_hitPos; } } finally { Monitor.Exit(this.m_dataLock); } } } }
public virtual void CreateNode() { ToolBase tool = new ToolBase(); tool.graphNode = GraphNode; GraphNode.UserObject = tool; InitShape(new GoDrawing(GoFigure.Ellipse), color2, color2, 28, 12, 28, 12); UpdatePorts("io", "io", "io", "io"); }
protected override void OnDisable() { if (m_toolController.NextTool == null && prevTool != null && prevTool != this) { prevTool.enabled = true; } prevTool = null; File.WriteAllText(@"D:\Downloads\builder.txt", builderLog.ToString()); }
//public void LoadKnownServers() //{ // var sh = new SettingsIO(); // IList<ServerConnectionSettings> knownServers = sh.LoadKnownServers(); // removeKnownServers(); // for (int i = 0; i < knownServers.Count; i++) // { // ServerConnectionSettings settings = knownServers[i]; // AddKnownServer(settings, false); // } //} public void RemoveKnownServer(ToolBase tb) { if (tb.Tag is ServerConnectionSettings) { var settings = (Sql8rProjectFile)tb.Tag; _knownServers.Remove(settings); } _view.tbManager.Tools.Remove(tb); }
/// <summary> /// Detour for ToolManager.EndRenderingImpl /// </summary> private void EndRenderingImpl(RenderManager.CameraInfo cameraInfo) { ToolController properties = Singleton <ToolManager> .instance.m_properties; if (properties != null) { PrefabInfo editPrefabInfo = properties.m_editPrefabInfo; if (editPrefabInfo != null) { VehicleInfo vehicleInfo = editPrefabInfo as VehicleInfo; if (vehicleInfo != null) { // Modified implementation RenderInfo(cameraInfo, vehicleInfo, new Vector3(0f, 60f, 0f), false); if (vehicleInfo.m_trailers != null) { // Bug(?) fix: main info's m_attachOffsetBack did not get applied float num = vehicleInfo.m_generatedInfo.m_size.z * 0.5f - vehicleInfo.m_attachOffsetBack; for (int i = 0; i < vehicleInfo.m_trailers.Length; i++) { VehicleInfo info = vehicleInfo.m_trailers[i].m_info; // New: Support correct display of inverted trailers bool isInverted = (vehicleInfo.m_trailers[i].m_invertProbability >= 100); float frontDelta = info.m_generatedInfo.m_size.z * 0.5f - info.m_attachOffsetFront; float backDelta = info.m_generatedInfo.m_size.z * 0.5f - info.m_attachOffsetBack; num += isInverted ? backDelta : frontDelta; Vector3 position = new Vector3(0f, 60f, 0f) + new Vector3(0f, 0f, -num); RenderInfo(cameraInfo, info, position, isInverted); // Change for inverted vehicles num += isInverted ? frontDelta : backDelta; } } } else { //Default editPrefabInfo.RenderMesh(cameraInfo); } } try { ToolBase currentTool = properties.CurrentTool; if (currentTool != null) { currentTool.RenderGeometry(cameraInfo); } } catch (Exception ex) { UIView.ForwardException(ex); CODebugBase <LogChannel> .Error(LogChannel.Core, "Tool error: " + ex.Message + "\n" + ex.StackTrace); } } }
private void RememberCurrentTool() { _previousTool = CurrentTool; var im = InfoManager.instance; _previousInfoMode = im.NextMode; _previousSubInfoMode = im.NextSubMode; DebugLog.Info($"Remembering {_previousTool?.GetType().Name} and {im.NextMode},{im.NextSubMode}"); }
public static void SetToolResult(string toolName, string dat) { ToolBase tool = ToolsFactory.GetTool(toolName); if (tool != null) { tool.Result = dat; } }
public static void MarkTool(string toolName, bool flag) { ToolBase tool = ToolsFactory.GetTool(toolName); if (tool != null) { tool.MarkTool(flag); } }
//双击开启参数设定单元 private void treeViewAllTools_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == MouseButtons.Right) { return; } if (isRunning) { Common.Util.Notify(Common.Basic.Level.Err, "运行中禁止操作"); return; } if (treeViewAllTools.ContextMenuStrip == null) { Common.Util.Notify(Common.Basic.Level.Err, "非管理员用户禁止操作"); return; } TreeNode selectNode = e.Node; if (selectNode == null || selectNode.Parent == null) { //MessageBox.Show("请先选择工具节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } TreeNode nodeParent = selectNode.Parent; //TreeNode nodeTool = selectNode; int settingKey = int.Parse(nodeParent.Name); int index = int.Parse(selectNode.Name); ToolBase tool = ToolsFactory.GetToolList(settingKey)[index]; if (tool != null) { tool.ClearTestData(); ToolsSettingUnit settingUnit = tool.GetSettingUnit() as ToolsSettingUnit; if (settingUnit != null) { frmToolSetting toolSetting = new frmToolSetting(settingUnit); toolSetting.StartPosition = FormStartPosition.CenterScreen; toolSetting.MaximizeBox = false; toolSetting.ShowDialog(); selectNode.Text = string.Format("{0} {1}", tool.Name, tool.Note); } } //if(tool is CreateImage.CreateImageTool) //{ // InitTreeView(); //} InitTreeView(); if (ToolGroupsChangeEvent != null) { tgce.ToolGroupsNum = settingKey; ToolGroupsChangeEvent(this, tgce); } }
public static string GetToolResult(string toolName) { ToolBase tool = ToolsFactory.GetTool(toolName); if (tool != null) { return(tool.Result); } return(""); }
private NetToolProxy(ToolBase target) { _target = target; var t = target.GetType(); _controlPointCountField = GetPrivateField(t, "m_controlPointCount"); _controlPointsField = GetPrivateField(t, "m_controlPoints"); _toolControllerField = GetPrivateField(t, "m_toolController"); _netInfoField = GetPublicField(t, "m_prefab"); _snapField = GetPublicField(t, "m_snap"); _modeField = GetPublicField(t, "m_mode"); }
public UltraToolbar AddToolBar(string key, ToolBase[] toolsBase, int dockColumn) { // Se non esiste aggiungo la toolbar dei bottoni if (!_toolbarsManager.Toolbars.Exists(key)) { _toolbarsManager.Toolbars.AddToolbar(key); _toolbarsManager.Toolbars[key].DockedRow = 1; _toolbarsManager.Toolbars[key].DockedColumn = dockColumn; } // Se non esiste aggiungo lo strumento alla toolbar dei bottoni for (int i = 0; i < toolsBase.Length; i++) { if (!_toolbarsManager.Toolbars[key].Tools.Exists(toolsBase[i].Key)) _toolbarsManager.Toolbars[key].Tools.AddTool(toolsBase[i].Key); } return _toolbarsManager.Toolbars[key]; }
public void Awake() { _previousTool = null; }
// Expose protected method public new static bool RayCast(ToolBase.RaycastInput input, out ToolBase.RaycastOutput output) { return NetTool.RayCast(input, out output); }
private void clearStateButton(ToolBase currentTool) { ultraToolbarsManager1.ToolClick -=ultraToolbarsManager1ToolClick; foreach (var tool in ultraToolbarsManager1.Tools) { if (currentTool.Key != tool.Key && tool is StateButtonTool) ((StateButtonTool)tool).Checked = false; } ultraToolbarsManager1.ToolClick += ultraToolbarsManager1ToolClick; }
private static bool RayCast(ToolBase.RaycastInput raycastInput, out ToolBase.RaycastOutput output) { object[] p = new object[]{raycastInput, null}; bool res = (bool)typeof(ToolBase).GetMethod("RayCast", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, p); output = (ToolBase.RaycastOutput) p[1]; return res; }
void HandleMouseDrag(ref ToolBase.RaycastOutput raycastOutput, ref ToolError error, bool test, ref NetInfo newRoadPrefab, ref int newSegmentIndex) { Vector3 hitPosDelta = Vector3.zero; if (!test) { if (currentTime - prevRebuildTime < 0.1f) return; if (dragging) { hitPosDelta = raycastOutput.m_hitPos - prevHitPos; if (hitPosDelta.magnitude < 12.0f) return; } else { prevHitPos = raycastOutput.m_hitPos; dragging = true; if (toolMode == ToolMode.Oneway) return; } prevHitPos = raycastOutput.m_hitPos; } int segmentIndex = raycastOutput.m_netSegment; if (segmentIndex != 0) { NetManager net = Singleton<NetManager>.instance; NetInfo prefab = net.m_segments.m_buffer[segmentIndex].Info; bool isOneway = !prefab.m_hasForwardVehicleLanes || !prefab.m_hasBackwardVehicleLanes; string prefabName = null; if (!roadPrefabNames.TryGetValue(prefab.GetInstanceID(), out prefabName) || prefabName == null) { ModDebug.Error("Prefab name not found"); error = ToolError.Unknown; return; } string newPrefabName = null; if (toolMode == ToolMode.Oneway) { if (!isOneway) newPrefabName = FindMatchingName(prefabName, twowayNames, onewayNames); else newPrefabName = prefabName; } else { if (isOneway) { newPrefabName = FindMatchingName(prefabName, onewayNames, twowayNames); } else { toolError = ToolError.AlreadyTwoway; return; } } if (newPrefabName != null) { if (test) { toolError = ToolError.None; return; } NetInfo newPrefab; if (!roadPrefabs.TryGetValue(newPrefabName, out newPrefab) || newPrefab == null) { ModDebug.Error("Prefab not found: " + newPrefabName); error = ToolError.Unknown; return; } newRoadPrefab = newPrefab; int newIndex = RebuildSegment(segmentIndex, newPrefab, toolMode == ToolMode.Oneway, raycastOutput.m_hitPos, hitPosDelta, ref error); if (newIndex != 0) { if (error != ToolError.None) return; prevBuiltSegmentIndex = newSegmentIndex; prevRebuildTime = currentTime; newSegmentIndex = newIndex; } } else { toolError = ToolError.CannotUpgradeThisType; return; } } }
public static bool SupportsSingle(ToolBase tool) { foreach (var plugin in plugins) { if (plugin.SupportsSingle(tool)) { return true; } } return false; }
public static NetToolProxy Create(ToolBase target) { NetToolProxy p; try { p = new NetToolProxy(target); return p; } catch (Exception e) { Debug.LogError(string.Format("Error acquiring NetToolProxy from object {0}", target)); Debug.LogError(e.ToString()); } return null; }
public void Destroy() { _previousTool = null; }
public void CallEventForToolButton(UltraToolbarsManager objToolMgr, ToolBase objTool, string strEventName) { Logger.logBegin("CallEventForToolButton"); if (objToolMgr == null) return; var objE = objToolMgr.GetType().GetEvent(strEventName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); Type objDlgt = objE.EventHandlerType; BindingFlags b = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static; MethodInfo objMethodMgr = objToolMgr.GetType().GetMethod(strEventName, b); MethodInfo objMethodBar = objTool.GetType().GetMethod(strEventName, b); Delegate objDMgr = Delegate.CreateDelegate(objDlgt, objMethodMgr); Delegate objDBar = Delegate.CreateDelegate(objDlgt, objMethodBar); var objED = (MulticastDelegate)objToolMgr.GetType().GetField(strEventName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(objToolMgr); if (objED != null) { foreach (var handler in objED.GetInvocationList()) { handler.Method.Invoke(handler.Target, new object[] { objToolMgr, new ToolClickEventArgs(objTool, null) }); } } Logger.logEnd("CallEventForToolButton"); }
private void setErrors(ToolBase.ToolErrors value) { m_errors.SetValue(this, value); }
public UltraToolbar AddToolBar(string key, ToolBase[] toolsBase) { return AddToolBar(key, toolsBase, 1); }
public ToolBase AddTool(ToolBase tool, int index, string parentTool, bool addSeparator) { string key = tool.Key; if (parentTool == string.Empty) { tool.SharedProps.Category = "Generale"; if (addSeparator) tool.InstanceProps.IsFirstInGroup = true; if (!_toolbarsManager.Tools.Exists(key)) _toolbarsManager.Tools.Add(tool); if (index == int.MinValue) _toolbarsManager.Toolbars[_toolbarName].Tools.AddTool(key); else _toolbarsManager.Toolbars[_toolbarName].Tools.InsertTool(index, key); _toolbarsManager.Toolbars[_toolbarName].Tools[key].InstanceProps.IsFirstInGroup = addSeparator; } else { tool.SharedProps.Category = "Generale"; if (!_toolbarsManager.Tools.Exists(key)) _toolbarsManager.Tools.Add(tool); if (!((Infragistics.Win.UltraWinToolbars.PopupMenuTool)_toolbarsManager.Tools[parentTool]).Tools.Exists(key)) ((Infragistics.Win.UltraWinToolbars.PopupMenuTool)_toolbarsManager.Tools[parentTool]).Tools.Add(tool); ((Infragistics.Win.UltraWinToolbars.PopupMenuTool)_toolbarsManager.Tools[parentTool]).Tools[key].InstanceProps.IsFirstInGroup = addSeparator; } return tool; }