Ejemplo n.º 1
0
        /// <summary>
        /// 字体选中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem2_Click(object sender, EventArgs e)
        {
            try
            {
                int sel = Convert.ToInt32((sender as ToolStripMenuItem).Tag.ToString());
                if (this._KHNode.FontSize != sel)
                {
                    this._KHNode.FontSize   = sel;
                    this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    new KHNodeService().Update(this._KHNode);

                    //改变选中对象
                    ToolStripMenuItem item = null;
                    for (int i = 0; i < this.tsmSize.DropDownItems.Count; i++)
                    {
                        item = this.tsmSize.DropDownItems[i] as ToolStripMenuItem;
                        if (item.Name == "FontSizeMenuItem" + sel)
                        {
                            item.Checked    = true;
                            item.CheckState = System.Windows.Forms.CheckState.Checked;
                        }
                        else
                        {
                            item.Checked    = false;
                            item.CheckState = System.Windows.Forms.CheckState.Unchecked;
                        }
                    }

                    //设置
                    DuiTextBox txtBox = this.lblContent.DUIControls[0] as DuiTextBox;
                    if (txtBox != null)
                    {
                        FontStyle fontStyle = this._KHNode.Bold == 1 ? FontStyle.Bold : FontStyle.Italic;
                        txtBox.Font = new System.Drawing.Font(this._KHNode.FontName, sel, fontStyle, GraphicsUnit.Point);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
        }
Ejemplo n.º 2
0
 private void TxtBox_FocusedChanged(object sender, EventArgs e)
 {
     try
     {
         string txt = (sender as DuiTextBox).Text;
         if (!this._KHNode.Content.Equals(txt))
         {
             this._KHNode.Width      = this.Size.Width;
             this._KHNode.Height     = this.Size.Height;
             this._KHNode.LocationX  = this.Location.X;
             this._KHNode.LocationY  = this.Location.Y;
             this._KHNode.Content    = txt;
             this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             new KHNodeService().Update(this._KHNode);
         }
     }
     catch (Exception ex)
     {
         CommonMethod.WriteLogErr(ex.Message);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载便签
        /// </summary>
        public void LoadNodeList()
        {
            try
            {
                List <KHNode> lst = new KHNodeService().GetList();
                foreach (KHNode node in lst)
                {
                    if (string.IsNullOrEmpty(node.Content))
                    {
                        continue;
                    }

                    frmNode fmNode = new frmNode(node);
                    fmNode.Show();
                }
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 颜色选中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem3_Click(object sender, EventArgs e)
        {
            try
            {
                string sel = (sender as ToolStripMenuItem).Tag.ToString();
                if (sel != this._KHNode.FontColor)
                {
                    this._KHNode.FontColor  = sel;
                    this._KHNode.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    new KHNodeService().Update(this._KHNode);
                    //改变选中对象
                    ToolStripMenuItem item = null;
                    for (int i = 0; i < this.tmsColor.DropDownItems.Count; i++)
                    {
                        item = this.tmsColor.DropDownItems[i] as ToolStripMenuItem;
                        if (item.Name == "FontColorMenuItem" + sel)
                        {
                            item.Checked    = true;
                            item.CheckState = System.Windows.Forms.CheckState.Checked;
                        }
                        else
                        {
                            item.Checked    = false;
                            item.CheckState = System.Windows.Forms.CheckState.Unchecked;
                        }
                    }

                    //设置
                    DuiTextBox txtBox = this.lblContent.DUIControls[0] as DuiTextBox;
                    if (txtBox != null)
                    {
                        txtBox.ForeColor = Color.FromName(sel);
                    }
                }
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
        }
Ejemplo n.º 5
0
        public SQLiteConnection GetSQLiteConnection()
        {
            SQLiteConnection mySQLiteConnection = new SQLiteConnection();

            try
            {
                string file = AppDomain.CurrentDomain.BaseDirectory + "khope.db";
                if (!Directory.Exists(file.Substring(0, file.LastIndexOf("\\"))))
                {
                    Directory.CreateDirectory(file.Substring(0, file.LastIndexOf("\\")));
                }
                if (!File.Exists(file)) //判断数据库文件是否存在
                {
                    SQLiteConnection.CreateFile(file);
                }

                mySQLiteConnection = new SQLiteConnection("Data Source = " + file + ";Pooling=true;FailIfMissing=false;Version=3;");
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
            return(mySQLiteConnection);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 创建表
        /// </summary>
        public void Create()
        {
            SQLiteHelper     sqliteHelper = new SQLiteHelper();
            SQLiteConnection conn         = sqliteHelper.GetSQLiteConnection();

            try
            {
                conn.Open();
                bool          isExists = false;
                StringBuilder sbSql    = new StringBuilder();

                #region kh_user

                isExists = TableExists(sqliteHelper, conn, "kh_user");
                if (!isExists)
                {
                    sbSql.Append("create table kh_user([id] integer not null,[user_id] nvarchar(50),[user_name] nvarchar(50),[pass_word] nvarchar(50),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region kh_node

                isExists = TableExists(sqliteHelper, conn, "kh_node");
                if (!isExists)
                {
                    sbSql.Append("create table kh_node([id] integer not null,[width] int,[height] int,[location_x] int,[location_y] int,[font_name] nvarchar(50),[bold] int,[font_size] int,[font_color] nvarchar(50),[content] nvarchar(500),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region kh_param

                isExists = TableExists(sqliteHelper, conn, "kh_param");
                if (!isExists)
                {
                    sbSql.Append("create table kh_param([id] integer not null,[name] nvarchar(50),[value] nvarchar(200),[description] nvarchar(200),[enabled] int,[create_date] nvarchar(50),[update_date] nvarchar(50), Primary Key(id) on conflict abort);");
                }
                #endregion

                #region 事务提交脚本
                if (sbSql.Length > 0)
                {
                    SQLiteTransaction transaction = null;
                    try
                    {
                        transaction = conn.BeginTransaction();
                        sqliteHelper.ExecuteSql(conn, sbSql.ToString());
                        transaction.Commit(); //提交
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        CommonMethod.WriteLogErr(ex.Message);
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Dispose();
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                CommonMethod.WriteLogErr(ex.Message);
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 非UI线程异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     CommonMethod.WriteLogErr(e.Exception.Message + "\r\n" + e.Exception.StackTrace);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// UI线程异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     CommonMethod.WriteLogErr(e.ExceptionObject.ToString());
 }