예제 #1
0
        private void descriptionMnuItem_Click(object sender, EventArgs e)
        {
            InputForm dlg = new InputForm();

            dlg.Text      = "檔案敘述";
            dlg.desc.Text = "請輸入檔案敘述";
            if (File.Exists(Program.GetDescriptionFileFullPath()))
            {
                XmlDocument desc = new XmlDocument();
                desc.Load(Program.GetDescriptionFileFullPath());
                XmlNode files = desc.SelectSingleNode(@"Files/" + Program.projectFileName);
                if (files != null)
                {
                    XmlElement element = (XmlElement)files;
                    dlg.inputTxt.Text = element.GetAttribute("Text");
                }
            }
            else
            {
                dlg.inputTxt.Text = "";
            }
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }
            if (File.Exists(Program.GetDescriptionFileFullPath()))
            {   //更新說明檔
                XmlDocument desc = new XmlDocument();
                desc.Load(Program.GetDescriptionFileFullPath());
                XmlNode    files = desc.SelectSingleNode(@"Files"); //選擇節點
                XmlElement f     = files.SelectSingleNode(Program.projectFileName) as XmlElement;
                if (f != null)
                {   //更新欄位
                    f.SetAttribute("Text", dlg.inputTxt.Text);
                }
                else
                {   //新增欄位
                    XmlElement f2 = desc.CreateElement(Program.projectFileName);
                    f2.SetAttribute("Text", dlg.inputTxt.Text);
                    files.AppendChild(f2);
                }
                desc.Save(Program.GetDescriptionFileFullPath());
            }
            else
            {                                                    //建立說明檔
                XmlDocument doc   = new XmlDocument();
                XmlNode     files = doc.CreateElement(@"Files"); //選擇節點
                doc.AppendChild(files);
                XmlElement description = doc.CreateElement(Program.projectFileName);
                description.SetAttribute("Text", dlg.inputTxt.Text);    //設定屬性
                files.AppendChild(description);
                doc.Save(Program.GetDescriptionFileFullPath());
            }
        }
예제 #2
0
 private void descriptionMnuItem_Click(object sender, EventArgs e)
 {
     InputForm dlg = new InputForm();
     dlg.Text = "檔案敘述";
     dlg.desc.Text = "請輸入檔案敘述";
     if (File.Exists(Program.GetDescriptionFileFullPath()))
     {
         XmlDocument desc = new XmlDocument();
         desc.Load(Program.GetDescriptionFileFullPath());
         XmlNode files = desc.SelectSingleNode(@"Files/" + Program.projectFileName);
         if (files != null)
         {
             XmlElement element = (XmlElement)files;
             dlg.inputTxt.Text = element.GetAttribute("Text");
         }
     }
     else
     {
         dlg.inputTxt.Text = "";
     }
     if (DialogResult.OK != dlg.ShowDialog())
     {
         return;
     }
     if (File.Exists(Program.GetDescriptionFileFullPath()))
     {   //更新說明檔
         XmlDocument desc = new XmlDocument();
         desc.Load(Program.GetDescriptionFileFullPath());
         XmlNode files = desc.SelectSingleNode(@"Files");    //選擇節點
         XmlElement f = files.SelectSingleNode(Program.projectFileName) as XmlElement;
         if (f != null)
         {   //更新欄位
             f.SetAttribute("Text", dlg.inputTxt.Text);
         }
         else
         {   //新增欄位
             XmlElement f2 = desc.CreateElement(Program.projectFileName);
             f2.SetAttribute("Text", dlg.inputTxt.Text);
             files.AppendChild(f2);
         }
         desc.Save(Program.GetDescriptionFileFullPath());
     }
     else
     {   //建立說明檔
         XmlDocument doc = new XmlDocument();
         XmlNode files = doc.CreateElement(@"Files");//選擇節點
         doc.AppendChild(files);
         XmlElement description = doc.CreateElement(Program.projectFileName);
         description.SetAttribute("Text", dlg.inputTxt.Text);    //設定屬性
         files.AppendChild(description);
         doc.Save(Program.GetDescriptionFileFullPath());
     }
 }
