/// <summary> /// Delete label definitions. /// </summary> /// <param name="query">Delete query</param> /// <param name="token">Optional cancellation token</param> /// <returns></returns> public async Task DeleteAsync(LabelDelete query, CancellationToken token = default) { if (query is null) { throw new ArgumentNullException(nameof(query)); } var req = Labels.delete(query); await RunAsync(req, token).ConfigureAwait(false); }
/// <summary> /// Delete label definitions. /// </summary> /// <param name="ids">External ids to delete</param> /// <param name="token">Optional cancellation token</param> /// <returns></returns> public async Task DeleteAsync(IEnumerable <CogniteExternalId> ids, CancellationToken token = default) { if (ids is null) { throw new ArgumentNullException(nameof(ids)); } var req = new LabelDelete { Items = ids }; await DeleteAsync(req, token).ConfigureAwait(false); }
/// <summary> Draws the component [have to be invoked in OnGUI].</summary> /// <param name="rect">X position for the timeline.</param> /// <param name="scrollDelta">Scroll delta.</param> /// <returns>Real component size.</returns> public Rect GUIDraw(float xPos, float scrollDelta) { base.Draw(_rect, _rectWasChanged); if (_rect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.ContextClick) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Add"), false, HandleLabelAdd, null); if (CopyDataAvailable) { menu.AddItem(new GUIContent("Paste"), false, HandleLabelPaste, null); } else { menu.AddItem(new GUIContent("Paste"), false, null, null); } menu.ShowAsContext(); } if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { _wasMouseDown = true; } if (Event.current.type == EventType.MouseDrag) { foreach (Label label in _labels) { if (label.OnDrag) { _wasMouseDown = false; break; } } } if (_wasMouseDown && (Event.current.type == EventType.MouseDrag || Event.current.type == EventType.MouseUp)) { _timeLineEngine.SetTime(WorldXToTime(Event.current.mousePosition.x)); } if (Event.current.type == EventType.MouseUp) { _wasMouseDown = false; } } if (_strokeTexture == null || _durationWasChanged || _rectWasChanged || _lastXPos != xPos || scrollDelta != 0 || _zoomChanged) { RecalcScale(_rect.width); _zoomChanged = false; int textureWidth = (int)_rect.width; int textureHeight = (int)_rect.height; if (_rectWasChanged) { _timelineBackgroundColor = new Color[textureHeight * textureWidth]; _timelineBackgroundColor.Fill(new Color(1, 1, 1, 0)); } _strokeTexture = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false); _strokeTexture.SetPixels(_timelineBackgroundColor); _strokeTextureOryginal = new Texture2D(textureWidth, textureHeight, TextureFormat.ARGB32, false); _smallStroke = (int)GUI.skin.label.CalcSize(new GUIContent("text")).y + 5; _bigStroke = _smallStroke + 10; _lastXPos = xPos; _rectWasChanged = false; _durationWasChanged = false; _GUILabelDatas.Clear(); float significantStepDuration = Mathf.Ceil((_timeLabelSize.x * 1.5f) / _timeLineEngine.PixelsPerSecond) * _timeLineEngine.PixelsPerSecond; float significantStrokeBuffor = (_timeLabelSize.x * 1.5f); Color[] strokeLong = new Color[_bigStroke * 2]; strokeLong.Fill(Color.black); float offset = significantStepDuration - ((xPos / significantStepDuration) - (int)(xPos / significantStepDuration)) * significantStepDuration; int divider = Mathf.CeilToInt((_timeLabelSize.x * 1.5f) / _timeLineEngine.PixelsPerSecond) - 1; if (divider < 2) { divider = 2; } int minorStrokeCount = divider - ((divider - 1) / 5) * 5; // do not simplify! Int type is not by accident! if (minorStrokeCount < 2) { minorStrokeCount = 2; } float step = (_timeLineEngine.PixelsPerSecond * (divider - 1)) / (minorStrokeCount - 1); for (float x = offset - significantStepDuration; x + _labelStrokesWidth * 2 < _rect.width; x += step) { if (significantStrokeBuffor >= (_timeLabelSize.x * 1.5f)) { if (x >= 0) { _strokeTexture.SetPixels((int)x, Mathf.RoundToInt(_controlRect.height - _bigStroke), _labelStrokesWidth * 2, _bigStroke, strokeLong); } TimeSpan strokeTime = new TimeSpan(0, 0, Mathf.RoundToInt((x + xPos) / _timeLineEngine.PixelsPerSecond)); float labelX = TimeToWorldX(strokeTime) - _timeLabelSize.x / 2; if (strokeTime == TimeSpan.Zero) { labelX = TimeToWorldX(strokeTime); } _GUILabelDatas.Add(new GUITimeLabelData(labelX, _controlRect.y + _smallStroke, _timeLabelSize, strokeTime.ToStringSpecial())); significantStrokeBuffor = step; } else { if (x >= 0) { _strokeTexture.SetPixels((int)x, Mathf.RoundToInt(_controlRect.height - _smallStroke), _labelStrokesWidth, _smallStroke, strokeLong); } significantStrokeBuffor += step; } } _GUILabelDatas.Add(new GUITimeLabelData(TimeToWorldX(_timeLineEngine.Duration) - _timeLabelSize.x, _controlRect.y + _smallStroke, _timeLabelSize, _timeLineEngine.Duration.ToStringSpecial())); if (_GUILabelDatas.Count >= 2 && _GUILabelDatas[_GUILabelDatas.Count - 2].Rect.x + _GUILabelDatas[_GUILabelDatas.Count - 2].Rect.width > _GUILabelDatas[_GUILabelDatas.Count - 1].Rect.x) { _GUILabelDatas.RemoveAt(_GUILabelDatas.Count - 2); } _strokeTextureStyle.normal.background = _strokeTexture; foreach (Label label in _labels) { label.Refresh(); } _strokeTexture.Apply(); _strokeTextureOryginal.SetPixels(_strokeTexture.GetPixels()); } bool redrawRequest = false; // checking if any label need redraw for (int i = _labels.Count - 1; i >= 0; i--) { if (_labels[i].DrawRequest || _labels[i].SourceData.RemoveRequest) { // reset to oryginal if (!redrawRequest) { _strokeTexture.SetPixels(_strokeTextureOryginal.GetPixels()); } redrawRequest = true; // removing requested label if (_labels[i].SourceData.RemoveRequest) { TimeLabelData data = _labels[i].SourceData as TimeLabelData; _labels.RemoveAt(i); if (LabelDelete != null) { LabelDelete.Invoke(data); } } } } if (redrawRequest) { foreach (Label label in _labels) { label.Draw(_strokeTextureOryginal, _strokeTexture); } _strokeTexture.Apply(); } GUI.Box(_rect, GUIContent.none, _strokeTextureStyle); foreach (Label label in _labels) { label.DrawGUI(); } foreach (GUITimeLabelData label in _GUILabelDatas) { label.Draw(_controlRect.y + _bigStroke); } return(_controlRect); }
public Label Delete(LabelDelete label) { return(_api.Delete().With(label).To <Label>(string.Format(ProjectLabelUrl, label.Id))); }