// ========================================
        // method
        // ========================================
        public override void ConfigureEditor(IEditor editor)
        {
            var facade = MemopadApplication.Instance;

            var editorHandle = new MemoShapeEditorHandle();

            editorHandle.KeyMap = facade.KeySchema.MemoContentEditorKeyMap;
            editor.InstallEditorHandle(editorHandle);

            editor.InstallHandle(new ResizeHandle(Directions.Left)
            {
                Cursor = Cursors.SizeWE
            });
            editor.InstallHandle(new ResizeHandle(Directions.Up)
            {
                Cursor = Cursors.SizeNS
            });
            editor.InstallHandle(new ResizeHandle(Directions.Right)
            {
                Cursor = Cursors.SizeWE
            });
            editor.InstallHandle(new ResizeHandle(Directions.Down)
            {
                Cursor = Cursors.SizeNS
            });
            editor.InstallHandle(new ResizeHandle(Directions.UpLeft)
            {
                Cursor = Cursors.SizeNWSE
            });
            editor.InstallHandle(new ResizeHandle(Directions.UpRight)
            {
                Cursor = Cursors.SizeNESW
            });
            editor.InstallHandle(new ResizeHandle(Directions.DownLeft)
            {
                Cursor = Cursors.SizeNESW
            });
            editor.InstallHandle(new ResizeHandle(Directions.DownRight)
            {
                Cursor = Cursors.SizeNWSE
            });

            editor.InstallRole(new SelectRole());
            editor.InstallRole(new FocusRole(InitFocus, CommitFocus));
            editor.InstallRole(new ResizeRole());
            editor.InstallRole(new RemoveRole());
            editor.InstallRole(new CopyRole());
            editor.InstallRole(new ReorderRole());
            editor.InstallRole(new SetStyledTextFontRole(() => Model.StyledText, FontModificationKinds.All));
            editor.InstallRole(new SetStyledTextColorRole(() => Model.StyledText));
            editor.InstallRole(new SetStyledTextAlignmentRole(() => Model.StyledText, AlignmentModificationKinds.All));

            var editorFocus = new MemoStyledTextFocus(Host, facade.Settings.KeyScheme == KeySchemeKind.Emacs, false);

            editorFocus.LinkClicked += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };

            editor.InstallFocus(editorFocus);
        }
示例#2
0
 /// <inheritdoc/>
 protected override void OnMouseUp(MouseDevice device, MouseButton button, RoutedEventData data)
 {
     if (button == MouseButton.Left)
     {
         LinkUtil.ExecuteTextLink(textLayoutCommands, this, data);
     }
     base.OnMouseUp(device, button, data);
 }
示例#3
0
        private bool inserir(LinkUtil OLinkUtil)
        {
            OLinkUtil.setDefaultInsertValues();

            db.LinkUtil.Add(OLinkUtil);

            db.SaveChanges();

            return(OLinkUtil.id > 0);
        }
示例#4
0
 public override void Update()
 {
     base.Update();
     if (active && linkItem != null)
     {
         context.Clear();
         Debug.Log("UpdateBrotherPos");
         LinkUtil.UpdateBrotherPos(linkItem, context);
     }
 }
        public List <string> GetMatchingFiles()
        {
            var path = Path.Combine(
                Environment.GetEnvironmentVariable("AppData"),
                "Microsoft",
                "Windows",
                "Recent"
                );

            List <string> result = new List <string>();
            var           files  = Directory.EnumerateFiles(path, "*.lnk");

            foreach (var file in files)
            {
                // Typically happens with pendrives. Maybe we should treat this as a "Yes, please filter"?
                // Have a separate option to always delete no
                if (!File.Exists(file))
                {
                    Logger.Debug($"File {file} does not exist, skipping..");
                    continue;
                }

                string target;
                try {
                    target = LinkUtil.GetLnkTarget(_shell, file);
                }
                catch (COMException ex) {
                    if (LinkUtil.IsMissingDriveException(ex))
                    {
                        if (_filterMissingDrives)
                        {
                            result.Add(file);
                        }

                        continue;
                    }
                    else
                    {
                        throw;
                    }
                }

                foreach (var filter in _masks)
                {
                    var doFilter = target.StartsWith(filter, StringComparison.OrdinalIgnoreCase);
                    if (doFilter)
                    {
                        result.Add(file);
                        break;
                    }
                }
            }

            return(result);
        }
