// ###################################### MyForm.cs ########################################## using System.Windows.Forms; using System; using System.Collections.Generic; public class MyForm : Form { [System.STAThread] static void Main() { Application.Run(new MyForm()); } // ==================================================================== public Panel basepanel; public string strbase = Environment.CurrentDirectory; ToolStripMenuItem menu_File; public MyTable myTable; string strdir; public string strpivot; public MyForm() { this.Controls.Add(MainMenuStrip = new MenuStrip()); MainMenuStrip.Location = new System.Drawing.Point(0, 0); MainMenuStrip.Size = new System.Drawing.Size(800, 24); MainMenuStrip.TabIndex = 0; menu_File=MainMenuStrip.addItem("ファイル(&F)"); menu_File.addItem("開く").Click+=(o, e) => { fileread(); Refresh(); }; menu_File.DropDownItems.Add(new ToolStripSeparator()); menu_File.addItem("名前を付けて保存").Click+=(o, e) => { FileDialog fd=new SaveFileDialog(); fd.Filter="yer files (*.yer)|*.yer|All files (*.*)|*.*"; fd.InitialDirectory = getinitialdir(); DialogResult dr = fd.ShowDialog(); if (dr == DialogResult.OK) { strpivot=fd.FileName; string strsubt=strsubfname(strpivot, strbase); this.Text=strsubt+" --- "; } string nm = fd.FileName; strpivot = nm; filewrite(nm); }; menu_File.addItem("上書き保存").Click+=(o, e) => { filewrite(strpivot); }; // basepanel = new Panel(); basepanel.AutoScroll = true; basepanel.Dock = DockStyle.Fill; // located at (0,0) Controls.Add(basepanel); // basepanel.Controls.Add(myTable = new MyTable(this)); myTable.Location = new System.Drawing.Point(0, 24); myTable.getpxs(); myTable.getpys(); // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(500, 500); this.Text = "MyForm"; } // ======================================================================= string getstr(ref int c, string str) { int ir=str.IndexOf("\r", c); string stri=str.Substring(c, ir-c); int il=int.Parse(stri); c=ir+2; string stra=str.Substring(c, il); c += il; return stra; } // ======================================================= List getstrs(ref int c, string str) { int ir=str.IndexOf("\r", c); int il=int.Parse(str.Substring(c, ir-c)); c=ir+2; List titles=new List(); for (int j=0; j=0; ii--) { if (strdir.Substring(ii,1)=="\\") {ct++; } if (ct==3) {break; } } string toret=strdir.Substring(0,ii); return toret; } // ======================================================= void fileread() { FileDialog fd=new OpenFileDialog(); fd.Filter="yer files (*.yer)|*.yer|All files (*.*)|*.*"; fd.InitialDirectory = getinitialdir(); // strdir.Substring(0,ii); DialogResult dr = fd.ShowDialog(); if (dr == DialogResult.OK) { strpivot=fd.FileName; int idir=strpivot.Length-1; for ( ; idir>0; idir--) { if (strpivot.Substring(idir, 1) == "\\") { break; } } strbase=strpivot.Substring(0, idir+1); { string strsubt=strsubfname(strpivot, strbase); this.Text=strsubt+" --- "; } } if (strpivot == null) { return; } System.IO.FileStream fst = new System.IO.FileStream( strpivot, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None); int filelen=(int)fst.Length; byte[] bytes=new byte[filelen]; for (int i=0; i strs=new List(); int c=0; List titlesy=getstrs(ref c, str), titlesx=getstrs(ref c, str); myTable.settitles(titlesx, titlesy); int ysz=titlesy.Count, xsz=titlesx.Count; for (int y=0; y0; idir--) { if (strpivot.Substring(idir, 1) == "\\") { break; } } strbase=strpivot.Substring(0, idir+1); { string strsubt=strsubfname(strpivot, strbase); this.Text=strsubt+" --- "; } System.IO.StreamWriter sw = new System.IO.StreamWriter(strpivot,false, System.Text.Encoding.Default); sw.Write(str); sw.Flush(); sw.Close(); } // ======================================================= protected override void OnActivated(EventArgs e) { myTable.Refresh(); } // ======================================================================= protected override void Dispose(bool disposing) { base.Dispose(disposing); } // ======================================================================= public static string getPostfix(string filename) { int ind=filename.IndexOf(".", 0); for ( ; ; ) { int indnw=filename.IndexOf(".", ind+1); if (indnw < 0) {break; } ind=indnw; } return filename.Substring(ind+1); } // ========================================================================== public static string strsubfname(string strs, string strm) { int lens=strs.Length, lenm=strm.Length, lenf=lens; if (lenf>lenm) {lenf=lenm; } int lasti=0; for (int i=0; i xopen, yopen; Font ここでのfont = new Font("MS Pゴシック", 14); Font 数のfont = new Font("MS Pゴシック", 12); Brush 緑のブラシ = new SolidBrush(Color.DarkGreen); Brush redbrush = new SolidBrush(Color.Red), graybrush=new SolidBrush(Color.Gray); public int ysz=0, xsz=0; public List pxs, pys; MyForm par; public List xtitles, ytitles; List multiplierx, multipliery; List accumy, accumx; public Term[,] terms; long totalsum; public MyTable(MyForm partf) { par=partf; this.BackColor = Color.White; // Yellow; getpxs(); getpys(); OnClick(null); bandDH=bandD+bandH; bandDHH=bandD+bandH+bandH; par=partf; recalcu(); xopen=new List(); yopen=new List(); xtitles=new List(); ytitles=new List(); multiplierx=new List(); multipliery=new List(); accumx=new List(); accumy=new List(); } // ======================================================= public void getpxs() { pxs = new List(); int xdevi=xdeviinit; for (int x=0 ; x<=xsz; x++) { pxs.Add(xdevi); if (x==xsz) {break; } if (xopen[x]) { xdevi+=bandDHH; } else { xdevi+=bandD; } } int w=pxs[xsz]+bandF+3; if (this.Width!=w) { this.Width=w; } } // ======================================================= public void getpys() { pys = new List(); int ydevi=ydeviinit; for (int y=0 ; y<=ysz; y++) { pys.Add(ydevi); if (y==ysz) {break; } if (yopen[y]) { ydevi += bandDHH; } else { ydevi+=bandD; } } int h=pys[ysz]+bandF+3; if (this.Height!=h) { this.Height=h; } } // ======================================================= public void onmousemove(int xonpanel, int yonpanel) { int xnowprev=xnow, ynowprev=ynow; if (xmode && yonpanel>0 && yonpanel < ydevifinal+bandF && xonpanel >= xdeviinit) { for (xnow=0; xnow xonpanel) {break; } } } else if (ymode && xonpanel>0 && xonpanel < xdevifinal+bandF && yonpanel >= ydeviinit) { for (ynow=0; ynow yonpanel) {break; } } } if (xnowprev != xnow || ynowprev != ynow) { Invalidate(); } } // ======================================================= public void paint(Graphics g) { int xdevi, ydevi; xdevifinal = pxs[xsz]; ydevifinal = pys[ysz]; for (int x=0;x<=xsz ; x++) { // vertical lines g.DrawLine(pen, pxs[x], 0, pxs[x], ydevifinal+bandF); } for (int y=0;y<=ysz ; y++) { // horizontal lines g.DrawLine(pen, 0, pys[y], xdevifinal+bandF, pys[y]); } if (ymode) { g.FillRectangle(dbrush, 0, pys[yinit], pxs[xsz]+bandF, pys[yinit+1]-pys[yinit]); } if (xmode) { g.FillRectangle(dbrush, pxs[xinit], 0, pxs[xinit+1]-pxs[xinit], pys[ysz]+bandF); } g.DrawLine(gpen, 0, ydevifinal+bandF, xdevifinal+bandF, ydevifinal+bandF); // bottom line g.DrawLine(gpen, xdevifinal+bandF, 0, xdevifinal+bandF, ydevifinal+bandF); // right line if (xmode) { if (xinit < xnow && xnow < xsz) { g.DrawLine(bkpen, pxs[xnow+1], 0, pxs[xnow+1], ydevifinal+bandF); } else if (xnow < xinit) { g.DrawLine(bkpen, pxs[xnow], 0, pxs[xnow], ydevifinal+bandF); } } else if (ymode) { if (yinit < ynow && ynow < ysz) { g.DrawLine(bkpen, 0, pys[ynow+1], xdevifinal+bandF, pys[ynow+1]); } else if (ynow < yinit) { g.DrawLine(bkpen, 0, pys[ynow], xdevifinal+bandF, pys[ynow]); } } // ---------------------------------------------------------------- ydevi=ydeviinit; for (int y=0; y0) { g.DrawString("+", ここでのfont, brush, xdevi+3, ydevi+1); } else if (terms[x,y].final<0) { g.DrawString("-", ここでのfont, brush, xdevi+3, ydevi+1); } ydevi+=bandD; } } xdevi += bandD; } } ydevi=ydeviinit; xdevi += bandF; for (int y=0; y xonpanel) { if (xinit == x) { xopen[x]=!xopen[x]; } else { string xres=xtitles[xinit]; bool bres=xopen[xinit]; for (int y=0; yx; xsc--) { xtitles[xsc]=xtitles[xsc-1]; xopen[xsc]=xopen[xsc-1]; for (int y=0; y yonpanel) { if (yinit == y) { yopen[y]=!yopen[y]; } else { string yres=ytitles[yinit]; bool bres=yopen[yinit]; for (int x=0; xy; ysc--) { ytitles[ysc]=ytitles[ysc-1]; yopen[ysc]=yopen[ysc-1]; for (int x=0; x xonpanel) { break; } } for (yfinal=0; yfinal yonpanel) { break; } } if (xfinal == xinit && yfinal == yinit) { TermForm tf=new TermForm(terms[xfinal, yfinal], par.strbase, xtitles[xfinal], ytitles[yfinal]); tf.textmulti.Text=terms[xfinal, yfinal].strincidents; foreach (string str in terms[xfinal, yfinal].files) { tf.combo.Items.Add(str); } // Point pto=new Point(pxs[xfinal+1], pys[yfinal]); tf.location=new Point(xtoglobal(pto.X), ytoglobal(pto.Y)); // DialogResult dr=tf.ShowDialog(); if (dr == DialogResult.OK) { terms[xfinal, yfinal].final=tf.term.final; // long.Parse(tf.textfinal.Text); // ; // terms[xfinal, yfinal].strincidents=tf.textmulti.Text; terms[xfinal, yfinal].files.Clear(); foreach (string str in tf.combo.Items) { terms[xfinal, yfinal].files.Add(str); } recalcu(); } } } // =================================================== public void settitles(List xtitlestf, List ytitlestf) { xtitles=xtitlestf; ytitles=ytitlestf; xsz=xtitles.Count; ysz=ytitles.Count; xopen=new List(); yopen=new List(); terms=new Term[xsz, ysz]; accumx=new List(); accumy=new List(); multiplierx=new List(); multipliery=new List(); for (int x=0; x 0 && ytitles[y].Substring(0,1) == "-") { multipliery[y]=-1; } else if (ytitles[y].Substring(0,1) == "0") { multipliery[y]=0; } else { multipliery[y]=1; } for (int x=0; x0 && yonpanel < ydeviinit && xonpanel >= xdeviinit) { scantitlex(xonpanel); } else if (ymode && xonpanel>0 && xonpanel < xdeviinit && yonpanel >= ydeviinit) { scantitley(yonpanel); } else if (xymode && xonpanel >= xdeviinit && yonpanel >= ydeviinit && xonpanel < xdevifinal && yonpanel < ydevifinal) { scanxy(xonpanel, yonpanel); } xmode=ymode=xymode=false; Invalidate(); } // ======================================================= public void mousedownleft(int xonpanel, int yonpanel) { if (yonpanel>0 && yonpanel < ydeviinit && xonpanel >= xdeviinit) { // on x titles for (xinit=0; xinit xonpanel) { xmode=true; break; } } } else if (xonpanel>0 && xonpanel < xdeviinit && yonpanel >= ydeviinit) { // on y titles for (yinit=0; yinit yonpanel) { ymode=true; break; } } } else if (xonpanel >= xdeviinit && yonpanel >= ydeviinit && xonpanel < xdevifinal && yonpanel < ydevifinal) { for (xinit=0; xinit xonpanel) { break; } } for (yinit=0; yinit yonpanel) { break; } } xymode=true; } Invalidate(); } // =============================================================================== public void mousedownright(int xonpanel, int yonpanel) { if (yonpanel>0 && yonpanel < ydeviinit && xonpanel >= xdeviinit) { // x titles for (xinit=xsz; xinit>=0; xinit--) { if (pxs[xinit] <= xonpanel) { string titleconv = ""; if (xinit < xsz) { titleconv=xtitles[xinit]; } righttitile(titleconv, true, xinit, xsz); break; } } } else if (xonpanel>0 && xonpanel < xdeviinit && yonpanel >= ydeviinit) { // y titles for (yinit=ysz; yinit>=0; yinit--) { if (pys[yinit] <= yonpanel) { string titleconv = ""; if (yinit < ysz) { titleconv=ytitles[yinit]; } righttitile(titleconv, false, yinit, ysz); break; } } } } // ======================================================= void righttitile(string str, bool xf, int nfix, int sz) { FormSelection formpre; if (nfix == sz) { formpre=new FormSelection(new string[]{"insert","nop"}); } else { formpre=new FormSelection(new string[]{"remove","insert","rename","nop"}); } formpre.Activated+=(o, e) => { if (xf) {formpre.Location=new Point(xtoglobal(pxs[nfix]), ytoglobal(pys[0])); } else {formpre.Location=new Point(xtoglobal(pxs[0]), ytoglobal(pys[nfix])); } }; DialogResult drpre=formpre.ShowDialog(); string strsele=formpre.list.SelectedItem.ToString(); if (strsele == "rename") { if (xf) { rcorrecttitle(xtitles[nfix], xf, nfix, "rename"); } else { rcorrecttitle(ytitles[nfix], xf, nfix, "rename"); } recalcu(); Invalidate(); } else if (strsele == "remove") { remove(xf, nfix); recalcu(); Invalidate(); } else if (strsele == "insert") { insert(xf, nfix); // === here xsz increases rcorrecttitle("", xf, nfix, "set title"); recalcu(); Invalidate(); } if (xf) { getpxs(); } else { getpys(); } } // =============================================================================== void rcorrecttitle(string strz, bool xf, int nfix, string strbutton) { Form formhere=new Form(); formhere.Size=new Size(310, 160); TextBox texthere=new TextBox(); texthere.Size=new Size(260, 20); texthere.Location=new Point(20, 30); Button buttonOK=new Button(), buttonCancel=new Button(); buttonOK.Location=new Point(60, 70); buttonCancel.Location=new Point(160, 70); buttonOK.Size=new Size(80, 20); buttonCancel.Size=new Size(80, 20); formhere.Controls.Add(texthere); formhere.Controls.Add(buttonOK); formhere.Controls.Add(buttonCancel); // formhere.Controls.Add(buttonyes); buttonOK.DialogResult=DialogResult.OK; buttonCancel.DialogResult=DialogResult.Cancel;// buttonyes.DialogResult=DialogResult.Yes; buttonOK.Text=strbutton; buttonCancel.Text="Cancel"; //buttonyes.Text="Remove"; texthere.Text=strz; formhere.Activated+=(o, e) => { if (xf) {formhere.Location=new Point(xtoglobal(pxs[nfix]), ytoglobal(pys[0])); } else {formhere.Location=new Point(xtoglobal(pxs[0]), ytoglobal(pys[nfix])); } }; DialogResult dr=formhere.ShowDialog(); if (dr==DialogResult.OK) { strz=texthere.Text; if (xf) {xtitles[nfix]=strz; } else {ytitles[nfix]=strz; } recalcu(); } } // ======================================================= bool checkxy(int x, int y) { if (terms[x,y].strincidents != "") {return true; } if (terms[x,y].files.Count!=0) {return true; } return false; } // ======================================================= void remove (bool xf, int nfix) { if (xf) { for (int y=0; y pxsnew=new List(); for (int x=0; x<=nfix; x++) { pxsnew.Add(pxs[x]); } for (int x=nfix+1; x psnew=new List(); for (int y=0; y<=nfix; y++) { psnew.Add(pys[y]); } for (int y=nfix+1; y psnew=new List(); for (int x=0; x psnew = new List(); for (int y=0; y=2 && strhere.Substring(strhere.Length-2,2) != "\r\n") { strhere += "\r\n"; } int slen=strhere.Length; string strlen=slen.ToString()+"\r\n"; str += strlen + strhere; } } } return str; } // =========================================================== Term[] lres=new Term[1000]; public class FormSelection : Form { // === a small Dialog to do "remove","insert","rename","nop" !!! public string[] strs; public ListBox list; public FormSelection(string[] strstf) { strs=strstf; list=new ListBox(); this.FormBorderStyle=FormBorderStyle.None; list.Location=new Point(0, 0); Controls.Add(list); this.Width=150; list.Width=this.Width; foreach (string str in strstf) { list.Items.Add(str); } list.Height=list.ItemHeight*list.Items.Count+2; this.Height=list.Height; list.SelectedIndexChanged+=new EventHandler(list_SelectedIndexChanged); } // ====================================================================== void list_SelectedIndexChanged (object sender, EventArgs e) { Dispose(); } // ====================================================================== } // ########################################################################## } // ############################# MyTable.cs end ################################### // ############################### Term.cs ################################### using System.Collections.Generic; using System.Windows.Forms; public class Term { public long final; public List files; public string strincidents=""; public Term() { final=0; files=new List(); } // ================================================== public void setfiles(string stra) { int i=0; for ( ; i strings=tostrings(textmultis); long[] llls=new long[strings.Count]; int[] timess=new int[strings.Count]; long laccum=0; for (int i=0; i= ib) {ic-=12; } // 0,1,2 ic = (ic / iinterval); string strb=ib.ToString()+" "+ie.ToString()+" "+id.ToString()+" "+ic.ToString(); laccum += ic*lll; stringa += lll.ToString("n0")+"\r\n"; stringb += strb+"\r\n"; stringc += strc+"\r\n"; } return laccum; } // ================================================= public static List tostrings(string textmultis) { List strings=new List(); string strline=""; for (int i=0; i 0) { try { ib=int.Parse(str.Substring(0, intm)); if (ib < 0 || ib > 12) { ib=0; return false; } } catch { MessageBox.Show("Wrong character for number is used !!!"); return false; } } else { return false; } id=0; if (intt+1 < str.Length) { try { id=int.Parse(str.Substring(intt+1)); } catch { return false; } } try { iinterval = 1; int intb = intm+1; for ( ; intb < str.Length; intb++, iinterval++) { if (str[intb] != '-') { break; } } ie=int.Parse(str.Substring(intb, intt-intb)); } catch { ie=ib; } if (ie <= 0 || ie > 12) { ib=0; ie=0; id=0; return false; } if (ib == 0) { ie=0; id=0; } if (id < 0 || id > 31) {id=0; } return true; } // ================================================= } // ###################################### Term.cs end ######################################### // ######################################## TermForm.cs ########################################## using System; using System.Windows.Forms; using System.Drawing; using System.Collections; public class TermForm : Form { public Point location; public Term term; Button buttonOK, buttonCancel; Button buttonPicture; public ListBox combo; public TextBox textfinalz; public TextBox textmulti, amountmulti, bmountmulti, cmountmulti; Hashtable hash; public string strbase; public TermForm(Term termtf, string strbasetf, string titlex, string titley) { strbase=strbasetf; this.Size=new Size(810,504); this.Text=titlex+" : "+titley; term=termtf; buttonOK=new Button(); buttonCancel=new Button(); buttonOK.SetBounds(10, 10, 50, 20); buttonCancel.SetBounds(70, 10, 50, 20); Controls.Add(buttonOK); Controls.Add(buttonCancel); buttonOK.Text="OK"; buttonCancel.Text="Cancel"; buttonOK.DialogResult=DialogResult.OK; buttonCancel.DialogResult=DialogResult.Cancel; combo=new ListBox(); // === to select receipts !!! combo.SetBounds(130, 10, 650, 90); Controls.Add(combo); combo.SelectedValueChanged+=(o, e) => { if (combo.SelectedItem==null) {return; } string str=combo.SelectedItem.ToString(); string stradded=straddfname(strbase, str); DialogResult dr=callfile(stradded, false); // === to select !!! if (dr==DialogResult.Yes) {combo.Items.Remove(combo.SelectedItem); } }; hash=new Hashtable(); { Label label=new Label(); label.SetBounds(10, 65, 30, 15); label.Text="total"; Controls.Add(label); } textfinalz=new TextBox(); textfinalz.SetBounds(10, 80, 110, 20); textfinalz.TextAlign=HorizontalAlignment.Right; Controls.Add(textfinalz); textfinalz.Enabled=false; buttonPicture=new Button(); buttonPicture.SetBounds(50, 40, 70, 20); buttonPicture.Text="add image"; buttonPicture.Click+=(o, e) => { FileDialog fd=new OpenFileDialog(); fd.FileName=strbase; fd.Filter = "Img files(*.jpg,png,bmp,gif,pdf)" + "|*.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.bmp; *.gif; *.pdf|All files (*.*)|*.*"; DialogResult dr=fd.ShowDialog(); if (dr==DialogResult.OK) { DialogResult dr2=callfile(fd.FileName, true); // === to add !!! if (dr2 == DialogResult.OK) { string strdiffe=strsubfname(fd.FileName, strbase); combo.Items.Add(strdiffe); } } }; Controls.Add(buttonPicture); textfinalz.Text=term.final.ToString("n0"); // int yl=115; { Label label=new Label(); label.SetBounds(10, yl, 70, 15); label.Text="amount"; Controls.Add(label); } { Label label=new Label(); label.SetBounds(90, yl, 70, 15); label.Text="bg ed dy ct"; Controls.Add(label); } { Label label=new Label(); label.SetBounds(170, yl, 105, 15); label.Text="head of comment"; Controls.Add(label); } { Label label=new Label(); label.SetBounds(280, yl, 300, 15); label.Text="amount month(-month)/day comment"; Controls.Add(label); } // int y=130; amountmulti=new TextBox(); amountmulti.SetBounds(10, y, 70, 330); amountmulti.Multiline=true; amountmulti.TextAlign=HorizontalAlignment.Right; amountmulti.Enabled=false; Controls.Add(amountmulti); // bmountmulti=new TextBox(); bmountmulti.SetBounds(90, y, 70, 330); bmountmulti.Multiline=true; bmountmulti.Enabled=false; Controls.Add(bmountmulti); // cmountmulti=new TextBox(); cmountmulti.SetBounds(170, y, 100, 330); cmountmulti.Multiline=true; cmountmulti.Enabled=false; Controls.Add(cmountmulti); // textmulti=new TextBox(); textmulti.SetBounds(280, y, 500, 330); textmulti.AcceptsTab=true; textmulti.Multiline=true; textmulti.TextChanged+=(o, e) => { string stringa, stringb, stringc; long laccum=Term.todoexe(out stringa, out stringb, out stringc, textmulti.Text); amountmulti.Text=stringa; bmountmulti.Text=stringb; cmountmulti.Text=stringc; textfinalz.Text=laccum.ToString("n0"); term.final=laccum; }; Controls.Add(textmulti); } // =================================================== DialogResult callfile(string strName, bool activef) { string fname=strName; string strpost = getPostfix(fname); int w=170, h=0; Form fm=new Form(); fm.BackColor=Color.LightGray; int wd=120, hd=100; try{ Bitmap obj = (Bitmap)Bitmap.FromFile(fname); int wo=obj.Width, ho=obj.Height; if (wh) { wd = 600; hd = 600 * h / w; } else { hd = 600; wd = 600 * w / h; } fm.Size=new Size(wd+17, hd+60); fm.Paint+=(oo,ee) => { Graphics g=ee.Graphics; g.DrawImage(obj, new Rectangle(0, 21, wd, hd)); }; } catch { } Button buttonCancelT=new Button(); buttonCancelT.Text = "Cancel"; buttonCancelT.DialogResult = DialogResult.Cancel; buttonCancelT.SetBounds(wd/2-100, 0, 60, 20); fm.Controls.Add(buttonCancelT); if (activef) { Button buttonOKT=new Button(); buttonOKT.SetBounds(wd/2-30, 0, 60, 20); buttonOKT.DialogResult=DialogResult.OK; buttonOKT.Text="Add"; fm.Controls.Add(buttonOKT); } else { Button buttonDelT=new Button(); buttonDelT.SetBounds(wd/2-30, 0, 60, 20); buttonDelT.DialogResult=DialogResult.Yes; buttonDelT.Text="Remove"; fm.Controls.Add(buttonDelT); } if (strpost == "pdf") { Button buttonShowT= new Button(); buttonShowT.Text = "Show"; buttonShowT.SetBounds(wd/2+40, 0, 60, 20); fm.Controls.Add(buttonShowT); buttonShowT.Click += (o, e) => { System.Diagnostics.Process.Start("EXPLORER.EXE", strName); }; } fm.Activated+=(o, e) => { fm.Location=new Point(this.Location.X+50, this.Location.Y); }; DialogResult dr2=fm.ShowDialog(); return dr2; } // ================================================== string strfl=""; bool usedf=false; protected override void OnActivated (EventArgs e) { if (!usedf) { Location=location; usedf=true; } } // ================================================== Image image=null; protected override void OnPaint (PaintEventArgs e) { Graphics g=e.Graphics; if (strfl != "") { image=Image.FromFile(strfl); g.DrawImage(image,0,0); } } // ================================================== public static string straddfname(string strm, string stradder) { int ctm=0, i; for ( ; ; ) { if (stradder.Substring(0,3) == "..\\") { stradder=stradder.Substring(3); ctm++; } else {break; } } for (i=strm.Length-1; i>=0; i--) { if (strm[i] == '\\' || strm[i] == ':') {ctm--; } if (ctm < 0) {break; } } string stra=strm.Substring(0, i+1)+stradder; return stra; } // =========================================================================== public static string strsubfname(string strs, string strm) { int lens=strs.Length, lenm=strm.Length, lenf=lens; if (lenf>lenm) {lenf=lenm; } int lasti=0; for (int i=0; i