Esempio n. 1
0
 public void AddBufferItem(int id, IBufferItem bufferItem)
 {
     lock (this.BufferItemDict)
     {
         this.BufferItemDict[id] = bufferItem;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 /// <param name="parent">Parent</param>
 public BufferItemWrapper(BufferDirectoryWrapper parent, IBufferData item)
 {
     this.item   = item;
     this.parent = parent;
     parent.items.Add(this);
     StaticExtensionDataPerformerInterfaces.items[item.Id] = this;
 }
  void SetUrl()
  {
      TreeNode n = treeViewMain.SelectedNode;
      if (n == current)
      {
          return;
      }
      current = n;
      changeNode(n);
      if (n == null)
      {
          return;
      }
      if (buffer == null)
      {
          return;
      }
      if (n.Tag is IBufferItem)
      {
          IBufferItem d = n.Tag as IBufferItem;
          string uid = d.GetUrl();
          try
          {
              buffer.Url = uid;
          //    toolStripLabelSize.Text = "";//"Length = " + d.GetLength();
          //    toolStripLabelSize.Visible = true;
          }
          catch (Exception exception)
          {
              exception.ShowError();
          }
          return;
      }
 //     toolStripLabelSize.Visible = false;
  }
 /// <summary>
 /// Обновляет заголовок окна после удаления последнего буфера
 /// </summary>
 /// <param name="obj"></param>
 void CopyPasteController_Update(IBufferItem obj)
 {
     if (_buffers.Count == 0)
     {
         ViewName = NavigationKeys.HelpView;
     }
 }
Esempio n. 5
0
        public IBufferItem FindBufferItem(int id)
        {
            IBufferItem bufferItem = null;

            lock (this.BufferItemDict)
            {
                this.BufferItemDict.TryGetValue(id, out bufferItem);
            }
            return(bufferItem);
        }
Esempio n. 6
0
 /// <summary>
 /// Обрабатывает обновление коллекции
 /// </summary>
 /// <param name="obj">Буфер, который стал причиной обновления</param>
 void CopyPasteController_Update(IBufferItem obj)
 {
     if (Buffers.Count == 0)
     {
         NavigationManager.Navigate(NavigationKeys.HelpView);
     }
     else
     {
         NavigationManager.Navigate(NavigationKeys.BuffersView);
     }
 }
 /// <summary>
 /// Обновляет указнный буфер
 /// </summary>
 /// <param name="item">Новый буфер</param>
 /// <returns></returns>
 public async Task UpdateAsync(IBufferItem item)
 {
     var dataItem = new BufferItemDataModel
     {
         Id    = 0,
         Name  = item.Name,
         Value = item.Value,
         Key   = (int)item.Key
     };
     HttpResponseMessage httpResponse = await _httpClient.PutAsJsonAsync(dataItem.Key.ToString(), dataItem);
 }
Esempio n. 8
0
        /// <summary>
        /// Вставляет текст из указанного буфера
        /// </summary>
        /// <param name="key">Нажатая клавиша, указывающая, из какого буфера будет вставлен текст</param>
        void Paste(object sender, InputHandlerEventArgs key)
        {
            IBufferItem tmpItem = _bufferItemFactory.GetBuffer();

            tmpItem.Key = key.Key;

            int index = Buffer.IndexOf(tmpItem);

            if (index > -1)
            {
                Clipboard.SetText(Buffer[index].Value);
            }
        }
        /// <summary>
        /// Creates a tree
        /// </summary>
        /// <param name="data">Database interface</param>
        /// <returns>roots of trees</returns>
        static IBufferDirectory[] CreateTree(this IDatabaseInterface data)
        {
            Dictionary <object, IParentSet> dictionary  = new Dictionary <object, IParentSet>();
            IEnumerable <object>            list        = data.Elements;
            List <IBufferDirectory>         directories = new List <IBufferDirectory>();

            foreach (object o in list)
            {
                IBufferItem item = data[o];
                IParentSet  ps   = null;
                if (item is IBufferData)
                {
                    ps = new BufferItemWrapper(item as IBufferData);
                }
                else
                {
                    ps = new BufferDirectoryWrapper(item);
                }
                dictionary[o] = ps;
            }
            foreach (IParentSet ps in dictionary.Values)
            {
                IBufferItem it = (ps as IBufferItem);
                object      o  = it.ParentId;
                if (!o.Equals(it.Id))
                {
                    if (dictionary.ContainsKey(o))
                    {
                        ps.Parent = dictionary[o] as IBufferItem;
                    }
                }
            }
            List <IBufferDirectory> l = new List <IBufferDirectory>();

            foreach (IParentSet ps in dictionary.Values)
            {
                if (ps is IBufferDirectory)
                {
                    IBufferDirectory item = (ps as IBufferDirectory);
                    if (item.Parent == null)
                    {
                        l.Add(item);
                    }
                }
            }
            return(l.ToArray());
        }
Esempio n. 10
0
        private void treeViewDir_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                return;
            }
            TreeNode s = e.Node;

            if (s == null)
            {
                return;
            }
            object o = s.Tag;

            if (o == null)
            {
                return;
            }
            if (o is IBufferItem)
            {
                IBufferItem item = o as IBufferItem;
                IBufferItem p    = item.Parent;
                if (p == null | !(p is IBufferDirectory))
                {
                    MessageBox.Show("Prohibited");
                    return;
                }
                IBufferDirectory d     = p as IBufferDirectory;
                List <string>    names = d.GetDirectoryNames();
                string           name  = e.Label;
                if (names.Contains(name))
                {
                    MessageBox.Show("Name alredy exists");
                    return;
                }
                try
                {
                    item.Name = name;
                }
                catch (Exception exception)
                {
                    exception.ShowError();
                }
            }
        }
        /// <summary>
        /// Full directory
        /// </summary>
        /// <param name="item">Item</param>
        /// <param name="action">Action</param>
        /// <returns>Full directory</returns>
        public static IEnumerable <IBufferItem> FullDirectory(this IBufferItem item, Action <IBufferItem> action = null)
        {
            if (action != null)
            {
                action(item);
            }
            yield return(item);

            if (item is IBufferDirectory)
            {
                IBufferDirectory          ld  = item as IBufferDirectory;
                IEnumerable <IBufferItem> enu = ld.Children;
                foreach (IBufferItem it in enu)
                {
                    IEnumerable <IBufferItem> enn = it.FullDirectory(action);
                    foreach (IBufferItem itt in enn)
                    {
                        yield return(itt);
                    }
                }
            }
        }
  void GetUrl()
  {
      if (buffer == null)
      {
          return;
      }
      string url = buffer.Url;
      TreeNode n = treeViewMain.Find(url);
      if (n != null)
      {
          if (treeViewMain.SelectedNode == n)
          {
              return;
          }
          treeViewMain.SelectedNode = n;
          IBufferItem d = n.Tag as IBufferItem;
 //         toolStripLabelSize.Text = "";// = "Length = " + d.GetLength();
 //         toolStripLabelSize.Visible = true;
      }
      else
      {
   //       toolStripLabelSize.Visible = false;
      }
  }