示例#6
0
        void Init()
        {
            ImageButton backButton = FindViewById <ImageButton>(Resource.Id.arrow_back);

            backButton.ContentDescription = SettingsViewModel.BACK_BUTTON_ACCESSIBILITY_TEXT;

            TextView titleField          = FindViewById <TextView>(Resource.Id.settings_how_it_works_title);
            TextView intro               = FindViewById <TextView>(Resource.Id.settings_how_it_works_intro);
            TextView heading1            = FindViewById <TextView>(Resource.Id.settings_how_it_works_heading1);
            TextView paragraph1textView1 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph1textView1);
            TextView paragraph1textView2 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph1textView2);
            TextView heading2            = FindViewById <TextView>(Resource.Id.settings_how_it_works_heading2);
            TextView paragraph2textView1 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph2textView1);
            TextView paragraph2textView2 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph2textView2);
            TextView paragraph2textView3 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph2textView3);
            TextView paragraph2textView4 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph2textView4);
            TextView heading3            = FindViewById <TextView>(Resource.Id.settings_how_it_works_heading3);
            TextView paragraph3textView1 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph3textView1);
            TextView heading4            = FindViewById <TextView>(Resource.Id.settings_how_it_works_heading4);
            TextView paragraph4textView1 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph4textView1);
            TextView paragraph4textView2 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph4textView2);
            TextView paragraph4textView3 = FindViewById <TextView>(Resource.Id.settings_how_it_works_paragraph4textView3);

            titleField.Text          = SettingsPage2ViewModel.SETTINGS_PAGE_2_HEADER;
            intro.Text               = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_INTRO;
            heading1.Text            = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_1_TITLE;
            paragraph1textView1.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_1_CONTENT;
            paragraph1textView2.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_1_CONTENT2;
            heading2.Text            = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_2_TITLE;
            paragraph2textView1.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_2_CONTENT;
            paragraph2textView2.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_2_CONTENT2;
            paragraph2textView3.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_2_CONTENT3;
            paragraph2textView4.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_2_CONTENT4;
            heading3.Text            = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_3_TITLE;
            paragraph3textView1.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_3_CONTENT;
            heading4.Text            = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_4_TITLE;
            paragraph4textView1.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_4_CONTENT;
            paragraph4textView2.Text = SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_4_CONTENT2;

            paragraph4textView3.TextFormatted = HtmlCompat.FromHtml(SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT_TEXT_PARAGRAPH_4_CONTENT3,
                                                                    HtmlCompat.FromHtmlModeLegacy);

            titleField.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());

            LinkUtil.LinkifyTextView(paragraph4textView3);
            FormatLink(paragraph4textView3);

            backButton.Click += new SingleClick((sender, args) => Finish()).Run;

            View rootView = Window.DecorView.RootView;

            rootView.LayoutDirection = LayoutUtils.GetLayoutDirection();
            backButton.SetBackgroundResource(LayoutUtils.GetBackArrow());
        }
        protected override void OnFigureMouseDown(MouseEventArgs e)
        {
            _startRowIndex = -1;
            _startColIndex = -1;
            _endRowIndex   = -1;
            _endColIndex   = -1;

            _isScenarioHandled = false;

            if (KeyUtil.IsShiftPressed())
            {
                var parent          = Host.Parent;
                var man             = Host.Site.SelectionManager;
                var selectedEditors = man.SelectedEditors;
                if (selectedEditors.Any() && selectedEditors.First().Parent == parent)
                {
                    var tableData   = GetParentTableData();
                    var firstEditor = selectedEditors.First();
                    _startRowIndex = tableData.GetRowIndex(firstEditor.Figure as TableCellFigure);
                    _startColIndex = tableData.GetColumnIndex(firstEditor.Figure as TableCellFigure);

                    _endRowIndex = tableData.GetRowIndex(Host.Figure as TableCellFigure);
                    _endColIndex = tableData.GetColumnIndex(Host.Figure as TableCellFigure);
                    SelectRange(_startRowIndex, _startColIndex, _endRowIndex, _endColIndex);
                }
            }
            else if (
                e.Button == MouseButtons.Left &&
                !KeyUtil.IsAltPressed() &&
                !KeyUtil.IsControlPressed() &&
                !KeyUtil.IsShiftPressed()
                )
            {
                var run = GetRun(e.Location);
                if (run != null && run.HasLink)
                {
                    LinkUtil.GoLink(run.Link);
                    _isScenarioHandled = true;
                }
                else
                {
                    _selectScenario.HandleMouseDown(this, e);
                }
            }
            else
            {
                _selectScenario.HandleMouseDown(this, e);
            }

            base.OnFigureMouseDown(e);
        }
示例#8
0
        //Status Veiculo
        public static string exibirStatus(this LinkUtil OLinkUtil)
        {
            string descricaoAtivo = "Desativado";

            switch (OLinkUtil.ativo)
            {
            case true:
                descricaoAtivo = "Ativo";
                break;
            }


            return(descricaoAtivo);
        }
        protected override void OnDrawPropertys()
        {
            base.OnDrawPropertys();

            if (selected == 0)
            {
                using (var hor = new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("坐标坍缩", EditorStyles.miniButtonRight, GUILayout.Width(100)))
                    {
                        LinkUtil.Clamp(targetItem.transform);
                    }
                }
            }
        }
        private Subscribe CreateModel()
        {
            var dataSourceId = RenderingContext.CurrentOrNull.Rendering.DataSource;
            var item         = Sitecore.Context.Database.GetItem(dataSourceId);

            var mailingList = new Subscribe()
            {
                Title                 = new HtmlString(FieldRenderer.Render(item, "Title")),
                LabelInputArial       = item.Fields["LabelInputArial"].Value,
                LabelInputPlaceHolder = item.Fields["LabelInputPlaceHolder"].Value,
                LabelButtonSubscribe  = item.Fields["LabelButtonSubscribe"].Value,
                SubmitUrl             = LinkUtil.GetUrlFromLinkField(item.Fields["SubmitUrl"])
            };

            return(mailingList);
        }
