Exemplo n.º 1
0
        private void DomNode_AttributeChanging(object sender, AttributeEventArgs e)
        {
            ITimelineObject item = e.DomNode.As <ITimelineObject>();

            if (item != null)
            {
                if (!IsEditable(item, e.AttributeInfo))
                {
                    if (ActiveDocument.Cast <ITransactionContext>().InTransaction)
                    {
                        throw new InvalidTransactionException("timeline object can't be edited");
                    }
                    else
                    {
                        return;
                    }
                }

                // Check if a URI on a timeline reference has changed, so we can unload
                //  old document and load new document.
                if (e.AttributeInfo.Equivalent(Schema.timelineRefType.refAttribute))
                {
                    UnloadSubDocument((Uri)e.OldValue);
                    LoadSubDocument((Uri)e.NewValue);
                }
            }
        }
Exemplo n.º 2
0
 private void exportAsHtmlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.ExportAsHtml();
     }
 }
        private void InitializeCommands(XmlRepository repository, IConfiguration configuration, IMenuCommandService commandService)
        {
            var activeDocument = new ActiveDocument();

            var subMenu = CreateSubMenu(activeDocument);
            commandService.AddCommand(subMenu);

            var copyGenericXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyGenericXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyGenericXPathCommand);

            var copyAbsoluteXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyAbsoluteXPath, repository, activeDocument, () => new AbsoluteXPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes)}), new CommandTextFormatter());
            commandService.AddCommand(copyAbsoluteXPathCommand);

            var copyDistinctXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopyDistinctXPath, repository, activeDocument, () => new XPathWriter(new[] {new AttributeFilter(configuration.AlwaysDisplayedAttributes), new DistinctAttributeFilter(configuration.PreferredAttributeCandidates)}), new CommandTextFormatter());
            commandService.AddCommand(copyDistinctXPathCommand);

            var copySimplifiedXPathCommand = new CopyXPathCommand(Symbols.CommandIDs.CopySimplifiedXPath, repository, activeDocument, () => new SimplifiedXPathWriter(new[] { new AttributeFilter(configuration.AlwaysDisplayedAttributes) }), new TrimCommandTextFormatter());
            commandService.AddCommand(copySimplifiedXPathCommand);

            var showXPathWorkbenchCommand = new ShowXPathWorkbenchCommand(this, commandService, Symbols.CommandIDs.ShowXPathWorkbench, repository, activeDocument);
            commandService.AddCommand(showXPathWorkbenchCommand.Command);

            var copyXmlStructureCommand = new CopyXmlStructureCommand(Symbols.CommandIDs.CopyXmlStructure, repository, activeDocument, () => new XmlStructureWriter(), new CommandTextFormatter());
            commandService.AddCommand(copyXmlStructureCommand);
        }
Exemplo n.º 4
0
 private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.SaveAs();
     }
 }
Exemplo n.º 5
0
 private void tsbClose_Click(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.Close();
     }
 }
Exemplo n.º 6
0
        private OleMenuCommand CreateSubMenu(ActiveDocument activeDocument)
        {
            EventHandler onBeforeQuery    = (sender, args) => { ((OleMenuCommand)sender).Visible = activeDocument.IsXmlDocument; };
            var          subMenuCommandId = new CommandID(Guid.Parse(Symbols.PackageID), Symbols.MenuIDs.SubMenu);

            return(new OleMenuCommand(null, null, onBeforeQuery, subMenuCommandId));
        }
Exemplo n.º 7
0
        public void SetProgressBarVisibility(bool visibility)
        {
            if (this.TaskbarItemInfo != null)
            {
                // taskbar progress object
                this.TaskbarItemInfo.ProgressState = visibility ? System.Windows.Shell.TaskbarItemProgressState.Normal : System.Windows.Shell.TaskbarItemProgressState.None;
            }

            WaitReadyBrowser();
            if (ActiveDocument != null)
            {
                var cssdisplay    = visibility ? "" : "display: none;";
                var pbarcontainer = ActiveDocument.GetElementById(ScriptConsoleConfigs.ProgressBlockId);
                if (pbarcontainer.Style != null)
                {
                    if (pbarcontainer.Style.Contains("display:"))
                    {
                        pbarcontainer.Style = Regex.Replace(pbarcontainer.Style, "display:.+?;",
                                                            cssdisplay,
                                                            RegexOptions.IgnoreCase);
                    }
                    else
                    {
                        pbarcontainer.Style += cssdisplay;
                    }
                }
                else
                {
                    pbarcontainer.Style = cssdisplay;
                }
            }
        }