Esempio n. 13
0
        /// <summary>
        /// Копирует текст и сохраняет его в указанный буфер
        /// </summary>
        /// <param name="key">Нажатая клавиша, указывающая, в какой буфер будет вставлен текст</param>
        void Copy(object sender, InputHandlerEventArgs key)
        {
            IBufferItem tmpItem = _bufferItemFactory.GetBuffer();

            tmpItem.Key   = key.Key;
            tmpItem.Value = key.Value;

            int index = Buffer.IndexOf(tmpItem);

            if (index > -1)
            {
                Buffer[index].Value = tmpItem.Value;
            }
            else
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    Buffer.Add(tmpItem);
                    tmpItem.Delete += TmpItem_Delete;
                }));
            }

            Update?.Invoke(tmpItem);
        }
 /// <summary>
 /// Gets url of item
 /// </summary>
 /// <param name="item">The item</param>
 /// <returns>The url</returns>
 static public string GetUrl(this IBufferItem item)
 {
     return("database://ConnectionString=[" + connectionString + "]&Id=[" + item.Id + "]");
 }
Esempio n. 15
0
 /// <summary>
 /// Удаляет выбранный буфер
 /// </summary>
 /// <param name="obj"></param>
 void TmpItem_Delete(IBufferItem obj)
 {
     Buffer.Remove(obj);
     Update?.Invoke(obj);
 }
Esempio n. 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="item">Item</param>
 public BufferDirectoryWrapper(IBufferItem item)
 {
     this.item = item;
     StaticExtensionDataPerformerInterfaces.items[item.Id] = this;
 }