示例#11
0
        void Init()
        {
            ImageButton backButton = FindViewById <ImageButton>(Resource.Id.arrow_back);

            backButton.ContentDescription = SettingsViewModel.SETTINGS_CHILD_PAGE_ACCESSIBILITY_BACK_BUTTON;

            TextView textField  = FindViewById <TextView>(Resource.Id.settings_how_it_works_text);
            TextView titleField = FindViewById <TextView>(Resource.Id.settings_how_it_works_title);

            titleField.Text         = SettingsPage2ViewModel.SETTINGS_PAGE_2_HEADER;
            textField.TextFormatted = HtmlCompat.FromHtml(SettingsPage2ViewModel.SETTINGS_PAGE_2_CONTENT,
                                                          HtmlCompat.FromHtmlModeLegacy);
            LinkUtil.LinkifyTextView(textField);
            FormatLink(textField);

            backButton.Click += new SingleClick((sender, args) => Finish()).Run;
        }
示例#12
0
        private bool ContainsPattern(CFStorage storage, string fileName)
        {
            var stream = storage.GetStream(fileName);
            var data   = stream.GetData();

            if (data.Length == 0)
            {
                Logger.Debug($"Ignoring \"{fileName}\", len: 0");
                return(false);
            }

            foreach (var pattern in _masks)
            {
                try {
                    var target = GetLnkTarget(data);
                    if (target.ToLowerInvariant().StartsWith(pattern.ToLowerInvariant()))
                    {
                        Logger.Debug($"Target \"{target}\" matches pattern \"{pattern}\"");
                        return(true);
                    }
                    else if (string.Empty.Equals(target))
                    {
                        Logger.Debug($"Target \"{target}\" ignored, not a lnk file");
                    }
                }
                catch (System.Runtime.InteropServices.COMException ex) {
                    if (LinkUtil.IsMissingDriveException(ex))
                    {
                        Logger.Debug($"Target drive does not exist, marking for deletion");
                        return(true);
                    }
                    else
                    {
                        Logger.Debug($"Target ignored, not a lnk file");
                    }
                }

                /*if (ContainsSubstring(data, pattern)) {
                 *  return true;
                 * }*/
            }

            return(false);
        }
示例#13
0
        void Init()
        {
            Button backButton = FindViewById <Button>(Resource.Id.arrow_back_help);

            backButton.ContentDescription = ViewModels.SettingsViewModel.SETTINGS_CHILD_PAGE_ACCESSIBILITY_BACK_BUTTON;

            TextView textField  = FindViewById <TextView>(Resource.Id.settings_help_text);
            TextView titleField = FindViewById <TextView>(Resource.Id.settings_help_title);
            TextView hiddenLink = FindViewById <TextView>(Resource.Id.settings_help_link);

            titleField.Text         = HEADER;
            textField.TextFormatted =
                HtmlCompat.FromHtml($"{CONTENT_TEXT_BEFORE_SUPPORT_LINK} <a href=\"https://{SUPPORT_LINK}\">{SUPPORT_LINK_SHOWN_TEXT}</a><br><br>"

                                    /* Note:
                                     * This functionality is not planned for release 1.0. Kept for future use.
                                     *                      //$"{EMAIL_TEXT} <a href=\"mailto:{EMAIL}\">{EMAIL}</a> {PHONE_NUM_Text} <a href=\"tel:{PHONE_NUM}\">{PHONE_NUM}</a>.<br><br>" +
                                     *                      //$"{PHONE_OPEN_TEXT}<br><br>" +
                                     *                      //$"{PHONE_OPEN_MON_THU}<br>" +
                                     *                      //$"{PHONE_OPEN_FRE}<br><br>" +
                                     *                      //$"{PHONE_OPEN_SAT_SUN_HOLY}"
                                     */
                                    , HtmlCompat.FromHtmlModeLegacy);
            textField.ContentDescriptionFormatted =
                HtmlCompat.FromHtml($"{CONTENT_TEXT_BEFORE_SUPPORT_LINK} <a href=\"https://{SUPPORT_LINK}\">{SUPPORT_LINK_SHOWN_TEXT}</a><br><br>"

                                    /* Note:
                                     * This functionality is not planned for release 1.0. Kept for future use.
                                     *                      //$"{EMAIL_TEXT} <a href=\"mailto:{EMAIL}\">{EMAIL}</a> {PHONE_NUM_Text} <a href=\"tel:{PHONE_NUM}\">{PHONE_NUM_ACCESSIBILITY}</a>.<br><br>" +
                                     *                      //$"{PHONE_OPEN_TEXT}<br><br>" +
                                     *                      //$"{PHONE_OPEN_MON_THU_ACCESSIBILITY}<br>" +
                                     *                      //$"{PHONE_OPEN_FRE_ACCESSIBILITY}<br><br>" +
                                     *                      //$"{PHONE_OPEN_SAT_SUN_HOLY}"
                                     */
                                    , HtmlCompat.FromHtmlModeLegacy);
            textField.MovementMethod = LinkMovementMethod.Instance;
            backButton.Click        += new SingleClick((sender, args) => Finish()).Run;

            hiddenLink.Text = SUPPORT_LINK;
            hiddenLink.ContentDescription = SUPPORT_LINK_SHOWN_TEXT;

            LinkUtil.LinkifyTextView(hiddenLink);
        }
