private void Copy_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (selectedItems.Count != 0)
            {
                List <ProjectElementBase> elements = new List <ProjectElementBase>();
                foreach (TreeViewItem i in selectedItems)
                {
                    if (i != null)
                    {
                        ProjectElementBase elem = i.Tag as ProjectElementBase;
                        elements.Add(elem);
                    }
                }

                ClipboardBufferData data = new ClipboardBufferData(ClipboardOperationType.Copy, elements);
                if (ClipboardBufferData.CanSendToClipboard(data))
                {
                    ClipboardBufferData.SendToClipboard(data);
                }

                foreach (TreeViewItem i in selectedItems)
                {
                    if (i != null)
                    {
                        ProjectElementBase elem = i.Tag as ProjectElementBase;
                        elem.Copy_Executed(sender, e);
                    }
                }
            }
        }
        private void LoadSubelements(ProjectElementBase elem, ItemCollection item_parent)
        {
            TreeViewItem item_sc = new TreeViewItem();

            item_sc.Tag = elem;

            item_sc.Header = CreateHeader(elem);

            if (elem is ProjectFolder)
            {
                item_sc.IsExpanded = (elem as ProjectFolder).Expanded;
            }
            if (elem is SolutionFolder)
            {
                item_sc.IsExpanded = (elem as SolutionFolder).Expanded;
            }
            if (elem is Solution)
            {
                item_sc.IsExpanded = (elem as Solution).RootFolder.Expanded;
            }
            if (elem is Project)
            {
                item_sc.IsExpanded = (elem as Project).RootFolder.Expanded;
            }

            if ((elem.Childrens != null) && (elem.Childrens.Count != 0))
            {
                foreach (ProjectElementBase item in elem.Childrens)
                {
                    LoadSubelements(item, item_sc.Items);
                }
            }
            item_parent.Add(item_sc);
        }
        /// <summary>
        /// Создание объекта Header для элемента TreeView
        /// </summary>
        /// <param name="elem"></param>
        /// <returns></returns>
        private object CreateHeader(ProjectElementBase elem)
        {
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            BitmapImage b_img = new BitmapImage(new Uri(elem.Icon, UriKind.Relative));
            Image       img   = new Image()
            {
                Source = b_img, Width = 16, Height = 16,
            };
            EditableTextBlock text = new EditableTextBlock()
            {
                Text = elem.Caption
            };

            text.Tag = elem;
            elem.Tag = panel;

            text.PreviewMouseDoubleClick += new MouseButtonEventHandler(TreeViewIcon_PreviewMouseDoubleClick);
            //text.PreviewMouseDoubleClick += new MouseButtonEventHandler(EditableTextBlock_PreviewMouseDoubleClick);
            text.OnIsInEditModeChanged += new EditableTextBlock.OnIsInEditModeChangedDelegate(text_OnIsInEditModeChanged);
            panel.Children.Add(img);
            panel.Children.Add(text);
            panel.ContextMenu = elem.CreateElementContextMenu(this);
            return(panel);
        }
        private void TreeViewExplorer_MouseMove(object sender, MouseEventArgs e)
        {
            TreeViewItem item = TreeViewExtensions.GetNearestContainer(e.OriginalSource as UIElement);

            if ((e.LeftButton == MouseButtonState.Pressed) && (item != null))
            {
                var mousePos = e.GetPosition(null);
                var diff     = startPoint - mousePos;

                if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                    Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
                {
                    if (selectedItems.Count != 0)
                    {
                        List <ProjectElementBase> elements = new List <ProjectElementBase>();
                        foreach (TreeViewItem i in selectedItems)
                        {
                            if (i != null)
                            {
                                ProjectElementBase elem = i.Tag as ProjectElementBase;
                                elements.Add(elem);
                            }
                        }

                        if (ClipboardBufferData.CheckGroupValid(elements) != GroupType.IllegalGroup)
                        {
                            var dragData = new DataObject(new ClipboardBufferData(ClipboardOperationType.Cut, elements));
                            DragDrop.DoDragDrop(TreeViewExplorer, dragData, DragDropEffects.Move | DragDropEffects.None);
                        }
                    }
                }
            }
        }
        private void Copy_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            if (selectedItems.Count != 0)
            {
                List <ProjectElementBase> elements = new List <ProjectElementBase>();
                foreach (TreeViewItem i in selectedItems)
                {
                    if (i != null)
                    {
                        ProjectElementBase elem = i.Tag as ProjectElementBase;
                        elements.Add(elem);
                    }
                }

                e.CanExecute = (ClipboardBufferData.CheckGroupValid(elements) != GroupType.IllegalGroup);

                foreach (TreeViewItem i in selectedItems)
                {
                    if (i != null)
                    {
                        ProjectElementBase elem = i.Tag as ProjectElementBase;
                        elem.Copy_CanExecute(sender, e);
                    }
                }
            }
        }
