Пример #1
0
        public static int Compare(ILayoutItem x, ILayoutItem y)
        {
            int rez = 0;

            if (x == null && y == null)
            {
                rez = 0;
            }
            else if (x == null)
            {
                rez = -1;
            }
            else if (y == null)
            {
                rez = 1;
            }
            else
            {
                if (x.Map != null && y.Map != null)
                {
                    rez = Compare(x.Map, y.Map);
                }
                if (rez == 0)
                {
                    rez = x.Row.CompareTo(y.Row);
                }
                if (rez == 0)
                {
                    rez = x.Column.CompareTo(y.Column);
                }
            }
            return(rez);
        }
Пример #2
0
 private static void setManagedContentProperties(ILayoutItem layoutItem, ManagedContent content)
 {
     content.Content = layoutItem;
     content.Title   = layoutItem.Title;
     content.Name    = layoutItem.Name;
     content.Icon    = layoutItem.Icon;
 }
Пример #3
0
 protected double CalcHeight(ILayoutItem item)
 {
     if (item is GroupBoxItem box)
     {
         double height = 0;
         if (box.Expand)
         {
             if (box.Widget != null && box.Autosize)
             {
                 var size = box.Widget.Surface.GetPreferredSize(SizeConstraint.Unconstrained, SizeConstraint.Unconstrained);
                 //if (box.Autosize);// || size.Height > box.DefaultHeight)
                 return(size.Height + box.HeaderHeight + 10);
             }
             height = box.Height + box.HeaderHeight + 10;
         }
         else
         {
             height = box.HeaderHeight;
         }
         //if (height > map.Bound.Height)
         //    height = map.Bound.Height;
         return(height);
     }
     return(item.Height);
 }
    /// <inheritdoc cref="IGraphicEngine"/>
    /// <summary>
    /// Draws the item.
    /// </summary>
    /// <param name="layoutItem">The layout item.</param>
    /// <seealso cref="IGraphicEngine"/>
    public void Draw(ILayoutItem layoutItem)
    {
        var font  = this.GetFont(layoutItem.Word.Occurrences);
        var color = this.GetPseudoRandomColorFromPalette(layoutItem);
        var point = new Point((int)layoutItem.Rectangle.X, (int)layoutItem.Rectangle.Y);

        this.graphics.DrawString(layoutItem.Word.Text, font, new SolidBrush(color), point);
    }
Пример #5
0
        public void HideAutoHideWindow(ILayoutItem activeLayoutItem)
        {
            var window = Manager.AutoHideWindow;

            if (window != null &&
                ((ShellViewModel)window.DataContext).ActiveLayoutItem != activeLayoutItem)
            {
                window.Visibility = Visibility.Hidden;
            }
        }
Пример #6
0
 public void removeChild(ILayoutItem item)
 {
     if (!childLayoutItems.Contains(item))
     {
         throw new Exception("Item not in list");
     }
     else
     {
         childLayoutItems.Remove(item);
     }
 }
    /// <inheritdoc cref="IGraphicEngine"/>
    /// <summary>
    /// Draws the item emphasized.
    /// </summary>
    /// <param name="layoutItem">The layout item.</param>
    /// <seealso cref="IGraphicEngine"/>
    public void DrawEmphasized(ILayoutItem layoutItem)
    {
        var font  = this.GetFont(layoutItem.Word.Occurrences);
        var color = this.GetPseudoRandomColorFromPalette(layoutItem);
        var point = new Point((int)layoutItem.Rectangle.X, (int)layoutItem.Rectangle.Y);

        this.graphics.DrawString(layoutItem.Word.Text, font, new SolidBrush(Color.LightGray), point.X, point.Y);
        var offset = (int)(5 * font.Size / this.MaximumFontSize) + 1;

        point.Offset(-offset, -offset);
        this.graphics.DrawString(layoutItem.Word.Text, font, new SolidBrush(color), point.X, point.Y);
    }
Пример #8
0
        protected override void OnActivationProcessed(IDocument item, bool success)
        {
            base.OnActivationProcessed(item, success);

            if (!success)
            {
                return;
            }

            _activeLayoutItem = item;
            NotifyOfPropertyChange(() => ActiveLayoutItem);
        }
Пример #9
0
        public void ShowTool(ITool tool)
        {
            if (!Tools.Contains(tool))
            {
                Tools.Add(tool);
            }
            tool.IsVisible  = true;
            tool.IsSelected = true;

            _activeLayoutItem = tool;
            NotifyOfPropertyChange(() => ActiveLayoutItem);
        }
Пример #10
0
        private ICommandHandler GetCommandHandlerForLayoutItem(CommandDefinition commandDefinition,
                                                               ILayoutItem layoutItem)
        {
            // get view to trav visual tree
            var view = ViewLocator.LocateForModel(layoutItem, null, null);
            // check for current working view
            var window = Window.GetWindow(view);

            if (window == null)
            {
                return(null);
            }

            // trav
            var initialElement = FocusManager.GetFocusedElement(view) ?? view;

            return(FindCommandHandlerInVisualTree(commandDefinition, initialElement));
        }
Пример #11
0
        public LayoutItem FindItem(float x, float y)
        {
            // for this function we ignore any threading errors
            // that might happen when accessing the tree
            try {
                if (Tree != null)
                {
                    ILayoutItem li = Tree.Query(new RectangleF(x, y, 1, 1)).FirstOrDefault();
                    if (li == null)
                    {
                        return(LayoutItem.Empty);
                    }
                    return((LayoutItem)li);
                }
            } catch {}

            return(LayoutItem.Empty);
        }