示例#14
0
        private HeroContent CreateModel()
        {
            var dataSourceId = RenderingContext.CurrentOrNull.Rendering.DataSource;
            var item         = Sitecore.Context.Database.GetItem(dataSourceId);

            var heroContent = new HeroContent()
            {
                Title               = new HtmlString(FieldRenderer.Render(item, "Title")),
                SubTitle            = new HtmlString(FieldRenderer.Render(item, "SubTitle")),
                Description         = new HtmlString(FieldRenderer.Render(item, "Description")),
                LinkMoreInformation = new HtmlString(FieldRenderer.Render(item, "LinkMoreInformation")),
                LinkJoin            = new HtmlString(FieldRenderer.Render(item, "LinkJoin")),
                BackgroundImage     = LinkUtil.GetUrlFromLinkField(item.Fields["BackgroundImage"]),
                VideoUrl            = LinkUtil.GetUrlFromLinkField(item.Fields["VideoUrl"]),
                MainEventDate       = ((DateField)item.Fields["MainEventDate"]).DateTime.ToString(),
                LabelDaysLeft       = new HtmlString(FieldRenderer.Render(item, "LabelDaysLeft")),
            };

            return(heroContent);
        }
示例#15
0
        //Alteracao de status
        public JsonMessageStatus alterarStatus(int id)
        {
            var retorno = new JsonMessageStatus();

            LinkUtil item = this.carregar(id);

            if (item == null)
            {
                retorno.error   = true;
                retorno.message = NotificationMessages.invalid_register_id;
            }
            else
            {
                item.ativo = (item.ativo == true ? false : true);
                db.SaveChanges();
                retorno.active  = item.ativo == true ? "S" : "N";
                retorno.message = NotificationMessages.updateSuccess;
            }
            return(retorno);
        }
示例#16
0
        private void bindTopicOne(IBlock block, ForumPost data, List <Attachment> attachList)
        {
            String quoteLink = Link.To(new Users.PostController().QuoteTopic, data.TopicId) + "?boardId=" + data.ForumBoardId;
            String replyLink = Link.To(new Users.PostController().ReplyTopic, data.TopicId) + "?boardId=" + data.ForumBoardId;
            String topicUrl  = LinkUtil.appendListPageToTopic(Link.To(new TopicController().Show, data.TopicId), ctx);

            block.Set("post.ReplyQuoteUrl", quoteLink);
            block.Set("post.ReplyUrl", replyLink);
            block.Set("post.TitleStyle", string.Empty);
            block.Set("post.PostUrl", topicUrl);
            String content = getTopicContent(data, attachList);

            block.Set("post.Body", content);

            block.Set("post.PostFullUrl", getFullUrl(topicUrl));

            block.Set("post.AdBody", AdItem.GetAdById(AdCategory.ForumTopicInner));

            block.Set("nofollow", "");
        }
示例#17
0
        //Atualizar os dados de um associado e os objetos relacionados
        private bool atualizar(LinkUtil OLinkUtil)
        {
            LinkUtil dbLinkUtil = this.carregar(OLinkUtil.id);

            if (dbLinkUtil == null)
            {
                return(false);
            }

            var entryLinkUtil = db.Entry(dbLinkUtil);

            OLinkUtil.setDefaultUpdateValues();

            entryLinkUtil.CurrentValues.SetValues(OLinkUtil);

            entryLinkUtil.ignoreFields();

            db.SaveChanges();

            return(OLinkUtil.id > 0);
        }
示例#18
0
        void Init()
        {
            ImageButton backButton = FindViewById <ImageButton>(Resource.Id.arrow_back_about);

            backButton.ContentDescription = ViewModels.SettingsViewModel.SETTINGS_CHILD_PAGE_ACCESSIBILITY_BACK_BUTTON;

            TextView titleField = FindViewById <TextView>(Resource.Id.settings_about_title);
            TextView textField  = FindViewById <TextView>(Resource.Id.settings_about_text);
            TextView hiddenLink = FindViewById <TextView>(Resource.Id.settings_about_link);

            FindViewById <TextView>(Resource.Id.settings_about_version_info_textview).Text = ViewModels.SettingsPage5ViewModel.GetVersionInfo();

            titleField.Text = SettingsPage5ViewModel.SETTINGS_PAGE_5_HEADER;
            textField.Text  = SettingsPage5ViewModel.SETTINGS_PAGE_5_CONTENT +
                              $" {SettingsPage5ViewModel.SETTINGS_PAGE_5_LINK}";

            backButton.Click += new SingleClick((sender, args) => Finish()).Run;

            hiddenLink.Text = SettingsPage5ViewModel.SETTINGS_PAGE_5_LINK;

            LinkUtil.LinkifyTextView(hiddenLink);
        }