예제 #3
0
        private void descriptionMnuItem_Click(object sender, EventArgs e)
        {
            InputForm dlg = new InputForm();

            dlg.Text      = "案例敘述";
            dlg.desc.Text = "請輸入案例敘述";

            if (File.Exists(Program.GetDescriptionFileFullPath()))
            {
                if (Program.GetDescriptionFileVersion() != Utility.GetDescriptXMLVersion(Program.GetDescriptionFileFullPath()))
                {   //XML版本不符合則刪除重建
                    Utility.DeleteFileOrFolder(Program.GetDescriptionFileFullPath());
                    dlg.inputTxt.Text = "";
                }
                else
                {   //尋找已存在之敘述,找不到傳回空字串
                    dlg.inputTxt.Text = Utility.GetDescriptionText(Program.GetDescriptionFileFullPath(), Program.projectFileName);
                }
            }
            else
            {
                dlg.inputTxt.Text = "";
            }

            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }

            if (File.Exists(Program.GetDescriptionFileFullPath()))
            {   //更新說明檔
                bool b = Utility.UpdateDescriptionText(Program.GetDescriptionFileFullPath(), Program.projectFileName, dlg.inputTxt.Text);
            }
            else
            {   //建立說明檔
                bool b = Utility.CreateDescriptionText(Program.GetDescriptionFileFullPath(), Program.projectFileName, dlg.inputTxt.Text);
            }
        }
예제 #4
0
        public static void FillSelectedValue(DataGridView v)
        {
            InputForm dlg = new InputForm();

            dlg.Text          = "填入數值";
            dlg.desc.Text     = "請輸入數值";
            dlg.inputTxt.Text = "";
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return;
            }
            if (dlg.inputTxt.Text.Length > 0)
            {
                foreach (DataGridViewCell c in v.SelectedCells)
                {
                    if (c == null || c.ReadOnly)
                    {
                        continue;
                    }
                    c.Value = dlg.inputTxt.Text;
                }
            }
        }
예제 #5
0
        public static bool NewProjectFile(IWin32Window w, string projectPath)
        {
            //FindNewProjectName(projectFolder);
            InputForm dlg = new InputForm();

            dlg.Text          = "新增檔案";
            dlg.desc.Text     = "請輸入檔案名稱";
            dlg.inputTxt.Text = FindNewProjectFileName(projectPath);
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return(false);
            }

            if (System.IO.Directory.Exists(projectPath + "\\" + dlg.inputTxt.Text))
            {
                MessageBox.Show("此檔案已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            try
            {
                Program.projectFileName        = dlg.inputTxt.Text;
                RiverSimulationProfile.profile = new RiverSimulationProfile();
                SaveProject(RiverSimulationProfile.profile);
            }
            catch (Exception)
            {
                MessageBox.Show("無法建立檔案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            //RiverSimulationProfile.profile = new RiverSimulationProfile();
            //Program.projectFolder = Program.documentPath + "\\" + dlg.inputTxt.Text;
            //Program.SaveDefaultProjectFolder();
            return(true);
        }
예제 #6
0
        private void mapPicBox_SelectedGroupChangedEvent(List <Point> pl)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;
            int index = listBox.SelectedIndex;

            if (onlySelectMode)
            {
                InputForm dlg = new InputForm();
                dlg.Text          = "填入數值";
                dlg.desc.Text     = "請輸入數值";
                dlg.inputTxt.Text = "";
                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return;
                }
                selectedPl        = new List <Point>(pl);
                selectedValue     = dlg.inputTxt.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
                return;
            }


            int type = -1, count = 0;

            StructureSetUtility.CalcTypeCount(index, ref type, ref count, typeIndex);

            //檢查連續
            if (!StructureSetUtility.IsContinuous(pl))
            {
                UpdateSelectedGroup(pl, true);
                MessageBox.Show("請圈選連續區域!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                UpdateSelectedGroup(null);
                return;
            }

            //檢查重疊
            for (int n = 0; n < StructureTypeNumber; ++n)
            {
                bool overlapping = false;
                switch (n)
                {
                case 0:
                    overlapping = CheckOverlapping(pl, p.tBarSets, (n == type) ? count : -1);
                    break;

                case 1:
                    overlapping = CheckOverlapping(pl, p.bridgePierSets, (n == type) ? count : -1);
                    break;

                case 2:
                    overlapping = CheckOverlapping(pl, p.groundsillWorkSets, (n == type) ? count : -1);
                    break;

                case 3:
                    overlapping = CheckOverlapping(pl, p.sedimentationWeirSets, (n == type) ? count : -1);
                    break;

                default:
                    break;
                }
                if (!overlapping)
                {
                    return;
                }
            }

            //最後確認 [20141121]更新客製化需求 回報問題 新增規格
            if (DialogResult.OK == MessageBox.Show("請確認以此次圈選範圍取代原先資料。", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.None))
            {
                UpdateSelectedGroup(pl);
            }
            //StructureSetUtility.EditBottomElevation(p, "編輯" + structureName[type] + (1 + count).ToString() + "高程", type, count);
            //if (StructureSetUtility.IsOverlapping(rg, pl, index))
            //{
            //    UpdateSelectedGroup(pl, true);
            //    if (DialogResult.Yes == MessageBox.Show("圈選到重覆區域,是否刪減重複範圍(選「否」將放棄此次圈選)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
            //    {
            //        StructureSetUtility.RemoveOverlapping(ref pl, rg, index);
            //        if (!StructureSetUtility.IsContinuous(pl))
            //        {
            //            UpdateSelectedGroup(pl, true);
            //            MessageBox.Show("刪減後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //            UpdateSelectedGroup(null);
            //            return;
            //        }
            //    }
            //    else
            //    {
            //        UpdateSelectedGroup(null);
            //        return;
            //    }
            //}

            //UpdateSelectedGroup(pl);
        }
예제 #7
0
파일: Utility.cs 프로젝트: alcor0/ResedUI
        public static bool NewProjectFile(IWin32Window w, string projectPath)
        {
            //FindNewProjectName(projectFolder);
            InputForm dlg = new InputForm();
            dlg.Text = "新增檔案";
            dlg.desc.Text = "請輸入檔案名稱";
            dlg.inputTxt.Text = FindNewProjectFileName(projectPath);
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return false;
            }

            if (System.IO.Directory.Exists(projectPath + "\\" + dlg.inputTxt.Text))
            {
                MessageBox.Show("此檔案已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            try
            {
                Program.projectFileName = dlg.inputTxt.Text;
                RiverSimulationProfile.profile = new RiverSimulationProfile();
                SaveProject(RiverSimulationProfile.profile);
            }
            catch (Exception)
            {
                MessageBox.Show("無法建立檔案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            //RiverSimulationProfile.profile = new RiverSimulationProfile();
            //Program.projectFolder = Program.documentPath + "\\" + dlg.inputTxt.Text;
            //Program.SaveDefaultProjectFolder();
            return true;
        }
예제 #8
0
파일: Utility.cs 프로젝트: alcor0/ResedUI
        public static bool NewProject(IWin32Window w)
        {
            FolderBrowserDialog folderOpen = new FolderBrowserDialog();
            RiverSimulationApplication.Properties.Settings s = RiverSimulationApplication.Properties.Settings.Default;
            folderOpen.ShowNewFolderButton = false;
            if (s.DefaultOpenProjectFolder != null && s.DefaultOpenProjectFolder.Length > 0)
            {
                folderOpen.SelectedPath = s.DefaultOpenProjectFolder;
            }
            else
            {
                folderOpen.SelectedPath = Program.documentPath;
            }
            //folderOpen.RootFolder = Environment.SpecialFolder.MyComputer;
            SendKeys.Send("{TAB}{TAB}{RIGHT}");

            string projectFolder;
            if (folderOpen.ShowDialog(w) == DialogResult.OK)
            {
                projectFolder = folderOpen.SelectedPath;
                Program.projectBaseFolder = folderOpen.SelectedPath;
            }
            else
            {
                return false;
            }

            //FindNewProjectName(projectFolder);
            InputForm dlg = new InputForm();
            dlg.Text = "建立專案";
            dlg.desc.Text = "請輸入新專案名稱";
            dlg.inputTxt.Text = FindNewProjectName(projectFolder);
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return false;
            }

            if (System.IO.Directory.Exists(projectFolder + "\\" + dlg.inputTxt.Text))
            {
                MessageBox.Show("此專案已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            try
            {
                Program.projectName = dlg.inputTxt.Text;
                System.IO.Directory.CreateDirectory(Program.GetProjectFullPath());
            }
            catch (Exception)
            {
                MessageBox.Show("無法建立專案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return false;
            }

            //RiverSimulationProfile.profile = new RiverSimulationProfile();
            //Program.projectFolder = Program.documentPath + "\\" + dlg.inputTxt.Text;
            Program.SaveDefaultProjectFolder();
            return true;
        }
예제 #9
0
파일: Utility.cs 프로젝트: alcor0/ResedUI
 public static void FillSelectedValue(DataGridView v)
 {
     InputForm dlg = new InputForm();
     dlg.Text = "填入數值";
     dlg.desc.Text = "請輸入數值";
     dlg.inputTxt.Text = "";
     if (DialogResult.OK != dlg.ShowDialog())
     {
         return;
     }
     if (dlg.inputTxt.Text.Length > 0)
     {
         foreach (DataGridViewCell c in v.SelectedCells)
         {
             if (c == null || c.ReadOnly)
             {
                 continue;
             }
             c.Value = dlg.inputTxt.Text;
         }
     }
 }
예제 #10
0
        public static bool NewProject(IWin32Window w)
        {
            FolderBrowserDialog folderOpen = new FolderBrowserDialog();

            RiverSimulationApplication.Properties.Settings s = RiverSimulationApplication.Properties.Settings.Default;
            folderOpen.ShowNewFolderButton = false;
            if (s.DefaultOpenProjectFolder != null && s.DefaultOpenProjectFolder.Length > 0)
            {
                folderOpen.SelectedPath = s.DefaultOpenProjectFolder;
            }
            else
            {
                folderOpen.SelectedPath = Program.documentPath;
            }
            //folderOpen.RootFolder = Environment.SpecialFolder.MyComputer;
            SendKeys.Send("{TAB}{TAB}{RIGHT}");

            string projectFolder;

            if (folderOpen.ShowDialog(w) == DialogResult.OK)
            {
                projectFolder             = folderOpen.SelectedPath;
                Program.projectBaseFolder = folderOpen.SelectedPath;
            }
            else
            {
                return(false);
            }

            //FindNewProjectName(projectFolder);
            InputForm dlg = new InputForm();

            dlg.Text          = "建立專案";
            dlg.desc.Text     = "請輸入新專案名稱";
            dlg.inputTxt.Text = FindNewProjectName(projectFolder);
            if (DialogResult.OK != dlg.ShowDialog())
            {
                return(false);
            }

            if (System.IO.Directory.Exists(projectFolder + "\\" + dlg.inputTxt.Text))
            {
                MessageBox.Show("此專案已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            try
            {
                Program.projectName = dlg.inputTxt.Text;
                System.IO.Directory.CreateDirectory(Program.GetProjectFullPath());
            }
            catch (Exception)
            {
                MessageBox.Show("無法建立專案!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }

            //RiverSimulationProfile.profile = new RiverSimulationProfile();
            //Program.projectFolder = Program.documentPath + "\\" + dlg.inputTxt.Text;
            Program.SaveDefaultProjectFolder();
            return(true);
        }
예제 #11
0
        private void mapPicBox_SelectedGroupChangedEvent(List<Point> pl)
        {
            RiverSimulationProfile p = RiverSimulationProfile.profile;
            int index = listBox.SelectedIndex;

            if(onlySelectMode)
            {
                InputForm dlg = new InputForm();
                dlg.Text = "填入數值";
                dlg.desc.Text = "請輸入數值";
                dlg.inputTxt.Text = "";
                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return;
                }
                selectedPl = new List<Point>(pl);
                selectedValue = dlg.inputTxt.Text;
                this.DialogResult = DialogResult.OK;
                this.Close();
                return;
            }

            int type = -1, count = 0;
            StructureSetUtility.CalcTypeCount(index, ref type, ref count, typeIndex);

            //檢查連續
            if (!StructureSetUtility.IsContinuous(pl))
            {
                UpdateSelectedGroup(pl, true);
                MessageBox.Show("請圈選連續區域!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                UpdateSelectedGroup(null);
                return;
            }

            //檢查重疊
            for (int n = 0; n < StructureTypeNumber; ++n)
            {
                bool overlapping = false;
                switch(n)
                {
                    case 0:
                        overlapping = CheckOverlapping(pl, p.tBarSets, (n == type) ? count : -1);
                        break;
                    case 1:
                        overlapping = CheckOverlapping(pl, p.bridgePierSets, (n == type) ? count : -1);
                        break;
                    case 2:
                        overlapping = CheckOverlapping(pl, p.groundsillWorkSets, (n == type) ? count : -1);
                        break;
                    case 3:
                        overlapping = CheckOverlapping(pl, p.sedimentationWeirSets, (n == type) ? count : -1);
                        break;
                    default:
                        break;
                }
                if(!overlapping)
                {
                    return;
                }
            }

            //最後確認 [20141121]更新客製化需求 回報問題 新增規格
            if (DialogResult.OK == MessageBox.Show("請確認以此次圈選範圍取代原先資料。", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.None))
            {
                UpdateSelectedGroup(pl);
            }
            //StructureSetUtility.EditBottomElevation(p, "編輯" + structureName[type] + (1 + count).ToString() + "高程", type, count);
            //if (StructureSetUtility.IsOverlapping(rg, pl, index))
            //{
            //    UpdateSelectedGroup(pl, true);
            //    if (DialogResult.Yes == MessageBox.Show("圈選到重覆區域,是否刪減重複範圍(選「否」將放棄此次圈選)", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
            //    {
            //        StructureSetUtility.RemoveOverlapping(ref pl, rg, index);
            //        if (!StructureSetUtility.IsContinuous(pl))
            //        {
            //            UpdateSelectedGroup(pl, true);
            //            MessageBox.Show("刪減後不是連續區域,請重新選取!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            //            UpdateSelectedGroup(null);
            //            return;
            //        }
            //    }
            //    else
            //    {
            //        UpdateSelectedGroup(null);
            //        return;
            //    }
            //}

            //UpdateSelectedGroup(pl);
        }