Пример #12
0
        public void Insert(ILayoutItem item)
        {
            // if the item is not contained in this quad, there's a problem

            // *** This is an important bug-fix by kroll
            if (!Bounds.IntersectsWith(item.Bounds))
            //if (!m_Bounds.Contains(item.Bounds))
            {
                //Trace.TraceWarning("feature is out of the bounds of this quadtree node");
                return;
            }

            // if the subnodes are null create them. may not be sucessfull: see below
            // we may be at the smallest allowed size in which case the subnodes will not be created
            if (m_Nodes.Length == 0)
            {
                CreateSubNodes();
            }

            // for each subnode:
            // if the node contains the item, add the item to that node and return
            // this recurses into the node that is just large enough to fit this item
            foreach (QuadTreeNode node in m_Nodes)
            {
                if (node.Bounds.Contains(item.Bounds))
                {
                    node.Insert(item);
                    return;
                }
            }

            // if we make it to here, either
            // 1) none of the subnodes completely contained the item. or
            // 2) we're at the smallest subnode size allowed
            // add the item to this node's contents.
            this.Contents.Push(item);
        }
Пример #13
0
 public LayoutChangeEventArgs(ILayoutItem oldLayoutItem, ILayoutItem newLayoutItem)
 {
     OldLayoutItem = oldLayoutItem;
     NewLayoutItem = newLayoutItem;
 }
 public SelectedLayoutItemChangedMessage(ILayoutItem item)
 {
     this.LayoutItem = item;
 }
Пример #15
0
        public void LoadState(IShell shell, IShellView shellView, string fileName)
        {
            var layoutItems = new Dictionary <string, ILayoutItem>();

            if (!File.Exists(fileName))
            {
                return;
            }

            FileStream stream = null;

            try
            {
                stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);

                using (var reader = new BinaryReader(stream))
                {
                    stream = null;

                    int count = reader.ReadInt32();

                    for (int i = 0; i < count; i++)
                    {
                        string typeName         = reader.ReadString();
                        string contentId        = reader.ReadString();
                        long   stateEndPosition = reader.ReadInt64();
                        stateEndPosition += reader.BaseStream.Position;

                        var  contentType   = Type.GetType(typeName);
                        bool skipStateData = true;

                        if (contentType != null)
                        {
                            // lookup the content within exported tools and document factories
                            ILayoutItem contentInstance = AllExportedTools.Where(x => x.Metadata.ToolType == contentType).Select(x => x.Value).FirstOrDefault();
                            if (contentInstance == null)
                            {
                                // see if it is a document type, and support instancing multiple times
                                var factory = AllExportedDocuments.Where(x => typeName.Contains(x.Metadata.Type.ToString())).FirstOrDefault();
                                if (factory != null)
                                {
                                    contentInstance = factory.CreateExport().Value;
                                }
                            }

                            if (contentInstance == null)
                            {
                                // fall back to the old way - ELIMINATE THIS SOON!
                                try
                                {
                                    contentInstance = IoC.GetInstance(contentType, null) as ILayoutItem;
                                }
                                catch
                                {
                                    // print to log?
                                }
                            }

                            if (contentInstance != null)
                            {
                                layoutItems.Add(contentId, contentInstance);

                                try
                                {
                                    contentInstance.LoadState(reader);
                                    skipStateData = false;
                                }
                                catch
                                {
                                    skipStateData = true;
                                }
                            }
                        }

                        // Skip state data block if we couldn't read it.
                        if (skipStateData)
                        {
                            reader.BaseStream.Seek(stateEndPosition, SeekOrigin.Begin);
                        }
                    }

                    shellView.LoadLayout(reader.BaseStream, shell.ShowTool, shell.OpenDocument, layoutItems);
                }
            }
            catch
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Пример #16
0
 public void Add(ILayoutItem item)
 {
     m_Root.Insert(item);
 }
Пример #17
0
 public LayoutDeactivateEventArgs(ILayoutItem item, bool close)
 {
     Item  = item;
     Close = close;
 }
Пример #18
0
 private static void setManagedContentProperties(ILayoutItem layoutItem, ManagedContent content)
 {
     content.Content = layoutItem;
     content.Title = layoutItem.Title;
     content.Name = layoutItem.Name;
     content.Icon = layoutItem.Icon;
 }
Пример #19
0
 public bool Contains(ILayoutItem item)
 {
     return(items.Contains(item));
 }
    /// <summary>
    /// Gets a pseudo random color from the color palette.
    /// </summary>
    /// <param name="layoutItem">The layout item.</param>
    /// <returns>A new <see cref="Color"/>.</returns>
    private Color GetPseudoRandomColorFromPalette(ILayoutItem layoutItem)
    {
        var color = this.Palette[(layoutItem.Word.Occurrences * layoutItem.Word.Text.Length) % this.Palette.Length];

        return(color);
    }
Пример #21
0
        protected LayoutItemViewModel(ILayoutItem item)
        {
            this.Model = item;

            this.renderElements = new ObservableCollection<IElement>();
        }
Пример #22
0
 public void addChild(ILayoutItem layoutItem)
 {
     childLayoutItems.Add(layoutItem);
 }
Пример #23
0
        private Color GetPresudoRandomColorFromPalette(ILayoutItem layoutItem)
        {
            var color = Palette[layoutItem.Word.Occurrences * layoutItem.Word.Text.Length % Palette.Length];

            return(color);
        }