示例#19
0
        public override void ConfigureEditor(IEditor editor)
        {
            var facade = MemopadApplication.Instance;

            var editorHandle = new MemoTableCellEditorHandle();

            editorHandle.KeyMap = facade.KeySchema.MemoTableCellEditorKeyMap;
            editor.InstallEditorHandle(editorHandle);

            editor.InstallHandle(new SelectionIndicatingHandle());

            editor.InstallRole(new SelectRole());
            editor.InstallRole(new FocusRole(InitFocus, CommitFocus));
            editor.InstallRole(new SetStyledTextFontRole(() => Model.StyledText, FontModificationKinds.All));
            editor.InstallRole(new SetStyledTextColorRole(() => Model.StyledText));
            editor.InstallRole(new SetStyledTextAlignmentRole(() => Model.StyledText, AlignmentModificationKinds.All));

            var editorFocus = new MemoStyledTextFocus(Host, facade.Settings.KeyScheme == KeySchemeKind.Emacs, false);

            editorFocus.IsConsiderHostBounds = true;
            editorFocus.LinkClicked         += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };
            editor.InstallFocus(editorFocus);

            editor.SelectionChanged += (sender, e) => {
                if (editor.IsSelected)
                {
                    var canvas = Host.Site.EditorCanvas;
                    var rect   = Figure.GetCharRect(0);
                    canvas.Caret.Position = rect.Location;

                    var loc = canvas.TranslateToControlPoint(rect.Location);
                    canvas.SetImePosition(loc);

                    canvas.EnsureVisible(editor);
                }
            };
        }
示例#20
0
        protected override void OnFigureMouseClick(MouseEventArgs e)
        {
            var handled = false;

            if (
                e.Button == MouseButtons.Left &&
                !KeyUtil.IsAltPressed() &&
                !KeyUtil.IsControlPressed() &&
                !KeyUtil.IsShiftPressed()
                )
            {
                var run = GetRun(e.Location);
                if (run != null && run.HasLink)
                {
                    LinkUtil.GoLink(run.Link);
                    handled = true;
                }
            }

            if (!handled)
            {
                base.OnFigureMouseClick(e);
            }
        }
