public void GetNodePos(out Point srcPos, out Point tarPos) { var scene = UIManager.Instance().GetScene(); var srcNode = scene.GetNode(m_srcUniqueName); var tarNode = scene.GetNode(m_tarUniqueName); if (srcNode == null || tarNode == null) { srcPos = tarPos = new Point(); } srcPos = srcNode.GetRightSlotPos(); tarPos = tarNode.GetLeftSlotPos(); //srcPos = srcNode.Pos; //tarPos = tarNode.Pos; }
public void UpdateScheme() { var scene = UIManager.Instance().GetScene(); var nameList = scene.GetSchemeNameList(); var filter = filterEdit.Text.ToLower(); schemeList.Items.Clear(); foreach (var name in nameList) { if (name.ToLower().Contains(filter)) { schemeList.Items.Add(new SchemeItem(name)); } } }
void MoveItems() { var scene = UIManager.Instance().GetScene(); scene.MoveItems(); if (scene.View != null) { Point centerPnt; bool res = scene.GetSelectedCenter(out centerPnt); if (res && scene.IsAutoFocus()) { scene.View.MoveView(centerPnt); } } }
public Point GetMiddlePos() { var scene = UIManager.Instance().GetScene(); var srcNode = scene.GetNode(m_srcUniqueName); var tarNode = scene.GetNode(m_tarUniqueName); if (srcNode == null || tarNode == null) { return(new Point()); } var srcPnt = srcNode.Pos; var tarPnt = tarNode.Pos; return(srcPnt + (tarPnt - srcPnt) * 0.5); }
void onDeleteForbidden() { var item = forbiddenList.SelectedItem as ForbiddenItem; var scene = UIManager.Instance().GetScene(); if (item == null || scene == null) { return; } scene.AcquireLock(); scene.DeleteForbiddenSymbol(item.m_uniqueName); UpdateForbiddenSymbol(); scene.ReleaseLock(); }
public void OnShowInAtlas(object sender, ExecutedRoutedEventArgs e) { var result = DoShowInAtlas(); // Connect edge automatically if (result != null && result.bestEntity != null) { var scene = UIManager.Instance().GetScene(); var sourceUname = scene.m_customEdgeSource; if (sourceUname != null && sourceUname != "") { scene.DoAddCustomEdge(sourceUname, result.bestEntity.UniqueName()); scene.CancelCustomEdgeMode(); } } }
/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { CodeAtlasCommand.Initialize(this); base.Initialize(); var mainUI = UIManager.Instance().GetMainUI(); mainUI.SetPackage(this); AddCommand(0x0103, mainUI.OnFindCallers); AddCommand(0x0104, mainUI.OnFindCallees); AddCommand(0x0105, mainUI.OnFindMembers); AddCommand(0x0106, mainUI.OnFindOverrides); AddCommand(0x0107, mainUI.OnFindBases); AddCommand(0x0108, mainUI.OnFindUses); AddCommand(0x0109, mainUI.OnGoUp); AddCommand(0x010a, mainUI.OnGoDown); AddCommand(0x010b, mainUI.OnGoLeft); AddCommand(0x010c, mainUI.OnGoRight); AddCommand(0x0130, mainUI.OnGoUpInOrder); AddCommand(0x0131, mainUI.OnGoDownInOrder); AddCommand(0x010d, mainUI.OnDelectSelectedItems); AddCommand(0x011b, mainUI.OnDeleteNearbyItems); AddCommand(0x010e, mainUI.OnDeleteSelectedItemsAndAddToStop); AddCommand(0x010f, mainUI.OnAddSimilarCodeItem); AddCommand(0x0110, mainUI.OnShowInAtlas); AddCommand(0x011c, mainUI.OnShowDefinitionInAtlas); AddCommand(0x0111, mainUI.OnShowScheme1); AddCommand(0x0112, mainUI.OnShowScheme2); AddCommand(0x0113, mainUI.OnShowScheme3); AddCommand(0x0114, mainUI.OnShowScheme4); AddCommand(0x0115, mainUI.OnShowScheme5); AddCommand(0x0116, mainUI.OnToggleScheme1); AddCommand(0x0117, mainUI.OnToggleScheme2); AddCommand(0x0118, mainUI.OnToggleScheme3); AddCommand(0x0119, mainUI.OnToggleScheme4); AddCommand(0x011a, mainUI.OnToggleScheme5); AddCommand(0x011d, mainUI.OnFastAnalyseSolutionButton); AddCommand(0x011e, mainUI.OnFastAnalyseProjectsButton); AddCommand(0x0124, mainUI.OnOpen); AddCommand(0x0125, mainUI.OnClose); AddCommand(0x0128, mainUI.OnBeginCustomEdge); AddCommand(0x0129, mainUI.OnEndCustomEdge); }
void _BuildContextMenu() { var mainUI = UIManager.Instance().GetMainUI(); ContextMenu context = new ContextMenu(); _AddContextMenuItem(context, "Delete", mainUI.OnDelectSelectedItems); _AddContextMenuItem(context, "Show Bookmark 1", mainUI.OnShowScheme1); _AddContextMenuItem(context, "Show Bookmark 2", mainUI.OnShowScheme2); _AddContextMenuItem(context, "Show Bookmark 3", mainUI.OnShowScheme3); _AddContextMenuItem(context, "Show Bookmark 4", mainUI.OnShowScheme4); _AddContextMenuItem(context, "Show Bookmark 5", mainUI.OnShowScheme5); _AddContextMenuItem(context, "Toggle Bookmark 1", mainUI.OnToggleScheme1); _AddContextMenuItem(context, "Toggle Bookmark 2", mainUI.OnToggleScheme2); _AddContextMenuItem(context, "Toggle Bookmark 3", mainUI.OnToggleScheme3); _AddContextMenuItem(context, "Toggle Bookmark 4", mainUI.OnToggleScheme4); _AddContextMenuItem(context, "Toggle Bookmark 5", mainUI.OnToggleScheme5); this.ContextMenu = context; }
void OnShowScheme() { var item = schemeList.SelectedItem as SchemeItem; if (item == null) { MessageBox.Show("Please select an item to show.", "Show Graph"); return; } var schemeName = item.m_uniqueName; var scene = UIManager.Instance().GetScene(); scene.AcquireLock(); scene.ShowScheme(schemeName, true); scene.ReleaseLock(); UpdateScheme(); }
private void background_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { var source = e.OriginalSource; //if (source == this || true) { var point = e.GetPosition(background); if (!Point.Equals(point, m_backgroundMovePos)) { m_mouseMoveTime = DateTime.Now; } var scene = UIManager.Instance().GetScene(); var selectedItems = scene.SelectedItems(); if (e.RightButton == System.Windows.Input.MouseButtonState.Pressed) { CaptureMouse(); var element = this.canvas as UIElement; var transform = this.canvas.RenderTransform as MatrixTransform; var matrix = transform.Matrix; var offset = (point - m_backgroundMovePos) / matrix.M11; matrix.TranslatePrepend(offset.X, offset.Y); transform.Matrix = matrix; } else { m_isMouseDown = false; } m_backgroundMovePos = point; } if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && m_isFrameSelection) { var newPoint = e.GetPosition(canvas); var delta = newPoint - m_rectBeginPos; var rectWidth = Math.Abs(delta.X); var rectHeight = Math.Abs(delta.Y); var topPoint = delta.Y >= 0 ? m_rectBeginPos.Y : m_rectBeginPos.Y + delta.Y; var leftPoint = delta.X >= 0 ? m_rectBeginPos.X : m_rectBeginPos.X + delta.X; selectionRect.Width = rectWidth; selectionRect.Height = rectHeight; Canvas.SetLeft(selectionRect, leftPoint); Canvas.SetTop(selectionRect, topPoint); } }
double UpdateForceDirectedLayout() { var scene = UIManager.Instance().GetScene(); var itemDict = scene.GetItemDict(); var edgeDict = scene.GetEdgeDict(); double totalDist = 0; foreach (var pairA in itemDict) { foreach (var pairB in itemDict) { if (pairA.Key == pairB.Key) { continue; } var itemA = pairA.Value; var itemB = pairB.Value; Size sizeA = new Size(itemA.GetWidth(), itemA.GetHeight()); Size sizeB = new Size(itemB.GetWidth(), itemB.GetHeight()); Point positionA = itemA.GetTargetPos(); Point positionB = itemB.GetTargetPos(); double xOverlap = (sizeA.Width + sizeB.Width) * 0.5 + 120 - Math.Abs(positionB.X - positionA.X); double yOverlap = (sizeA.Height + sizeB.Height) * 0.5 + 4 - Math.Abs(positionB.Y - positionA.Y); if (xOverlap > 0 && yOverlap > 0) { //double xOffset = (positionB.X > positionA.X) ? -xOverlap : xOverlap; //const double xFactor = 0.001; //positionA.X += xOffset * 0.5 * xFactor; //positionB.X += -xOffset * 0.5 * xFactor; //totalDist += xOverlap * xFactor; double yOffset = (positionB.Y > positionA.Y) ? -yOverlap : yOverlap; const double yFactor = 1.1; positionA.Y += yOffset * 0.5 * yFactor; positionB.Y += -yOffset * 0.5 * yFactor; totalDist += yOverlap * yFactor; } itemA.SetTargetPos(positionA); itemB.SetTargetPos(positionB); } } return(totalDist); }
protected override void OnRender(DrawingContext drawingContext) { //var beg = System.Environment.TickCount; base.OnRender(drawingContext); var scene = UIManager.Instance().GetScene(); scene.AcquireLock(); int nColor = m_schemeColorList.Count; if (nColor > 0) { var dashPattern = new List <double> { 5.0, 5.0 * (nColor - 1) }; for (int i = 0; i < nColor; i++) { var pen = new Pen(new SolidColorBrush(m_schemeColorList[i]), 1.5); pen.DashStyle = new DashStyle(dashPattern, 0.0); pen.DashStyle.Offset = 5.0 * i; pen.Thickness = 2.0; drawingContext.DrawGeometry(Brushes.Transparent, pen, m_geometry); } } if (m_orderData != null) { var formattedText = new FormattedText(m_orderData.m_order.ToString(), CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, new Typeface("tahoma"), 10.0, Brushes.Black); var pos = new Point(m_orderData.m_point.X - formattedText.Width * 0.5, m_orderData.m_point.Y - formattedText.Height * 0.5); drawingContext.DrawEllipse(this.Stroke, new Pen(), m_orderData.m_point, 6.0, 6.0); drawingContext.DrawText(formattedText, pos); } scene.ReleaseLock(); //var end = System.Environment.TickCount; //Logger.Debug("edge render time:" + (end-beg)); }
void MouseMoveCallback(object sender, MouseEventArgs args) { if (dragStart != null && args.LeftButton == MouseButtonState.Pressed) { var scene = UIManager.Instance().GetScene(); var canvas = GetCanvas(); var p2 = args.GetPosition(canvas); //Pos = new Point(p2.X - dragStart.Value.X, p2.Y - dragStart.Value.Y); //SetTargetPos(Pos); var offset = p2 - lastMove; scene.MoveSelectedItems(offset); lastMove = p2; m_deselectOnUp = false; } if (m_customEdgeMode || m_interCustomEdgeMode) { IsDirty = true; } }
void UpdateLegend() { var scene = UIManager.Instance().GetScene(); if (scene.View != null) { if (m_selectTimeStamp != scene.m_selectTimeStamp) { scene.View.InvalidateLegend(); scene.View.InvalidateScheme(); } m_selectTimeStamp = scene.m_selectTimeStamp; //if (scene.IsFileListDirty()) { scene.View.InvalidateFileList(); //scene.CleanFileListDirty(); } } }
public void OnFindUses(object sender, ExecutedRoutedEventArgs e) { var scene = UIManager.Instance().GetScene(); var selectedItem = scene.SelectedNodes(); foreach (var item in selectedItem) { if (item.GetKind() == DoxygenDB.EntKind.PAGE) { scene.ReplaceBookmarkItem(item.GetUniqueName()); } } if (selectedItem.Count == 1 && selectedItem[0].GetKind() != DoxygenDB.EntKind.PAGE) { // m_refSearcher.BeginNewRefSearch(); m_refSearcher.BeginNewNormalSearch(); m_checkCount = 0; } }
private void searchBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { var text = searchBox.Text; if (text == null || text == "") { return; } text = text.ToLower(); var scene = UIManager.Instance().GetScene(); var items = scene.GetItemDict(); var keyList = new List <string>(items.Keys); var selectedList = scene.SelectedNodes(); int startIdx = 0; int count = keyList.Count; if (selectedList.Count > 0) { var firstUname = selectedList[0].GetUniqueName(); int firstIdx = keyList.IndexOf(firstUname); if (firstIdx != -1) { startIdx = firstIdx + 1; count = keyList.Count - 1; } } for (int i = 0; i < count; i++) { int idx = (startIdx + i) % keyList.Count; var itemUname = keyList[idx]; var item = items[itemUname]; if (item.GetName().ToLower().Contains(text) || item.GetCommentText().ToLower().Contains(text)) { scene.SelectCodeItem(itemUname); break; } } } }
void MouseDoubleClickCallback(object sender, MouseEventArgs args) { var scene = UIManager.Instance().GetScene(); scene.SelectCodeItem(this.m_uniqueName); if (m_kind == DoxygenDB.EntKind.DIR) { try { System.Diagnostics.Process.Start(m_longName); } catch (Exception) { } } else { UIManager.Instance().GetScene().ShowInEditor(); } }
void MouseClickCallback(object sender, MouseEventArgs args) { if (args.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { bool isClean = !(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)); var scene = UIManager.Instance().GetScene(); if (m_isSelected) { scene.DeselectOneEdge(this, isClean); } else { scene.SelectOneEdge(this, isClean); } } else if (args.RightButton == System.Windows.Input.MouseButtonState.Pressed) { _BuildContextMenu(); CaptureMouse(); } }
public void OnAddToScene() { var item = resultList.SelectedItem as ResultItem; if (item == null) { return; } var scene = UIManager.Instance().GetScene(); if (scene == null) { return; } scene.AcquireLock(); scene.AddCodeItem(item.m_uniqueName); scene.SelectCodeItem(item.m_uniqueName); scene.ReleaseLock(); }
public void Invalidate() { if (m_inValidating) { return; } var scene = UIManager.Instance().GetScene(); var srcNode = scene.GetNode(m_srcUniqueName); var tarNode = scene.GetNode(m_tarUniqueName); if (IsDirty || srcNode.IsDirty || tarNode.IsDirty) { m_inValidating = true; this.Dispatcher.BeginInvoke((ThreadStart) delegate { this._Invalidate(); m_inValidating = false; }); } }
void PerformFrameSelection() { bool isClean = !(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)); var scene = UIManager.Instance().GetScene(); var itemDict = scene.GetItemDict(); var itemKeyList = new List <string>(); var rectGeometry = selectionRect.RenderedGeometry.Clone(); var rectTrans = selectionRect.TransformToVisual(canvas) as MatrixTransform; rectGeometry.Transform = rectTrans; foreach (var itemPair in itemDict) { var itemGeo = itemPair.Value.RenderedGeometry.Clone(); var itemTrans = itemPair.Value.TransformToVisual(canvas) as MatrixTransform; itemGeo.Transform = itemTrans; var isect = rectGeometry.FillContainsWithDetail(itemGeo); if (isect != IntersectionDetail.Empty && isect != IntersectionDetail.NotCalculated) { itemKeyList.Add(itemPair.Key); } } scene.SelectCodeItems(itemKeyList, isClean); var edgeDict = scene.GetEdgeDict(); var edgeKeyList = new List <Tuple <string, string> >(); foreach (var itemPair in edgeDict) { var itemGeo = itemPair.Value.RenderedGeometry.Clone(); var itemTrans = itemPair.Value.TransformToVisual(canvas) as MatrixTransform; itemGeo.Transform = itemTrans; var isect = rectGeometry.FillContainsWithDetail(itemGeo); if (isect != IntersectionDetail.Empty && isect != IntersectionDetail.NotCalculated) { edgeKeyList.Add(itemPair.Key); } } scene.SelectEdges(edgeKeyList, false); }
protected override void OnRender(DrawingContext dc) { base.OnRender(dc); var scene = UIManager.Instance().GetScene(); scene.AcquireLock(); var itemDict = scene.GetItemDict(); double x = m_margin, y = m_margin; var colorSize = new Size(m_lineHeight, m_lineHeight); double contentWidth = m_maxTextWidth + colorSize.Width + m_lineHeight; double contentHeight = (m_lineHeight + m_lineSpace) * m_classNameDict.Count - m_lineSpace; var parent = this.Parent as Grid; if (parent != null) { //y = parent.ActualHeight - contentHeight - m_margin; x = parent.ActualWidth - contentWidth - m_margin; } if (m_classNameDict.Count > 0) { dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(150, 0, 0, 0)), new Pen(), new Rect(new Point(x - m_rectThickness, y - m_rectThickness), new Size(contentWidth + m_rectThickness * 2, contentHeight + m_rectThickness * 2))); } foreach (var item in m_classNameDict) { var className = item.Key; var color = item.Value.Item1; var textObj = item.Value.Item2; dc.DrawRectangle(new SolidColorBrush(color), new Pen(), new Rect(new Point(x, y), colorSize)); dc.DrawText(textObj, new Point(x + m_lineHeight + m_colorTextSpace, y - 2)); y += m_lineHeight + m_lineSpace; } scene.ReleaseLock(); }
public void UpdateUI() { schemeWindow.Dispatcher.Invoke((ThreadStart) delegate { schemeWindow.UpdateScheme(); }); symbolWindow.Dispatcher.Invoke((ThreadStart) delegate { symbolWindow.UpdateForbiddenSymbol(); symbolWindow.UpdateSymbol("", ""); }); symbolWindow.Dispatcher.Invoke((ThreadStart) delegate { searchWindow.OnSearch(); }); analysisWindow.Dispatcher.Invoke((ThreadStart) delegate { analysisWindow.UpdateExtensionList(); analysisWindow.UpdateMacroList(); }); this.Dispatcher.Invoke((ThreadStart) delegate { var scene = UIManager.Instance().GetScene(); switch (scene.m_layoutType) { case LayoutType.LAYOUT_FORCE: forceLayoutButton.IsChecked = true; break; case LayoutType.LAYOUT_GRAPH: graphLayoutButton.IsChecked = true; break; case LayoutType.LAYOUT_NONE: noLayoutButton.IsChecked = true; break; } }); }
public bool BeginNewRefSearch() { Clear(); var scene = UIManager.Instance().GetScene(); var selectedNodes = scene.SelectedNodes(); if (selectedNodes.Count == 0) { return(false); } CodeUIItem node = selectedNodes[0]; m_srcUniqueName = node.GetUniqueName(); m_srcLongName = node.GetLongName(); m_srcName = node.GetName(); bool res = LaunchRefSearch(node.GetLongName()); if (!res) { res = LaunchRefSearch(node.GetName()); } return(res); }
bool _AnalyseSolution(bool useClang, AnalyseType type = AnalyseType.ANALYSE_SOLUTION) { if (!GetCommandActive()) { return(false); } try { Logger.Info("Analysis Begin."); SetCommandActive(false); var traverser = new ProjectFileCollector(); if (type == AnalyseType.ANALYSE_SELECTED_PROJECTS) { traverser.SetToSelectedProjects(); } if (type == AnalyseType.ANALYSE_OPENED_FILES) { traverser.SetIncludeScope(ProjectFileCollector.IncludeScope.INCLUDE_OPEN_FOLDERS); } else { traverser.SetIncludeScope(ProjectFileCollector.IncludeScope.INCLUDE_PROJECT_FOLDERS); } var scene = UIManager.Instance().GetScene(); traverser.SetCustomExtension(scene.GetCustomExtensionDict()); traverser.SetCustomMacro(scene.GetCustomMacroSet()); traverser.Traverse(); var dirList = traverser.GetDirectoryList(); var solutionFolder = traverser.GetSolutionFolder(); if ((type == AnalyseType.ANALYSE_DUMMY && dirList.Count == 0) || solutionFolder == "") { SetCommandActive(true); return(false); } string doxyFolder = solutionFolder; if (analysisWindow.customDirectoryEdit.Text != null && analysisWindow.customDirectoryEdit.Text != "") { doxyFolder = analysisWindow.customDirectoryEdit.Text; } doxyFolder += "/CodeGraphData"; CheckOrCreateFolder(doxyFolder); Logger.Info("Folder: " + doxyFolder); // Use selected projects as postfix string postFix = ""; if (type == AnalyseType.ANALYSE_SELECTED_PROJECTS) { var projectNameList = traverser.GetSelectedProjectName(); foreach (string item in projectNameList) { postFix += "_" + item; } } else if (type == AnalyseType.ANALYSE_DUMMY) { postFix = "_dummy"; } else if (type == AnalyseType.ANALYSE_OPENED_FILES) { postFix = "_files"; } else { postFix = "_solution"; } postFix = postFix.Replace(" ", ""); DoxygenDB.DoxygenDBConfig config = new DoxygenDB.DoxygenDBConfig(); config.m_configPath = doxyFolder + "/Result" + postFix + ".graph"; if (type != AnalyseType.ANALYSE_DUMMY) { config.m_inputFolders = dirList; config.m_includePaths = traverser.GetAllIncludePath(); } config.m_outputDirectory = doxyFolder + "/Result" + postFix; config.m_projectName = traverser.GetSolutionName() + postFix; config.m_defines = traverser.GetAllDefines(); config.m_useClang = useClang; config.m_mainLanguage = traverser.GetMainLanguage(); config.m_customExt = scene.GetCustomExtensionDict(); DBManager.Instance().CloseDB(); System.Threading.Thread analysisThread = new System.Threading.Thread((ThreadStart) delegate { try { if (DoxygenDB.DoxygenDB.GenerateDB(config)) { DBManager.Instance().OpenDB(config.m_configPath); } else { SetCommandActive(true); } } catch (Exception) { SetCommandActive(true); } }); analysisThread.Name = "Analysis Thread"; analysisThread.Start(); } catch (Exception) { Logger.Warning("Analyse failed. Please try again."); DBManager.Instance().CloseDB(); SetCommandActive(true); } return(true); }
public void ToggleAnchor(object sender, RoutedEventArgs e) { var scene = UIManager.Instance().GetScene(); scene.ToggleAnchorItem(); }
public void OnEndCustomEdge(object sender, RoutedEventArgs e) { var scene = UIManager.Instance().GetScene(); scene.EndAddCustomEdge(); }
public void ShowScheme(int ithScheme, bool isSelected = false) { var scene = UIManager.Instance().GetScene(); scene.ShowIthScheme(ithScheme, isSelected); }
void ToggleSelectedEdgeToScheme(int ithScheme) { var scene = UIManager.Instance().GetScene(); scene.ToggleSelectedEdgeToScheme(ithScheme); }
public void OnAddSimilarCodeItem(object sender, ExecutedRoutedEventArgs e) { var scene = UIManager.Instance().GetScene(); scene.AddSimilarCodeItem(); }