Exemplo n.º 8
0
        public List <IRoomInformations> GetAllRoomUpdatesSinceLastTimeChecked(string ServerVersion)
        {
            DateTime CurrentTime = DateTime.Now;
            FilterDefinition <BsonDocument> LastTimeCheckedFilter = Builders <BsonDocument> .Filter.Gte("LastUpdate", LastTimeChecked);

            List <BsonDocument>      ListFoundRoomDocument = RoomsCollection.Find(LastTimeCheckedFilter).ToList();
            List <IRoomInformations> ListFoundRoom         = new List <IRoomInformations>();

            foreach (BsonDocument ActiveDocument in ListFoundRoomDocument)
            {
                string RoomID             = ActiveDocument.GetValue("_id").AsObjectId.ToString();
                string RoomName           = ActiveDocument.GetValue("RoomName").AsString;
                string RoomType           = ActiveDocument.GetValue("RoomType").AsString;
                string RoomSubtype        = ActiveDocument.GetValue("RoomSubtype").AsString;
                bool   IsPlaying          = ActiveDocument.GetValue("IsPlaying").AsBoolean;
                string Password           = ActiveDocument.GetValue("Password").AsString;
                string OwnerServerIP      = ActiveDocument.GetValue("OwnerServerIP").AsString;
                int    OwnerServerPort    = ActiveDocument.GetValue("OwnerServerPort").AsInt32;
                byte   CurrentPlayerCount = (byte)ActiveDocument.GetValue("CurrentPlayerCount").AsInt32;
                byte   MinNumberOfPlayer  = (byte)ActiveDocument.GetValue("MinNumberOfPlayer").AsInt32;
                byte   MaxNumberOfPlayer  = (byte)ActiveDocument.GetValue("MaxNumberOfPlayer").AsInt32;
                bool   IsDead             = ActiveDocument.GetValue("IsDead").AsBoolean;

                IRoomInformations NewRoom = new ServerRoomInformations(RoomID, RoomName, RoomType, RoomSubtype, IsPlaying, Password,
                                                                       OwnerServerIP, OwnerServerPort, CurrentPlayerCount, MinNumberOfPlayer, MaxNumberOfPlayer, IsDead);
                ListFoundRoom.Add(NewRoom);
            }

            LastTimeChecked = CurrentTime;
            return(ListFoundRoom);
        }
Exemplo n.º 9
0
 void textEditorControl1_DocumentChanged(object sender, DocumentEventArgs e)
 {
     if (e.Length != 0)
     {
         ActiveDocument.DocumentEdited(this);
     }
 }
Exemplo n.º 10
0
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.Close();
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// When we click redo
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnRedoClick(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.DoCommand(BindableCommand.Redo);
     }
 }
Exemplo n.º 12
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (ActiveDocument.IsEdited)
     {
         ActiveDocument.Save(this);
     }
 }
 private void comboBox_entity_subtype_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!m_ignore_combobox_entity_sub_type_changed)
     {
         ActiveDocument.SetSelectedEntitySubType(((ComboBox)sender).SelectedIndex);
     }
 }
Exemplo n.º 14
0
 private void OnLineUncommentClick(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.DoCommand(BindableCommand.LineUncomment);
     }
 }
Exemplo n.º 15
0
 private void OnBlockCommentClick(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.DoCommand(BindableCommand.StreamComment);
     }
 }
Exemplo n.º 16
0
 private void closeMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.Close();
     }
 }
Exemplo n.º 17
0
 private void saveAsMenuItem_Click(object sender, RoutedEventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.SaveAs();
     }
 }
