예제 #1
0
        private void addAbrevation(object sender, EventArgs e)
        {
            QuickSettings.settingAbbrevation sta = new QuickGenerator.QuickSettings.settingAbbrevation();
            sta.AbbrevationDictionary = settingsQuickGenerator.abbrevationDictList;
            sta.CustomList = settingsQuickGenerator.customList;
            sta.ColorArgument = settingsQuickGenerator.ColorArgument;

            AbbrevationCompletionForm frm = new AbbrevationCompletionForm(sta, vca);
            ScintillaNet.ScintillaControl sci = ASContext.CurSciControl;

            string text = ASContext.CurSciControl.SelText;
            int pos = sci.SelectionStart;
            int end = sci.SelectionEnd;

            int initLine = sci.LineFromPosition(pos);
            int endLine = sci.LineFromPosition(end);

            int indent = sci.GetLineIndentation(initLine);

            if (initLine != endLine)
            {
                while(initLine<endLine)
                {
                    initLine++;
                    int newIdent = sci.GetLineIndentation(initLine);
                    if (newIdent < indent)
                        indent = newIdent;
                }
            }

            string tabString = new string('\t',indent / sci.Indent);

            StringBuilder sb = new StringBuilder(text.Length);

            if (tabString.Length!=0)
            {
                string[] str = text.Split('\n');

                //sb.Append(str[0]);
                //sb.Append("\n");
                int ind = -1;
                int lenght = tabString.Length;
                for (int i = 0; i < str.Length; i++)
                {
                    ind = str[i].IndexOf(tabString, 0);
                    if (ind != -1)
                    {
                        //sb.Append(str[i].Replace(tabString, ""));
                       // string sg = str[i].Substring(ind + lenght);
                        sb.Append(str[i].Substring(ind + lenght));
                    }
                    else
                    {

                        //sb.Append(str[i].TrimStart('\t'));
                        sb.Append(str[i]);
                    }
                    sb.Append("\n");
                }

                sb.Remove(sb.Length - 1, 1);
            }
            else
                sb.Append(text);

            frm.getAbbrevationExternal(sb.ToString());
            frm.ShowDialog();
            sta = frm.getSettingAbbrevation();
            settingsQuickGenerator.abbrevationDictList = sta.AbbrevationDictionary;
            settingsQuickGenerator.customList = sta.CustomList;
            settingsQuickGenerator.ColorArgument = sta.ColorArgument;
        }
예제 #2
0
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                IWindowsFormsEditorService iwfse = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (iwfse == null) return null;

                settingAbbrevation sta = (settingAbbrevation)value;

                if (sta == null)
                    sta = new settingAbbrevation();
                //QuickGenerator.se

                //frmAbbrevationCompletion form = new frmAbbrevationCompletion((Dictionary<string, Dictionary<string, string>>)value);
                AbbrevationCompletionForm form = new AbbrevationCompletionForm(sta, null);
                form.ShowDialog();
                   // value = form.getDictAbbrevations();
                   // sta._abbrevationDictList = form.getDictAbbrevations();

                value = form.getSettingAbbrevation();
                return base.EditValue(context, provider, value);
            }