コード例 #1
0
        private static String DecompileMethod(String methodName)
        {
            MethodInfo netMethodInfo = typeof(MethodBodyTest).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Static);

            if (netMethodInfo == null)
            {
                netMethodInfo = typeof(MethodBodyTest).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
            }

            IMethodReference methodReferece = AssemblyManager.FindMethod(netMethodInfo);

            CSharpWriter    languageWriter      = new CSharpWriter();
            PlainTextWriter formattedCodeWriter = new PlainTextWriter();

            languageWriter.WriteMethodDeclaration(methodReferece.Resolve(), formattedCodeWriter);
            return(formattedCodeWriter.ToString());
        }
コード例 #2
0
        /// <summary>
        /// Serializes the object and saves it to the specified path.
        /// </summary>
        /// <param name="savePath">The relative or absolute path where the settings should be saved to.</param>
        /// <param name="overrideInstance">True to use the specified file path for future Save() method calls, otherwise false.</param>
        public override void SaveAs(string savePath, bool overrideInstance = true)
        {
            if (savePath == null)
            {
                throw new ArgumentNullException(nameof(savePath));
            }

            string textPath = OmitExtension ? savePath : FixPathExtension(savePath);

            using (FileStream stream = new FileStream(textPath, FileMode.Create))
                using (PlainTextWriter writer = PlainTextWriter.Create(stream, Settings))
                    new PlainTextSerializer().Serialize(writer, this);

            if (overrideInstance)
            {
                SavePath = savePath;
            }
        }
コード例 #3
0
        // ========================================
        // method
        // ========================================
        public override void Execute()
        {
            var data = new DataObject();
            var copy = _target.CopyBlocksAndInlines(_range);

            data.SetData(StyledTextConsts.BlocksAndInlinesFormat.Name, false, copy);

            /// plain text
            {
                var writer = new PlainTextWriter();
                var text   = writer.ToPlainText(copy);
                data.SetText(text, TextDataFormat.UnicodeText);
            }

            /// html
            if (SupportHtml)
            {
                var writer = new HtmlWriter();
                var html   = writer.ToHtml(copy);
                data.SetData(DataFormats.Html, ClipboardUtil.GetCFHtmlMemoryStream(html));
            }

            Clipboard.SetDataObject(data, true);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Ruzzie/Textorizer
 public string ReduceHtmlWhiteSpaces()
 {
     return(PlainTextWriter.ReduceHtmlWhiteSpaces(Data));
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: Ruzzie/Textorizer
 public string ClassicReplace()
 {
     return(PlainTextWriter.ReplaceHtmlWhiteSpacesClassic(Data));
 }
コード例 #6
0
 public static void Save(string filePath, string fileContent)
 => PlainTextWriter.Save(filePath, fileContent);
コード例 #7
0
        protected IDragSource CreateFocusFigureDragSource()
        {
            var ret = MouseOperatableFactory.CreateDragSource(DragDropEffects.Copy | DragDropEffects.Move);

            ret.JudgeDragStart += (sender, e) => {
                e.DoIt = false;
                if (e.Button == MouseButtons.Left && e.Clicks == 1)
                {
                    var loc   = new Point(e.X, e.Y);
                    var focus = Host.Focus as StyledTextFocus;
                    if (focus.Figure.IsInSelection(loc))
                    {
                        _selectionRangeOnDragStart = focus.Selection.Range;
                        e.DoIt = true;
                    }
                }
            };

            //ret.DragStart += delegate {
            //    var focus = Host.Focus as StyledTextFocus;
            //    _selectionRangeOnDragStart = focus.Selection.Range;
            //};
            ret.DragSetData += (sender, e) => {
                var focus = Host.Focus as StyledTextFocus;
                var flows = focus.Referer.Target.CopyBlocksAndInlines(focus.Selection.Range);
                var data  = new DataObject();
                //data.SetData(StyledTextConsts.BlocksAndInlinesFormat.Name, flows);
                data.SetData(StyledTextConsts.BlocksAndInlinesFormat.Name, false, flows);

                /// plain text
                {
                    var writer = new PlainTextWriter();
                    var text   = writer.ToPlainText(flows);
                    data.SetText(text, TextDataFormat.UnicodeText);
                }

                var app = MemopadApplication.Instance;

                /// html
                {
                    var writer = new HtmlWriter();
                    var html   = writer.ToHtml(flows);
                    data.SetData(DataFormats.Html, ClipboardUtil.GetCFHtmlMemoryStream(html));
                }

                e.DataObject = new DataObject(data);
            };
            ret.DragFinish += (sender, e) => {
                if (Host.IsFocused)
                {
                    /// このEditorにdropされた場合,
                    /// Moveの処理もDragTargetのDragDropで処理されるので何もしない
                }
                else
                {
                    /// 他のEditorにdropされた
                    if (e.Effects == DragDropEffects.Move)
                    {
                        var memoStyledText = (MemoStyledText)Host.Model;
                        var node           = (INode)Host.Figure;

                        BeginUpdate();
                        using (node.BeginUpdateStyledText()) {
                            var cmd = new RemoveCommand(
                                memoStyledText.StyledText,
                                _selectionRangeOnDragStart.Offset,
                                _selectionRangeOnDragStart.Length
                                );
                            Host.Site.CommandExecutor.Execute(cmd);
                        }
                        EndUpdate();

                        /// コメント線の処理
                        DisconnectRemovedAnchor(node, node);

                        /// StyledText.IsEmptyになったら削除
                        var model = Host.Model as MemoStyledText;
                        if (model != null && model.StyledText.IsEmpty)
                        {
                            Host.RequestRemove();
                        }
                    }
                }
                _selectionRangeOnDragStart = Range.Empty;
            };

            return(ret);
        }