Ejemplo n.º 1
0
 protected override void OnDrawNode(DrawTreeNodeEventArgs e)
 {
     if (e.Node is ILibraryTreeNode)
     {
         ILibraryTreeNode ltn = (ILibraryTreeNode)e.Node;
         if (ltn.NeedsUpdate)
         {
             Font   f        = e.Node.NodeFont ?? this.Font;
             SizeF  textSize = e.Graphics.MeasureString(e.Node.Text, f);
             Bitmap bmp;
             if (updateHoverNode == e.Node)
             {
                 if (isMouseDown)
                 {
                     bmp = Properties.Resources.update_d;
                 }
                 else
                 {
                     bmp = Properties.Resources.update_o;
                 }
             }
             else
             {
                 bmp = Properties.Resources.update_n;
             }
             Rectangle rectUpdate = new Rectangle(new Point(e.Node.Bounds.X + (int)textSize.Width + 10, e.Bounds.Y), bmp.Size);
             e.Graphics.DrawImageUnscaled(bmp, rectUpdate.Location);
             ltn.UpdateRectangle = rectUpdate;
         }
     }
     e.DrawDefault = true;
 }
Ejemplo n.º 2
0
 private void CheckNodesForUpdates(TreeNodeCollection col, ref bool hasUpdates)
 {
     foreach (TreeNode tn in col)
     {
         if (tn is ILibraryTreeNode)
         {
             ILibraryTreeNode ltn = (ILibraryTreeNode)tn;
             if (ltn.CanUpdate)
             {
                 string path = MainForm.CurrentStage.WorkingFolderFull + tn.FullPath;
                 if (File.Exists(path))
                 {
                     DateTime curTime = File.GetLastWriteTimeUtc(path);
                     if (ltn.Date.AddSeconds(5) < curTime)
                     {
                         ltn.NeedsUpdate = true;
                         hasUpdates      = true;
                     }
                 }
             }
             else if (tn.Nodes.Count > 0)
             {
                 CheckNodesForUpdates(tn.Nodes, ref hasUpdates);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void ResetImage()
 {
     if (selectedItem != null)
     {
         ILibraryTreeNode ltn = selectedItem;
         ltn.RenderThumbnail((Bitmap)pictureBox.Image);
         pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
         pictureBox.Invalidate();
     }
 }
Ejemplo n.º 4
0
 void LibraryTreeView_MouseLeave(object sender, EventArgs e)
 {
     this.MouseMove -= new MouseEventHandler(LibraryTreeView_MouseMove);
     isMouseDown     = false;
     if (updateHoverNode != null)
     {
         Rectangle r = updateHoverNode.UpdateRectangle;
         updateHoverNode = null;
         InvalidateUpdate(r);
     }
 }
Ejemplo n.º 5
0
 public void Clear()
 {
     symbolTree.Nodes.Clear();
     if (pictureBox.Image != null)
     {
         Graphics     g    = Graphics.FromImage(pictureBox.Image);
         GraphicsUnit unit = GraphicsUnit.Pixel;
         g.FillRectangle(Brushes.White, pictureBox.Image.GetBounds(ref unit));
         g.Dispose();
         pictureBox.Invalidate();
     }
     selectedItem = null;
     this.Invalidate();
 }
Ejemplo n.º 6
0
        public void LoadCurrentLibrary()
        {
            selectedItem = null;
            symbolTree.Nodes.Clear();
            Library lib = MainForm.CurrentLibrary;

            uint[] keys = lib.Keys;
            for (uint i = 0; i < keys.Length; i++)
            {
                LibraryItem li = lib[keys[i]];
                if (!(li.Definition is Vex.Symbol) && li.Definition.Id != MainForm.CurrentStage.RootId)
                {
                    AddItemToLibrary(li);
                }
            }
            this.Invalidate();
        }
Ejemplo n.º 7
0
        void LibraryTreeView_MouseClick(object sender, MouseEventArgs e)
        {
            // Update library element, not undoable so no command stack
            ILibraryTreeNode ltn = (ILibraryTreeNode)GetNodeAt(e.Location);

            if (ltn != null && ltn.NeedsUpdate && ltn.UpdateRectangle.Contains(e.Location))
            {
                ltn.NeedsUpdate = false;
                isMouseDown     = false;
                Rectangle r = updateHoverNode.UpdateRectangle;
                updateHoverNode = null;
                InvalidateUpdate(r);

                // todo: move import off the UI thread
                string            path = MainForm.CurrentStage.WorkingFolderFull + GetNodePath((TreeNode)ltn);
                ImportFileCommand ifc  = new ImportFileCommand(path);
                ifc.Execute();
                ltn.ResetDate();

                MainForm.CurrentLibraryView.Invalidate();
                MainForm.CurrentStage.InvalidateAll();
            }
        }
Ejemplo n.º 8
0
        void LibraryTreeView_MouseMove(object sender, MouseEventArgs e)
        {
            ILibraryTreeNode ltn = (ILibraryTreeNode)GetNodeAt(e.Location);

            if (ltn != null && ltn.NeedsUpdate && ltn.UpdateRectangle.Contains(e.Location))
            {
                if (updateHoverNode != ltn)
                {
                    updateHoverNode = ltn;
                    InvalidateUpdate(ltn.UpdateRectangle);
                }
            }
            else
            {
                isMouseDown = false;
                if (updateHoverNode != null && updateHoverNode != ltn)
                {
                    Rectangle r = updateHoverNode.UpdateRectangle;
                    updateHoverNode = null;
                    InvalidateUpdate(r);
                }
            }
        }
Ejemplo n.º 9
0
 void symbolTree_AfterSelect(object sender, TreeViewEventArgs e)
 {
     selectedItem = (ILibraryTreeNode)symbolTree.SelectedNode;
     symbolTree.Update();
     ResetImage();
 }