Пример #1
0
        private int AddItem()
        {
            try
            {
                // ToDo
                // Add 버튼 클릭시 추가하는게 텍스트인지 이미지인지

                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                ClipboardInfo     clipboardInfo     = new ClipboardInfo();
                clipboardInfo.CONTENTSTYPE = ContentsType.Text;
                clipboardInfo.COPIEDTIME   = (DateTime.Now).ToString();
                clipboardInfoList.Insert(0, clipboardInfo);

                // Focusing
                this.grdView.FocusedRowHandle = 0;

                return(clipboardInfoList.Count);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                               ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return(0);
            }
        }
Пример #2
0
        /// <summary>
        /// Load Button Click
        /// </summary>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title  = "Open File";
                openFileDialog.Filter = "XML File(*.xml)|*.xml";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    this.grdCtrl.DataSource = null;
                    this.hotKeyInfoList.ResetHotKey();

                    DataSet ds = new DataSet();
                    ds.ReadXml(openFileDialog.FileName);

                    ClipboardInfoList clipboardInfoList = new ClipboardInfoList();
                    clipboardInfoList       = clipboardInfoList.SetDataTable(ds.Tables[0]);
                    this.grdCtrl.DataSource = clipboardInfoList;

                    foreach (ClipboardInfo clipboardInfo in clipboardInfoList)
                    {
                        this.SetShortcutKey(clipboardInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                               ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #3
0
        private void MoveDown()
        {
            try
            {
                int[] rowhandle = this.grdView.GetSelectedRows();

                if (rowhandle != null && rowhandle.Length == 1)
                {
                    this.grdView.BeginUpdate();
                    ClipboardInfoList list = this.grdView.DataSource as ClipboardInfoList;

                    if (rowhandle[0] < list.Count - 1)
                    {
                        this.SwapAfter(list, rowhandle[0]);
                        this.grdView.SelectRow(rowhandle[0] + 1);
                        this.grdView.FocusedRowHandle = rowhandle[0] + 1;
                    }
                    this.grdView.EndUpdate();
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #4
0
        /// <summary>
        /// Set global hotkey
        /// </summary>
        private void SetShortcutKey(ClipboardInfo selectedInfo)
        {
            try
            {
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                HotKeyInfo        hkInfo            = new HotKeyInfo();

                if (selectedInfo != null)
                {
                    string hotkey    = selectedInfo.SHORTKEY;
                    string hotkeyNum = hotkey.Substring(hotkey.LastIndexOf("+") + 1);
                    bool   ctrl      = hotkey.Contains("Ctrl");
                    bool   alt       = hotkey.Contains("Alt");
                    bool   shift     = hotkey.Contains("Shift");

                    // setting global hotKey
                    Keys key = Keys.None;
                    switch (hotkeyNum)
                    {
                    case "1": key = Keys.D1; break;

                    case "2": key = Keys.D2; break;

                    case "3": key = Keys.D3; break;

                    case "4": key = Keys.D4; break;

                    case "5": key = Keys.D5; break;

                    case "6": key = Keys.D6; break;

                    case "7": key = Keys.D7; break;

                    case "8": key = Keys.D8; break;

                    case "9": key = Keys.D9; break;

                    case "0": key = Keys.D0; break;

                    default: break;
                    }

                    Hotkey hk = this.SetHotKey(key, shift, ctrl, alt, false, selectedInfo);
                    if (hk == null)
                    {
                        return;
                    }

                    hkInfo.HOTKEY     = hk;
                    hkInfo.HOTKEYNAME = hotkey;
                    hotKeyInfoList.Add(hkInfo);
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #5
0
        /// <summary>
        /// 트레이 컨텍스트 메뉴 - 리스트 삭제 버튼
        /// </summary>
        private void trayMenu_DelList_Click(object sender, EventArgs e)
        {
            try
            {
                this.trayMenu_ShowList.DropDownItems.Clear();

                ClipboardInfoList list = this.GetClipboardInfoList;
                list.Clear();
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #6
0
        private void SwapAfter(ClipboardInfoList list, int index)
        {
            try
            {
                if (index == list.Count - 1)
                {
                    return;
                }

                ClipboardInfo temp = list[index + 1];
                list[index + 1] = list[index];
                list[index]     = temp;
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #7
0
        public int AddData()
        {
            try
            {
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;

                // 리스트에 이미 포함되어 있을때 다시 추가하지 않음
                foreach (ClipboardInfo info in clipboardInfoList)
                {
                    if (info.CONTENTS == Clipboard.GetText())
                    {
                        return(clipboardInfoList.Count);
                    }
                }

                ClipboardInfo clipboardInfo = new ClipboardInfo();
                if (Clipboard.ContainsText()) // if the copied object is a text
                {
                    ConsoleLib.ConsoleLib.WriteFormatted("Copy: " + Clipboard.GetText(), ConsoleLib.ConsoleLib.ConsoleAttributes.ForegroundGreen);
                    clipboardInfo.CONTENTS     = Clipboard.GetText();
                    clipboardInfo.CONTENTSTYPE = ContentsType.Text;
                }
                else if (Clipboard.ContainsImage()) // if the copied object is an image
                {
                    clipboardInfo.CONTENTS     = " ** Copying an image is not supported. **";
                    clipboardInfo.CONTENTSTYPE = ContentsType.Image;
                }

                clipboardInfo.COPIEDTIME = (DateTime.Now).ToString();
                clipboardInfoList.Insert(0, clipboardInfo);

                // Focusing
                this.grdView.FocusedRowHandle = 0;

                return(clipboardInfoList.Count);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return(0);
            }
        }
Пример #8
0
        private void hk_Pressed0(object sender, HandledEventArgs e)
        {
            try
            {
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                ClipboardInfo     clipboardInfo     = clipboardInfoList.FindClipboardInfoByIndex(10);
                if (clipboardInfo == null)
                {
                    return;
                }

                Clipboard.SetText(clipboardInfo.CONTENTS);
                SendKeys.SendWait("^v");
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #9
0
        private int DeleteItem()
        {
            try
            {
                ClipboardInfo clipboardInfo = this.GetClipboardInfoByRowHandle(this.grdView.FocusedRowHandle);
                if (clipboardInfo != null)
                {
                    this.DelHotKey(clipboardInfo.SHORTKEY);
                }
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                clipboardInfoList.Remove(clipboardInfo);

                return(clipboardInfoList.Count);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return(0);
            }
        }
Пример #10
0
        /// <summary>
        /// Save Button
        /// </summary>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.OverwritePrompt = true;
                saveFileDialog.ValidateNames   = true;
                saveFileDialog.FileName        = "CtrlCVMaster_SavedClipboard.xml";
                saveFileDialog.Filter          = "XML File(*.xml)|*.xml";

                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                {
                    ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                    DataTable         dt = clipboardInfoList.GetDataTable();
                    dt.WriteXml(saveFileDialog.FileName);
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #11
0
        /// <summary>
        /// Check whether the shortcut key is already being used
        /// </summary>
        private bool CheckShortKeyDuplicate(string key)
        {
            try
            {
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;

                foreach (ClipboardInfo info in clipboardInfoList)
                {
                    if (info.SHORTKEY.Equals(key))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
                return(false);
            }
        }
Пример #12
0
        /// <summary>
        /// 트레이 컨텍스트 메뉴 - 리스트 보기 펼쳐질때 발생
        /// </summary>
        private void trayMenu_ShowList_DropDownOpening(object sender, EventArgs e)
        {
            try
            {
                int listNum = 0;
                this.trayMenu_ShowList.DropDownItems.Clear();
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                if (clipboardInfoList.Count == 0)
                {
                    this.trayMenu_ShowList.DropDownItems.Add("Empty");
                }
                else
                {
                    foreach (ClipboardInfo info in clipboardInfoList)
                    {
                        this.trayMenu_ShowList.DropDownItems.Add(info.CONTENTS);

                        if (info.CONTENTSTYPE == ContentsType.Text)
                        {
                            this.trayMenu_ShowList.DropDownItems[listNum].Image = ((System.Drawing.Image)(this.imgResource.GetObject("trayMenu_Text.Image")));
                        }
                        else if (info.CONTENTSTYPE == ContentsType.Image)
                        {
                            // 이미지 아이콘 표시
                        }

                        listNum++;
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #13
0
        private void SwapBefore(ClipboardInfoList list, int index)
        {
            try
            {
                if (index == 0)
                    return;

                ClipboardInfo temp = list[index - 1];
                list[index - 1] = list[index];
                list[index] = temp;
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #14
0
        /// <summary>
        /// 단축키 설정 확인 버튼
        /// </summary>
        private void btn_ShortCutOk_Click(object sender, EventArgs e)
        {
            try
            {
                ClipboardInfoList clipboardInfoList = this.GetClipboardInfoList;
                ClipboardInfo     selectedInfo      = this.GetClipboardInfoByRowHandle(this.grdView.FocusedRowHandle);

                if (selectedInfo != null)
                {
                    if (this.chkBox_Ctrl.Checked || this.chkBox_Alt.Checked) // Ctrl or Alt CheckBox is checked.
                    {
                        if (this.comboBoxEdit_Keys.Text.Length > 0)          // Key number is selected.
                        {
                            string shortCutKey = "";

                            if (this.chkBox_Ctrl.Checked)
                            {
                                shortCutKey = "Ctrl+";
                            }
                            if (this.chkBox_Alt.Checked)
                            {
                                shortCutKey += "Alt+";
                            }
                            if (this.chkbox_shift.Checked)
                            {
                                shortCutKey += "Shift+";
                            }

                            shortCutKey += this.comboBoxEdit_Keys.Text;

                            if (this.CheckShortKeyDuplicate(shortCutKey))
                            {
                                selectedInfo.SHORTKEY = shortCutKey;
                                selectedInfo.INDEX    = clipboardInfoList.GetNextIndex();

                                this.SetShortcutKey(selectedInfo);

                                this.grdView.RefreshRow(this.grdView.FocusedRowHandle);
                            }
                            else
                            {
                                MessageBox.Show("Shortcut Key [" + shortCutKey + "] is already being used.", "WARNING");
                            }
                        }
                        else
                        {
                            MessageBox.Show("To set a shortcut key, key number must be selected.", "WARNING");
                        }
                    }
                    else
                    {
                        MessageBox.Show("To set a shortcut key, at least one of Ctrl or Alt key must be checked.", "WARNING");
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                    ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #15
0
        /// <summary>
        /// Load Button Click
        /// </summary>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title = "Open File";
                openFileDialog.Filter = "XML File(*.xml)|*.xml";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    this.grdCtrl.DataSource = null;
                    this.hotKeyInfoList.ResetHotKey();

                    DataSet ds = new DataSet();
                    ds.ReadXml(openFileDialog.FileName);

                    ClipboardInfoList clipboardInfoList = new ClipboardInfoList();
                    clipboardInfoList = clipboardInfoList.SetDataTable(ds.Tables[0]);
                    this.grdCtrl.DataSource = clipboardInfoList;

                    foreach (ClipboardInfo clipboardInfo in clipboardInfoList)
                    {
                        this.SetShortcutKey(clipboardInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                ConsoleLib.ConsoleLib.WriteFormatted(ex.ToString() + "                               ", t);
                ConsoleLib.ConsoleLib.WriteLine(Environment.NewLine);
            }
        }
Пример #16
0
 private void SetData()
 {
     ClipboardInfoList clipboardInfoList = new ClipboardInfoList();
     this.grdCtrl.DataSource = clipboardInfoList;
 }
Пример #17
0
        private void SetData()
        {
            ClipboardInfoList clipboardInfoList = new ClipboardInfoList();

            this.grdCtrl.DataSource = clipboardInfoList;
        }