Exemplo n.º 1
0
        public void ChangeSettingofEditor(Sgry.Azuki.WinForms.AzukiControl textBox)
        {
            if (textBox == null)
            {
                return;
            }
            textBox.FontInfo = new Sgry.Azuki.FontInfo(Properties.Settings.Default.editorFont);
            var x = Properties.Settings.Default.editorFontColor;

            textBox.DrawsEofMark          = Properties.Settings.Default.editorDrawEOF;
            textBox.DrawsEolCode          = Properties.Settings.Default.editorDrawEOL;
            textBox.DrawsFullWidthSpace   = Properties.Settings.Default.editorDrawFullWidthSpace;
            textBox.DrawsSpace            = Properties.Settings.Default.editorDrawSpace;
            textBox.DrawsTab              = Properties.Settings.Default.editorDrawTab;
            textBox.AcceptsTab            = Properties.Settings.Default.editorAcceptTab;
            textBox.TabWidth              = Properties.Settings.Default.editorTabWidth;
            textBox.ColorScheme.ForeColor = Properties.Settings.Default.editorFontColor["テキスト"].Font;
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.Normal, Properties.Settings.Default.editorFontColor["テキスト"].Font, Properties.Settings.Default.editorFontColor["テキスト"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.Heading1, Properties.Settings.Default.editorFontColor["テキスト"].Font, Properties.Settings.Default.editorFontColor["テキスト"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.Heading2, Properties.Settings.Default.editorFontColor["テキスト"].Font, Properties.Settings.Default.editorFontColor["テキスト"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.Heading3, Properties.Settings.Default.editorFontColor["テキスト"].Font, Properties.Settings.Default.editorFontColor["テキスト"].Back);
            textBox.ColorScheme.SelectionFore = Properties.Settings.Default.editorFontColor["選択範囲"].Font;
            textBox.ColorScheme.SelectionBack = Properties.Settings.Default.editorFontColor["選択範囲"].Back;
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.LatexCommand, Properties.Settings.Default.editorFontColor["コントロールシークエンス"].Font, Properties.Settings.Default.editorFontColor["コントロールシークエンス"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.LatexEquation, Properties.Settings.Default.editorFontColor["$"].Font, Properties.Settings.Default.editorFontColor["$"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.LatexBracket, Properties.Settings.Default.editorFontColor["中 / 大括弧"].Font, Properties.Settings.Default.editorFontColor["中 / 大括弧"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.LatexCurlyBracket, Properties.Settings.Default.editorFontColor["中 / 大括弧"].Font, Properties.Settings.Default.editorFontColor["中 / 大括弧"].Back);
            textBox.ColorScheme.SetColor(Sgry.Azuki.CharClass.Comment, Properties.Settings.Default.editorFontColor["コメント"].Font, Properties.Settings.Default.editorFontColor["コメント"].Back);
            textBox.ColorScheme.EofColor           = Properties.Settings.Default.editorFontColor["改行,EOF"].Font;
            textBox.ColorScheme.EolColor           = Properties.Settings.Default.editorFontColor["改行,EOF"].Font;
            textBox.ColorScheme.MatchedBracketFore = Properties.Settings.Default.editorFontColor["対応する括弧"].Font;
            textBox.ColorScheme.MatchedBracketBack = Properties.Settings.Default.editorFontColor["対応する括弧"].Back;
            textBox.ColorScheme.WhiteSpaceColor    = Properties.Settings.Default.editorFontColor["空白"].Font;
            Color backColor = new Color();

            if (textBox.Enabled)
            {
                backColor = Properties.Settings.Default.editorFontColor["テキスト"].Back;
            }
            else
            {
                backColor = System.Drawing.SystemColors.ButtonFace;
            }
            textBox.ColorScheme.BackColor = backColor;
        }
Exemplo n.º 2
0
 /// <summary>
 /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
 /// コード エディタで変更しないでください。
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmScript));
     this.mainMenu1          = new System.Windows.Forms.MainMenu(this.components);
     this.miCommand          = new System.Windows.Forms.MenuItem();
     this.miSave             = new System.Windows.Forms.MenuItem();
     this.miCloseWithSave    = new System.Windows.Forms.MenuItem();
     this.miCloseWithoutSave = new System.Windows.Forms.MenuItem();
     this.miFuncList         = new System.Windows.Forms.MenuItem();
     this.miScriptFuncs      = new System.Windows.Forms.MenuItem();
     this.miLuaFuncs         = new System.Windows.Forms.MenuItem();
     this.menuItem1          = new System.Windows.Forms.MenuItem();
     this.miFuncCategory     = new System.Windows.Forms.MenuItem();
     this.miCatEnable0       = new System.Windows.Forms.MenuItem();
     this.miCatEnable1       = new System.Windows.Forms.MenuItem();
     this.miCatEnable2       = new System.Windows.Forms.MenuItem();
     this.miCatEnable3       = new System.Windows.Forms.MenuItem();
     this.miCatEnable4       = new System.Windows.Forms.MenuItem();
     this.miCatEnable5       = new System.Windows.Forms.MenuItem();
     this.miCatEnable6       = new System.Windows.Forms.MenuItem();
     this.miCatEnable7       = new System.Windows.Forms.MenuItem();
     this.miCatEnable8       = new System.Windows.Forms.MenuItem();
     this.miCatEnable9       = new System.Windows.Forms.MenuItem();
     this.miCatEnable10      = new System.Windows.Forms.MenuItem();
     this.cmbVals            = new System.Windows.Forms.ComboBox();
     this.panelInsertion     = new System.Windows.Forms.Panel();
     this.cmbFunction        = new System.Windows.Forms.ComboBox();
     this.cmbNames           = new System.Windows.Forms.ComboBox();
     this.txtScript          = new Sgry.Azuki.WinForms.AzukiControl();
     this.panelInsertion.SuspendLayout();
     this.SuspendLayout();
     //
     // mainMenu1
     //
     this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miCommand,
         this.miFuncList
     });
     //
     // miCommand
     //
     this.miCommand.Index = 0;
     this.miCommand.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miSave,
         this.miCloseWithSave,
         this.miCloseWithoutSave
     });
     this.miCommand.Text = "コマンド(&C)";
     //
     // miSave
     //
     this.miSave.Index    = 0;
     this.miSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
     this.miSave.Text     = "変更を保存(&S)";
     this.miSave.Click   += new System.EventHandler(this.miSave_Click);
     //
     // miCloseWithSave
     //
     this.miCloseWithSave.Index  = 1;
     this.miCloseWithSave.Text   = "変更を保存して閉じる(&C)";
     this.miCloseWithSave.Click += new System.EventHandler(this.miCloseWithSave_Click);
     //
     // miCloseWithoutSave
     //
     this.miCloseWithoutSave.Index  = 2;
     this.miCloseWithoutSave.Text   = "変更を保存しないで閉じる(&Q)";
     this.miCloseWithoutSave.Click += new System.EventHandler(this.miCloseWithoutSave_Click);
     //
     // miFuncList
     //
     this.miFuncList.Index = 1;
     this.miFuncList.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miScriptFuncs,
         this.miLuaFuncs,
         this.menuItem1,
         this.miFuncCategory
     });
     this.miFuncList.Text = "関数リスト(&F)";
     //
     // miScriptFuncs
     //
     this.miScriptFuncs.Checked    = true;
     this.miScriptFuncs.Index      = 0;
     this.miScriptFuncs.RadioCheck = true;
     this.miScriptFuncs.Text       = "&Script";
     this.miScriptFuncs.Click     += new System.EventHandler(this.miScriptFuncs_Click);
     //
     // miLuaFuncs
     //
     this.miLuaFuncs.Index      = 1;
     this.miLuaFuncs.RadioCheck = true;
     this.miLuaFuncs.Text       = "&Lua";
     this.miLuaFuncs.Click     += new System.EventHandler(this.miLuaFuncs_Click);
     //
     // menuItem1
     //
     this.menuItem1.Index = 2;
     this.menuItem1.Text  = "-";
     //
     // miFuncCategory
     //
     this.miFuncCategory.Index = 3;
     this.miFuncCategory.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
         this.miCatEnable0,
         this.miCatEnable1,
         this.miCatEnable2,
         this.miCatEnable3,
         this.miCatEnable4,
         this.miCatEnable5,
         this.miCatEnable6,
         this.miCatEnable7,
         this.miCatEnable8,
         this.miCatEnable9,
         this.miCatEnable10
     });
     this.miFuncCategory.Text = "表示するカテゴリ(&C)";
     //
     // miCatEnable0
     //
     this.miCatEnable0.Checked = true;
     this.miCatEnable0.Index   = 0;
     this.miCatEnable0.Text    = "画面サイズ・パフォーマンス";
     this.miCatEnable0.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable1
     //
     this.miCatEnable1.Checked = true;
     this.miCatEnable1.Index   = 1;
     this.miCatEnable1.Text    = "ライン描画";
     this.miCatEnable1.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable2
     //
     this.miCatEnable2.Checked = true;
     this.miCatEnable2.Index   = 2;
     this.miCatEnable2.Text    = "入力検知";
     this.miCatEnable2.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable3
     //
     this.miCatEnable3.Checked = true;
     this.miCatEnable3.Index   = 3;
     this.miCatEnable3.Text    = "モデル情報";
     this.miCatEnable3.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable4
     //
     this.miCatEnable4.Checked = true;
     this.miCatEnable4.Index   = 4;
     this.miCatEnable4.Text    = "チップ情報";
     this.miCatEnable4.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable5
     //
     this.miCatEnable5.Checked = true;
     this.miCatEnable5.Index   = 5;
     this.miCatEnable5.Text    = "切り離し";
     this.miCatEnable5.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable6
     //
     this.miCatEnable6.Checked = true;
     this.miCatEnable6.Index   = 6;
     this.miCatEnable6.Text    = "チップタイプ取得";
     this.miCatEnable6.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable7
     //
     this.miCatEnable7.Checked = true;
     this.miCatEnable7.Index   = 7;
     this.miCatEnable7.Text    = "オブジェクト(ボール)";
     this.miCatEnable7.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable8
     //
     this.miCatEnable8.Checked = true;
     this.miCatEnable8.Index   = 8;
     this.miCatEnable8.Text    = "CCDカメラ";
     this.miCatEnable8.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable9
     //
     this.miCatEnable9.Checked = true;
     this.miCatEnable9.Index   = 9;
     this.miCatEnable9.Text    = "ネットワーク";
     this.miCatEnable9.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // miCatEnable10
     //
     this.miCatEnable10.Checked = true;
     this.miCatEnable10.Index   = 10;
     this.miCatEnable10.Text    = "数学関数";
     this.miCatEnable10.Click  += new System.EventHandler(this.miCatEnable_Click);
     //
     // cmbVals
     //
     this.cmbVals.DropDownWidth = 400;
     this.cmbVals.Location      = new System.Drawing.Point(0, 0);
     this.cmbVals.Name          = "cmbVals";
     this.cmbVals.Size          = new System.Drawing.Size(121, 20);
     this.cmbVals.TabIndex      = 0;
     this.cmbVals.Text          = "(変数)";
     this.cmbVals.Enter        += new System.EventHandler(this.cmbVals_Enter);
     this.cmbVals.KeyPress     += new System.Windows.Forms.KeyPressEventHandler(this.cmbInsertion_KeyPress);
     //
     // panelInsertion
     //
     this.panelInsertion.Controls.Add(this.cmbFunction);
     this.panelInsertion.Controls.Add(this.cmbNames);
     this.panelInsertion.Controls.Add(this.cmbVals);
     this.panelInsertion.Dock     = System.Windows.Forms.DockStyle.Top;
     this.panelInsertion.Location = new System.Drawing.Point(0, 0);
     this.panelInsertion.Name     = "panelInsertion";
     this.panelInsertion.Size     = new System.Drawing.Size(352, 24);
     this.panelInsertion.TabIndex = 1;
     this.panelInsertion.Layout  += new System.Windows.Forms.LayoutEventHandler(this.panelInsertion_Layout);
     //
     // cmbFunction
     //
     this.cmbFunction.DropDownWidth = 400;
     this.cmbFunction.Location      = new System.Drawing.Point(248, 0);
     this.cmbFunction.Name          = "cmbFunction";
     this.cmbFunction.Size          = new System.Drawing.Size(121, 20);
     this.cmbFunction.TabIndex      = 2;
     this.cmbFunction.Text          = "(関数)";
     this.cmbFunction.Enter        += new System.EventHandler(this.cmbFunction_Enter);
     this.cmbFunction.KeyPress     += new System.Windows.Forms.KeyPressEventHandler(this.cmbFunction_KeyPress);
     this.cmbFunction.DropDown     += new System.EventHandler(this.cmbFunction_Enter);
     //
     // cmbNames
     //
     this.cmbNames.DropDownWidth = 400;
     this.cmbNames.Location      = new System.Drawing.Point(128, 0);
     this.cmbNames.Name          = "cmbNames";
     this.cmbNames.Size          = new System.Drawing.Size(121, 20);
     this.cmbNames.TabIndex      = 1;
     this.cmbNames.Text          = "(チップ名)";
     this.cmbNames.Enter        += new System.EventHandler(this.cmbNames_Enter);
     this.cmbNames.KeyPress     += new System.Windows.Forms.KeyPressEventHandler(this.cmbInsertion_KeyPress);
     //
     // txtScript
     //
     this.txtScript.AllowDrop     = true;
     this.txtScript.Cursor        = System.Windows.Forms.Cursors.IBeam;
     this.txtScript.Dock          = System.Windows.Forms.DockStyle.Fill;
     this.txtScript.DrawingOption = ((Sgry.Azuki.DrawingOption)(((((Sgry.Azuki.DrawingOption.DrawsFullWidthSpace | Sgry.Azuki.DrawingOption.DrawsTab)
                                                                   | Sgry.Azuki.DrawingOption.DrawsEol)
                                                                  | Sgry.Azuki.DrawingOption.HighlightCurrentLine)
                                                                 | Sgry.Azuki.DrawingOption.ShowsLineNumber)));
     this.txtScript.Font         = new System.Drawing.Font("MS ゴシック", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
     this.txtScript.Location     = new System.Drawing.Point(0, 24);
     this.txtScript.Name         = "txtScript";
     this.txtScript.Size         = new System.Drawing.Size(352, 226);
     this.txtScript.TabIndex     = 3;
     this.txtScript.TabWidth     = 8;
     this.txtScript.Text         = "txtScript";
     this.txtScript.ViewWidth    = 328;
     this.txtScript.TextChanged += new System.EventHandler(this.txtScript_TextChanged);
     this.txtScript.Validated   += new System.EventHandler(this.txtScript_Validated);
     this.txtScript.Enter       += new System.EventHandler(this.txtScript_Enter);
     //
     // frmScript
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
     this.ClientSize        = new System.Drawing.Size(352, 250);
     this.Controls.Add(this.txtScript);
     this.Controls.Add(this.panelInsertion);
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox     = false;
     this.Menu            = this.mainMenu1;
     this.MinimizeBox     = false;
     this.Name            = "frmScript";
     this.Text            = "Script{...}/Lua{...}設定";
     this.Load           += new System.EventHandler(this.frmScript_Load);
     this.VisibleChanged += new System.EventHandler(this.frmScript_VisibleChanged);
     this.FormClosing    += new System.Windows.Forms.FormClosingEventHandler(this.frmScript_Closing);
     this.panelInsertion.ResumeLayout(false);
     this.ResumeLayout(false);
 }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();
            types      = ReadXml("types.xml");
            azuki      = new Sgry.Azuki.WinForms.AzukiControl();
            azuki.Dock = DockStyle.Fill;
            this.Controls.Add(azuki);
            char[] c = azuki.Document.EolCode.ToCharArray();
            for (int i = 0; i < c.Length; i++)
            {
                Console.WriteLine((int)c[i]);
            }
            azuki.Document.EolCode = "\r";

            int           InputBegin                 = 0;
            int           InputEnd                   = 0;
            string        NewInputString             = "";
            List <string> CurrentList                = null;
            Dictionary <string, JSType> OriginalList = null;

            azuki.KeyPress += delegate(object sender, KeyPressEventArgs e)
            {
                Console.WriteLine((int)'.' + " " + (e.KeyChar == 0x08));
                if (listBox1.Visible)
                {
                    if (e.KeyChar == '\r')
                    {
                        // エンターキー
                        if (listBox1.SelectedIndex >= 0)
                        {
                            e.Handled = true;
                            azuki.Document.Replace((string)listBox1.SelectedItem, InputBegin, InputEnd);
                        }
                        listBox1.Visible = false;
                    }
                    else if (e.KeyChar == ' ')
                    {
                        // スペースキー
                        if (listBox1.SelectedIndex >= 0)
                        {
                            azuki.Document.Replace((string)listBox1.SelectedItem, InputBegin, InputEnd);
                        }
                        listBox1.Visible = false;
                    }
                    else if (e.KeyChar == '\t')
                    {
                        // タブキー
                        if (listBox1.SelectedIndex >= 0)
                        {
                            e.Handled = true;
                            azuki.Document.Replace((string)listBox1.SelectedItem, InputBegin, InputEnd);
                        }
                        listBox1.Visible = false;
                    }
                    else if (e.KeyChar == '.')
                    {
                        // ピリオド
                        if (listBox1.SelectedIndex >= 0)
                        {
                            azuki.Document.Replace((string)listBox1.SelectedItem, InputBegin, InputEnd);
                        }
                        listBox1.Visible = false;
                    }
                    else
                    {
                        if (e.KeyChar != 0x08)
                        {
                            NewInputString += e.KeyChar;
                            InputEnd++;
                        }
                        else if (e.KeyChar == 0x08)
                        {
                            if (NewInputString.Length > 0)
                            {
                                NewInputString = NewInputString.Substring(0, NewInputString.Length - 1);
                                InputEnd--;
                            }
                            else
                            {
                                listBox1.Visible = false;
                            }
                        }
                        // 入力候補を探して候補がある場合のみリスト更新
                        List <string> NewList = new List <string>();
                        foreach (string member in CurrentList)
                        {
                            if (member.StartsWith(NewInputString))
                            {
                                NewList.Add(member);
                            }
                        }
                        if (NewList.Count > 0)
                        {
                            listBox1.Items.Clear();
                            foreach (string member in NewList)
                            {
                                listBox1.Items.Add(member);
                            }
                            listBox1.SelectedIndex = 0;
                        }
                        else
                        {
                            listBox1.SelectedIndex = -1;
                        }
                    }
                }


                if (!listBox1.Visible)
                {
                    if (e.KeyChar == '.')
                    {
                        string src   = azuki.Text.Substring(0, azuki.CaretIndex);
                        string token = lastToken(src, 1);
                        Console.WriteLine(token);
                        //string className = GetClass(src, token);
                        string className;
                        if (types.ContainsKey(token))
                        {
                            // クラス名
                            className = token;
                        }
                        else
                        {
                            // 変数名
                            className = GetClassEx(src);
                        }

                        if (className != null && types[className] != null)
                        {
                            //OriginalList = types[className].Members;
                            OriginalList = types[className].GetMembers();
                            if (OriginalList != null && OriginalList.Count > 0)
                            {
                                // リストボックスを所定の位置に移動
                                Point apiPoint;
                                GetCaretPos(out apiPoint);
                                listBox1.Left = apiPoint.X;
                                listBox1.Top  = apiPoint.Y + (azuki.LineHeight + 2);

                                // 入力候補取得、表示
                                //OriginalList = GetMembers(className);

                                CurrentList = new List <string>(OriginalList.Keys);
                                CurrentList.Sort();
                                listBox1.Items.Clear();
                                foreach (string member in CurrentList)
                                {
                                    listBox1.Items.Add(member);
                                }
                                listBox1.SelectedIndex = 0;
                                listBox1.Visible       = true;
                                int lineIndex, columnIndex;
                                azuki.GetSelection(out lineIndex, out columnIndex);
                                InputBegin     = lineIndex + 1;
                                InputEnd       = InputBegin;
                                NewInputString = "";

                                //Popup f = new Popup();
                                //f.Show(this);
                                //f.Size = new Size(300, 50);
                                //Rectangle clientRect = this.ClientRectangle;
                                //Point winP = this.PointToClient(this.Bounds.Location);
                                //f.Left = this.Left - winP.X + listBox1.Left - 300;
                                //f.Top = this.Top - winP.Y + listBox1.Top;

                                //azuki.Focus();
                            }
                        }
                    }
                    else if (('A' <= e.KeyChar && e.KeyChar <= 'Z') || ('a' <= e.KeyChar && e.KeyChar <= 'z'))
                    {
                        string src   = azuki.Text.Substring(0, azuki.CaretIndex);
                        string token = lastToken(src, 1);
                        Console.WriteLine("[" + token + "]");
                        if (";(){}+-*/=new".IndexOf(token) >= 0)
                        {
                            CurrentList = GetLocalWords(src);
                            if (CurrentList.Count > 0)
                            {
                                // リストボックスを所定の位置に移動
                                Point apiPoint;
                                GetCaretPos(out apiPoint);
                                listBox1.Left = apiPoint.X;
                                listBox1.Top  = apiPoint.Y + (azuki.LineHeight + 2);

                                // 入力候補取得、表示
                                //OriginalList = GetMembers(className);

                                CurrentList.Sort();
                                listBox1.Items.Clear();
                                foreach (string member in CurrentList)
                                {
                                    listBox1.Items.Add(member);
                                }
                                //listBox1.SelectedIndex = 0;
                                listBox1.Visible = true;
                                int lineIndex, columnIndex;
                                azuki.GetSelection(out lineIndex, out columnIndex);
                                InputBegin     = lineIndex;
                                InputEnd       = InputBegin + 1;
                                NewInputString = "" + e.KeyChar;
                            }
                        }
                    }
                }
            };
            azuki.KeyDown += delegate(object sender, KeyEventArgs e)
            {
                if (listBox1.Visible && ((e.KeyData & Keys.Right) == Keys.Right))
                {
                    Console.WriteLine("Right");
                    listBox1.Visible = false;
                }
                else if (listBox1.Visible && ((e.KeyData & Keys.Left) == Keys.Left))
                {
                    Console.WriteLine("Left");
                    listBox1.Visible = false;
                }
                else if (listBox1.Visible && ((e.KeyData & Keys.Up) == Keys.Up))
                {
                    Console.WriteLine("Up");
                    if (listBox1.SelectedIndex > 0)
                    {
                        listBox1.SelectedIndex--;
                    }
                    e.Handled = true;
                }
                else if (listBox1.Visible && (e.KeyData & Keys.Down) == Keys.Down)
                {
                    if (listBox1.SelectedIndex < listBox1.Items.Count - 1)
                    {
                        listBox1.SelectedIndex++;
                    }
                    e.Handled = true;
                }
            };
            Console.WriteLine(azuki.LineHeight);
            //LineHeight = TextRenderer.MeasureText("test", textBox1.Font, textBox1.ClientSize, TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl).Height + 2;
            azuki.Text = ReadSrc("main.js");
        }
