void BuiltinListSelectedIndexChanged(object sender, EventArgs e) { if (builtinList.SelectedIndex == -1) { copyButton.Enabled = false; return; } HighlightItem item = (HighlightItem)builtinList.SelectedItem; string filename = item.FileName; if (filename == null) { filename = item.SyntaxMode.FileName; } string newname = Path.GetFileName(filename); foreach (HighlightItem item2 in userList.Items) { if (Path.GetFileName(item2.FileName) == newname) { copyButton.Enabled = false; return; } } copyButton.Enabled = true; }
void ModifyButtonClick(object sender, EventArgs ev) { if (userList.SelectedIndex == -1) { return; } HighlightItem item = (HighlightItem)userList.SelectedItem; using (EditHighlightingDialog dlg = new EditHighlightingDialog(item.Node)) { DialogResult res = dlg.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); if (res == DialogResult.OK) { using (XmlTextWriter writer = new XmlTextWriter(item.FileName, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.IndentChar = '\t'; writer.Indentation = 1; writer.WriteStartDocument(); item.Node.WriteXml(writer); writer.WriteEndDocument(); } // refresh item text userList.Items.RemoveAt(userList.SelectedIndex); userList.Items.Add(item); } try { item.Node.Remove(); } catch {} } }
private void SortItems(HighlightItem item, ListSortDirection dir) { int?i = null; int?tmp = null; switch (dir) { case ListSortDirection.Ascending: i = ((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext).IndexOf(item); if (i != null && i > 0 && i < ((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext).Count) { tmp = item.Order; item.Order = ((HighlightItem)((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext)[i.Value - 1]).Order; ((HighlightItem)((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext)[i.Value - 1]).Order = tmp.Value; } break; case ListSortDirection.Descending: i = ((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext).IndexOf(item); if (i != null && i >= 0 && i < (((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext).Count - 1)) { tmp = item.Order; item.Order = ((HighlightItem)((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext)[i.Value + 1]).Order; ((HighlightItem)((HighlightCollection <HighlightItem>) this.listViewPatterns.DataContext)[i.Value + 1]).Order = tmp.Value; } break; default: break; } this.Sort(Constants.HIGHLIGHT_ITEM_SORT_HEADER, ListSortDirection.Descending); }
public HighlightCollection <HighlightItem> Read() { HighlightCollection <HighlightItem> highlights = new HighlightCollection <HighlightItem>(); DbConnection.Open(); using (DbTransaction trans = DbConnection.BeginTransaction(System.Data.IsolationLevel.Serializable)) { using (DbDataAdapter adpt = Factory.CreateDataAdapter()) { using (DbCommand cmd = DbConnection.CreateCommand()) { cmd.Transaction = trans; cmd.CommandText = Constants.HIGHTLIGHTITEMS_SELECT_ALL; cmd.ExecuteNonQuery(); adpt.SelectCommand = cmd; using (DbCommandBuilder bld = Factory.CreateCommandBuilder()) { bld.DataAdapter = adpt; using (DataTable tbl = new DataTable()) { adpt.Fill(tbl); foreach (DataRow row in tbl.Rows) { HighlightItem item = new HighlightItem() { ID = int.Parse(row[0].ToString()), Pattern = row[1].ToString(), Order = int.Parse(row[2].ToString()), }; //HACK: System.Drawing.Color allows storing of the colour as one integer, gonna use this to populate DB and re-hydrate back in code. Easier! System.Drawing.Color tempCol = System.Drawing.Color.FromArgb(int.Parse(row[3].ToString())); Color tempCol2 = Color.FromArgb(tempCol.A, tempCol.R, tempCol.G, tempCol.B); item.ForeColour = tempCol2; tempCol = System.Drawing.Color.FromArgb(int.Parse(row[4].ToString())); tempCol2 = Color.FromArgb(tempCol.A, tempCol.R, tempCol.G, tempCol.B); item.BackColour = tempCol2; tempCol = System.Drawing.Color.FromArgb(int.Parse(row[5].ToString())); tempCol2 = Color.FromArgb(tempCol.A, tempCol.R, tempCol.G, tempCol.B); item.BorderColour = tempCol2; highlights.Add(item); } } } } } } DbConnection.Close(); return(highlights); }
private void buttonOrderUp_Click(object sender, RoutedEventArgs e) { HighlightItem item = (HighlightItem)this.listViewPatterns.SelectedItem; this.SortItems(item, ListSortDirection.Ascending); this.Patterns.FireListChanged(item); }
protected void AddNewHighlightItem(string text, Color foreColour, Color backColour) { HighlightItem item = new HighlightItem(text, foreColour, backColour); item.Order = Patterns.Add(item); this.Sort(Constants.HIGHLIGHT_ITEM_SORT_HEADER, ListSortDirection.Descending); }
void Start() { HighlightItem highlight = GetComponent <HighlightItem>(); if (highlight != null) { currentOutlineState = HighlightColours.DEFAULT_COLOUR; previousOutlineState = HighlightColours.DEFAULT_COLOUR; defaultOutlineColour = highlight.GetCurrentColour(); } initialize(); }
public void SetOutlineColour(HighlightColours colourType) { HighlightItem highlight = GetComponent <HighlightItem>(); if (highlight == null) { return; } Vector4 colour = getHighlightColour(colourType); highlight.SetColour(colour); previousOutlineState = currentOutlineState; currentOutlineState = colourType; }
private void listViewPatterns_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.listViewPatterns.SelectedItem == null || this.listViewPatterns.SelectedItem.GetType() != typeof(HighlightItem)) { return; } if (e.AddedItems != null && e.AddedItems.Count == 1) { HighlightItem selectedPattern = (HighlightItem)e.AddedItems[0]; this.textBoxPattern.Text = selectedPattern.Pattern; this.textBoxPattern.Foreground = new SolidColorBrush(selectedPattern.ForeColour); this.textBoxPattern.Background = new SolidColorBrush(selectedPattern.BackColour); this.buttonColour.SelectedColour = selectedPattern.ForeColour; this.buttonBackColour.SelectedColour = selectedPattern.BackColour; } }
public static void Run() { // Create an instance of Parser class using (Parser parser = new Parser(Constants.SamplePdf)) { // Extract a highlight: HighlightItem hl = parser.GetHighlight(2, true, new HighlightOptions(3)); // Check if highlight extraction is supported if (hl == null) { Console.WriteLine("Highlight extraction isn't supported"); return; } // Print an extracted highlight Console.WriteLine(string.Format("At {0}: {1}", hl.Position, hl.Text)); } }
void DeleteButtonClick(object sender, EventArgs ev) { if (userList.SelectedIndex == -1) { return; } HighlightItem item = (HighlightItem)userList.SelectedItem; if (!MessageService.AskQuestion("${res:Dialog.Options.TextEditorOptions.EditHighlighting.DeleteConfirm}")) { return; } try { File.Delete(item.FileName); } catch (Exception e) { MessageService.ShowError(e, "${res:Dialog.Options.TextEditorOptions.EditHighlighting.DeleteError}"); } userList.Items.RemoveAt(userList.SelectedIndex); BuiltinListSelectedIndexChanged(this, EventArgs.Empty); }
/// <summary> /// Gets the highlight item of a found piece of text /// </summary> /// <param name="line">The line of text to match</param> /// <returns></returns> private bool GetFoundHighlightItem(ref HighlightedItem item) { HighlightItem special = new HighlightItem(this.SearchText, Constants.DEFAULT_FORECOLOUR, Constants.DEFAULT_BACKCOLOUR); if (!string.IsNullOrEmpty(special.Pattern) && !string.IsNullOrEmpty(item.Text)) { if (item.Text == special.Pattern || _patternMatching.MatchPattern(item.Text, special.Pattern)) { item.Selected = true; return(true); } else { item.Selected = false; return(false); } } return(false); }
void CopyButtonClick(object sender, EventArgs ev) { if (builtinList.SelectedIndex == -1) { return; } try { HighlightItem item = (HighlightItem)builtinList.SelectedItem; string filename = item.FileName; if (filename == null) { filename = item.SyntaxMode.FileName; } string newname = Path.GetFileName(filename); newname = Path.Combine(PropertyService.ConfigDirectory, "modes" + Path.DirectorySeparatorChar + newname); using (StreamWriter fs = File.CreateText(newname)) { fs.Write(item.Node.Content); } SchemeNode newNode = LoadFile(new XmlTextReader(newname), true, Path.GetFileNameWithoutExtension(newname)); if (newNode == null) { throw new Exception(); } userList.Items.Add(new HighlightItem(null, newname, newNode)); } catch (Exception e) { MessageService.ShowError(e, "${res:Dialog.Options.TextEditorOptions.EditHighlighting.CopyError}"); } BuiltinListSelectedIndexChanged(this, EventArgs.Empty); }
void LateUpdate() { bool distanceCondition = false; if (Physics.Raycast(transform.position, transform.forward, out hitInfo, 50f, raycastMask, QueryTriggerInteraction.Ignore)) { if (targetedItem != hitInfo.collider.gameObject) { checkAndCleanItem(); if (targetedItem && targetedItem.GetComponent <HighlightItem>()) { if (targetedItem.GetComponent <PuzzleElementPlaceholder>()) { targetedItem.GetComponent <PuzzleElementPlaceholder>().SetOutlineColour(HighlightColours.INACTIVE_COLOUR); } else { targetedItem.GetComponent <HighlightItem>().OutlineOff(); } } targetedItem = hitInfo.collider.gameObject; } bool isUsable = targetedItem.GetComponent <UsableTarget>(); bool isDraggable = !isUsable && (targetedItem.GetComponent <DraggableItem>()); bool isPickable = !isUsable && (targetedItem.GetComponent <Item>() || targetedItem.GetComponent <Item>()); bool isPuzzle = !isUsable && !isPickable && targetedItem.GetComponent <PuzzleElementPlaceholder>(); float requiredDistance = (isUsable ? targetedItem.GetComponent <UsableTarget>().UseDistance : (isDraggable ? targetedItem.GetComponent <DraggableItem>().UseDistance : (isPickable || isPuzzle ? itemPickupDistance : float.MaxValue))); float distance = Vector3.Distance(transform.position, targetedItem.transform.position); distanceCondition = distance <= requiredDistance; if (distanceCondition) { if (isUsable && string.IsNullOrEmpty(itemToUse)) { UsableTarget ut = targetedItem.GetComponent <UsableTarget>(); if (ut.UsesItems) { itemToUse = checkItems(ut); if (!string.IsNullOrEmpty(itemToUse)) { ut.SetOutlineColour(HighlightColours.ITEM_USE_COLOUR); inventory.HighlightItem(itemToUse, true); } } } if (isPuzzle && (pickedUpItem != null)) { DraggableItem di = pickedUpItem.GetComponent <DraggableItem>(); PuzzleElementPlaceholder pep = targetedItem.GetComponent <PuzzleElementPlaceholder>(); if (di.IsPuzzleElement) { puzzleElementMatching = pep.CheckElementOnTrace(di.PuzzleElementId); } pep.SetOutlineColour((puzzleElementMatching ? HighlightColours.ITEM_USE_COLOUR : HighlightColours.WRONG_ELEMENT_COLOUR)); } HighlightItem highlight = targetedItem.GetComponent <HighlightItem>(); if (highlight != null) { highlight.OutlineOn(); } } } else { checkAndCleanItem(); return; } if (Input.GetKeyDown(USE_KEY_CODE)) { handleUse(distanceCondition); } else if (Input.GetKeyUp(USE_KEY_CODE) && (pickedUpItem != null)) { handleDeactivate(); } else if (Input.GetKey(USE_KEY_CODE) && targetedItem.GetComponent <ConstantUsableTarget>() && distanceCondition) { usableTargetUse(); } }
private void UpdateHighlightTracker() { if (HighlightItem != null && RowItems.Count > 0 && AllItems != null && RowItems.IndexOf(HighlightItem) >= 0) { PathPosition.Opacity = 0.3; CheckCurrentName.Opacity = 0.5; BlurCurrentName.Radius = 6; PathHighlightPosition.Visibility = Visibility.Visible; CheckHighlightCurrentName.Visibility = Visibility.Visible; int PositionIndex = RowItems.IndexOf(HighlightItem); double IdealOffset = (PositionIndex + 0.5) * ItemWidth; PathHighlightPosition.Margin = new Thickness(Math.Max(0, Math.Min(IdealOffset - PathHighlightPosition.ActualWidth / 2, ActualWidth - PathHighlightPosition.ActualWidth)), 0, 0, 0); string TextString = $"{HighlightItem.RootName} ({AllItems.IndexOf(HighlightItem) + 1}/{AllItems.Count})"; Size TextSize = MeasureString(TextString); CheckHighlightCurrentName.Margin = new Thickness(Math.Max(0, Math.Min(IdealOffset - TextSize.Width / 2, ActualWidth - TextSize.Width) - 24), 6, 0, 7); TextHighlightCurrentName.Text = TextString; CheckHighlightCurrentName.IsChecked = HighlightItem.UnselectManual != null ? !(bool)HighlightItem.UnselectManual : (bool?)null; ProcessingOptionsMovieCTF OptionsCTF = MainWindow.Options.GetProcessingMovieCTF(); ProcessingOptionsMovieMovement OptionsMovement = MainWindow.Options.GetProcessingMovieMovement(); ProcessingOptionsBoxNet OptionsBoxNet = MainWindow.Options.GetProcessingBoxNet(); ProcessingOptionsMovieExport OptionsExport = MainWindow.Options.GetProcessingMovieExport(); PenHighlightCurrentName.Brush = StatusBar.StatusToBrush(StatusBar.GetMovieProcessingStatus(HighlightItem, OptionsCTF, OptionsMovement, OptionsBoxNet, OptionsExport, MainWindow.Options)); PanelSegmentHighlight.Children.Clear(); Rectangle Segment = new Rectangle { Width = ItemWidth, Height = 12, Fill = new SolidColorBrush(Colors.Transparent), Stroke = PathHighlightPosition.Fill, StrokeThickness = 1, SnapsToDevicePixels = false }; PanelSegmentHighlight.Children.Add(Segment); Canvas.SetLeft(Segment, PositionIndex * ItemWidth); if (File.Exists(HighlightItem.ThumbnailsPath)) { ImageSource Image = new BitmapImage(new Uri(HighlightItem.ThumbnailsPath)); ImageThumbnail.Source = Image; PopupThumbnail.HorizontalOffset = Mouse.GetPosition(PanelSegments).X - Image.Width / 2; ImageThumbnail.Visibility = Visibility.Visible; } else { PopupThumbnail.HorizontalOffset = Mouse.GetPosition(PanelSegments).X; ImageThumbnail.Visibility = Visibility.Collapsed; } #region Figure out processing status bool DoCTF = MainWindow.Options.ProcessCTF; bool DoMovement = MainWindow.Options.ProcessMovement; bool DoPicking = MainWindow.Options.ProcessPicking; bool DoExport = OptionsExport.DoAverage || OptionsExport.DoStack || OptionsExport.DoDeconv || DoPicking; bool NeedsNewCTF = OptionsCTF != HighlightItem.OptionsCTF; bool NeedsNewMotion = OptionsMovement != HighlightItem.OptionsMovement; bool NeedsNewPicking = (OptionsBoxNet != HighlightItem.OptionsBoxNet || NeedsNewMotion); bool NeedsNewExport = (DoMovement && NeedsNewMotion) || OptionsExport != HighlightItem.OptionsMovieExport || (OptionsExport.DoDeconv && NeedsNewCTF && DoCTF); if (HighlightItem.OptionsCTF != null) { IndicatorCTF.Foreground = NeedsNewCTF ? (DoCTF ? BrushOutdatedOpaque : BrushDeselected) : BrushProcessedOpaque; } else if (DoCTF) { IndicatorCTF.Foreground = BrushUnprocessedOpaque; } else { IndicatorCTF.Foreground = BrushDeselected; } if (HighlightItem.OptionsMovement != null) { IndicatorMotion.Foreground = NeedsNewMotion ? (DoMovement ? BrushOutdatedOpaque : BrushDeselected) : BrushProcessedOpaque; } else if (DoMovement && HighlightItem.GetType() == typeof(Movie)) { IndicatorMotion.Foreground = BrushUnprocessedOpaque; } else { IndicatorMotion.Foreground = BrushDeselected; } if (HighlightItem.OptionsBoxNet != null) { IndicatorPicking.Foreground = NeedsNewPicking ? (DoPicking ? BrushOutdatedOpaque : BrushDeselected) : BrushProcessedOpaque; } else if (DoPicking && HighlightItem.GetType() == typeof(Movie)) { IndicatorPicking.Foreground = BrushUnprocessedOpaque; } else { IndicatorPicking.Foreground = BrushDeselected; } if (HighlightItem.OptionsMovieExport != null) { IndicatorExport.Foreground = NeedsNewExport ? (DoExport ? BrushOutdatedOpaque : BrushDeselected) : BrushProcessedOpaque; } else if (DoExport && HighlightItem.GetType() == typeof(Movie)) { IndicatorExport.Foreground = BrushUnprocessedOpaque; } else { IndicatorExport.Foreground = BrushDeselected; } #endregion PopupThumbnail.PlacementTarget = PanelSegments; PopupThumbnail.VerticalOffset = -12; PopupThumbnail.IsOpen = true; } else { PathPosition.Opacity = 1; CheckCurrentName.Opacity = 1; BlurCurrentName.Radius = 0; PathHighlightPosition.Visibility = Visibility.Collapsed; CheckHighlightCurrentName.Visibility = Visibility.Collapsed; PanelSegmentHighlight.Children.Clear(); PopupThumbnail.IsOpen = false; } }
// Use this for initialization void Start() { highlight = GetComponent <HighlightItem> (); highlight.SetColour(HighlightItem.INTACTIVE_OUTLINE_COLOUR); highlight.OutlineOn(); }
/// <summary> /// lalal /// </summary> public MainScreen() { InitializeComponent(); //initialize controls Label centerXLabel = new Label() { Text = "Center X", }; SetRectangle(centerXLabel, new Point(0, 0)); SetRectangle(this.centerX, new Point(1, 0)); Label centerYLabel = new Label() { Text = "Center Y", }; SetRectangle(centerYLabel, new Point(0, 1)); SetRectangle(this.centerY, new Point(1, 1)); Label maxIterCountLabel = new Label() { Text = "Max Iterations", }; SetRectangle(this.maxIterCount, new Point(3, 0)); SetRectangle(maxIterCountLabel, new Point(2, 0)); Label scaleLabel = new Label() { Text = "Scale", }; SetRectangle(this.scale, new Point(3, 1)); SetRectangle(scaleLabel, new Point(2, 1)); Button okButton = new Button() { Text = "OK", }; okButton.Click += this.OnOkButtonClick; SetRectangle(okButton, new Point(4, 1)); Label threadCountLabel = new Label() { Text = "Number of Threads", }; SetRectangle(this.threadCount, new Point(5, 0)); SetRectangle(threadCountLabel, new Point(4, 0)); ComboBox highlights = new ComboBox(); SetRectangle(highlights, new Point(5, 1)); highlights.SelectedValueChanged += (sender, e) => { ((ComboBoxItem)highlights.SelectedItem).Click(); }; var basis = new HighlightItem("Basis", new PointD(0.0, 0.0), 2.0, this.mandelbrotImage, this.scale, this.centerX, this.centerY); var infiniteZoom = new HighlightItem("Infinite Zoom", new PointD(-1.4845903478, 0.0), 1.0, this.mandelbrotImage, this.scale, this.centerX, this.centerY); var star = new HighlightItem("Star", new PointD(-0.6702091879, -0.4580609753), 0.07, this.mandelbrotImage, this.scale, this.centerX, this.centerY); var explosion = new HighlightItem("Explosion", new PointD(-0.7084314944, -0.2573555293), 0.00273082440794726, this.mandelbrotImage, this.scale, this.centerX, this.centerY); highlights.Items.AddRange(new ComboBoxItem[] { basis, infiniteZoom, star, explosion, }); highlights.SelectedItem = basis; this.Controls.AddRange(new Control[] { centerXLabel, centerYLabel, maxIterCountLabel, scaleLabel, threadCountLabel, okButton, highlights, this.centerX, this.centerY, this.scale, this.maxIterCount, this.threadCount, this.mandelbrotImage }); //add events this.Resize += OnFormResize; this.MouseWheel += OnMouseWheel; this.mandelbrotImage.MouseClick += OnMandelbrotClick; this.Text = "Mandelbrot"; this.WindowState = FormWindowState.Maximized; this.UpdateMandelbrotImage(); }
private bool CheckNode(AstNode node, HighlightItem highlightItem) { if (highlightItem.HighlightType.HasFlag(HighlightType.Exception)) { if (node.Parent is ThrowStatement) { } return node is ThrowStatement; } else if (highlightItem.HighlightType.HasFlag(HighlightType.Method)) { switch (highlightItem.MethodType) { case MethodType.Call: return node is InvocationExpression; case MethodType.Get: if (node is MemberReferenceExpression) { MemberReferenceExpression mre = (MemberReferenceExpression)node; return (mre.MemberName == highlightItem.Method.Name.Substring(4)); } return false; case MethodType.Set: return node is AssignmentExpression; case MethodType.Ctor: return node is ObjectCreateExpression; } } return false; }