示例#21
0
        private string GetLnkTarget(byte[] linkBytes)
        {
            var tmp = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".lnk");

            try {
                try {
                    File.WriteAllBytes(tmp, linkBytes);
                    // TODO: Verify that we're dealing with a .lnk before writing this to disk etc?
                    return(LinkUtil.GetLnkTarget(_shell, tmp));
                }
                catch (IOException ex) {
                    Logger.Warn(ex);
                    return(string.Empty);
                }
            }
            finally {
                try {
                    File.Delete(tmp);
                }
                catch (Exception ex) {
                    Logger.Warn(ex);
                }
            }
        }
        protected override void OnFigureMouseDown(MouseEventArgs e)
        {
            var handled = false;

            if (
                (e.Button == MouseButtons.Left || e.Button == MouseButtons.Middle) &&
                !KeyUtil.IsAltPressed() &&
                !KeyUtil.IsControlPressed() &&
                !KeyUtil.IsShiftPressed()
                )
            {
                var run = GetRun(e.Location);
                if (run != null && run.HasLink)
                {
                    LinkUtil.GoLink(run.Link);
                    handled = true;
                }
            }

            /// checkbox
            if (e.Button == MouseButtons.Left)
            {
                var node = _Figure as INode;
                if (node != null)
                {
                    var bulcmd = node.GetProcessCheckBoxBulletCommand(e.Location);
                    if (bulcmd != null)
                    {
                        /// bulcmdはFigureのStyledTextを変更するだけ
                        /// ModelのStyledTextを変えないといけない
                        bulcmd.Execute();

                        var model    = Host.Model as MemoText;
                        var oldStext = model.StyledText;
                        var newStext = node.StyledText.CloneDeeply() as StyledText.Core.StyledText;
                        var cmd      = new DelegatingCommand(
                            () => {
                            model.StyledText = newStext;
                        },
                            () => {
                            model.StyledText = oldStext;
                        }
                            );
                        Host.Site.CommandExecutor.Execute(cmd);
                        handled = true;
                    }
                }
            }


            if (!handled)
            {
                _isSelectedOnMouseDown = Host.IsSelected;
                _toggle = KeyUtil.IsControlPressed();

                /// EditorがFocusされていたらCommitしておく
                var focused = Host.Site.FocusManager.FocusedEditor;
                if (focused != null)
                {
                    focused.RequestFocusCommit(true);
                }

                Host.RequestSelect(SelectKind.True, !_toggle && !Host.IsSelected);
                if (e.Button == MouseButtons.Left && !KeyUtil.IsControlPressed())
                {
                    Host.RequestFocus(FocusKind.Begin, e.Location);
                    Host.Site.EditorCanvas.EventDispatcher.SetDnDTarget(Host.Focus.Figure);
                }
                base.OnFigureMouseDown(e);
            }
        }
        private void InitMenuItems()
        {
            _cutInNewMemo        = new ToolStripMenuItem("切り出す(&C)");
            _cutInNewMemo.Click += (sender, e) => {
                using (var form = new CreateMemoForm()) {
                    form.Font      = _app.Theme.CaptionFont;
                    form.MemoTitle = "新しいノート";
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        var copied = Owner.Referer.Target.CopyBlocksAndInlines(Owner.Referer.Selection.Range);

                        _app.ShowMainForm();
                        _app.ActivateMainForm();
                        var info = _app.CreateMemo(form.MemoTitle);

                        if (form.OriginalModification == CreateMemoForm.OriginalModificationKind.Remove)
                        {
                            Owner.RemoveForward();
                        }
                        else if (form.OriginalModification == CreateMemoForm.OriginalModificationKind.ReplaceWithLink)
                        {
                            Owner.RemoveForward();
                            Owner.InsertLink(info.Title, new Link(UriUtil.GetUri(info)));
                            if (copied.Last() is BlockBreak)
                            {
                                Owner.InsertBlockBreak();
                            }
                        }

                        var pageContent = _app.MainForm.FindPageContent(info);
                        var canvas      = pageContent.EditorCanvas;
                        var caret       = canvas.Caret;
                        var loc         = CaretUtil.GetExpectedMemoTextPosition(caret.Position);
                        MemoEditorHelper.AddBlocksAndInlines(canvas.RootEditor.Children.First(), loc, copied, false);
                    }
                }
            };


            _splitThisParagraph        = new ToolStripMenuItem("この行で分割(&S)");
            _splitThisParagraph.Click += (sender, e) => {
                using (_editor.Site.CommandExecutor.BeginChain()) {
                    var referer = Owner.Referer;
                    var stext   = referer.Target;

                    var lineIndex = stext.GetLineIndex(referer.CaretIndex);
                    var lineStart = stext.GetLineStartCharIndex(lineIndex);
                    var flows     = stext.CopyBlocksAndInlines(lineStart);

                    var rect = Rectangle.Empty;
                    rect = _focus.Figure.GetCharRect(lineStart);

                    Owner.Selection.Range = Range.FromStartAndEnd(lineStart - 1, stext.Length - 2);
                    Owner.RemoveForward();
                    _editor.RequestFocus(FocusKind.Commit, null);

                    var loc        = new Point(_editor.Figure.Left, rect.Bottom + 16);
                    var memoEditor = _editor.Parent;
                    var created    = MemoEditorHelper.AddBlocksAndInlines(memoEditor, loc, flows, true);
                    created.RequestFocusCommit(true);
                }
            };

            _splitParagraphs        = new ToolStripMenuItem("段落ごとに分割(&P)");
            _splitParagraphs.Click += (sender, e) => {
                using (_editor.Figure.Root.DirtManager.BeginDirty())
                    using (_editor.Site.CommandExecutor.BeginChain()) {
                        var referer    = Owner.Referer;
                        var stext      = referer.Target;
                        var memoEditor = _editor.Parent;

                        var created  = default(IEditor);
                        var createds = new List <IEditor>();
                        var cTop     = _editor.Figure.Top;
                        foreach (var block in stext.Blocks)
                        {
                            var flows = new Flow[] { block.CloneDeeply() as Block, };
                            var loc   = new Point(_editor.Figure.Left, cTop);
                            created = MemoEditorHelper.AddBlocksAndInlines(memoEditor, loc, flows, true);
                            createds.Add(created);
                            cTop += created.Figure.Height + 16;
                        }
                        created.RequestFocusCommit(true);

                        _editor.RequestRemove();

                        var cmd = new SelectMultiCommand(createds, SelectKind.True, true);
                        cmd.Execute();
                    }
            };


            _openLink        = new ToolStripMenuItem("リンクを開く(&O)");
            _openLink.Click += (sender, e) => {
                var run = Owner.GetInlineAtCaretIndex() as Run;
                if (run != null && run.HasLink)
                {
                    LinkUtil.GoLink(run.Link);
                }
            };

            _removeLink        = new ToolStripMenuItem("リンクを削除(&R)");
            _removeLink.Click += (sender, e) => {
                Owner.UnsetLink();
            };

            _setLink        = new ToolStripMenuItem("リンクを設定(&L)");
            _setLink.Click += (sender, e) => {
                if (Owner.Selection.IsEmpty)
                {
                    var run = Owner.GetInlineAtCaretIndex() as Run;
                    if (run != null)
                    {
                        var oldUri = default(string);
                        if (run != null && run.HasLink)
                        {
                            oldUri = run.Link.Uri;
                        }

                        var oldText = run.Text;
                        var dialog  = new LinkSelectForm();
                        if (dialog.ShowDialog(_app.MainForm, oldUri, run.Text) == DialogResult.OK)
                        {
                            var uri     = dialog.Uri;
                            var newText = dialog.TitleText;
                            if (newText != oldText)
                            {
                                Owner.SetRunText(run, newText);
                            }
                            if (uri != oldUri)
                            {
                                Owner.SetLink(uri, null);
                            }
                        }
                    }
                }
                else
                {
                    var range   = Owner.Selection.Range;
                    var oldText = Owner.Referer.Target.Text.Substring(range.Offset, range.Length);

                    var dialog = new LinkSelectForm();
                    dialog.TitleTextTextBoxEnabled = false;
                    if (dialog.ShowDialog(_app.MainForm, null, oldText) == DialogResult.OK)
                    {
                        Owner.SetLink(dialog.Uri, null);
                    }
                }
            };


            _addComment        = new ToolStripMenuItem("コメントを追加(&C)");
            _addComment.Click += (sender, e) => {
                MemoEditorHelper.AddCommentForMemoText(Owner);
            };
        }
