Exemplo n.º 1
0
        /// <summary>
        /// 메모 폼에서 이벤트 발생
        /// </summary>
        /// <param name="type"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        bool memo_occurred_event(DEFINE.EVENTTYPE type, object obj)
        {
            // 메모 폼 Close 시
            if (type == DEFINE.EVENTTYPE.EVENTTYPE_CLOSEMEMO)
            {
                object sender = ((object[])obj)[0];
                Item   item   = (Item)(((object[])obj)[1]);
                bool   isSave = (string)((object[])obj)[2] == "Y" ? true : false;

                if (isSave)
                {
                    saveMemo(item);
                }

                //memoForms.Remove((Form_Memo)sender);
                memoForms.Remove((Form_Memo_RIchText)sender);
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_SAVEMEMO) // 메모 폼 Save 시
            {
                Item item = (Item)obj;
                saveMemo(item);
            }
            return(true);
            //throw new NotImplementedException();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 설정 폼에서 이벤트 발생
        /// </summary>
        /// <param name="type"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        private bool settingForm_occurred_event(DEFINE.EVENTTYPE type, object obj)
        {
            if (type == DEFINE.EVENTTYPE.EVENTTYPE_SAVEMEMODATAPATH) // 메모 Path 지정
            {
                string str_memo_path = (String)obj;
                if (!System.IO.File.Exists(str_memo_path))
                {
                    MessageBox.Show("메모데이터가 해당 경로에 존재하지 않습니다.");
                    return(false);
                }

                XmlDocument memoDoc  = Common.XmlControl.getInstance().xmlLoad(str_memo_path);
                XmlNode     memoNode = memoDoc.SelectSingleNode("//MEMODATA");
                if (memoNode == null)
                {
                    MessageBox.Show("해당 경로 파일은 메모데이터가 아닙니다.");
                    return(false);
                }

                // 메모 폼이 현재 열려있으면 폼을 닫음
                for (int i = memoForms.Count - 1; i >= 0; i--)
                {
                    Item tmpItem = memoForms[i].g_item;
                    memoForms[i].closeForce = true;
                    memoForms[i].Close();
                }

                // 폴더 폼 닫음
                if (mainFolder != null)
                {
                    mainFolder.Close();
                }

                XmlNode settingNode  = configDoc.SelectSingleNode("//SETTING");
                XmlNode memoPathNode = settingNode.SelectSingleNode(String.Format("./{0}", DEFINE.CONFIG_SETTING_MEMODATAPATH));

                memoPathNode.InnerText = str_memo_path;
                DEFINE.MEMO_DATA_PATH  = str_memo_path;

                if (Common.XmlControl.getInstance().xmlSave(configDoc, System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME))
                {
                    configDoc = Common.XmlControl.getInstance().xmlLoad(System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME);
                }

                // 최근메모에 존재하는지 검사 후 저장
                settingForm_occurred_event(DEFINE.EVENTTYPE.EVENTTYPE_SAVE_RECENT_MEMODATAPATH, obj);

                showFormFolder();
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_SAVE_RECENT_MEMODATAPATH)  // 최근 메모 Path 저장
            {
                // 최근 Open한 메모리스트에 존재하는지 검사 후 없으면 추가
                XmlNode     settingNode         = configDoc.SelectSingleNode("//SETTING");
                bool        is_exist            = false;
                XmlNodeList recentMemoPathNodes = settingNode.SelectNodes(String.Format("./{0}", DEFINE.CONFIG_SETTING_RECENT_MEMODATAPATH));
                for (int i = 0; i < recentMemoPathNodes.Count; i++)
                {
                    XmlNode item = recentMemoPathNodes.Item(i);
                    if (item.InnerText == DEFINE.MEMO_DATA_PATH)
                    {
                        is_exist = true;
                        break;
                    }
                }
                if (!is_exist)
                {
                    XmlNode tmpNode = configDoc.CreateNode(XmlNodeType.Element, DEFINE.CONFIG_SETTING_RECENT_MEMODATAPATH, "");
                    tmpNode.InnerText = (String)obj;
                    settingNode.AppendChild(tmpNode);
                    if (Common.XmlControl.getInstance().xmlSave(configDoc, System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME))
                    {
                        configDoc = Common.XmlControl.getInstance().xmlLoad(System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME);
                    }
                }

                // 데이터 및 Setting Form Relaod
                reload_recent_memo_data();
                if (mainSetting != null)
                {
                    mainSetting.reloadForm();
                }
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_DELETE_RECENT_MEMODATAPATH) // 최근 메모 Path 삭제
            {
                int         idx                 = (int)obj;                         // index 순서
                XmlNode     settingNode         = configDoc.SelectSingleNode("//SETTING");
                XmlNodeList RecentMemoPathNodes = settingNode.SelectNodes(String.Format("./{0}", DEFINE.CONFIG_SETTING_RECENT_MEMODATAPATH));
                if (idx < RecentMemoPathNodes.Count)
                {
                    // 노드 삭제
                    XmlNode tmpNode = RecentMemoPathNodes.Item(idx);
                    tmpNode.ParentNode.RemoveChild(tmpNode);

                    // 저장
                    if (Common.XmlControl.getInstance().xmlSave(configDoc, System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME))
                    {
                        configDoc = Common.XmlControl.getInstance().xmlLoad(System.Windows.Forms.Application.StartupPath + "\\" + DEFINE.CONFIG_FILENAME);
                    }
                }
                // 데이터 및 Setting Form Relaod
                reload_recent_memo_data();
                if (mainSetting != null)
                {
                    mainSetting.reloadForm();
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 폴더 폼에서 이벤트 발생
        /// </summary>
        /// <param name="type"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        bool mainFolder_occurred_event(DEFINE.EVENTTYPE type, object obj)
        {
            // 메모 폼 OPEN EVENT 발생
            if (type == DEFINE.EVENTTYPE.EVENTTYPE_LOADMEMO)
            {
                Item item = (Item)obj;
                // 중복 생성 방지
                for (int i = 0; i < memoForms.Count; i++)
                {
                    Item tmpItem = memoForms[i].g_item;
                    if (tmpItem.PATH == item.PATH && tmpItem.TITLE == item.TITLE)
                    {
                        memoForms[i].textBoxFocus();
                        return(true);
                    }
                }

                //Form_Memo memo = new Form_Memo();
                Form_Memo_RIchText memo = new Form_Memo_RIchText();
                memo.g_item        = item;
                memo.ShowInTaskbar = false;
                memo.Show(this);
                memo.occurred_event += memo_occurred_event;

                memoForms.Add(memo);
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_DELETEMEMO)
            {
                Item item = (Item)obj;
                // 메모 폼이 현재 열려있으면 폼을 닫음
                for (int i = memoForms.Count - 1; i >= 0; i--)
                {
                    Item tmpItem = memoForms[i].g_item;
                    if (tmpItem.PATH == item.PATH && tmpItem.TITLE == item.TITLE)
                    {
                        memoForms[i].closeForce = true;
                        memoForms[i].Close();
                        //memoForms.RemoveAt(i);
                        break;
                    }
                }

                XmlDocument xmlDoc   = Common.XmlControl.getInstance().xmlLoad(DEFINE.MEMO_DATA_PATH);
                XmlNode     memoNode = xmlDoc.SelectSingleNode("//MEMODATA");
                String      path     = item.PATH;
                if (path != "/")
                {
                    String[] paths = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < paths.Length; i++)
                    {
                        memoNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_GROUPNAME + "[@name='" + paths[i] + "']");
                    }
                }

                XmlNode targetNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_MEMONAME + "[@name='" + item.TITLE + "']");
                targetNode.ParentNode.RemoveChild(targetNode);

                Common.XmlControl.getInstance().xmlSave(xmlDoc, DEFINE.MEMO_DATA_PATH);
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_DELETEGROUP)
            {
                Item item = (Item)obj;

                // 해당 그룹에 속하는 메모 폼이 현재 열려있으면 폼을 닫음
                for (int i = memoForms.Count - 1; i >= 0; i--)
                {
                    Item tmpItem = memoForms[i].g_item;
                    if (tmpItem.PATH != "/")
                    {
                        String[] paths        = tmpItem.PATH.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                        string   groupPath    = item.PATH + item.TITLE;
                        String[] paths2       = groupPath.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                        bool     isGroupChild = true;
                        for (int j = 0; j < paths2.Length; j++)
                        {
                            if (paths.Length < paths2.Length ? true : paths2[j] != paths[j])
                            {
                                isGroupChild = false;
                                break;
                            }
                        }
                        if (isGroupChild)
                        {
                            //memoForms.Remove(memoForms[i]);
                            memoForms[i].closeForce = true;
                            memoForms[i].Close();
                        }
                    }
                }

                XmlDocument xmlDoc   = Common.XmlControl.getInstance().xmlLoad(DEFINE.MEMO_DATA_PATH);
                XmlNode     memoNode = xmlDoc.SelectSingleNode("//MEMODATA");
                if (item.PATH != "/")
                {
                    string[] paths = item.PATH.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < paths.Length; i++)
                    {
                        memoNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_GROUPNAME + "[@name='" + paths[i] + "']");
                    }
                }
                XmlNode targetNode = memoNode.SelectSingleNode("./" + DEFINE.NODE_GROUPNAME + "[@name='" + item.TITLE + "']");
                targetNode.ParentNode.RemoveChild(targetNode);

                Common.XmlControl.getInstance().xmlSave(xmlDoc, DEFINE.MEMO_DATA_PATH);
            }
            else if (type == DEFINE.EVENTTYPE.EVENTTYPE_RENAME) // 이름 변경 시
            {
                Item   item        = (Item)(((object[])obj)[0]);
                string str_newName = (string)(((object[])obj)[1]);

                renameItem(item, str_newName);
            }
            return(true);
            //throw new NotImplementedException();
        }