示例#6
0
 public void RemoveElement(ProjectElementBase element)
 {
     if (element is ProjectElement)
     {
         childrens.Remove(element as ProjectElement);
     }
     else
     {
         throw new Exception("Not correct type of item");
     }
 }
示例#7
0
 public void AddElement(ProjectElementBase element)
 {
     if (element is ProjectElement)
     {
         childrens.Add(element as ProjectElement);
         element.Parent = this;
     }
     else
     {
         throw new Exception("Not correct type of item");
     }
 }
        private void TreeViewIcon_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb != null)
            {
                ProjectElementBase elem = etb.Tag as ProjectElementBase;
                if (elem != null)
                {
                    core.OpenNewWindow(elem);
                }
            }
        }
 private void Paste_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
     //1 выбранный элемент
     //этот элемент может принять данные
     if (selectedItems.Count != 0)
     {
         TreeViewItem item = selectedItems[0];
         if (item != null)
         {
             ProjectElementBase elem = item.Tag as ProjectElementBase;
             elem.Paste_CanExecute(sender, e);
         }
     }
 }
 private void Remove_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (selectedItems.Count != 0)
     {
         foreach (TreeViewItem i in selectedItems)
         {
             if (i != null)
             {
                 ProjectElementBase elem = i.Tag as ProjectElementBase;
                 elem.Remove_Executed(sender, e);
             }
         }
     }
 }
示例#11
0
        public void RemoveElement(ProjectElementBase element)
        {
            if (element is Project)
            {
                Projects.Remove(element as Project);
                return;
            }

            if (element is SolutionFolder)
            {
                SubFolders.Remove(element as SolutionFolder);
                return;
            }
            throw new Exception("Not correct type of item");
        }
        private void Paste_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (selectedItems.Count != 0)
            {
                TreeViewItem item = selectedItems[0];
                if (item != null)
                {
                    ProjectElementBase elem = item.Tag as ProjectElementBase;
                    elem.Paste_Executed(sender, e);
                }

                Solution.Save();
                UpdateInfo();
            }
        }
示例#13
0
        public void AddElement(ProjectElementBase element)
        {
            if (element is Project)
            {
                Projects.Add(element as Project);
                element.Parent = this;
                return;
            }

            if (element is SolutionFolder)
            {
                SubFolders.Add(element as SolutionFolder);
                element.Parent = this;
                return;
            }
            throw new Exception("Not correct type of item");
        }
 void text_OnIsInEditModeChanged(EditableTextBlock sender, bool IsEditable)
 {
     if (IsEditable == false)
     {
         ProjectElementBase elem = (sender.Tag) as ProjectElementBase;
         try
         {
             elem.Caption = sender.Text;
         }
         catch (Exception ex)
         {
             sender.Text = elem.Caption;
             Schematix.Core.Logger.Log.Error("OnCaptionChange error.", ex);
             System.Windows.MessageBox.Show(string.Format("Could not rename file.\n", ex.Message), "File system error ocurred", System.Windows.MessageBoxButton.OK);
         }
     }
 }
示例#15
0
        /// <summary>
        /// Коструктор для элемента, чье имя не совадает с именем файла
        /// </summary>
        /// <param name="path"></param>
        /// <param name="caption"></param>
        /// <param name="parent"></param>
        public ProjectElementBase(string path, string caption, ProjectElementBase parent)
        {
            this.parent  = parent;
            this.path    = path;
            this.caption = caption;

            if (System.IO.Directory.Exists(path))
            //Это папка, заглавие не меняем
            {
                extention = string.Empty;
            }
            else
            {
                if (System.IO.Path.HasExtension(path))
                {
                    this.extention = System.IO.Path.GetExtension(path);
                }
            }
        }