Exemplo n.º 18
0
        private int MatchNext(string matchText)
        {
            if (String.IsNullOrEmpty(matchText))
            {
                return(-1);
            }

            int indexOf = -1;

            try
            {
                ActiveTextArea.BeginUpdate();
                int    lineNo          = ActiveTextArea.Caret.Line;
                int    colNo           = ActiveTextArea.Caret.Column;
                int    totalNumOfLines = ActiveDocument.TotalNumberOfLines;
                string LineText        = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                LineText = ActiveDocument.GetText(ActiveTextArea.Caret.Offset, LineText.Length - colNo);

                indexOf = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                int offset = colNo;

                if (indexOf < 0)
                {
                    offset = 0;
                    do
                    {
                        int tmpLineNo = ActiveDocument.GetNextVisibleLineAbove(lineNo, 1);
                        if (tmpLineNo == lineNo)
                        {
                            break;
                        }
                        lineNo   = tmpLineNo;
                        LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                        indexOf  = LineText.IndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                    }while (indexOf < 0 && lineNo < totalNumOfLines);
                }

                if (indexOf >= 0)
                {
                    ActiveTextArea.Caret.Column = 0;
                    ActiveTextArea.Caret.Line   = lineNo;

                    Point startPoint = ActiveTextArea.Caret.Position;
                    startPoint.X = indexOf + offset;
                    Point endPoint = startPoint;
                    endPoint.X = endPoint.X + matchText.Length;
                    ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint);
                    ActiveTextArea.Caret.Column = endPoint.X;
                }
                else if (lineNo == totalNumOfLines - 1)
                {
                    MessageBox.Show("Reached end of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
            return(indexOf);
        }
Exemplo n.º 19
0
 /// <summary>
 /// When we click find
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnFindClick(object sender, EventArgs e)
 {
     if (ActiveDocument != null)
     {
         ActiveDocument.ShowFind();
     }
 }
Exemplo n.º 20
0
        public System.Windows.Forms.HtmlElement ComposeEntry(string contents, string HtmlElementType)
        {
            WaitReadyBrowser();
            var htmlElement = ActiveDocument.CreateElement(HtmlElementType);

            htmlElement.InnerHtml = ScriptOutputEmojis.Emojize(contents);
            return(htmlElement);
        }
Exemplo n.º 21
0
 protected CopyCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func<IWriter> writerProvider, ICommandTextFormatter textFormatter)
 {
     _activeDocument = activeDocument;
     Repository = repository;
     Command = new OleMenuCommand(OnInvoke, null, OnBeforeQueryStatus, new CommandID(Guid.Parse(Symbols.PackageID), id));
     WriterProvider = writerProvider;
     TextFormatter = textFormatter;
 }
Exemplo n.º 22
0
 protected CopyCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func <IWriter> writerProvider, ICommandTextFormatter textFormatter)
 {
     Repository      = repository ?? throw new ArgumentNullException(nameof(repository));
     _activeDocument = activeDocument ?? throw new ArgumentNullException(nameof(activeDocument));
     Command         = new OleMenuCommand(OnInvoke, null, OnBeforeQueryStatus, new CommandID(Guid.Parse(Symbols.PackageID), id));
     WriterProvider  = writerProvider ?? throw new ArgumentNullException(nameof(writerProvider));
     TextFormatter   = textFormatter ?? throw new ArgumentNullException(nameof(textFormatter));
 }
Exemplo n.º 23
0
 public void Freeze()
 {
     WaitReadyBrowser();
     _lastDocumentBody           = ActiveDocument.CreateElement("<body>");
     _lastDocumentBody.InnerHtml = ActiveDocument.Body.InnerHtml;
     _frozen = true;
     UpdateInlineWaitAnimation();
 }
