private void GetInstrument(SienItem si, bool isFirst) { InstrumentAtValSound iavs = new InstrumentAtValSound(); iavs.isFirst = isFirst; string[] param = new string[6]; string[] val = si.content.Split(','); for (int i = 0; i < param.Length; i++) { param[i] = val[i].Trim().Trim('\''); } if (!instCache.ContainsKey(si.content)) { iavs.Start( parent , si , param[0] , param[1] , Encoding.GetEncoding(param[2]) , param[3] , param[4] , param[5] , GetInstrumentComp); } else { GetInstrumentComp(si, instCache[si.content]); } }
private void ReplaceContents(SienItem si) { DockContent dc = (DockContent)parent.GetActiveDockContent(); Document d; if (dc == null) { return; } if (!(dc.Tag is Document)) { return; } try { d = (Document)dc.Tag; int ci = d.editor.azukiControl.CaretIndex; d.editor.azukiControl.Document.Replace( si.content, ci,// - si.foundCnt, ci); //d.editor.azukiControl.SetSelection(ci - si.foundCnt + si.nextAnchor, ci - si.foundCnt + si.nextCaret); d.editor.azukiControl.SetSelection(ci + si.nextAnchor, ci + si.nextCaret); } catch { } }
private void dgvItem_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { dgvItem.Rows[e.RowIndex].Selected = true; DockContent dc = (DockContent)parent.GetActiveDockContent(); Document d = null; if (dc != null) { if (dc.Tag is Document) { d = (Document)dc.Tag; int ci = d.editor.azukiControl.CaretIndex; SienItem si = (SienItem)dgvItem.Rows[e.RowIndex].Tag; d.editor.azukiControl.Document.Replace( si.content, ci - si.foundCnt, ci); d.editor.azukiControl.SetSelection(ci - si.foundCnt + si.nextAnchor, ci - si.foundCnt + si.nextCaret); } } } this.SetOpacity(false); parent.Activate(); }
private void GetInstrumentCompTN(object sender, TreeNode tn, string[] obj) { if (!(sender is SienItem)) { return; } if (obj == null || obj.Length < 1) { return; } try { SienItem si = (SienItem)sender; foreach (string line in obj) { SienItem ssi = new SienItem(); string lin = line; if (lin.IndexOf("\r\n") >= 0) { lin = lin.Substring(0, line.IndexOf("\r\n")).Trim(); } else { lin = lin.Substring(0, line.IndexOf("\n")).Trim(); } ssi.title = string.Format(si.title, lin); ssi.parentID = -1;// si.parentID; ssi.content = line; ssi.description = si.description; ssi.foundCnt = si.foundCnt; ssi.nextAnchor = si.nextAnchor; ssi.nextCaret = si.nextCaret; ssi.pattern = si.pattern; ssi.patternType = si.patternType; ssi.sienType = si.sienType + 1; TreeNode n = new TreeNode(ssi.title); n.Tag = ssi; tn.Nodes.Add(n); } update(); if (!instCache.ContainsKey(si.content)) { instCache.Add(si.content, obj); } } catch (Exception ex) { log.ForcedWrite(ex); } }
private void GetInstrumentFromFolder(SienItem si, TreeNode tn, bool isFirstFolder) { InstrumentAtLocal iavs = new InstrumentAtLocal(); iavs.isFirst = isFirstFolder; iavs.treenode = tn; string path = Path.Combine(Common.GetApplicationFolder(), "Instruments");// "C:\\Users\\kuma\\Desktop\\FM-SoundLibrary-master"; if (si.description != "") { path = si.description; } iavs.Start( parent, si, path, "", GetInstrumentFromFolderComp); }
private void GetInstrumentComp(object sender, string[] obj) { if (!(sender is SienItem)) { return; } if (obj == null || obj.Length < 1) { return; } try { SienItem si = (SienItem)sender; foreach (string line in obj) { SienItem ssi = new SienItem(); ssi.title = string.Format(si.title, line.Substring(0, line.IndexOf("\r\n")).Trim()); ssi.content = line; ssi.description = si.description; ssi.foundCnt = si.foundCnt; ssi.nextAnchor = si.nextAnchor; ssi.nextCaret = si.nextCaret; ssi.pattern = si.pattern; ssi.patternType = si.patternType; ssi.sienType = si.sienType + 1; dgvItem.Rows.Add( ssi.title, ssi.description, ssi.content); dgvItem.Rows[dgvItem.Rows.Count - 1].Tag = ssi; } if (!instCache.ContainsKey(si.content)) { instCache.Add(si.content, obj); } } catch (Exception ex) { log.ForcedWrite(ex); } }
private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node == null) { return; } if (e.Node.Tag == null) { return; } if (!(e.Node.Tag is SienItem)) { return; } SienItem si = (SienItem)e.Node.Tag; ReplaceContents(si); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { label2.Text = ""; if (treeView1.SelectedNode == null) { return; } if (treeView1.SelectedNode.Tag == null) { return; } if (!(treeView1.SelectedNode.Tag is SienItem)) { return; } SienItem si = (SienItem)treeView1.SelectedNode.Tag; label2.Text = si.description; }
private void treeView1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != 13) { return; } if (treeView1.SelectedNode == null) { return; } if (treeView1.SelectedNode.Tag == null) { return; } if (!(treeView1.SelectedNode.Tag is SienItem)) { return; } e.Handled = true; SienItem si = (SienItem)treeView1.SelectedNode.Tag; ReplaceContents(si); }
private void GetInstrument(SienItem si, TreeNode tns, bool isFirst) { if (setting.OfflineMode) { return; } InstrumentAtValSound iavs = new InstrumentAtValSound(); iavs.isFirst = isFirst; iavs.treenode = tns; string[] param = new string[6]; string[] val = si.content.Split(','); for (int i = 0; i < param.Length; i++) { param[i] = val[i].Trim().Trim('\''); } if (!instCache.ContainsKey(si.content)) { iavs.Start( parent , si , param[0] , param[1] , Encoding.GetEncoding(param[2]) , param[3] , param[4] , param[5] , GetInstrumentCompTN); } else { GetInstrumentCompTN(si, tns, instCache[si.content]); update();//キャッシュがある場合はここでupdateして大丈夫 } }
private void AzukiControl_KeyDown(object sender, KeyEventArgs e) { if (this.DockState == DockState.Float) { main.FrmMain_KeyDown(sender, e); } if (!frmSien.GetOpacity()) { e.SuppressKeyPress = false; return; } e.SuppressKeyPress = true; switch (e.KeyCode) { case Keys.Down: if (frmSien.selRow < 0) { frmSien.selRow = -1; } if (frmSien.dgvItem.Rows.Count - 1 > frmSien.selRow) { frmSien.selRow++; } frmSien.dgvItem.Rows[frmSien.selRow].Selected = true; frmSien.dgvItem.FirstDisplayedScrollingRowIndex = Math.Max(frmSien.selRow, 0); break; case Keys.Up: if (frmSien.dgvItem.Rows.Count > -1) { frmSien.selRow--; } if (frmSien.selRow < 0) { frmSien.SetOpacity(false); } else { frmSien.dgvItem.Rows[frmSien.selRow].Selected = true; frmSien.dgvItem.FirstDisplayedScrollingRowIndex = Math.Max(frmSien.selRow, 0); } break; case Keys.Enter: case Keys.Tab: frmSien.SetOpacity(false); if (frmSien.dgvItem.SelectedRows.Count == 1) { int ci = azukiControl.CaretIndex; SienItem si = (SienItem)frmSien.dgvItem.Rows[frmSien.dgvItem.SelectedRows[0].Index].Tag; azukiControl.Document.Replace( si.content, ci - si.foundCnt, ci); azukiControl.SetSelection(ci - si.foundCnt + si.nextAnchor, ci - si.foundCnt + si.nextCaret); } break; case Keys.Right: case Keys.Left: case Keys.Home: case Keys.End: case Keys.Escape: frmSien.SetOpacity(false); break; default: e.SuppressKeyPress = false; break; } }
private void GetInstrumentFromFolderComp(object sender, TreeNode tn, Tuple <InstrumentAtLocal.enmInstType, string, string>[] obj) { if (!(sender is SienItem)) { return; } if (obj == null || obj.Length < 1) { return; } try { SienItem si = (SienItem)sender; InstrumentAtLocal.enmInstType tp = InstrumentAtLocal.enmInstType.FM_L; foreach (InstrumentAtLocal.enmInstType e in Enum.GetValues(typeof(InstrumentAtLocal.enmInstType))) { if (e.ToString() != si.content) { continue; } tp = e; break; } int depth = -1; foreach (Tuple <InstrumentAtLocal.enmInstType, string, string> line in obj) { if (line.Item1 != InstrumentAtLocal.enmInstType.Dir) { continue; } depth++; SienItem ssi; string name = Path.GetFileName(line.Item2); string filePath = Path.GetDirectoryName(line.Item2); string[] paths = filePath.Split(Path.DirectorySeparatorChar); string lin = line.Item3; string treename = line.Item2.Replace(Path.Combine(Common.GetApplicationFolder(), "Instruments") + "\\", ""); ssi = new SienItem(); ssi.title = string.Format("{0}", name); ssi.tree = treename; ssi.ID = si.parentID; ssi.parentID = si.ID; ssi.haveChild = true; ssi.content = si.content; ssi.description = line.Item2; ssi.foundCnt = si.foundCnt; ssi.nextAnchor = si.nextAnchor; ssi.nextCaret = si.nextCaret; ssi.pattern = si.pattern; ssi.patternType = si.patternType; ssi.sienType = si.sienType; string[] flds = ssi.tree.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); TreeNode tns = tn; foreach (string fld in flds) { TreeNode fnd = null; foreach (TreeNode t in tns.Nodes) { if (t.Text == fld) { fnd = t; break; } } if (fnd == null) { fnd = new TreeNode(fld); tns.Nodes.Add(fnd); } tns = fnd; } } foreach (Tuple <InstrumentAtLocal.enmInstType, string, string> line in obj) { if (line.Item1 == InstrumentAtLocal.enmInstType.Dir) { continue; } depth++; SienItem ssi; string name = Path.GetFileName(line.Item2); string filePath = Path.GetDirectoryName(line.Item2); string[] paths = filePath.Split(Path.DirectorySeparatorChar); string lin = line.Item3; string treename = line.Item2.Replace(Path.Combine(Common.GetApplicationFolder(), "Instruments") + "\\", ""); ssi = new SienItem(); ssi.title = string.Format("{0}", name); ssi.tree = treename; ssi.ID = si.parentID; ssi.parentID = si.ID; ssi.haveChild = true; ssi.content = lin;// si.content; ssi.description = line.Item2; ssi.foundCnt = si.foundCnt; ssi.nextAnchor = si.nextAnchor; ssi.nextCaret = si.nextCaret; ssi.pattern = si.pattern; ssi.patternType = si.patternType; ssi.sienType = si.sienType; string[] flds = ssi.tree.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); TreeNode tns = tn; foreach (string fld in flds) { TreeNode fnd = null; foreach (TreeNode t in tns.Nodes) { if (t.Text == fld) { fnd = t; break; } } if (fnd == null) { fnd = new TreeNode(fld); fnd.Tag = ssi; tns.Nodes.Add(fnd); } tns = fnd; } } update(); if (!instCacheFolder.ContainsKey(si.content)) { instCacheFolder.Add(si.content, obj); } } catch (Exception ex) { log.ForcedWrite(ex); } }