示例#24
0
        // ------------------------------
        // private
        // ------------------------------
        private void InitEditorFocus(IEditor editor)
        {
            var app         = MemopadApplication.Instance;
            var editorFocus = new MemoStyledTextFocus(editor, app.Settings.KeyScheme == KeySchemeKind.Emacs, true);

            editorFocus.IsCurrentLineBackgroundEnable = true;
            editorFocus.IsConsiderImeWindowSize       = true;
            editorFocus.IsConsiderHostBounds          = true;
            editorFocus.Figure.Padding    = DefaultPadding;
            editorFocus.Figure.DragTarget = CreateFocusFigureDragTarget();
            editorFocus.Figure.DragSource = CreateFocusFigureDragSource();

            /// キー入力時にテキストがemptyなら削除
            editorFocus.ShortcutKeyProcess += (sender, e) => {
                RemoveIfEmpty(editorFocus, e.KeyData);
            };
            editorFocus.KeyDown += (sender, e) => {
                RemoveIfEmpty(editorFocus, e.KeyData);
            };
            //editorFocus.KeyDown += (sender, e) => {
            //    var mtext = Host.Model as MemoText;
            //    if (mtext.IsSticky) {
            //        /// stickyなら何もしない
            //        return;
            //    }

            //    var editorCanvas = Host.Site.EditorCanvas;
            //    if (
            //        editorFocus.StyledText.IsEmpty &&
            //        e.KeyData != Keys.ProcessKey &&
            //        editorCanvas.GetImeString().Length == 0
            //    ) {
            //        var parent = Host.Parent;
            //        Host.RequestFocus(FocusKind.Rollback, null);
            //        Host.RequestRemove();
            //        parent.RequestSelect(SelectKind.True, true);
            //    }
            //};
            editorFocus.LinkClicked += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };

            editor.InstallFocus(editorFocus);

            /// コミット時にStyledTextがemptyなら削除
            editor.FocusChanged += (sender, e) => {
                var mtext = Host.Model as MemoText;
                if (mtext.IsSticky)
                {
                    /// stickyなら何もしない
                    return;
                }

                if (!editor.IsFocused)
                {
                    var styledText = Model.StyledText;
                    if (styledText.IsEmpty)
                    {
                        var parent = editor.Parent;
                        editor.RequestRemove();
                        parent.RequestSelect(SelectKind.True, true);
                    }
                }
            };
        }
示例#25
0
 private void appendLink(String url, StringBuilder builder, int i)
 {
     builder.AppendFormat("<a href=\"{0}\" target=\"_blank\">{1}</a> ", LinkUtil.appendListPage(PageHelper.AppendNo(url, i), ctx), i);
 }
示例#26
0
        private void bindTopicOne(IBlock block, ForumTopic topic, Boolean isAdmin, Boolean isSticky, int replySize)
        {
            if (topic.Creator == null)
            {
                return;
            }

            String stickyIconName = topic.IsGlobalSticky ? "gsticky" : "sticky";

            if (isSticky)
            {
                block.Set("stickyIconName", stickyIconName);
            }

            String rewardInfo = string.Empty;

            if (topic.Reward > 0)
            {
                rewardInfo = getRewardInfo(topic, rewardInfo);
            }

            String   lblNew  = string.Empty;
            ForumApp app     = ctx.app.obj as ForumApp;
            int      newDays = app.GetSettingsObj().NewDays;

            if (DateTime.Now.Subtract(topic.Created).Days < newDays)
            {
                lblNew = "<span class=\"supNew\">new</span>";
            }


            String lblCategory = string.Empty;

            if (topic.Category != null && topic.Category.Id > 0)
            {
                String lnkCategory = to(new BoardController().Category, topic.ForumBoard.Id) + "?categoryId=" + topic.Category.Id;
                lblCategory = string.Format("<a href=\"{0}\" target=\"_blank\"><span style=\"color:{2}\">[{1}]</span></a>&nbsp;", lnkCategory, topic.Category.Name, topic.Category.NameColor);
            }

            String typeImg = string.Empty;

            if (strUtil.HasText(topic.TypeName))
            {
                typeImg = string.Format("<img src=\"{0}apps/forum/{1}.gif\">", sys.Path.Skin, topic.TypeName);
            }

            String priceInfo = string.Empty;

            if (topic.Price > 0)
            {
                priceInfo = alang("price") + " :" + topic.Price + " ";
            }

            String permissionInfo = string.Empty;

            if (topic.ReadPermission > 0)
            {
                permissionInfo = alang("readPermission") + ":" + topic.ReadPermission + "";
            }

            //String chkId = "";
            //if (isAdmin) chkId = "<input type=\"checkbox\" name=\"postSelect\" id=\"checkbox" + topic.Id + "\" value=\"" + topic.Id + "\" />";
            String chkId = "<input type=\"checkbox\" name=\"postSelect\" id=\"checkbox" + topic.Id + "\" value=\"" + topic.Id + "\" />";


            block.Set("p.CheckBox", chkId);

            block.Set("p.Id", topic.Id);
            block.Set("p.Category", lblCategory);
            block.Set("p.TypeImg", typeImg);
            block.Set("p.Reward", rewardInfo);
            block.Set("p.Price", priceInfo);
            block.Set("p.ReadPermission", permissionInfo);
            block.Set("p.Titile", strUtil.CutString(topic.Title, 40));
            block.Set("p.TitleStyle", topic.TitleStyle);
            block.Set("p.LabelNew", lblNew);

            String lnk = LinkUtil.appendListPage(to(new TopicController().Show, topic.Id), ctx);

            block.Set("p.Url", lnk);

            block.Set("p.Pages", getPostPagesString(alink.ToAppData(topic), topic.Replies, replySize));
            block.Set("p.MemberName", topic.Creator.Name);
            block.Set("p.MemberUrl", toUser(topic.Creator));
            block.Set("p.CreateTime", topic.Created.ToShortDateString());
            block.Set("p.ReplyCount", topic.Replies);
            block.Set("p.Hits", topic.Hits);
            block.Set("p.LastUpdate", topic.Replied.GetDateTimeFormats('g')[0]);
            block.Set("p.LastReplyUrl", toUser(topic.RepliedUserFriendUrl));
            block.Set("p.LastReplyName", topic.RepliedUserName);

            String attachments = topic.Attachments > 0 ? "<img src='" + sys.Path.Img + "attachment.gif'/>" : "";

            block.Set("p.Attachments", attachments);

            String statusImg;

            if (topic.IsLocked == 1)
            {
                statusImg = sys.Path.Skin + "apps/forum/lock.gif";
            }
            else if (topic.IsPicked == 1)
            {
                statusImg = sys.Path.Skin + "apps/forum/pick.gif";
            }
            else
            {
                statusImg = sys.Path.Skin + "apps/forum/topic.gif";
            }

            block.Set("postStatusImage", statusImg);
            block.Next();
        }