Exemplo n.º 24
0
        private int MatchPrev(string matchText)
        {
            if (String.IsNullOrEmpty(matchText))
            {
                return(-1);
            }

            int indexOf = -1;

            try
            {
                ActiveTextArea.BeginUpdate();
                int lineNo = ActiveTextArea.Caret.Line;
                int colNo  = ActiveTextArea.Caret.Column;

                string LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);
                LineText = LineText.Substring(0, ActiveTextArea.Caret.Column);

                indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                if (indexOf < 0)
                {
                    do
                    {
                        int tmpLineNo = ActiveDocument.GetNextVisibleLineBelow(lineNo, 1);
                        if (tmpLineNo == lineNo)
                        {
                            break;
                        }
                        lineNo   = tmpLineNo;
                        LineText = SharpDevelopTextEditorUtilities.GetLineAsString(ActiveDocument, lineNo);

                        indexOf = LineText.LastIndexOf(matchText, StringComparison.InvariantCultureIgnoreCase);
                    }while (indexOf < 0 && lineNo >= 0);
                }

                if (indexOf > 0)
                {
                    ActiveTextArea.Caret.Column = 0;
                    ActiveTextArea.Caret.Line   = lineNo;

                    Point startPoint = ActiveTextArea.Caret.Position;
                    startPoint.X = indexOf;
                    Point endPoint = startPoint;
                    endPoint.X = endPoint.X + matchText.Length;
                    ActiveTextArea.SelectionManager.SetSelection(startPoint, endPoint);
                    ActiveTextArea.Caret.Column = startPoint.X;
                }
                else if (lineNo == 0)
                {
                    MessageBox.Show("Reached start of document", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
            return(indexOf);
        }
Exemplo n.º 25
0
 private void SqlBulkCopy_SqlRowsCopied(object sender, SqlRowsCopiedEventArgs e)
 {
     if (CancelRequested)
     {
         e.Abort = true;
     }
     new StatusBarMessage(ActiveDocument, $"Exporting Table {currentTableIdx} of {totalTableCnt} : {sqlTableName} ({e.RowsCopied:N0} rows)");
     ActiveDocument.RefreshElapsedTime();
 }
Exemplo n.º 26
0
        public ShowXPathWorkbenchCommand(Package package, int id, XmlRepository repository, ActiveDocument activeDocument)
        {
            _package        = package ?? throw new ArgumentNullException(nameof(package));
            _repository     = repository ?? throw new ArgumentNullException(nameof(repository));
            _activeDocument = activeDocument ?? throw new ArgumentNullException(nameof(activeDocument));
            var menuCommandID = new CommandID(Guid.Parse(Symbols.PackageID), id);

            Command = new OleMenuCommand(ShowToolWindow, null, OnBeforeQueryStatus, menuCommandID, PackageResources.ShowXPathWorkbenchCommandText);
        }
Exemplo n.º 27
0
        private void ShowClipboardHistoryHandler(object sender, ExecutedRoutedEventArgs args)
        {
            ActiveDocument.EnsurePopupClosed();

            new WindowClipboardHistory {
                Owner = this
            }
            .ShowDialog();
        }
Exemplo n.º 28
0
        /// <summary>
        /// Import a document and merge it into the current active model.
        /// </summary>
        public void ImportDocument()
        {
            ModelDocument doc = OpenDocument(true);

            if (doc != null)
            {
                ActiveDocument.MergeIn(doc);
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Save the currently open document to a file path
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public bool SaveDocument(FilePath filePath)
 {
     try
     {
         ActiveDocument.SaveAs2(filePath.Path);
         return(true);
     }
     catch { }
     return(false);
 }
Exemplo n.º 30
0
        internal void Run(List <IBuildTarget> targets)
        {
            if (IsDirty(ActiveWindow))
            {
                SaveDocument();
            }

            ActiveDocument.SetTargets(targets);
            ActiveDocument.Run();
        }
Exemplo n.º 31
0
        public void ConvertTokensTo(TokenConversionType conversionType)
        {
            try
            {
                ActiveTextArea.BeginUpdate();

                StringBuilder       sb    = null;
                HighlightRuleSet    rules = ActiveDocument.HighlightingStrategy.GetRuleSet(null);
                IList <LineSegment> lines = ActiveDocument.LineSegmentCollection;
                for (int k = 0; k < lines.Count; k++)
                {
                    LineSegment segment = lines[k];
                    for (int i = 0; i < segment.Words.Count; i++)
                    {
                        TextWord word = segment.Words[i];
                        if (word.Type != TextWordType.Word)
                        {
                            continue;
                        }

                        if (rules.KeyWords[ActiveDocument, segment, word.Offset, word.Length] != null)
                        {
                            string newVal = word.Word;
                            switch (conversionType)
                            {
                            case TokenConversionType.Lower:
                                newVal = word.Word.ToLowerInvariant();
                                break;

                            case TokenConversionType.Upper:
                                newVal = word.Word.ToUpperInvariant();
                                break;

                            case TokenConversionType.Capitalize:
                                newVal = word.Word;
                                char[] chars = newVal.ToCharArray();
                                chars[0] = Char.ToUpperInvariant(newVal[0]);
                                sb       = new StringBuilder();
                                sb.Append(chars);
                                newVal = sb.ToString();
                                break;

                            default:
                                break;
                            }
                            ActiveDocument.Replace(segment.Offset + word.Offset, word.Length, newVal);
                        }
                    }
                }
            }
            finally
            {
                ActiveTextArea.EndUpdate();
            }
        }
Exemplo n.º 32
0
        internal void SaveFile(FileViewModelBase fileToSave, bool saveAsFlag = false)
        {
            if (fileToSave.FilePath == null || saveAsFlag)
            {
                var dlg = new SaveFileDialog();
                if (dlg.ShowDialog().GetValueOrDefault())
                {
                    fileToSave.FilePath = dlg.SafeFileName;
                }
            }

            if (fileToSave.FilePath == null)
            {
                return;
            }

            if (fileToSave is AudioFileViewModel)
            {
                // TODO : Save action
            }
            else if (fileToSave is GeneralFileViewModel)
            {
                GeneralFileViewModel file = fileToSave as GeneralFileViewModel;

                if (file.IsDirty)
                {
                    FileManager.WriteTextFile(file.FilePath, file.TextContent, Encoding.UTF8);
                }
            }
            else if (fileToSave is ImageFileViewModel)
            {
                // TODO : Save action
            }
            else if (fileToSave is JsonFileViewModel)
            {
                JsonFileViewModel file = fileToSave as JsonFileViewModel;

                if (file.IsDirty)
                {
                    FileManager.WriteTextFile(file.FilePath, file.DocumentText, Encoding.UTF8);
                }
            }
            else if (fileToSave is SaveFileViewModel)
            {
                // TODO : Save action
            }
            else if (fileToSave is ScriptFileViewModel)
            {
                // TODO : Save action
            }

            ActiveDocument.IsDirty = false;
            ActiveDocument.OnAfterSave(null);
        }
 public ShowXPathWorkbenchCommand(Package package, IMenuCommandService commandService, int id, XmlRepository repository, ActiveDocument activeDocument)
 {
     _package = package;
     _repository = repository;
     _activeDocument = activeDocument;
     if(commandService == null)
     {
         throw new ArgumentNullException(nameof(commandService));
     }
     var menuCommandID = new CommandID(Guid.Parse(Symbols.PackageID), id);
     Command = new OleMenuCommand(ShowToolWindow, null, OnBeforeQueryStatus, menuCommandID, PackageResources.ShowXPathWorkbenchCommandText);
 }
 private OleMenuCommand CreateSubMenu(ActiveDocument activeDocument)
 {
     EventHandler onBeforeQuery = (sender, args) => { ((OleMenuCommand)sender).Visible = activeDocument.IsXmlDocument; };
     var subMenuCommandId = new CommandID(Guid.Parse(Symbols.PackageID), Symbols.MenuIDs.SubMenu);
     return new OleMenuCommand(null, null, onBeforeQuery, subMenuCommandId);
 }
 public CopyXmlStructureCommand(int id, XmlRepository repository, ActiveDocument activeDocument, Func<IWriter> writerProvider, ICommandTextFormatter textFormatter)
     : base(id, repository, activeDocument, writerProvider, textFormatter)
 {
 }