/// <summary> /// must be performed after distance is ready /// </summary> private void _CalcPercentage() { m_EffectVertIdxLst.Clear(); for (int i = 0; i < m_Cont.Length; ++i) { _Data data = m_Cont[i]; float dist = data.dist; if (dist > m_Range) { data.percentage = 0; } else { float t = dist / m_Range; float percentage = m_Atten.Evaluate(t); // the curve would be better a [1, 0] curve, decreasing data.percentage = percentage; m_EffectVertIdxLst.Add(i); //Dbg.Log("_CalcPercentage: i:{0}, p:{1}", i, percentage); } } //Dbg.Log("SoftSelection._CalcPercentage"); }
private Vector3[] m_CachedVertPos; //used in dragging handle, cache the starting position of verts #endregion "data" #region "public method" // public method public void Init(EditableMesh m, MeshSelection sel, Pivotor p) { m_Mesh = m; m_Selection = sel; m_Pivot = p; Dbg.Assert(m_Pivot != null, "SoftSelection.Init: pivotor is null"); m_Range = 1f; m_Cont = new _Data[m.mesh.vertexCount]; for (int i = 0; i < m_Cont.Length; ++i) { m_Cont[i] = new _Data(); } m_EffectVertIdxLst = new VLst(); m_Mode = Mode.Off; m_PrepareMode = PrepareMode.Always; // atten curve var res = (SoftSelectionRes)AssetDatabase.LoadAssetAtPath(SOFTSEL_ATTEN_CURVE_PATH, typeof(SoftSelectionRes)); if (res == null) { res = ScriptableObject.CreateInstance <SoftSelectionRes>(); AssetDatabase.CreateAsset(res, SOFTSEL_ATTEN_CURVE_PATH); res = (SoftSelectionRes)AssetDatabase.LoadAssetAtPath(SOFTSEL_ATTEN_CURVE_PATH, typeof(SoftSelectionRes)); Dbg.Assert(res != null, "SoftSelection.Init: failed to create curve asset for SoftSelection"); } m_Atten = res.attenCurve; MeshManipulator.evtHandleDraggingStateChanged += this._OnHandleDraggingStateChanged; }
//Duomenys šalinami iš masyvo ir pastumiami, jei nebėra duomenų public void Salinti(_Data reiksme) { lock (Ivarciai) { for (int i = 0; i < Ivarciai.Count(); i++) { if (Ivarciai[i] != null) { if (Ivarciai[i].getRikiavimoLaukas() == reiksme.getRikiavimoLaukas()) { if (Ivarciai[i].getKiekis() == 1) { for (int j = i; j < Ivarciai.Count(); j++) { if (j + 1 != Ivarciai.Count()) { Ivarciai[j] = Ivarciai[j + 1]; } else { Ivarciai[j] = null; } } } else { Ivarciai[i].Atimti(); //arYra = true; break; } } } } } }
//Šalinančiųjų gijų metodas public static void Skaitytojas(int[] nr) { _Data temp; bool pap; for (int i = 0; i < nr.Length; i++) { temp = new _Data(nr[i]); K[0].Salinti(temp); } Thread.Sleep(4); pap = K[0].Tuscias(); if (!pap) { for (int i = 0; i < nr.Length; i++) { temp = new _Data(nr[i]); K[0].Salinti(temp); } } }
public Script(string filename) { if (!File.Exists(Glance.BuildSetting.scriptsDir + filename)) { throw new ArgumentException("script file not found " + Glance.BuildSetting.scriptsDir + filename); } FileName = Glance.BuildSetting.scriptsDir + filename; _data = new _Data(this); }
//Rašančiųjų gijų metodas public static void Rasytojas(int nr) { _Data temp; for (int i = 0; i < K[nr].kiekis(); i++) { temp = new _Data(K[nr].Imti(i).getRikiavimoLaukas()); K[0].Deti(temp); } }
public void Cancel() { if (_data == null) { return; } foreach (var r in _data.sciDoc.ZTempRanges_Enum(this)) { r.Remove(); } _data = null; _popupHtml?.Hide(); }
void _CancelUI() { if (_data == null) { return; } foreach (var r in _data.sci.ZTempRanges_Enum(this)) { r.Remove(); } _data = null; _textPopup?.Hide(); }
//Iš pradinių duomenų masyvų paimami rikiavimo lauka ir yra įrašomi į duomenų struktūros(rikiavimo laukas, kiekis) masyvus public static void Perrasyti() { _Data temp; for (int i = 0; i < 6; i++) { K[i] = new _Konteineris(P[i].Count); for (int j = 0; j < P[i].Count; j++) { temp = new _Data(P[i].Imti(j).getIvarciai()); K[i].DetiPaprastai(temp, j); } } }
//Duomenys įdedami į masyvą surikiuotai public void Deti(_Data reiksme) { lock (Ivarciai) { bool arYra = false; for (int i = 0; i < Ivarciai.Count(); i++) { if (Ivarciai[i] != null) { if (Ivarciai[i].getRikiavimoLaukas() == reiksme.getRikiavimoLaukas()) { Ivarciai[i].Prideti(); arYra = true; break; } } } if (!arYra) { reiksme.Prideti(); for (int i = 0; i < Ivarciai.Count(); i++) { if (Ivarciai[i] != null) { if (reiksme.getRikiavimoLaukas() < Ivarciai[i].getRikiavimoLaukas()) { _Data temp = Ivarciai[i]; _Data temp2; Ivarciai[i] = reiksme; for (int j = i + 1; j < Ivarciai.Count(); j++) { temp2 = Ivarciai[j]; Ivarciai[j] = temp; temp = temp2; } break; } } else { Ivarciai[i] = reiksme; break; } } } } }
void _PlayBgm(string key) { _LoadBgm(key); _Data _data = _poolBgm[key]; //既に再生中の同じBGMがあれば何もしない if (_sourceBgm.isPlaying && _sourceBgm.clip.Equals(_data.Clip)) { return; } // 再生 _sourceBgm.clip = _data.Clip; _sourceBgm.Play(); }
/// <summary> /// calculate for each vert, the minimum distance to a seed vert /// </summary> private void _CalcDist(VLst selectedVerts) { Transform meshTr = m_Mesh.transform; Mesh m = m_Mesh.mesh; Vector3[] oriVerts = m.vertices; //original verts pos // generate the transformed verts Vector3[] verts = new Vector3[oriVerts.Length]; //the verts transformed by matrix for (int i = 0; i < m.vertexCount; ++i) { verts[i] = meshTr.TransformPoint(oriVerts[i]); } // calc distances int found = 0; for (int i = 0; i < m_Cont.Length; ++i) { _Data lhs = m_Cont[i]; if (lhs.percentage == 1f) { continue; } Vector3 lhsPos = verts[i]; for (int j = 0; j < selectedVerts.Count; ++j) { int seedVertIdx = selectedVerts[j]; Vector3 seedPos = verts[seedVertIdx]; float d = Vector3.Distance(seedPos, lhsPos); lhs.dist = Mathf.Min(lhs.dist, d); } if (lhs.dist < m_Range) { ++found; } } //Dbg.Log("SoftSelection._CalcDist: found {0}", found); }
void _LoadBgm(string key) { //すでに存在する if (_poolBgm.ContainsKey(key)) { return; } _poolBgm.Add(key, new _Data(key, key, DateTime.Now)); if (_poolBgm.Count > MAX_BGM) { _Data old = _poolBgm.Last().Value; foreach (_Data d in _poolBgm.Values) { if (d.addTime < old.addTime) { old = d; } } _poolBgm.Remove(old.Key); } }
void _PlayVoice(string key) { _LoadVoice(key); // リソースの取得 _Data _data = _poolVoice[key]; //最終士用時間を適用 _data.addTime = DateTime.Now; //同じVoiceが使っている音源がれば利用 foreach (AudioSource source in _sourceVoiceArray) { if (source.name == key) { source.Play(); return; } } //再生されていない音源があれば利用 foreach (AudioSource source in _sourceVoiceArray) { if (!source.isPlaying) { source.clip = _data.Clip; source.Play(); return; } } //使える音源がなかった場合追加 _sourceVoiceArray.Add(_object.AddComponent <AudioSource>()); _SetVolume(eType.Voice, DEFAULT_VOLUME_VOICE); _sourceVoiceArray.Last().clip = _data.Clip; _sourceVoiceArray.Last().Play(); }
void _ShowSignature(SciCode doc, char ch) { //APerf.First(); if (!CodeInfo.GetContextAndDocument(out var cd, -2)) { return; //returns false if position is in meta comments } //APerf.Next(); var trigger = new SignatureHelpTriggerInfo(ch == default ? SignatureHelpTriggerReason.InvokeSignatureHelpCommand : SignatureHelpTriggerReason.TypeCharCommand, ch); var providers = _SignatureHelpProviders; //AOutput.Write(providers); //APerf.Next(); SignatureHelpItems r = null; foreach (var p in providers) { //APerf.First(); var r2 = p.GetItemsAsync(cd.document, cd.pos16, trigger, default).Result; //APerf.NW(); //quite fast, don't need async. But in the future can try to wrap this foreach+SignatureHelpProviders in async Task. Need to test with large files. if (r2 == null) { continue; } if (r == null || r2.ApplicableSpan.Start > r.ApplicableSpan.Start) { r = r2; } //Example: 'AOutput.Write(new Something())'. // The first provider probably is for Write (invocation). // Then the second is for Something (object creation). // We need the innermost, in this case Something. } if (r == null) { Cancel(); return; } //APerf.NW('s'); //AOutput.Write($"<><c orange>pos={de.position}, span={r.ApplicableSpan}, nItems={r.Items.Count}, argCount={r.ArgumentCount}, argIndex={r.ArgumentIndex}, argName={r.ArgumentName}, sel={r.SelectedItemIndex}, provider={provider}<>"); //var node = document.GetSyntaxRootAsync().Result; var span = new _Span(r.ApplicableSpan, cd.code); int iSel = _data?.GetUserSelectedItemIfSameSpan(span, r) ?? -1; //preserve user selection in same session _data = new _Data { r = r, span = span, iUserSelected = iSel, sciDoc = doc, }; if (iSel < 0) { iSel = r.SelectedItemIndex ?? (r.ArgumentCount == 0 ? 0 : -1); if (iSel < 0) { for (int i = 0; i < r.Items.Count; i++) { if (r.Items[i].Parameters.Length >= r.ArgumentCount) { iSel = i; break; } } if (iSel < 0) { for (int i = 0; i < r.Items.Count; i++) { if (r.Items[i].IsVariadic) { iSel = i; break; } } if (iSel < 0) { iSel = 0; } } } } string html = _FormatHtml(iSel, userSelected: false); doc.ZTempRanges_Add(this, r.ApplicableSpan.Start, r.ApplicableSpan.End, onLeave: () => { if (doc.ZTempRanges_Enum(doc.Z.CurrentPos8, this, utf8: true).Any()) { return; } Cancel(); }, SciCode.ZTempRangeFlags.NoDuplicate); var rect1 = CiUtil.GetCaretRectFromPos(doc, r.ApplicableSpan.Start); var rect2 = CiUtil.GetCaretRectFromPos(doc, cd.pos16); var rect = doc.RectangleToScreen(Rectangle.Union(rect1, rect2)); rect.Width += Au.Util.ADpi.ScaleInt(200); rect.X -= 6; _popupHtml ??= new CiPopupHtml(CiPopupHtml.UsedBy.Signature, onHiddenOrDestroyed: _ => _data = null) { OnLinkClick = (ph, e) => ph.Html = _FormatHtml(e.Link.ToInt(1), userSelected: true) }; _popupHtml.Html = html; _popupHtml.Show(Panels.Editor.ZActiveDoc, rect, PopupAlignment.TPM_VERTICAL); //APerf.NW(); }
/// <summary> /// Lấy đợt phân bổ /// </summary> /// <param name="ParentID"></param> /// <param name="iNamLamViec"></param> /// <param name="iID_MaDotPhanBo"></param> /// <returns></returns> /// public _Data obj_DSDotPhanBo(string ParentID, String MaND, String sLNS, String iID_MaDotPhanBo, String iID_MaTrangThaiDuyet,String TruongTien,String KhoGiay,String ToSo) { _Data _data = new _Data(); #region Option đợt phân bổ DataTable dtDotPhanBo = DanhSach_DotPhanBo(MaND, sLNS, iID_MaTrangThaiDuyet, TruongTien); SelectOptionList slTenDotPhanBo = new SelectOptionList(dtDotPhanBo, "iID_MaDotPhanBo", "dNgayDotPhanBo"); _data.iID_MaDotPhanBo = MyHtmlHelper.DropDownList(ParentID, slTenDotPhanBo, iID_MaDotPhanBo, "iID_MaDotPhanBo", "", "class=\"input1_2\" style=\"width: 80%\"onchange=\"ChonNLV()\""); dtDotPhanBo.Dispose(); #endregion #region Option Tờ số DataTable dtToSo = dtTo(MaND, sLNS, iID_MaDotPhanBo, iID_MaTrangThaiDuyet, TruongTien, KhoGiay); SelectOptionList slToSo = new SelectOptionList(dtToSo, "MaTo", "TenTo"); _data.ToSo = MyHtmlHelper.DropDownList(ParentID, slToSo, ToSo, "ToSo", "", "class=\"input1_2\" style=\"width: 80%\""); dtToSo.Dispose(); #endregion return _data; }
get => new Vertex(_Declaration, new ROW(_Data, index * _Stride, _Stride));
public GridInformationFormat() { data = new _Data(); Meta = new _Meta(); }
//Duomenys sudedami į masyva nerikiuotai public void DetiPaprastai(_Data reiksme, int Count) { Ivarciai[Count] = reiksme; }
async void _ShowSignature(SciCode doc, char ch, bool methodCompletion = false) { //using var p1 = perf.local(); if (!CodeInfo.GetContextAndDocument(out var cd, -2) || cd.pos < 2) { return; //returns false if position is in meta comments } _cancelTS?.Cancel(); _cancelTS = new CancellationTokenSource(); var cancelTS = _cancelTS; var cancelToken = cancelTS.Token; #if DEBUG if (Debugger.IsAttached) { cancelToken = default; _cancelTS = null; } #endif SyntaxNode root = null; //ISignatureHelpProvider provider = null; SignatureHelpItems r = null; try { //could be sync, quite fast, but then sometimes reenters (GetItemsAsync waits/dispatches) and sometimes hangs r = await Task.Run(async() => { //p1.Next(); root = cd.syntaxRoot; //p1.Next('r'); var providers = _SignatureHelpProviders; //print.it(providers); SignatureHelpItems r = null; var trigger = new SignatureHelpTriggerInfo(ch == default ? SignatureHelpTriggerReason.InvokeSignatureHelpCommand : SignatureHelpTriggerReason.TypeCharCommand, ch); foreach (var p in providers) { //print.it(p); var r2 = await p.GetItemsAsync(cd.document, cd.pos, trigger, SignatureHelpOptions.Default, cancelToken).ConfigureAwait(false); if (cancelToken.IsCancellationRequested) /*print.it("IsCancellationRequested");*/ return { (null); } //often if (r2 == null) { continue; } if (r == null || r2.ApplicableSpan.Start > r.ApplicableSpan.Start) { r = r2; //provider = p; } //Example: 'print.it(new Something())'. // The first provider probably is for Write (invocation). // Then the second is for Something (object creation). // We need the innermost, in this case Something. } return(r); }); } catch (OperationCanceledException) { /*Debug_.Print("canceled");*/ return; } //never noticed //catch (AggregateException e1) when (e1.InnerException is TaskCanceledException) { return; } finally { cancelTS.Dispose(); if (cancelTS == _cancelTS) { _cancelTS = null; } } //print.it(r, cancelToken.IsCancellationRequested); if (cancelToken.IsCancellationRequested) { return; } if (r == null) { _CancelUI(); return; } Debug.Assert(doc == Panels.Editor.ZActiveDoc); //when active doc changed, cancellation must be requested if (cd.pos != doc.zCurrentPos16 || (object)cd.code != doc.zText) { return; //changed while awaiting } //p1.Next('s'); //print.it($"<><c orange>pos={cd.pos}, span={r.ApplicableSpan}, nItems={r.Items.Count}, argCount={r.ArgumentCount}, argIndex={r.ArgumentIndex}, argName={r.ArgumentName}, sel={r.SelectedItemIndex}, provider={provider}<>"); //get span of the arglist. r.ApplicableSpan.Start is of the statement, not of the arglist. In chained methods it is the chain start. var fullSpan = r.ApplicableSpan; //CiUtil.HiliteRange(fullSpan); wait.doEvents(500); var start = fullSpan.Start; var tok = root.FindToken(cd.pos); if (tok.Kind() is SyntaxKind.OpenParenToken or SyntaxKind.OpenBracketToken or SyntaxKind.LessThanToken) { tok = tok.GetPreviousToken(); } var argNode = tok.Parent; while (argNode != null) { int i = argNode.SpanStart; if (i <= start) { break; } if (argNode is BaseArgumentListSyntax or AttributeArgumentListSyntax or TypeArgumentListSyntax) { start = i + 1; break; } //CiUtil.PrintNode(argNode); argNode = argNode.Parent; } var argSpan = new TextSpan(start, fullSpan.End - start); //CiUtil.PrintNode(argNode); CiUtil.HiliteRange(argSpan); //print.it(argSpan); var span = new _Span(argSpan, cd.code); int iSel = 0, iSel2 = 0; if (r.Items.Count > 1) { iSel2 = r.SelectedItemIndex ?? -1; if (_data?.IsSameArglist(span, r) ?? false) { iSel = _data.iUserSelected; //preserve user selection in same session if (iSel2 < 0) { iSel2 = _data.iRoslynSelected; //on error use last good Roslyn selection in same session, like in VS } } else { iSel = -1; } } _data = new _Data { r = r, span = span, iUserSelected = iSel, iRoslynSelected = iSel2, sci = doc, }; if (iSel < 0) { iSel = iSel2; } if (iSel < 0) { //r.SelectedItemIndex is null when cannot resolve overloads, eg when arglist is partially typed. Example: wnd.find(1, ); iSel = r.SelectedItemIndex ?? (r.ArgumentCount == 0 ? 0 : -1); if (iSel < 0) { for (int i = 0; i < r.Items.Count; i++) { if (r.Items[i].Parameters.Length >= r.ArgumentCount) { iSel = i; break; } } if (iSel < 0) { for (int i = 0; i < r.Items.Count; i++) { if (r.Items[i].IsVariadic) { iSel = i; break; } } if (iSel < 0) { iSel = 0; } } } } doc.ZTempRanges_Add(this, argSpan.Start, argSpan.End, onLeave: () => { if (doc.ZTempRanges_Enum(doc.zCurrentPos8, this, utf8: true).Any()) { return; } _CancelUI(); }, SciCode.ZTempRangeFlags.NoDuplicate); var rect = RECT.Union(CiUtil.GetCaretRectFromPos(doc, fullSpan.Start), CiUtil.GetCaretRectFromPos(doc, cd.pos)); doc.Hwnd.MapClientToScreen(ref rect); rect.Width += Dpi.Scale(200, doc.Hwnd); rect.left -= 6; _textPopup ??= new CiPopupText(CiPopupText.UsedBy.Signature, onHiddenOrDestroyed: (_, _) => _data = null) { OnLinkClick = (ph, e) => ph.Text = _FormatText(e.ToInt(1), userSelected: true) }; _textPopup.Text = _FormatText(iSel, userSelected: false); if (!_textPopup.IsVisible) { CodeInfo.HideTextPopupAndTempWindows(); if (CodeInfo._compl.IsVisibleUI) //without this does not show completions with selected enum when typed Function( when first parameter is enum { CodeInfo._compl.Cancel(); } if (methodCompletion) { CodeInfo._compl.ShowList(ch); //when autocompletion added (); may need to show enum list } } _textPopup.Show(Panels.Editor.ZActiveDoc, rect, System.Windows.Controls.Dock.Bottom); //also show Keys/Regex tool? //CiUtil.PrintNode(node); if (argNode is ArgumentListSyntax or BracketedArgumentListSyntax && cd.code.Eq(cd.pos - 1, "\"\"")) { //print.it("string"); var semo = cd.semanticModel; var token = root.FindToken(cd.pos); if (true == token.IsInString(cd.pos, cd.code, out var stringInfo)) { var stringFormat = CiUtil.GetParameterStringFormat(stringInfo.stringNode, semo, true); if (stringFormat != 0) { CodeInfo._tools.ShowForStringParameter(stringFormat, cd, stringInfo, _textPopup.PopupWindow.Hwnd); } } } }
public MMCPack fromProfile(LauncherProfile profile) { Data = new return(this); }
bool _PlayBgm(string resName) { //_dataBgmが存在し、既に再生中であれば何もしない if (_dataBgm != null && _dataBgm.ResName == resName) return true; _dataBgm = new _Data ("bgm", resName); // いったん止める _StopBgm(); // 再生 _sourceBgm.clip = _dataBgm.Clip; _sourceBgm.Play(); return true; }