Exemplo n.º 1
0
        public void TryPaste()
        {
            if (!string.IsNullOrEmpty(json))
            {
                rMindBaseElement element = null;;

                var result = new List <rMindBaseElement>();
                var list   = JsonConvert.DeserializeObject <List <object> >(json);

                foreach (var item in list)
                {
                    var s          = item.ToString();
                    var baseObject = JsonConvert.DeserializeObject <rMindBaseElement>(s);
                    var type       = baseObject?.ElementType ?? rElementType.RET_NONE;

                    switch (type)
                    {
                    case rElementType.RET_NONE:
                        element = JsonConvert.DeserializeObject <rMindBaseElement>(s);
                        element?.Translate(new Vector2(20, 20));
                        break;
                    }
                    if (element != null)
                    {
                        AddElement(element);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void SetSelectedItem(rMindBaseElement item, bool multi = false)
 {
     if (item == null)
     {
         foreach (var it in m_selected_items)
         {
             it.SetSelected(false);
         }
         m_selected_items.Clear();
         return;
     }
     if (!multi && !m_selected_items.Contains(item))
     {
         foreach (var it in m_selected_items)
         {
             if (it == item)
             {
                 continue;
             }
             it.SetSelected(false);
         }
         m_selected_items.Clear();
         m_selected_items.Add(item);
     }
     if (!m_selected_items.Contains(item))
     {
         item.SetSelected(true);
         m_selected_items.Add(item);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Add new element
        /// </summary>
        public virtual rMindBaseElement AddElement(rMindBaseElement item, bool silent = false)
        {
            m_items.Add(item);

            if (m_subscribed && !silent)
            {
                Draw(item);
            }

            return(item);
        }
Exemplo n.º 4
0
 public long GetIndexOfElement(rMindBaseElement element)
 {
     if (m_items.Contains(element))
     {
         return(m_items.IndexOf(element));
     }
     else
     {
         return(-1);
     }
 }
Exemplo n.º 5
0
 protected virtual void Draw(rMindBaseElement item)
 {
     if (m_subscribed && !m_canvas.Children.Contains(item.Template))
     {
         m_canvas.Children.Add(item.Template);
         item.Template.UpdateLayout();
         foreach (var node in item.Nodes)
         {
             node.Update();
         }
     }
 }
Exemplo n.º 6
0
        public virtual Vector2 GetScreenCenter(rMindBaseElement item = null)
        {
            if (!m_subscribed)
            {
                return(new Vector2(0, 0));
            }

            return(new Vector2(
                       (m_scroll.HorizontalOffset + m_scroll.ActualWidth / 2 - (item == null ? 0 : item.Width / 2)) / m_scroll.ZoomFactor,
                       (m_scroll.VerticalOffset + m_scroll.ActualHeight / 2 - (item == null ? 0 : item.Height / 2)) / m_scroll.ZoomFactor
                       ));
        }
Exemplo n.º 7
0
        public void SetDragItem(rMindBaseElement item, PointerRoutedEventArgs e)
        {
            m_items_state.DragedItem = item;
            if (item == null)
            {
                return;
            }

            var p = e.GetCurrentPoint(m_canvas);

            m_items_state.StartPointerPosition = new Vector2(p.Position.X, p.Position.Y);
            m_items_state.StartPosition        = item.Position;
        }
Exemplo n.º 8
0
        public void TranslateContainer(rMindBaseElement container, Vector2 translation)
        {
            if (SelectedItems.Contains(container))
            {
                foreach (var selection in SelectedItems)
                {
                    selection.Translate(translation);
                }
                return;
            }

            container.Translate(translation);
        }
Exemplo n.º 9
0
        public rMindBaseNode GetNodeByIndexPair(int itemIdx, int nodeIdx)
        {
            rMindBaseElement item = null;

            if (m_items.Count > itemIdx)
            {
                item = m_items[itemIdx];
                if (item.Nodes.Count > nodeIdx)
                {
                    return(item.Nodes[nodeIdx]);
                }
            }
            return(null);
        }
Exemplo n.º 10
0
        public virtual rMindBaseElement CreateElementByElementType(rElementType type, bool silent = false)
        {
            rMindBaseElement element = null;

            switch (type)
            {
            case rElementType.RET_NONE:
                element = new Content.rMindHeaderRowContainer(this);
                break;
            }
            AddElement(element, silent);

            return(element);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Remove item from canvas
        /// </summary>
        public virtual void RemoveElement(rMindBaseElement item)
        {
            if (CheckIsOvered(item))
            {
                m_overed_item = null;
            }

            if (m_items.Contains(item))
            {
                if (m_selected_items.Contains(item))
                {
                    m_selected_items.Remove(item);
                }

                m_canvas.Children.Remove(item.Template);
                m_items.Remove(item);
            }
        }
Exemplo n.º 12
0
        public virtual rMindBaseElement CreateElementByElementType(rElementType type, object createParams, bool silent = false)
        {
            rMindBaseElement element = null;

            switch (type)
            {
            case rElementType.RET_NONE:
                element = new Content.rMindHeaderRowContainer(this);
                break;

            case rElementType.RET_DEVICE_OUTPUT:
                element = new Content.rMindDeviceOutput(this);
                break;
            }
            AddElement(element, silent);

            return(element);
        }
Exemplo n.º 13
0
        public void SetSelectedItem(rMindBaseElement item, bool multi = false)
        {
            if (item == null)
            {
                foreach (var selection in SelectedItems)
                {
                    selection.SetSelected(false);
                }
                SelectedItems.Clear();
                return;
            }

            if (multi)
            {
                if (!SelectedItems.Contains(item))
                {
                    item.SetSelected(true);
                    SelectedItems.Add(item);
                }
            }
            else
            {
                if (!SelectedItems.Contains(item))
                {
                    foreach (var selection in SelectedItems)
                    {
                        selection.SetSelected(false);
                    }
                    SelectedItems.Clear();
                    item.SetSelected(true);
                    SelectedItems.Add(item);
                }
            }

            /*
             * if (item == null)
             * {
             *  foreach (var it in m_selected_items)
             *  {
             *      it.SetSelected(false);
             *  }
             *  m_selected_items.Clear();
             *  return;
             * }
             * if (!multi && !m_selected_items.Contains(item))
             * {
             *  foreach (var it in m_selected_items)
             *  {
             *      if (it == item)
             *          continue;
             *      it.SetSelected(false);
             *  }
             *  m_selected_items.Clear();
             *  m_selected_items.Add(item);
             * }
             * if (!m_selected_items.Contains(item))
             * {
             *  item.SetSelected(true);
             *  m_selected_items.Add(item);
             * }
             */
        }
Exemplo n.º 14
0
 public bool CheckIsDraged(rMindBaseElement item)
 {
     return(m_items_state.DragedItem == item);
 }
Exemplo n.º 15
0
 public bool CheckIsOvered(rMindBaseElement item)
 {
     return(m_overed_item == item);
 }
Exemplo n.º 16
0
 public void SetOveredItem(rMindBaseElement item)
 {
     m_overed_item = item;
 }