home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 October / CMCD1004.ISO / Software / Freeware / Utilitare / DesktopSidebar / Plugins / NotesEditor.DSPACKAGE / Source Code / AddNote.cs next >
Encoding:
Text File  |  2004-07-09  |  10.8 KB  |  338 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Resources;
  7. using DesktopSidebar;
  8.  
  9. namespace NotesEditor
  10. {
  11.     
  12.     public class AddNote : System.Windows.Forms.Form
  13.     {
  14.         private System.Windows.Forms.MenuItem menuItem4;
  15.         private System.Windows.Forms.Button button1;
  16.         private System.Windows.Forms.Label label1;
  17.         private System.Windows.Forms.TextBox txtNote;
  18.         private System.Windows.Forms.Button btnCancel;
  19.         private System.Windows.Forms.ContextMenu contextMenu1;
  20.         private System.Windows.Forms.ComboBox comboBox1;
  21.         private System.Windows.Forms.MenuItem menuItem3;
  22.         private System.Windows.Forms.Button btnOK;
  23.         private System.Windows.Forms.MenuItem menuItem2;
  24.         private System.Windows.Forms.MenuItem menuItem1;
  25.         private ISidebar m_sidebar;
  26.         private string cl;
  27.         private string dicl;
  28.         /// <summary>
  29.         /// Required designer variable.
  30.         /// </summary>
  31.         private System.ComponentModel.Container components = null;
  32.  
  33.         public AddNote(ISidebar sidebar)
  34.         {
  35.             //
  36.             // Required for Windows Form Designer support
  37.             //
  38.         m_sidebar = sidebar;
  39.         InitializeComponent();
  40.             sidebar.GetTranslator().TranslateDialog2(new DialogTranslator(this),"NotesEditor.AddNote");
  41.         }
  42.           public string GetNote()
  43.         {
  44.             return txtNote.Text;
  45.         }
  46.         
  47.            public string icl
  48.         {
  49.             get
  50.             {
  51.             return cl;
  52.             }
  53.         }
  54.  
  55.         public void setdicl(string dicl2)
  56.         {
  57.             dicl=dicl2;
  58.             try
  59.             {
  60.             int ind = this.comboBox1.Items.IndexOf(dicl);
  61.             this.comboBox1.SelectedIndex = ind;
  62.             }
  63.             catch
  64.             {
  65.                 int ind = this.comboBox1.Items.IndexOf(m_sidebar.GetTranslator().TranslateCommand("White"));
  66.                 this.comboBox1.SelectedIndex = ind;
  67.             }
  68.             if(this.comboBox1.SelectedIndex==-1)
  69.             {
  70.                 int ind = this.comboBox1.Items.IndexOf(m_sidebar.GetTranslator().TranslateCommand("White"));
  71.                 this.comboBox1.SelectedIndex = ind;
  72.             }
  73.         }
  74.  
  75.         public void SetNote(string sNote)
  76.         {
  77.             txtNote.Text = sNote;
  78.         }
  79.         
  80.  
  81.         protected override void Dispose( bool disposing )
  82.         {
  83.             if( disposing )
  84.             {
  85.                 if(components != null)
  86.                 {
  87.                     components.Dispose();
  88.                 }
  89.             }
  90.             base.Dispose( disposing );
  91.         }
  92.  
  93.         #region Windows Form Designer generated code
  94.         /// <summary>
  95.         /// Required method for Designer support - do not modify
  96.         /// the contents of this method with the code editor.
  97.         /// </summary>
  98.         private void InitializeComponent() {
  99.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(AddNote));
  100.             this.menuItem1 = new System.Windows.Forms.MenuItem();
  101.             this.menuItem2 = new System.Windows.Forms.MenuItem();
  102.             this.btnOK = new System.Windows.Forms.Button();
  103.             this.menuItem3 = new System.Windows.Forms.MenuItem();
  104.             this.comboBox1 = new System.Windows.Forms.ComboBox();
  105.             this.contextMenu1 = new System.Windows.Forms.ContextMenu();
  106.             this.btnCancel = new System.Windows.Forms.Button();
  107.             this.txtNote = new System.Windows.Forms.TextBox();
  108.             this.label1 = new System.Windows.Forms.Label();
  109.             this.button1 = new System.Windows.Forms.Button();
  110.             this.menuItem4 = new System.Windows.Forms.MenuItem();
  111.             this.SuspendLayout();
  112.             // 
  113.             // menuItem1
  114.             // 
  115.             this.menuItem1.Index = 0;
  116.             this.menuItem1.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem1");
  117.             this.menuItem1.Click += new System.EventHandler(this.menu1Ic);
  118.             // 
  119.             // menuItem2
  120.             // 
  121.             this.menuItem2.Index = 1;
  122.             this.menuItem2.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem2");
  123.             this.menuItem2.Click += new System.EventHandler(this.menu2Ic);
  124.             // 
  125.             // btnOK
  126.             // 
  127.             this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
  128.             this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
  129.             this.btnOK.Location = new System.Drawing.Point(272, 176);
  130.             this.btnOK.Name = "btnOK";
  131.             this.btnOK.TabIndex = 1;
  132.             this.btnOK.Text = "OK";
  133.             this.btnOK.Click += new System.EventHandler(this.BtnOKClick);
  134.             // 
  135.             // menuItem3
  136.             // 
  137.             this.menuItem3.Index = 2;
  138.             this.menuItem3.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem3");
  139.             this.menuItem3.Click += new System.EventHandler(this.menu3Ic);
  140.             // 
  141.             // comboBox1
  142.             // 
  143.             this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  144.             this.comboBox1.Items.AddRange(new object[] {
  145.                         m_sidebar.GetTranslator().TranslateCommand("Black"),
  146.                         m_sidebar.GetTranslator().TranslateCommand("Red"),
  147.                         m_sidebar.GetTranslator().TranslateCommand("Green"),
  148.                         m_sidebar.GetTranslator().TranslateCommand("Yellow"),
  149.                         m_sidebar.GetTranslator().TranslateCommand("Blue"),
  150.                         m_sidebar.GetTranslator().TranslateCommand("Purple"),
  151.                         m_sidebar.GetTranslator().TranslateCommand("Orange"),
  152.                         m_sidebar.GetTranslator().TranslateCommand("White"),
  153.                         m_sidebar.GetTranslator().TranslateCommand("Turquoise")});
  154.             this.comboBox1.Location = new System.Drawing.Point(16, 184);
  155.             this.comboBox1.Name = "comboBox1";
  156.             this.comboBox1.Size = new System.Drawing.Size(104, 21);
  157.             this.comboBox1.TabIndex = 3;
  158.             this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.ComboBox1SelectedIndexChanged);
  159.             // 
  160.             // contextMenu1
  161.             // 
  162.             this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  163.                         this.menuItem1,
  164.                         this.menuItem2,
  165.                         this.menuItem3,
  166.                         this.menuItem4});
  167.             // 
  168.             // btnCancel
  169.             // 
  170.             this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  171.             this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
  172.             this.btnCancel.Location = new System.Drawing.Point(352, 176);
  173.             this.btnCancel.Name = "btnCancel";
  174.             this.btnCancel.TabIndex = 2;
  175.             this.btnCancel.Text = "Cancel";
  176.             // 
  177.             // txtNote
  178.             // 
  179.             this.txtNote.Location = new System.Drawing.Point(8, 8);
  180.             this.txtNote.Multiline = true;
  181.             this.txtNote.Name = "txtNote";
  182.             this.txtNote.Size = new System.Drawing.Size(424, 160);
  183.             this.txtNote.TabIndex = 0;
  184.             this.txtNote.Text = "";
  185.             this.txtNote.WordWrap = false;
  186.             this.txtNote.ScrollBars = System.Windows.Forms.ScrollBars.Both;
  187.             // 
  188.             // label1
  189.             // 
  190.             this.label1.Location = new System.Drawing.Point(32, 168);
  191.             this.label1.Name = "label1";
  192.             this.label1.Size = new System.Drawing.Size(64, 16);
  193.             this.label1.TabIndex = 4;
  194.             this.label1.Text = "Text Color:";
  195.             // 
  196.             // button1
  197.             // 
  198.             this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
  199.             this.button1.Location = new System.Drawing.Point(128, 176);
  200.             this.button1.Name = "button1";
  201.             this.button1.TabIndex = 5;
  202.             this.button1.Text = "Options";
  203.             this.button1.Click += new System.EventHandler(this.Button1Click);
  204.             // 
  205.             // menuItem4
  206.             // 
  207.             this.menuItem4.Index = 3;
  208.             this.menuItem4.Text = m_sidebar.GetTranslator().TranslateCommand("menuItem4");
  209.             this.menuItem4.Click += new System.EventHandler(this.menu4Ic);
  210.             // 
  211.             // AddNote
  212.             // 
  213.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  214.             this.ClientSize = new System.Drawing.Size(442, 208);
  215.             this.Controls.Add(this.button1);
  216.             this.Controls.Add(this.label1);
  217.             this.Controls.Add(this.comboBox1);
  218.             this.Controls.Add(this.btnCancel);
  219.             this.Controls.Add(this.btnOK);
  220.             this.Controls.Add(this.txtNote);
  221.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  222.             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
  223.             this.Name = "AddNote";
  224.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  225.             this.Text = "Add a Note";
  226.             this.Load += new System.EventHandler(this.AddNoteLoad);
  227.             this.ResumeLayout(false);
  228.         }
  229.         #endregion
  230.     
  231.  
  232.     
  233.     void ComboBox1SelectedIndexChanged(object sender, System.EventArgs e)
  234.     {
  235.             this.cl= this.comboBox1.SelectedItem.ToString();    
  236.     }
  237.     
  238.     void AddNoteLoad(object sender, System.EventArgs e)
  239.     {
  240.         this.setdicl(dicl);
  241.     }
  242.     
  243.     
  244.     void BtnOKClick(object sender, System.EventArgs e)
  245.     {
  246.         this.cl = this.comboBox1.SelectedItem.ToString();
  247.     }
  248.     
  249.     void Button1Click(object sender, System.EventArgs e)
  250.     {
  251.         contextMenu1.Show(this, button1.Location);
  252.     }
  253.     
  254.     void menu1Ic(object sender, System.EventArgs e)
  255.     {
  256.         string hour = DateTime.Now.Hour.ToString();
  257.         if(hour.Length<2)
  258.         {
  259.             hour=String.Concat("0",DateTime.Now.Hour.ToString());
  260.         }
  261.         string minute = DateTime.Now.Minute.ToString();
  262.         if(minute.Length<2)
  263.         {
  264.             minute=String.Concat("0",DateTime.Now.Minute.ToString());
  265.         }
  266.         string second = DateTime.Now.Second.ToString();
  267.         if(second.Length<2)
  268.         {
  269.             second=String.Concat("0",DateTime.Now.Second.ToString());
  270.         }
  271.         int temper = txtNote.SelectionStart;
  272.         string temper2 = txtNote.Text;
  273.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  274.         string temper4 = temper2.Remove(0,temper);
  275.         string temper5 = temper3 + hour+":"+minute+":"+second + temper4;
  276.         this.txtNote.Text = temper5;
  277.     }
  278.     void menu2Ic(object sender, System.EventArgs e)
  279.     {
  280.         string hour = DateTime.Now.Hour.ToString();
  281.         if(hour.Length<2)
  282.         {
  283.             hour=String.Concat("0",DateTime.Now.Hour.ToString());
  284.         }
  285.         string minute = DateTime.Now.Minute.ToString();
  286.         if(minute.Length<2)
  287.         {
  288.             minute=String.Concat("0",DateTime.Now.Minute.ToString());
  289.         }
  290.         int temper = txtNote.SelectionStart;
  291.         string temper2 = txtNote.Text;
  292.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  293.         string temper4 = temper2.Remove(0,temper);
  294.         string temper5 = temper3 + hour+":"+minute + temper4;
  295.     this.txtNote.Text = temper5 ;
  296.     }
  297.     void menu3Ic(object sender, System.EventArgs e)
  298.     {
  299.         string day = DateTime.Now.Day.ToString();
  300.         if(day.Length<2)
  301.         {
  302.             day=String.Concat("0",DateTime.Now.Day.ToString());
  303.         }
  304.         string month = DateTime.Now.Month.ToString();
  305.         if(month.Length<2)
  306.         {
  307.             month=String.Concat("0",DateTime.Now.Month.ToString());
  308.         }
  309.     int temper = txtNote.SelectionStart;
  310.         string temper2 = txtNote.Text;
  311.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  312.         string temper4 = temper2.Remove(0,temper);
  313.         string temper5 = temper3 + day+"/"+month+"/"+DateTime.Now.Year + temper4;
  314.         this.txtNote.Text = temper5;
  315.     }
  316.     void menu4Ic(object sender, System.EventArgs e)
  317.     {
  318.         string day = DateTime.Now.Day.ToString();
  319.         if(day.Length<2)
  320.         {
  321.             day=String.Concat("0",DateTime.Now.Day.ToString());
  322.         }
  323.         string month = DateTime.Now.Month.ToString();
  324.         if(month.Length<2)
  325.         {
  326.             month=String.Concat("0",DateTime.Now.Month.ToString());
  327.         }
  328.         int temper = txtNote.SelectionStart;
  329.         string temper2 = txtNote.Text;
  330.         string temper3 = temper2.Remove(temper,temper2.Length-temper);
  331.         string temper4 = temper2.Remove(0,temper);
  332.         string temper5 = temper3 + month+"/"+day+"/"+DateTime.Now.Year + temper4;
  333.         this.txtNote.Text = temper5;
  334.     }
  335.     
  336.     }
  337. }
  338.