示例#27
0
        /// <inheritdoc/>
        protected override void OnIsMouseOverChanged()
        {
            LinkUtil.UpdateLinkCursor(textLayoutCommands, this, null);

            base.OnIsMouseOverChanged();
        }
        private void InitReorderLists()
        {
            portLists = new ReorderableList[linkPorts.Length];
            for (int i = 0; i < portLists.Length; i++)
            {
                var id   = i;
                var port = linkPorts[i];
                port.connectAble.Sort();

                portLists[i] = new ReorderableList(port.connectAble, typeof(LinkInfo));
                portLists[i].drawHeaderCallback = (rect) =>
                {
                    var nameRect  = new Rect(rect.x + 15, rect.y, rect.width * 0.4f, EditorGUIUtility.singleLineHeight);
                    var idRect    = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);

                    EditorGUI.LabelField(nameRect, string.Format("目标({0}:{1})", port.name, port.NodeID));
                    EditorGUI.LabelField(idRect, "端口");
                    EditorGUI.BeginChangeCheck();
                    port.Range  = GUI.HorizontalSlider(rangeRect, port.Range, 0.1f, 2);
                    port.NodeID = id;
                    port.InitLayer();
                    if (EditorGUI.EndChangeCheck())
                    {
                        port.Range = (float)System.Math.Round(port.Range, 2);
                    }
                    var btnRect = new Rect(rect.x + rect.width - buttonWidth * 2f, rect.y, buttonWidth, EditorGUIUtility.singleLineHeight);

                    if (GUI.Button(btnRect, "Record"))
                    {
                        List <LinkPort> otherPorts;
                        if (LinkUtil.FindTriggerNodes(port, out otherPorts))
                        {
                            if (otherPorts != null && otherPorts.Count > 0)
                            {
                                var window = EditorWindow.GetWindow <LinkWindow>();
                                window.InitPortGroup(port, otherPorts.ToArray());
                            }
                        }
                    }
                    btnRect.x += buttonWidth;
                    if (GUI.Button(btnRect, "Link"))
                    {
                        if (Selection.activeGameObject != null)
                        {
                            var linkport = Selection.activeGameObject.GetComponentInParent <LinkPort>();
                            if (linkport != null)
                            {
                                var linkItem = linkport.GetComponentInParent <LinkItem>();
                                var linkInfo = port.connectAble.Find(x => x.itemName == linkItem.Name && x.nodeId == linkport.NodeID);
                                if (linkInfo != null)
                                {
                                    LinkUtil.ResetTargetTranform(targetItem, linkItem, linkInfo.relativePos, linkInfo.relativeDir);
                                }
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("温馨提示", "请选择目标端口后重试", "确认");
                            }
                        }
                    }
                };
                portLists[i].drawElementCallback = (rect, index, isactive, isfoces) =>
                {
                    var linkInfo = port.connectAble[index];
                    var nameRect = new Rect(rect.x, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(nameRect, linkInfo.itemName);
                    var idRect = new Rect(rect.x + rect.width * 0.4f, rect.y, rect.width * 0.3f, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(idRect, linkInfo.nodeId.ToString());
                    var rangeRect = new Rect(rect.x + rect.width * 0.55f, rect.y, 60, EditorGUIUtility.singleLineHeight);
                    EditorGUI.LabelField(rangeRect, port.Range.ToString());
                };
            }
        }
示例#29
0
        /// <inheritdoc/>
        protected override void OnMouseLeave(MouseDevice device, RoutedEventData data)
        {
            LinkUtil.UpdateLinkCursor(textLayoutCommands, this, Mouse.GetPosition(this));

            base.OnMouseLeave(device, data);
        }
示例#30
0
        /// <inheritdoc/>
        protected override void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data)
        {
            LinkUtil.UpdateLinkCursor(textLayoutCommands, this, Mouse.GetPosition(this));

            base.OnMouseMove(device, x, y, dx, dy, data);
        }