Exemplo n.º 4
0
        private void loadSettings()
        {
            //sourceTextBox.Text = "\\qquad あ";

            const int minLength = 50;

            if (Properties.Settings.Default.Height > minLength)
            {
                this.Height = Properties.Settings.Default.Height;
            }
            if (Properties.Settings.Default.Width > minLength)
            {
                this.Width = Properties.Settings.Default.Width;
            }
            if (Properties.Settings.Default.Left > 0)
            {
                this.Left = Properties.Settings.Default.Left;
            }
            if (Properties.Settings.Default.Top > 0)
            {
                this.Top = Properties.Settings.Default.Top;
            }
            if (Properties.Settings.Default.preambleWindowHeight > minLength)
            {
                myPreambleForm.Height = Properties.Settings.Default.preambleWindowHeight;
            }
            if (Properties.Settings.Default.preambleWindowWidth > minLength)
            {
                myPreambleForm.Width = Properties.Settings.Default.preambleWindowWidth;
            }
            if (Properties.Settings.Default.outputWindowHeight > minLength)
            {
                myOutputForm.Height = Properties.Settings.Default.outputWindowHeight;
            }
            if (Properties.Settings.Default.outputWindowWidth > minLength)
            {
                myOutputForm.Width = Properties.Settings.Default.outputWindowWidth;
            }

            if (Properties.Settings.Default.outputFile != "")
            {
                outputFileNameTextBox.Text = Properties.Settings.Default.outputFile;
            }
            else
            {
                outputFileNameTextBox.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\equation.eps";
            }
            string ext = Path.GetExtension(outputFileNameTextBox.Text).ToLower();

            ExtensioncomboBox.SelectedIndex = 0;
            for (int i = 0; i < ExtensioncomboBox.Items.Count; ++i)
            {
                if (ext == "." + ExtensioncomboBox.Items[i].ToString())
                {
                    ExtensioncomboBox.SelectedIndex = i;
                }
            }
            inputFileNameTextBox.Text           = Properties.Settings.Default.inputFile;
            InputFromTextboxRadioButton.Checked = Properties.Settings.Default.inputFromTextBox;
            InputFromFileRadioButton.Checked    = !InputFromTextboxRadioButton.Checked;

            Sgry.Azuki.WinForms.AzukiControl preambleTextBox = myPreambleForm.PreambleTextBox;
            preambleTextBox.Text = Properties.Settings.Default.preamble;
            // プリアンブルフォームのキャレットを最後に持っていく
            preambleTextBox.SetSelection(preambleTextBox.TextLength, preambleTextBox.TextLength);
            preambleTextBox.Focus();
            preambleTextBox.ScrollToCaret();

            ChangeSetting();
            setEnabled();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 【非同期】一括置換を実行します。
        /// </summary>
        private async void doReplaceAll()
        {
            if (this.ltvTextSearchResult.Items.Count == 0)
            {
                return;
            }
            else if (this.uctlOneText.IsDirty && MessageBox.Show(Resources.MsgQ_Confirm.Replace("$", "現在のファイルを保存") + "\r\nなお、この操作は元に戻せませんのでご注意下さい。", Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }
            else if (this.uctlOneText.IsDirty == false && MessageBox.Show(Resources.MsgW_ImportantWork.Replace("$", "この操作は元に戻せません"), Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            //処理中に一旦閉じる必要があるため、最初に保存しておく
            this.uctlOneText.DoSave();

            //ファイルロックを解除
            this.ctlSwitchTextSearchReplace(false, false);
            this.uctlOneText.DoClose();

            //別スレッドで実行するために指示リストを作る
            var ReplaceText = this.txtTextReplace.Text;
            var taskList    = new ListView();

            foreach (ListViewItem item in this.ltvTextSearchResult.Items)
            {
                var add = new ListViewItem {
                    Text = item.Text
                };
                add.SubItems.Add(item.SubItems[(int)TextSearchListColumns.FileName].Text);
                add.SubItems.Add(item.SubItems[(int)TextSearchListColumns.Row].Text);
                add.SubItems.Add(item.SubItems[(int)TextSearchListColumns.Column].Text);
                add.SubItems.Add(item.SubItems[(int)TextSearchListColumns.IsReplaced].Text);
                add.SubItems.Add(item.SubItems[(int)TextSearchListColumns.SerachWord].Text);
                taskList.Items.Add(add);
            }

            //処理開始:置換できなかったインデックスのリストを戻り値にする
            var wordReplacer = await Task.Run(() => {
                var NGList    = new List <int>();
                var ctl       = new Sgry.Azuki.WinForms.AzukiControl();
                FileStream fs = null;

                //全項目を走査
                for (var i = 0; i < taskList.Items.Count; i++)
                {
                    if (taskList.Items[i].SubItems[(int)TextSearchListColumns.IsReplaced].Text == Resources.Text_ReplacedMark)
                    {
                        //既に置換されているものは処理しない
                        continue;
                    }

                    var line   = int.Parse(taskList.Items[i].SubItems[(int)TextSearchListColumns.Row].Text) - 1;
                    var col    = int.Parse(taskList.Items[i].SubItems[(int)TextSearchListColumns.Column].Text) - 1;
                    var length = int.Parse(taskList.Items[i].Text);

                    //新規の場合 or 次のファイルへ移る場合のみテキストを読み込む
                    if (ctl.Tag == null || ctl.Tag?.ToString() != taskList.Items[i].SubItems[(int)TextSearchListColumns.FileName].Text)
                    {
                        Common.EndFileAccessLock(ref fs);
                        fs = Common.OpenFileEditMode(ProjectManager.ProjectPath + taskList.Items[i].SubItems[(int)TextSearchListColumns.FileName].Text);
                        if (fs == null)
                        {
                            //編集権が得られなければスキップする
                            NGList.Add(i);
                            continue;
                        }
                        ctl.Text = Common.ReadFileAll(fs);
                        ctl.Tag  = taskList.Items[i].SubItems[(int)TextSearchListColumns.FileName].Text;
                    }

                    ctl.Document.SetCaretIndex(
                        int.Parse(taskList.Items[i].SubItems[(int)TextSearchListColumns.Row].Text) - 1,
                        int.Parse(taskList.Items[i].SubItems[(int)TextSearchListColumns.Column].Text) - 1
                        );
                    ctl.Document.SetSelection(
                        ctl.Document.AnchorIndex,
                        ctl.Document.AnchorIndex + int.Parse(taskList.Items[i].Text)
                        );

                    //検索文字列を正確に選択できているときのみ置換を実行する
                    if (ctl.GetSelectedText() == taskList.Items[i].SubItems[(int)TextSearchListColumns.SerachWord].Text)
                    {
                        //選択地点を置換
                        ctl.Document.Replace(ReplaceText);
                    }
                    else
                    {
                        NGList.Add(i);
                    }

                    //次のファイルへ移る場合は保存
                    if ((i + 1 >= taskList.Items.Count) ||
                        (i + 1 < taskList.Items.Count && taskList.Items[i + 1].SubItems[(int)TextSearchListColumns.FileName].Text != ctl.Tag?.ToString()))
                    {
                        Common.WriteFileAll(ref fs, ctl.Text);
                    }
                }

                Common.EndFileAccessLock(ref fs);
                return(NGList);
            });

            //結果を画面に反映
            if (this.uctlTextFiles.IsFileSelected)
            {
                //現在開いているファイルを読み直す
                this.uctlTextFiles.ReloadTree(this.uctlTextFiles.SelectedNodeFullPath);
            }

            for (var i = 0; i < this.ltvTextSearchResult.Items.Count; i++)
            {
                if (!wordReplacer.Contains(i))
                {
                    //正常終了
                    this.ltvTextSearchResult.Items[i].Text = this.txtTextReplace.Text.Length.ToString();
                    this.ltvTextSearchResult.Items[i].SubItems[(int)TextSearchListColumns.IsReplaced].Text = Resources.Text_ReplacedMark;
                }
                else
                {
                    //失敗
                    this.ltvTextSearchResult.Items[i].SubItems[(int)TextSearchListColumns.IsReplaced].Text = "";
                }
            }

            //System.Media.SystemSounds.Asterisk.Play();
            this.ctlSwitchTextSearchReplace(true);
            if (this.uctlTextFiles.IsFileSelected)
            {
                //ファイルロック再開
                this.uctlOneText.DoLoad(this.uctlTextFiles.SelectedNodeFullPath);
            }

            if (wordReplacer.Count == 0)
            {
                MessageBox.Show(Resources.MsgI_CompleteTextReplace, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                MessageBox.Show(Resources.MsgI_CompleteTextReplace.Replace("。", $"が、{wordReplacer.Count} 件 失敗しています。"), Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }