Пример #1
0
 /// <summary>
 /// 해당 EquationInfomation 클래스에 있는 변수값으로 파서내에 변수를 등록
 /// </summary>
 /// <param name="equainfo">등록할 EquationInfomation Class</param>
 private void SettingforCalc(EquationInformation equainfo)
 {
     foreach (var key in equainfo.m_Dictionary_Equation.Keys)
     {
         //if (equainfo.m_Dictionary_Equation[key].IsContainEquation == false)
         {
             try
             {
                 m_Term.SetVar(key, equainfo.m_Dictionary_Equation[key].Value);
             }
             catch (Exception e)
             {
                 Trace.WriteLine(e.Message + "setvar");
                 equainfo.m_Dictionary_Equation[key].Value = 0;
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Dictionary의 Key값을 변경
        /// </summary>
        /// <param name="before">전 Key</param>
        /// <param name="after">새 Key</param>
        private void ReNameEquationInformation(string before, string after)
        {
            EquationInformation equation = new EquationInformation();

            m_Dic_equationInfomation.TryGetValue(before, out equation);
            m_Dic_equationInfomation.Remove(before);
            string[] b1 = before.Split(':');
            string[] a1 = after.Split(':');
            m_Dic_equationInfomation.Add(after, equation);
            Trace.WriteLine("Complete! " + before + " -> " + after);
            foreach (VariableData vdata in equation.m_Dictionary_Equation.Values)
            {
                if (vdata.IsCorrespond)
                {
                    Trace.WriteLine("바뀌기 전 :" + vdata.CorrespontVarName);
                    vdata.CorrespontVarName = vdata.CorrespontVarName.Replace(b1[0], a1[0]);
                    Trace.WriteLine("바뀐뒤 :" + vdata.CorrespontVarName);
                }
            }
        }
Пример #3
0
 /// <summary>
 /// 검색 버튼 클릭 이벤트.
 /// </summary>
 /// <param name="key"></param>
 void MainForm_SearchEvent(string key)
 {
     if (m_Dictionary_EquationInfo == null)
     {
         return;
     }
     m_treeView.Nodes.Clear();
     m_Dictionary_Searched_EquationInfo.Clear();
     foreach (string eq_key in m_Dictionary_EquationInfo.Keys)
     {
         EquationInformation eqinfo = m_Dictionary_EquationInfo[eq_key];
         string key_tolower         = key.ToLower();
         if (eqinfo.m_Description.ToLower().Contains(key_tolower))
         {
             m_Dictionary_Searched_EquationInfo.Add(eq_key, eqinfo);
         }
     }
     find_text    = key.ToLower();
     isSearchMode = true;
     InitialTreeView(m_Dictionary_Searched_EquationInfo);
     this.Refresh();
 }
Пример #4
0
        /// <summary>
        /// EquationInfomation 의 변수를 토대로 UI를 작성.
        /// </summary>
        /// <param name="equainfo"></param>
        private void SettingForUI(EquationInformation equainfo)
        {
            TabControl tabControl   = new TabControl();
            TabPage    tabPage      = new TabPage();
            PictureBox pic_Equation = new PictureBox();


            // tab Page //
            tabPage.AutoScroll = true;
            tabPage.Controls.Add(pic_Equation);
            tabPage.Location = new System.Drawing.Point(4, 22);
            tabPage.Name     = "tabPage";
            tabPage.Padding  = new System.Windows.Forms.Padding(3);
            tabPage.Size     = new System.Drawing.Size(570, 171);
            tabPage.TabIndex = 0;
            tabPage.Text     = "공식 이미지";
            tabPage.UseVisualStyleBackColor = true;

            // tab Control //
            tabControl.Controls.Add(tabPage);
            tabControl.Dock          = System.Windows.Forms.DockStyle.Top;
            tabControl.Location      = new System.Drawing.Point(0, 0);
            tabControl.Name          = "tabControl";
            tabControl.SelectedIndex = 0;
            tabControl.Size          = new System.Drawing.Size(578, 197);
            tabControl.TabIndex      = 0;

            //pic_equation //
            pic_Equation.Location = new System.Drawing.Point(49, 3);
            pic_Equation.Name     = "pic_Equation";
            pic_Equation.Size     = new System.Drawing.Size(298, 165);
            pic_Equation.TabIndex = 0;
            pic_Equation.TabStop  = false;


            panel1.Controls.Add(tabControl);

            panel1.AutoScroll = false;

            toolStripLabel1.Text = m_SelectedEquation;

            if (equainfo.m_Dictionary_Equation.Keys.Count == 0)
            {
                toolStripLabel1.Text = "빈 계산기 페이지 입니다";
                return;
            }

            int Pic_X = 0;
            int Pic_Y = 0;


            bool isimageLoaded = false;

            try
            {
                Bitmap myBitmap = new Bitmap(m_Dictionary_EquationInfo[m_SelectedEquation].m_imagePath);
                Pic_X                 = myBitmap.Size.Width;
                Pic_Y                 = myBitmap.Size.Height;
                isimageLoaded         = true;
                pic_Equation.SizeMode = PictureBoxSizeMode.AutoSize;
                pic_Equation.Image    = myBitmap;
                pic_Equation.Click   += (a, b) => { panel1.Focus(); };
            }
            catch (Exception ex)
            {
                isimageLoaded = false;
            }


            // 사용자 이미지가 없으면 폴더 기본 이미지를 사용
            if (!isimageLoaded)
            {
                try
                {
                    string[]      foldertokenizer = m_SelectedEquation.Split(':');
                    StringBuilder folderpath      = new StringBuilder();

                    folderpath.Append(foldertokenizer[0]);
                    folderpath.Append("\\");
                    folderpath.Append(foldertokenizer[1]);


                    IEnumerable <string> filenames = from fullfilename in Directory.GetFiles(m_ProgramPath + "\\image\\", folderpath.ToString() + ".*")
                                                     select Path.GetFullPath(fullfilename);

                    string filename = " ";
                    foreach (var in_filename in filenames)
                    {
                        filename = in_filename;
                        break;
                    }
                    Bitmap myBitmap = new Bitmap(filename);
                    Pic_X = myBitmap.Size.Width;
                    Pic_Y = myBitmap.Size.Height;

                    pic_Equation.SizeMode = PictureBoxSizeMode.AutoSize;
                    pic_Equation.Image    = myBitmap;
                    pic_Equation.Click   += (a, b) => { panel1.Focus(); };
                    //m_Dictionary_EquationInfo[m_SelectedEquation].m_imagePath = filename;
                }
                catch (System.Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
            }
            if (Pic_Y > 400)
            {
                tabControl.Height = 300;
                Pic_Y             = 300;
            }
            else
            {
                tabControl.Height = Pic_Y + 60;
                Pic_Y             = tabControl.Height;
            }
            if (Pic_X > 800)
            {
                tabControl.Width = 800;
                Pic_X            = 800;
            }
            else
            {
                tabControl.Width = Pic_X + 50;
                Pic_X            = tabControl.Width;
            }


            // 내부 변수 갯수를 토대로 Textbox와 Label 작성
            int v_count = 0;

            foreach (var key in equainfo.m_Dictionary_Equation.Keys)
            {
                var    tempVariable = equainfo.m_Dictionary_Equation[key];
                double dvalue       = tempVariable.Value;
                try
                {
                    // 출력변수 대입하는 변수 인지 구분.
                    if (tempVariable.IsHiddenVariable == false)
                    {
                        if (tempVariable.IsCorrespond)
                        {
                            dvalue = FindValue(tempVariable.CorrespontVarName);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    dvalue = 0;
                }
                if (tempVariable.IsContainEquation == false)
                {
                    CreateLabel(key, 0, Variable_Label_X, Pic_Y + Variable_Label_Y + (v_count * 30));
                    CreateTextBox(key, dvalue, Variable_TextBox_X, Pic_Y + Variable_TextBox_Y + (v_count * 30), Color.LightSkyBlue, tempVariable.IsZeroIsNullValue);
                    v_count++;
                }
            }

            //             foreach (var key in equainfo.m_Dictionary_Equation.Keys)
            //             {
            //                 var tempVariable = equainfo.m_Dictionary_Equation[key];
            //                 if (tempVariable is ComparableVariable)
            //                 {
            //                     double dvalue = 0;
            //                     try
            //                     {
            //                         if (tempVariable.IsHiddenVariable == false)
            //                         {
            //                             if (tempVariable.IsCorrespond)
            //                             {
            //                                 dvalue = FindValue(tempVariable.CorrespontVarName);
            //                             }
            //                         }
            //                     }
            //                     catch (System.Exception ex)
            //                     {
            //                         dvalue = 0;
            //                     }
            //                     if (tempVariable.IsHiddenVariable == false)
            //                     {
            //                         CreateLabel(key, 0, Variable_Label_X, Pic_Y + Variable_Label_Y + (v_count * 30));
            //                         CreateTextBox(key, dvalue, Variable_TextBox_X, Pic_Y + Variable_TextBox_Y + (v_count * 30), Color.MediumAquamarine);
            //                         v_count++;
            //                     }
            //
            //                 }
            //             }

            foreach (var key in equainfo.m_Dictionary_Equation.Keys)
            {
                var tempVariable = equainfo.m_Dictionary_Equation[key];
                if (tempVariable is EquationVariable)
                {
                    double dvalue;
                    try
                    {
                        dvalue = m_Term.GetVar(tempVariable.Name);
                    }
                    catch (System.Exception ex)
                    {
                        dvalue = 0;
                    }
                    if (tempVariable.IsHiddenVariable == false)
                    {
                        CreateLabel(key, 0, Variable_Label_X, Pic_Y + Variable_Label_Y + (v_count * 30));
                        CreateTextBox(key, dvalue, Variable_TextBox_X, Pic_Y + Variable_TextBox_Y + (v_count * 30), Color.LightGoldenrodYellow, tempVariable.IsZeroIsNullValue);
                        v_count++;
                    }
                }
            }
            int ClientSize_X;
            int ClientSize_Y;


            ClientSize_X = tabControl.Width + 130;
            ClientSize_Y = Pic_Y + Variable_Label_Y + (v_count * 30);

            if (ClientSize_X > 800)
            {
                ClientSize_X = 800;
            }
            if (ClientSize_Y > 559)
            {
                ClientSize_Y = 559;
            }

            this.Refresh();
            this.ClientSize   = new Size(700, ClientSize_Y + 50);
            panel1.AutoScroll = true;
        }