示例#16
0
        /// <summary>
        /// Стандартный конструктор
        /// </summary>
        /// <param name="path"></param>
        /// <param name="parent"></param>
        public ProjectElementBase(string path, ProjectElementBase parent)
        {
            this.parent = parent;
            this.path   = path;

            if (System.IO.Directory.Exists(path))
            //Это папка, заглавие не меняем
            {
                extention = string.Empty;
                System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(path);
                caption = info.Name;
            }
            else
            {
                this.caption = System.IO.Path.GetFileNameWithoutExtension(path);
                if (System.IO.Path.HasExtension(path))
                {
                    this.extention = System.IO.Path.GetExtension(path);
                }
            }
        }
        private void TreeViewExplorer_Expanded(object sender, RoutedEventArgs e)
        {
            ProjectElementBase elem = (e.OriginalSource as TreeViewItem).Tag as ProjectElementBase;

            if (elem is Solution)
            {
                (elem as Solution).RootFolder.Expanded = true;
            }
            if (elem is Project)
            {
                (elem as Project).RootFolder.Expanded = true;
            }
            if (elem is ProjectFolder)
            {
                (elem as ProjectFolder).Expanded = true;
            }
            if (elem is SolutionFolder)
            {
                (elem as SolutionFolder).Expanded = true;
            }
        }
示例#18
0
        private void CreateDiagramFunction(object o)
        {
            string[] arguments        = o as string[];
            string   vhdFile          = arguments[0];
            string   EntityName       = arguments[1];
            string   ArchitectureName = arguments[2];
            string   vcdFile          = arguments[3];

            PrepareCompilator();
            compiler.Messages.Clear();
            bool res = compiler.CreateDiagram(vhdFile, EntityName, ArchitectureName, vcdFile);

            project.UpdateSimulationFolderContent();
            bool isContainsFile = false;

            foreach (Schematix.ProjectExplorer.Waveform_File w in project.GetProjectElements <Schematix.ProjectExplorer.Waveform_File>())
            {
                if (w.Path == vcdFile)
                {
                    isContainsFile = true;
                    break;
                }
            }
            if (isContainsFile == false)
            {
                Schematix.ProjectExplorer.ProjectElementBase vhdl   = core.SearchItemInSolution(vhdFile);
                Schematix.ProjectExplorer.ProjectFolder      folder = vhdl.Parent as Schematix.ProjectExplorer.ProjectFolder;
                Schematix.ProjectExplorer.ProjectElement     vcd    = Schematix.ProjectExplorer.ProjectElement.CreateProjectElementByPath(vcdFile, folder);
                folder.AddElement(vcd);
            }
            if (System.IO.File.Exists(vcdFile) == true)
            {
                core.SaveSolution();
                core.UpdateExplorerPanel();
                Schematix.Windows.Waveform.Waveform waveformWindow = core.OpenNewWindow(vcdFile, true) as Schematix.Windows.Waveform.Waveform;
                waveformWindow.SetParameters(vhdFile, EntityName, ArchitectureName);
                waveformWindow.Save();
            }
        }
示例#19
0
        /// <summary>
        /// Удаление элемента с заданным путем с папки
        /// </summary>
        /// <param name="RmPath"></param>
        protected void RemoveElementFromSolution(string RmPath, ProjectElementBase elem)
        {
            //Проверяем путь
            if (elem.Path.Equals(RmPath) == true)
            {
                //Если можно - то удаляем элемент
                if ((elem.parent != null) && (elem.parent is IElementProvider))
                {
                    (elem.parent as IElementProvider).RemoveElement(elem);
                    return;
                }
            }
            //Перебираем оставшиеся дочерние элементы
            if (elem.Childrens != null)
            {
                foreach (ProjectElementBase el in elem.Childrens)
                {
                    RemoveElementFromSolution(RmPath, el);
                }
            }

            SchematixCore.Core.UpdateExplorerPanel();
        }
示例#20
0
 public bool CanAddElement(ProjectElementBase element)
 {
     return(rootFolder.CanAddElement(element));
 }
示例#21
0
 public bool CanAddElement(ProjectElementBase element)
 {
     return((element is Project) || (element is SolutionFolder));
 }
示例#22
0
 public bool CanAddElement(ProjectElementBase element)
 {
     return(element is ProjectElement);
 }
示例#23
0
 public void RemoveElement(ProjectElementBase element)
 {
     rootFolder.RemoveElement(element);
 }
示例#24
0
 /// <summary>
 /// Стандартный конструктор
 /// </summary>
 /// <param name="path"></param>
 /// <param name="parent"></param>
 public ProjectElement(string path, ProjectElementBase parent)
     : base(path, parent)
 {
     removed = false;
 }
示例#25
0
 public void AddElement(ProjectElementBase element)
 {
     rootFolder.AddElement(element);
 }