System.Windows.Controls.ItemCollection.Add(object)

Here are the examples of the csharp api System.Windows.Controls.ItemCollection.Add(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

520 Examples 7

19 View Source File : MainWindow.xaml.Macros.cs
License : MIT License
Project Creator : 3RD-Dimension

private void RefreshMacroButtons()
		{
			StackPanelMacros.Children.Clear();
			for (int i = 0; i < Macros.Count; i++)
			{
				int index = i;

				Button b = new Button();
				b.Content = (Macros[i].Item3 ? "[E] " : "") + Macros[i].Item1;
				b.Margin = new Thickness(2, 0, 2, 2);
				b.Click += (sender, e) => { RunMacro(Macros[index].Item2, Macros[index].Item3); };
				b.ToolTip = Macros[i].Item2;

				MenuItem edireplacedem = new MenuItem();
				edireplacedem.Header = "Edit";
				edireplacedem.Click += (s, e) =>
				{
					var emiw = new EditMacroItemWindow(Macros[index].Item1, Macros[index].Item2, Macros[index].Item3);
					emiw.ShowDialog();
					if (emiw.Ok)
					{
						Macros[index] = new Tuple<string, string, bool>(emiw.MacroName, emiw.Commands, emiw.UseMacros);
						SaveMacros();
						RefreshMacroButtons();
					}
				};

				MenuItem removeItem = new MenuItem();
				removeItem.Header = "Remove";
				removeItem.Click += (s, e) => { Macros.RemoveAt(index); RefreshMacroButtons(); };

				ContextMenu menu = new ContextMenu();
				menu.Items.Add(edireplacedem);
				menu.Items.Add(removeItem);

				if (i > 0)
				{
					MenuItem moveUpItem = new MenuItem();
					moveUpItem.Header = "Move Up";

					moveUpItem.Click += (s, e) =>
					{
						var macro = Macros[index];
						Macros.RemoveAt(index);
						Macros.Insert(index - 1, macro);

						SaveMacros();
						RefreshMacroButtons();
					};

					menu.Items.Add(moveUpItem);
				}

				b.ContextMenu = menu;

				StackPanelMacros.Children.Add(b);
			}
		}

19 View Source File : ParticleExplorer.xaml.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public void PopulateTable(ListBox listBox, List<uint> ids)
        {
            listBox.Items.Clear();

            foreach (var id in ids)
                listBox.Items.Add($"{id:X8}");
        }

19 View Source File : ParticleExplorer.xaml.cs
License : GNU General Public License v3.0
Project Creator : ACEmulator

public void PopulateTable(ListBox listBox, Dictionary<uint, uint> kvps)
        {
            listBox.Items.Clear();

            foreach (var kvp in kvps)
                listBox.Items.Add($"{kvp.Key:X8} => {kvp.Value:X8}");
        }

19 View Source File : IntraTextNoteAdornmentManager.cs
License : MIT License
Project Creator : Actipro

protected override void AddAdornment(AdornmentChangeReason reason, ITextViewLine viewLine, TagSnapshotRange<IntraTextNoteTag> tagRange, TextBounds bounds) {
			// Create the adornment
			var image = new DynamicImage();
			image.Width = 16;
			image.Height = 16;
			image.SnapsToDevicePixels = true;
			image.Source = new BitmapImage(new Uri("/Images/Icons/Notes16.png", UriKind.Relative));
			image.Stretch = Stretch.Fill;

			// Create a popup button
			PopupButton button = new PopupButton();
			button.Content = image;
			button.Cursor = Cursors.Arrow;
			button.DisplayMode = PopupButtonDisplayMode.Merged;
			button.Focusable = false;
			button.IsTabStop = false;
			button.IsTransparencyModeEnabled = true;
			button.Margin = new Thickness(0);
			button.Padding = new Thickness(-1);
			button.ToolTip = new HtmlContentProvider(String.Format("<span style=\"color: green;\">{0}</span><br/>Created at <b>{1}</b> by <span style=\"color: blue;\">{2}</span><br/>Status: <b>{3}</b>",
				tagRange.Tag.Message, tagRange.Tag.Created.ToShortTimeString(), tagRange.Tag.Author, tagRange.Tag.Status)).GetContent();

			// Add a context menu
			ContextMenu contextMenu = new ContextMenu();
			button.PopupMenu = contextMenu;

			MenuItem removeItem = new MenuItem();
			removeItem.Header = "Remove Note";
			removeItem.Tag = tagRange;
			removeItem.Click += new RoutedEventHandler(OnRemoveNote);
			contextMenu.Items.Add(removeItem);
			
			contextMenu.Items.Add(new Separator());

			MenuItem pendingItem = new MenuItem();
			pendingItem.Header = "Mark as Pending";
			pendingItem.IsChecked = (tagRange.Tag.Status == ReviewStatus.Pending);
			pendingItem.Tag = tagRange;
			pendingItem.Click += new RoutedEventHandler(OnMarkNoteAsPending);
			contextMenu.Items.Add(pendingItem);
			
			MenuItem acceptedItem = new MenuItem();
			acceptedItem.Header = "Mark as Accepted";
			acceptedItem.IsChecked = (tagRange.Tag.Status == ReviewStatus.Accepted);
			acceptedItem.Tag = tagRange;
			acceptedItem.Click += new RoutedEventHandler(OnMarkNoteAsAccpeted);
			contextMenu.Items.Add(acceptedItem);

			MenuItem rejectedItem = new MenuItem();
			rejectedItem.Header = "Mark as Rejected";
			rejectedItem.IsChecked = (tagRange.Tag.Status == ReviewStatus.Rejected);
			rejectedItem.Tag = tagRange;
			rejectedItem.Click += new RoutedEventHandler(OnMarkNoteAsRejected);
			contextMenu.Items.Add(rejectedItem);

			// Get the location
			Point location = new Point(Math.Round(bounds.Left) + 1, Math.Round(bounds.Top + (bounds.Height - tagRange.Tag.Size.Height) / 2));

			// Add the adornment to the layer
			this.AdornmentLayer.AddAdornment(reason, button, location, tagRange.Tag.Key, null);
		}

19 View Source File : FolderRegPickerWindow.xaml.cs
License : MIT License
Project Creator : advancedmonitoring

private void folder_OnExpanded(object sender, RoutedEventArgs e)
        {
            var item = (TreeViewItem) sender;
            try
            {
                if (item.Items.Count == 1 && (item.Items[0] is TreeViewItem) && ( string.IsNullOrWhiteSpace((string)((TreeViewItem)item.Items[0]).Header)))
                {
                    EdtPath.Text = item.Tag.ToString().Trim();
                    item.Items.Clear();
                    try
                    {
                        foreach (var s in Directory.GetDirectories(item.Tag.ToString()))
                        {
                            var subitem = new TreeViewItem
                            {
                                Header = s.Substring(s.LastIndexOf("\\") + 1),
                                Tag = s
                            };
                            try
                            {
                                if (Directory.GetDirectories(s).Length != 0)
                                    subitem.Items.Add(new TreeViewItem {Header = ""});
                            }
                            catch { /* ignore */ }
                            subitem.Expanded += folder_OnExpanded;
                            subitem.Selected += element_OnSelected;
                            item.Items.Add(subitem);
                        }
                    }
                    catch { /* ignore */ }
                }
            }
            catch { /* ignore */ }
        }

19 View Source File : FolderRegPickerWindow.xaml.cs
License : MIT License
Project Creator : advancedmonitoring

private void keyreg_OnExpanded(object sender, RoutedEventArgs e)
        {
            var item = (TreeViewItem)sender;
            try
            {
                if (item.Items.Count == 1 && (item.Items[0] is TreeViewItem) && (string.IsNullOrWhiteSpace((string)((TreeViewItem)item.Items[0]).Header)))
                {
                    EdtPath.Text = item.Tag.ToString().Trim();
                    item.Items.Clear();
                    try
                    {
                        RegistryKey rk = GetKeyFromString(item.Tag.ToString());
                        foreach (string s in rk.GetSubKeyNames())
                        {
                            TreeViewItem subitem = new TreeViewItem
                            {
                                Header = s,
                                Tag = item.Tag + "\\" + s
                            };
                            try
                            {
                                var oSubKey = rk.OpenSubKey(s);
                                if (oSubKey != null && oSubKey.SubKeyCount != 0)
                                    subitem.Items.Add(new TreeViewItem { Header = "" });
                            }
                            catch { /* ignore */ }
                            subitem.Expanded += keyreg_OnExpanded;
                            subitem.Selected += element_OnSelected;
                            item.Items.Add(subitem);
                        }
                    }
                    catch { /* ignore */ }
                }
            }
            catch { /* ignore */ }
        }

19 View Source File : ReportModel.cs
License : MIT License
Project Creator : advancedmonitoring

private static TreeViewItem ACEToTreeViewItem(ACE ace, int rightsType, bool translateSID)
        {
            var rv = new TreeViewItem {Header = SecurityDescriptor.SIDToLong(ace.GetSID(), translateSID) };
            rv.Items.Clear();
            foreach (var right in ace.GetAllRights())
                rv.Items.Add(ACE.RigthToLong(right, rightsType));
            return rv;
        }

19 View Source File : EditorModel.cs
License : Mozilla Public License 2.0
Project Creator : agebullhu

private void CreateExtendEditor(string replacedle, ExtendViewOption option)
        {
            var editor = option.Create();
            var vm = (ExtendViewModelBase)editor.DataContext;
            vm.BaseModel = Model;
            var item = new TabItem
            {
                Header = replacedle,
                VerticalAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch
            };
            var ext = new ExtendPanel
            {
                Child = editor,
                DataContext = editor.DataContext,
                VerticalAlignment = VerticalAlignment.Stretch,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch,
            };
            item.Content = ext;
            ExtendEditorPanel.Items.Add(item);
            item.UpdateLayout();
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : AgileoAutomation

private TreeViewItem SetTreeViewComponenreplacedem(SoftwareComponent component)
        {
            TreeViewItem componenreplacedem = new TreeViewItem();
            componenreplacedem.Header = component.Name;

            //Color Management
            if (component.Color.Name != "Black")
            {
                componenreplacedem.Foreground = new SolidColorBrush(ConvertSystemDrawingToWindowsMediaColor(component.Color));
            }

           // Groups build
            if (component.HasGroups)
            {
                TreeViewItem groupsItem = new TreeViewItem();
                groupsItem.Header = "Groups";

                foreach (replacedemblyPointerGroup group in component.replacedemblyPointerGroups)
                {
                    groupsItem.Items.Add(SetTreeViewGroupItem(group));
                }

                componenreplacedem.Items.Add(groupsItem);
            }
            // Subcomponents build
            if (component.Hreplacedubcomponents)
            {
                TreeViewItem subcomponentsItem = new TreeViewItem();
                subcomponentsItem.Header = "Subcomponents";

                foreach (SoftwareComponent subcomponent in component.Subcomponents)
                {
                    subcomponentsItem.Items.Add(SetTreeViewComponenreplacedem(subcomponent));
                }

                componenreplacedem.Items.Add(subcomponentsItem);
            }

            return componenreplacedem;
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : AgileoAutomation

private TreeViewItem SetTreeViewGroupItem(replacedemblyPointerGroup group)
        {
            TreeViewItem groupItem = new TreeViewItem();
            groupItem.Header = group.Name;

            // Reported Errors
            if (group.Pointers.Any(x => x.HasErrors))
                ColorizeErrorItem(groupItem);

            foreach (replacedemblyPointer pointer in group.Pointers)
            {
                TreeViewItem pointerItem = new TreeViewItem();
                pointerItem.Header = pointer.PrettyName;
                if (pointer.HasErrors)
                    ColorizeErrorItem(pointerItem);

                groupItem.Items.Add(pointerItem);
            }

            return groupItem;
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : AgileoAutomation

private void UpdateTreeView()
        {
            treeView.Items.Clear();

            TreeViewItem modelItem = new TreeViewItem();
            modelItem.Header = "Model";
            TreeViewItem groupsItem = new TreeViewItem();
            groupsItem.Header = "Groups";
            TreeViewItem componentsItem = new TreeViewItem();
            componentsItem.Header = "Components";

            // Set TreeviewItems
            foreach (replacedemblyPointerGroup group in Model.replacedemblyPointerGroups)
            {
                groupsItem.Items.Add(SetTreeViewGroupItem(group));
            }

            foreach (SoftwareComponent component in Model.SoftwareComponents)
            {
                componentsItem.Items.Add(SetTreeViewComponenreplacedem(component));
            }

            //Treeview Build
            modelItem.Items.Add(groupsItem);
            modelItem.Items.Add(componentsItem);

            modelItem.IsExpanded = true;
            treeView.Items.Add(modelItem);
            foreach (TreeViewItem item in treeView.Items)
                OpenTreeView(item);

            treeView.Opacity = 100;
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private void ApplyNewName()
        {
            _tag.Visibility = Visibility.Visible;
            _renameBox.Visibility = Visibility.Collapsed;
            var oldPAth = Path;
            var newPath = Parent.Path + @"\" + _renameBox.Text;
            MagicLaboratory.CleanPath(ref newPath);
            try
            {
                if (!Folder)
                    if (File.Exists(Path))
                    {
                        File.Move(Path
                            , newPath);
                        ItemName = _renameBox.Text;
                        var itemName = ItemName;
                        MagicLaboratory.CleanPath(ref itemName);
                        ItemName = itemName;
                        Path = newPath;
                    }

                if (Directory.Exists(Path) && Path != newPath)
                {
                    Directory.Move(Path
                        , Uri.UnescapeDataString(newPath));
                    ItemName = _renameBox.Text;
                    var itemName = ItemName;
                    MagicLaboratory.CleanPath(ref itemName);
                    ItemName = itemName;
                    Path = newPath;
                    var node = Parent.Container.GetNode(oldPAth, Parent.Container.FoldersTree.Items);
                    var parentNode = Parent.Container.GetNode(Parent.Path, Parent.Container.FoldersTree.Items);
                    if (node == null)
                    {
                        parentNode.Items.Add(new TreeViewItem {Header = new FolderItem(Path, ItemName)});
                    }
                    else
                    {
                        var folderItem = node.Header as FolderItem;
                        if (folderItem != null)
                        {
                            folderItem.FolderName = itemName;
                            folderItem.Path = Path;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var result = MessageBox.Show(ex.Message + "\n" + "Try again?", "Couldn't modify the name.",
                    MessageBoxButton.YesNo, MessageBoxImage.Error);
                Parent.Container.Disable();
                if (result == MessageBoxResult.Yes)
                {
                    Parent.Container.Enable();
                    Rename();
                }
            }
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu contentsMenu()
        {
            var cm = new ContextMenu();
            var import_tb = new TextBlock();
            import_tb.Inlines.Add(new Run("⇓")
            {
                Foreground = Brushes.White,
                FontSize = 14,
                FontFamily = new FontFamily("Yu Gothic UI Semibold")
            });
            import_tb.Inlines.Add(new Run(" Import") {Foreground = Brushes.White});
            var new_tb = new TextBlock();
            new_tb.Inlines.Add(new Run("🗋")
            {
                Foreground = Brushes.White,
                FontSize = 14,
                FontFamily = new FontFamily("Verdana")
            });
            new_tb.Inlines.Add(new Run(" New") {Foreground = Brushes.White});
            var openexplorer_tb = new TextBlock();
            openexplorer_tb.Inlines.Add(new Run("🗀")
            {
                Foreground = Brushes.Yellow,
                FontSize = 16,
                FontFamily = new FontFamily("Yu Gothic UI Semibold")
            });
            openexplorer_tb.Inlines.Add(new Run(" Open in Folder in File Explorer") {Foreground = Brushes.White});
            var refresh_tb = new TextBlock();
            refresh_tb.Inlines.Add(new Run("↻")
            {
                Foreground = Brushes.Cyan,
                FontSize = 14,
                FontFamily = new FontFamily("Yu Gothic UI Semibold")
            });
            refresh_tb.Inlines.Add(new Run(" Refresh") {Foreground = Brushes.White});
            var import = new MenuItem
            {
                Header = import_tb
            };
            import.Click += (s, e) => { ImportFile(); };
            var newitem = new MenuItem
            {
                Header = new_tb
            };
            NewItemMenu(newitem);
            var openexplorer = new MenuItem
            {
                Header = openexplorer_tb
            };
            openexplorer.Click += (s, e) => { Process.Start(Item.Path); };
            var refresh = new MenuItem
            {
                Header = refresh_tb
            };
            refresh.Click += (s, e) => { Item.Load(Item.Path); };
            cm.Items.Add(openexplorer);
            cm.Items.Add(new Separator {Foreground = Brushes.White});
            cm.Items.Add(import);
            cm.Items.Add(newitem);
            var paste = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Paste"
                }
            };
            paste.Click += (s, e) =>
            {
                try
                {
                    var p = Item.Path;
                    if (p.Substring(0, Math.Max(0, p.Length - 1)) == @"\")
                        File.Copy(PathToCopy, Item.Path + Path.GetFileName(PathToCopy));
                    else
                        File.Copy(PathToCopy, Item.Path + @"\" + Path.GetFileName(PathToCopy));
                    Item.Load(Item.Path);
                }
                catch
                {
                    //Ignored
                }
            };
            cm.Items.Add(paste);
            cm.Items.Add(new Separator {Foreground = Brushes.White});
            cm.Items.Add(refresh);
            return cm;
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu BuildContextMenu()
        {
            var sp = new Separator {Foreground = Brushes.Gray};
            var sp1 = new Separator {Foreground = Brushes.Gray};
            var cMenu = new ContextMenu();
            var open = new MenuItem
            {
                Header = new TextBlock {Foreground = Brushes.WhiteSmoke, Text = "Open"}
            };
            open.Click += (s, e) => { Process.Start(Path); };
            cMenu.Items.Add(open);

            cMenu.Items.Add(sp);
            var addToVirtualControl = new MenuItem();
            var addNodeStack = new StackPanel {Orientation = Orientation.Horizontal};
            addNodeStack.Children.Add(new TextBlock {Text = "◰", FontSize = 18, Foreground = Brushes.DarkCyan});
            addNodeStack.Children.Add(new TextBlock
            {
                Text = "Create node.",
                Foreground = Brushes.WhiteSmoke,
                VerticalAlignment = VerticalAlignment.Center
            });
            addToVirtualControl.Header = addNodeStack;
            addToVirtualControl.Click += (s, e) =>
            {
                var node = new ReadFile(Hub.CurrentHost, false);
                node.OutputPorts[0].Data.Value = Path;
                Hub.CurrentHost.AddNode(node, Hub.CurrentHost.ActualWidth / 2 - node.ActualWidth / 2,
                    Hub.CurrentHost.ActualHeight / 2);
            };
            cMenu.Items.Add(addToVirtualControl);
            cMenu.Items.Add(sp1);
            var cut = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Cut"
                }
            };
            var copy = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Copy"
                }
            };


            var rename = new MenuItem
            {
                Header = new TextBlock
                {
                    Foreground = Brushes.WhiteSmoke,
                    Text = "Rename"
                }
            };
            var deleteTextBlock = new TextBlock();
            deleteTextBlock.Inlines.Add(new TextBlock {Text = "X", Foreground = Brushes.Red});
            deleteTextBlock.Inlines.Add(new TextBlock
            {
                Text = $" Delete {ItemCategory}",
                Foreground = Brushes.WhiteSmoke
            });
            var delete = new MenuItem
            {
                Header = deleteTextBlock
            };
            delete.Click += (s, e) =>
            {
                var res = MessageBox.Show($"Do you really want to delete this {ItemCategory}?", "Delete",
                    MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (res == MessageBoxResult.No) return;
                try
                {
                    if (Folder)
                    {
                        Directory.Delete(Path);
                        Task.Factory.StartNew(() =>
                        {
                            Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                            {
                                Parent.Container.GetNode(Parent.Path, Parent.Container.FoldersTree.Items).Items
                                    .Remove(Parent.Container.GetNode(Path, Parent.Container.FoldersTree.Items));
                            }));
                        });
                    }
                    else
                    {
                        File.Delete(Path);
                    }
                    Parent.Items.Remove(this);
                }
                catch (Exception exception)
                {
                    if (!exception.Message.Contains("The directory is not empty."))
                    {
                        MessageBox.Show(exception.Message, $"Could not delete the {ItemCategory}",
                            MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        var answer = MessageBox.Show(exception.Message + "\n" + "Delete everything in this directory?",
                            $"Could not delete the {ItemCategory}",
                            MessageBoxButton.YesNo, MessageBoxImage.Error);
                        if (answer == MessageBoxResult.Yes)
                        {
                            Directory.Delete(Path, true);
                            Parent.Container.GetNode(Parent.Path, Parent.Container.FoldersTree.Items).Items
                                .Remove(Parent.Container.GetNode(Path, Parent.Container.FoldersTree.Items));
                            Parent.Items.Remove(this);
                        }
                    }
                }
            };
            cut.Click += (s, e) => { Parent.Container.PathToCut = Path; };
            copy.Click += (s, e) =>
            {
                Parent.Container.PathToCut = "";
                Parent.Container.PathToCopy = Path;
            };

            rename.Click += (ss, e) => { Rename(); };
            cMenu.Items.Add(cut);
            cMenu.Items.Add(copy);
            cMenu.Items.Add(rename);
            var sp2 = new Separator();
            cMenu.Items.Add(sp2);
            cMenu.Items.Add(delete);
            return cMenu;
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private void NewItemMenu(MenuItem item)
        {
            var folder_tb = new TextBlock();
            folder_tb.Inlines.Add(new Run("📁")
            {
                Foreground = Brushes.LightGoldenrodYellow,
                FontSize = 16,
                FontFamily = new FontFamily("Vendana")
            });
            folder_tb.Inlines.Add(new Run(" New Folder.") {Foreground = Brushes.White});
            var file_tb = new TextBlock();
            file_tb.Inlines.Add(new Run("🗋")
            {
                Foreground = Brushes.LightGoldenrodYellow,
                FontSize = 16,
                FontFamily = new FontFamily("Vendana")
            });
            file_tb.Inlines.Add(new Run(" New Folder.") {Foreground = Brushes.White});
            var folder = new MenuItem
            {
                Header = folder_tb
            };
            folder.Click += (s, e) =>
            {
                var name = MagicLaboratory.RandomString(6);
                Directory.CreateDirectory(Item.Path + @"\" + name);
                Item.AddFolder(name, "", Item.Path + @"\" + name);
                Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
                    new Action(() => { Item.Items[Item.Items.Count - 1].Rename("New folder..."); }));
            };
            var file = new MenuItem
            {
                Header = file_tb
            };
            item.Items.Add(folder);
            item.Items.Add(file);
        }

19 View Source File : Comment.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu DeleteComment()
        {
            var cm = new ContextMenu();
            var delete = new TextBlock
            {
                Text = "Uncomment",
                Foreground = Brushes.WhiteSmoke
            };
            var uncomment = new MenuItem {Header = delete};
            uncomment.Click += (s, e) => { Dispose(); };
            cm.Items.Add(uncomment);
            return cm;
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private void ListDirectory(TreeView treeView, string path)
        {
            treeView.Items.Clear();
            var rootDirectoryInfo = new DirectoryInfo(path);
            treeView.Items.Add(CreateDirectoryNode(rootDirectoryInfo));
        }

19 View Source File : ContentsBrowser.cs
License : MIT License
Project Creator : alaabenfatma

private TreeViewItem CreateDirectoryNode(DirectoryInfo directoryInfo)
        {
            var directoryNode = new TreeViewItem {Header = new FolderItem(directoryInfo.FullName, directoryInfo.Name)};
            Task.Factory.StartNew(() =>
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    try
                    {
                        foreach (var directory in directoryInfo.GetDirectories())
                            Task.Factory.StartNew(() =>
                            {
                                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(
                                    () => { directoryNode.Items.Add(CreateDirectoryNode(directory)); }));
                            });
                    }
                    catch
                    {
                    }
                }));
            });
            return directoryNode;
        }

19 View Source File : Search.cs
License : MIT License
Project Creator : alaabenfatma

private void Go_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            lv.Items.Clear();
            foreach (var node in _host.Nodes)
                if (node.Search(tb.Text) != null)
                {
                    var tv = new TreeView {Background = new SolidColorBrush(Color.FromArgb(35, 35, 35, 35))};
                    tv.Items.Add(node.Search(tb.Text));
                    lv.Items.Add(tv);
                }
        }

19 View Source File : Connectors.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu wireMenu()
        {
            var cm = new ContextMenu();
            var divide = new MenuItem {Header = "Divide", Foreground = Brushes.WhiteSmoke};
            divide.Click += (s, e) =>
            {
                if (StartPort.ParentNode.Types != NodeTypes.SpaghettiDivider &&
                    EndPort.ParentNode.Types != NodeTypes.SpaghettiDivider)
                    Task.Factory.StartNew(() =>
                    {
                        Wire.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle,
                            new Action(() =>
                            {
                                var divider = new SpaghettiDivider(Host, this, false);
                                Host.AddNode(divider, Mouse.GetPosition(Host).X, Mouse.GetPosition(Host).Y);
                                e.Handled = true;
                            }));
                    });
                e.Handled = true;
            };
            var delete = new MenuItem {Header = "Delete", Foreground = Brushes.WhiteSmoke};
            delete.Click += (s, e) => Delete();
            cm.Items.Add(divide);
            cm.Items.Add(delete);
            return cm;
        }

19 View Source File : Connectors.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu wireMenu()
        {
            var cm = new ContextMenu();

            var delete = new MenuItem {Header = "Delete", Foreground = Brushes.WhiteSmoke};
            delete.Click += (s, e) => Delete();
            cm.Items.Add(delete);
            return cm;
        }

19 View Source File : VirtualControl.cs
License : MIT License
Project Creator : alaabenfatma

private ContextMenu VirtualContextMenu()
        {
            var cm = new ContextMenu();
            var add = new TextBlock {Text = "Add Node", Foreground = Brushes.WhiteSmoke};
            var addNode = new MenuItem {Header = add};
            addNode.Click += (s, e) => { NodesTree.Show(); };
            var delete = new TextBlock {Text = "Delete Selected", Foreground = Brushes.WhiteSmoke};
            var deleteNodes = new MenuItem {Header = delete};
            deleteNodes.Click += (s, e) => { DeleteSelected(); };
            var cut = new TextBlock {Text = "Cut Selected", Foreground = Brushes.WhiteSmoke};
            var cutNodes = new MenuItem {Header = cut};
            cutNodes.Click += (s, e) =>
            {
                Copy();
                DeleteSelected();
            };
            var copy = new TextBlock {Text = "Copy Selected", Foreground = Brushes.WhiteSmoke};
            var copyNodes = new MenuItem {Header = copy};
            copyNodes.Click += (s, e) => { Copy(); };
            var paste = new TextBlock {Text = "Paste Selected", Foreground = Brushes.WhiteSmoke};
            var pasteNodes = new MenuItem {Header = paste};
            pasteNodes.Click += (s, e) => { Paste(); };
            var comment = new TextBlock {Text = "Comment Selected", Foreground = Brushes.WhiteSmoke};
            var commentNodes = new MenuItem {Header = comment};
            commentNodes.Click += (s, e) =>
            {
                if (SelectedNodes.Count > 0)
                {
                    var comm = new Comment(SelectedNodes, this);
                }
            };
            cm.Items.Add(addNode);
            cm.Items.Add(deleteNodes);
            cm.Items.Add(new Separator {Foreground = Brushes.White});
            cm.Items.Add(cutNodes);
            cm.Items.Add(copyNodes);
            cm.Items.Add(pasteNodes);
            cm.Items.Add(new Separator {Foreground = Brushes.White});
            cm.Items.Add(commentNodes);
            return cm;
        }

19 View Source File : Search.cs
License : MIT License
Project Creator : alaabenfatma

private void Go_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            lv.Items.Clear();
            foreach (var node in _host.Nodes)
                if (node.Search(tb.Text) != null)
                {
                    var tv = new TreeView {Background = new SolidColorBrush(Color.FromArgb(35, 35, 35, 35))};
                    tv.Items.Add(node.Search(tb.Text));
                    lv.Items.Add(tv);
                }
        }

19 View Source File : OsTraderMaster.cs
License : Apache License 2.0
Project Creator : AlexWan

private void Load()
        {
            if (!File.Exists(@"Engine\Settings" + _typeWorkKeeper + "Keeper.txt"))
            { // if there is no file we need. Just go out
              // если нет нужного нам файла. Просто выходим
                return;
            }


            int botCount = 0;
            using (StreamReader reader = new StreamReader(@"Engine\Settings" + _typeWorkKeeper + "Keeper.txt"))
            {
                while (!reader.EndOfStream)
                {
                    if (!string.IsNullOrWhiteSpace(reader.ReadLine()))
                    {
                        botCount++;
                    }
                }
            }

            if (botCount == 0)
            {
                return;
            }

            PanelsArray = new List<BotPanel>();

            int boreplacederator = 0;
            using (StreamReader reader = new StreamReader(@"Engine\Settings" + _typeWorkKeeper + "Keeper.txt"))
            {
                while (!reader.EndOfStream)
                {
                    string[] names = reader.ReadLine().Split('@');

                    BotPanel bot = null;

                    if (names.Length > 2)
                    {
                        try
                        {
                            bot = BotFactory.GetStrategyForName(names[1], names[0], _startProgram, Convert.ToBoolean(names[2]));
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(" Error on bot creation. Bot Name: " + names[1] + " \n" + e.ToString());
                            continue;
                        }
                    }
                    else
                    {
                        bot = BotFactory.GetStrategyForName(names[1], names[0], _startProgram, false);
                    }

                    if (bot != null)
                    {
                        PanelsArray.Add(bot);
                        _tabBotNames.Items.Add(" " + PanelsArray[boreplacederator].NameStrategyUniq + " ");
                        SendNewLogMessage(OsLocalization.Trader.Label2 + PanelsArray[boreplacederator].NameStrategyUniq,
                            LogMessageType.System);
                        boreplacederator++;
                    }

                }
            }
            if (PanelsArray.Count != 0)
            {
                ReloadActivBot(PanelsArray[0]);
            }
        }

19 View Source File : OsTraderMaster.cs
License : Apache License 2.0
Project Creator : AlexWan

public void DeleteActiv()
        {
            try
            {
                if (PanelsArray == null ||
               _activPanel == null)
                {
                    return;
                }

                AcceptDialogUi ui = new AcceptDialogUi(OsLocalization.Trader.Label4);
                ui.ShowDialog();

                if (ui.UserAcceptActioin == false)
                {
                    return;
                }

                _activPanel.StopPaint();

                _activPanel.Delete();

                SendNewLogMessage(OsLocalization.Trader.Label5 + _activPanel.NameStrategyUniq, LogMessageType.System);

                PanelsArray.Remove(_activPanel);

                _activPanel = null;

                Save();

                _tabBotNames.Items.Clear();

                if (PanelsArray != null && PanelsArray.Count != 0)
                {
                    for (int i = 0; i < PanelsArray.Count; i++)
                    {
                        _tabBotNames.Items.Add(" " + PanelsArray[i].NameStrategyUniq + " ");
                    }

                    ReloadActivBot(PanelsArray[0]);
                }

                ReloadRiskJournals();
            }
            catch (Exception error)
            {
                SendNewLogMessage(error.ToString(), LogMessageType.Error);
            }
        }

19 View Source File : OsTraderMaster.cs
License : Apache License 2.0
Project Creator : AlexWan

private void ReloadActivBot(BotPanel newActivBot)
        {
            try
            {
                if (_activPanel != null)
                {
                    _activPanel.StopPaint();
                }

                _activPanel = newActivBot;

                _activPanel.StartPaint(_gridChart, _hostChart, _hostGlreplaced, _hostOpenDeals, _hostCloseDeals, _hostboxLog,
                    _rectangleAroundChart, _hostAlerts, _tabBotTab, _textBoxLimitPrice, _gridChartControlPanel);

                _tabBotNames.SelectionChanged -= _tabBotControl_SelectionChanged;

                _tabBotNames.SelectedItem = " " + _activPanel.NameStrategyUniq + " ";

                if (_tabBotNames.SelectedItem == null || _tabBotNames.SelectedItem.ToString() != " " + _activPanel.NameStrategyUniq + " ")
                {
                    _tabBotNames.Items.Add(" " + _activPanel.NameStrategyUniq + " ");
                    _tabBotNames.SelectedItem = " " + _activPanel.NameStrategyUniq + " ";
                }

                _tabBotNames.SelectionChanged += _tabBotControl_SelectionChanged;
            }
            catch (Exception error)
            {
                SendNewLogMessage(error.ToString(), LogMessageType.Error);
            }
        }

19 View Source File : BarChartNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(BarChartNodeModel model, NodeView nodeView)
        {
            barChartControl = new BarChartControl(model);
            nodeView.inputGrid.Children.Add(barChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : HeatSeriesNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(HeatSeriesNodeModel model, NodeView nodeView)
        {
            heatSeriesControl = new HeatSeriesControl(model);
            nodeView.inputGrid.Children.Add(heatSeriesControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : XYLineChartNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(XYLineChartNodeModel model, NodeView nodeView)
        {
            xyLineChartControl = new XYLineChartControl(model);
            nodeView.inputGrid.Children.Add(xyLineChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : BasicLineChartNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(BasicLineChartNodeModel model, NodeView nodeView)
        {
            basicLineChartControl = new BasicLineChartControl(model);
            nodeView.inputGrid.Children.Add(basicLineChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : PieChartNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(PieChartNodeModel model, NodeView nodeView)
        {
            pieChartControl = new PieChartControl(model);
            nodeView.inputGrid.Children.Add(pieChartControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : ScatterPlotNodeModel.cs
License : MIT License
Project Creator : alfarok

public void CustomizeView(ScatterPlotNodeModel model, NodeView nodeView)
        {
            scatterPlotControl = new ScatterPlotControl(model);
            nodeView.inputGrid.Children.Add(scatterPlotControl);

            MenuItem exportImage = new MenuItem();
            exportImage.Header = "Export Chart as Image";
            exportImage.Click += ExportImage_Click;

            var contextMenu = (nodeView.Content as Grid).ContextMenu;
            contextMenu.Items.Add(exportImage);
        }

19 View Source File : DiagnosticViewExtension.cs
License : MIT License
Project Creator : alvpickmans

public void InitializeMenu(bool canRunExtension)
        {
            this.mainMenu = new MenuItem() { Header = NAME };

            if (!canRunExtension)
            {
                this.mainMenu.Click += (sender, arg) =>
                {
                    MessageBox.Show(
                        $"Diagnostic Toolkit cannot be used on your current Dynamo Version {this.currentVersion}.\nMinimum version required is {MINIMUM_VERSION}",
                        this.Name);
                };
                return;
            }

            var launchToolkit = new MenuItem() { Header = "Launch" };

            launchToolkit.Click += this.OpenDiagnosticWindow;

            var enableCheckbox = new CheckBox() {
                Content = "Profiling Enabled",
                IsChecked = this.manager.IsEnabled
            };
            enableCheckbox.Click += (sender, arg) =>
            {
                if (sender is CheckBox check && check.IsChecked.Value)
                    this.manager.EnableProfiling();
                else
                    this.manager.DisableProfiling();
            };

            this.mainMenu.Items.Add(launchToolkit);
            this.mainMenu.Items.Add(enableCheckbox);
            this.loadedParameters.dynamoMenu.Items.Add(this.mainMenu);
        }

19 View Source File : ContextMenu.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private void BindViewModelRecurcive(Control parent, Layouting.IMenuControl childViewModel)
        {
            ItemsControl itemsControl = parent as ItemsControl;
            if (itemsControl == null)
            {
                return;
            }
            Control control = MenuControlConverter.Convert(childViewModel);
            itemsControl.Items.Add(control);
            Layouting.IMenuControlCollection viewModelCollection = childViewModel as Layouting.IMenuControlCollection;
            if (viewModelCollection == null)
            {
                return;
            }
            foreach (Layouting.IMenuControl viewModel in viewModelCollection)
            {
                BindViewModelRecurcive(control, viewModel);
            }
        }

19 View Source File : Menu.cs
License : GNU General Public License v3.0
Project Creator : AndreiFedarets

private void BindViewModelRecurcive(Control parent, IMenuControl childViewModel)
        {
            ItemsControl itemsControl = parent as ItemsControl;
            if (itemsControl == null)
            {
                return;
            }
            Control control = MenuControlConverter.Convert(childViewModel);
            itemsControl.Items.Add(control);
            IMenuControlCollection viewModelCollection = childViewModel as IMenuControlCollection;
            if (viewModelCollection == null)
            {
                return;
            }
            foreach (IMenuControl viewModel in viewModelCollection)
            {
                BindViewModelRecurcive(control, viewModel);
            }
        }

19 View Source File : Monito.cs
License : MIT License
Project Creator : andydandy74

public void Loaded(ViewLoadedParams p)
        {
            var monitoMenuItem = new MenuItem { Header = "DynaMonito" };
            var VM = p.DynamoWindow.DataContext as DynamoViewModel;
			MenuItem subMenuItem;

            #region FIND_UNGROUPED
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableFindUngrouped"))
            {
				subMenuItem = new MenuItem { Header = "Find and Fix Ungrouped" };
				subMenuItem.ToolTip = new ToolTip { Content = "Identify nodes and notes that don't belong to a group.." };
				subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new FindUngroupedViewModel(p, VM);
                    var window = new FindUngroupedWindow
                    {
                        findUngroupedPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion FIND_UNGROUPED

            #region ISOLATE_IN_GEOMETRY_PREVIEW
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableIsolateInGeometryPreview"))
            {
				subMenuItem = new MenuItem { Header = "Isolate in Geometry Preview" };
				subMenuItem.ToolTip = new ToolTip { Content = "Quickly isolate the current selection in geometry preview..." };
				subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new IsolateInPreviewViewModel(p, VM, p.DynamoWindow);
                    var window = new IsolateInPreviewWindow
                    {
                        isolatePreviewPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion ISOLATE_IN_GEOMETRY_PREVIEW

            #region PLAYER_INPUTS
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePlayerInputs"))
            {
				subMenuItem = new MenuItem { Header = "Manage Dynamo Player Inputs" };
				subMenuItem.ToolTip = new ToolTip { Content = "Manage which input nodes should be displayed by Dynamo Player..." };
				subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new PlayerInputsViewModel(p, VM);
                    var window = new PlayerInputsWindow
                    {
                        playerInputsPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion PLAYER INPUTS

            #region MY_GRAPHS
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyGraphs"))
            {
                // Read list of graph directories from config
                var topDirs = monitoSettings["MyGraphsDirectoryPaths"].Value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (topDirs.Length > 0)
                {
					subMenuItem = new MenuItem { Header = "My Graphs" };
					subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your graphs..." };
                    if (topDirs.Length == 1)
                    {
						subMenuItem = BuildMyGraphsMenu(topDirs[0], subMenuItem, VM);
                    }
                    else
                    {
                        foreach(string topDir in topDirs)
                        {
                            string topDirName = Path.GetFileName(topDir);
                            MenuItem topDirMenuItem = new MenuItem { Header = topDirName };
                            topDirMenuItem.ToolTip = new ToolTip { Content = topDir };
                            topDirMenuItem = BuildMyGraphsMenu(topDir, topDirMenuItem, VM);
							subMenuItem.Items.Add(topDirMenuItem);
                        }
                    }
                    if (subMenuItem != null) { monitoMenuItem.Items.Add(subMenuItem); }
                }
                    
            }
            #endregion MY_GRAPHS

            #region MY_TEMPLATES
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableMyTemplates"))
            {
                var tplDir = monitoSettings["MyTemplatesDirectoryPath"].Value;
                if (Directory.Exists(tplDir))
                {
                    // Create a menu item for each template
                    List<MenuItem> tempMenuItems = new List<MenuItem>();
                    var templates = Directory.GetFiles(tplDir, "*.dyn");
                    foreach (string t in templates)
                    {
                        string tplName = Path.GetFileNameWithoutExtension(t);
                        MenuItem tplMenu = new MenuItem { Header = tplName };
                        tplMenu.ToolTip = new ToolTip { Content = t };
                        tplMenu.Click += (sender, args) =>
                        {
                            if (File.Exists(t))
                            {
                                // Close current home workspace, open template and set to manual mode
                                VM.CloseHomeWorkspaceCommand.Execute(null);
                                VM.OpenCommand.Execute(t);
                                VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
                                // Select all nodes and notes as well as annotations and copy everything
                                VM.SelectAllCommand.Execute(null);
                                foreach (var anno in VM.HomeSpaceViewModel.Model.Annotations) { VM.AddToSelectionCommand.Execute(anno); }
                                VM.CopyCommand.Execute(null);
                                // Create new home workspace, set to manual mode and paste template content
                                VM.NewHomeWorkspaceCommand.Execute(null);
                                VM.CurrentSpaceViewModel.RunSettingsViewModel.Model.RunType = RunType.Manual;
                                VM.Model.Paste();
								GeneralUtils.ClearSelection();
								VM.CurrentSpaceViewModel.ResetFitViewToggleCommand.Execute(null);
								VM.FitViewCommand.Execute(null);
							}
                            else { MessageBox.Show("Template " + tplName + " has been moved, renamed or deleted..."); }
                        };
                        tempMenuItems.Add(tplMenu);
                    }
                    // Only show the templates menu item if templates exist
                    if (tempMenuItems.Count > 0)
                    {
						subMenuItem = new MenuItem { Header = "New Workspace from Template" };
						subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your templates..." };
                        foreach (MenuItem tempMenuItem in tempMenuItems) { subMenuItem.Items.Add(tempMenuItem); }
                        monitoMenuItem.Items.Add(subMenuItem);
                    }
                }
            }
            #endregion MY_TEMPLATES

            #region PACKAGE_DIRECTORIES
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnablePackageDirectories"))
            {
				subMenuItem = new MenuItem { Header = "Package Directories" };
				subMenuItem.ToolTip = new ToolTip { Content = "Quick access to all your package directories..." };
                foreach (string packageDir in startupParams.Preferences.CustomPackageFolders)
                {
                    if (Directory.Exists(packageDir))
                    {
                        MenuItem monitoPackageDirMenuItem = new MenuItem { Header = packageDir };
                        monitoPackageDirMenuItem.ToolTip = new ToolTip { Content = "Show contents of " + packageDir + " ..." };
                        monitoPackageDirMenuItem.Click += (sender, args) =>
                        {
                            if (Directory.Exists(packageDir)) { Process.Start(@"" + packageDir); }
                            else { MessageBox.Show("Directory " + packageDir + " has been moved, renamed or deleted..."); }
                        };
						subMenuItem.Items.Add(monitoPackageDirMenuItem);
                    }
                }
                monitoMenuItem.Items.Add(subMenuItem);
            }          
            #endregion PACKAGE_DIRECTORIES

            #region SEARCH_IN_WORKSPACE
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableSearchInWorkspace"))
            {
				subMenuItem = new MenuItem { Header = "Search in Workspace" };
				subMenuItem.ToolTip = new ToolTip { Content = "Search for nodes, notes and groups in the current workspace..." };
				subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new SearchInWorkspaceViewModel(p, VM, monitoSettings);
                    var window = new SearchInWorkspaceWindow
                    {
                        searchPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
            #endregion SEARCH_IN_WORKSPACE

            #region UNFANCIFY
            if (monitoSettingsLoaded && monitoSettings.GetLoadedSettingAsBoolean("EnableUnfancify"))
            {
				subMenuItem = new MenuItem { Header = "Unfancify" };
				subMenuItem.ToolTip = new ToolTip { Content = "Simplify your graph..." };
				subMenuItem.Click += (sender, args) =>
                {
                    var viewModel = new UnfancifyViewModel(p, VM, monitoSettings, p.DynamoWindow);
                    var window = new UnfancifyWindow
                    {
                        unfancifyPanel = { DataContext = viewModel },
                        Owner = p.DynamoWindow
                    };
                    window.Left = window.Owner.Left + 400;
                    window.Top = window.Owner.Top + 200;
                    window.Show();
                };
                monitoMenuItem.Items.Add(subMenuItem);
            }
			#endregion UNFANCIFY

			#region ABOUT
			subMenuItem = new MenuItem { Header = "About DynaMonito" };
			subMenuItem.Click += (sender, args) =>
            {
                var window = new AboutWindow
                {
                    aboutPanel = { DataContext = this },
                    Owner = p.DynamoWindow
                };
                window.Left = window.Owner.Left + 400;
                window.Top = window.Owner.Top + 200;
                window.Show();
            };
            if (monitoMenuItem.Items.Count > 0) { monitoMenuItem.Items.Add(new Separator()); }
            monitoMenuItem.Items.Add(subMenuItem);
            #endregion ABOUT

            p.dynamoMenu.Items.Add(monitoMenuItem);
        }

19 View Source File : Monito.cs
License : MIT License
Project Creator : andydandy74

public MenuItem BuildMyGraphsMenu(string dir, MenuItem menuItem, DynamoViewModel vm)
        {
            if (!Directory.Exists(dir)) { return null; }
            List<MenuItem> tempMenuItems = new List<MenuItem>();
            foreach (string d in Directory.GetDirectories(dir))
            {
                string dirName = Path.GetFileName(d);
                if (dirName != "backup")
                {
                    MenuItem dirMenu = new MenuItem { Header = dirName };
                    dirMenu.ToolTip = new ToolTip { Content = d };
                    dirMenu = BuildMyGraphsMenu(d, dirMenu, vm);
                    if (dirMenu != null) { tempMenuItems.Add(dirMenu); }
                }
            }
            var files = Directory.GetFiles(dir, "*.dyn");
            foreach (string f in files)
            {
                string graphName = Path.GetFileNameWithoutExtension(f);
                MenuItem graphMenu = new MenuItem { Header = graphName };
                graphMenu.ToolTip = new ToolTip { Content = f };
                graphMenu.Click += (sender, args) =>
                {
                    if (File.Exists(f))
                    {
                        vm.CloseHomeWorkspaceCommand.Execute(null);
                        vm.OpenCommand.Execute(f);
                    }
                    else { MessageBox.Show("Graph " + graphName + " has been moved, renamed or deleted..."); }
                };
                tempMenuItems.Add(graphMenu);
            }
            if (tempMenuItems.Count > 0)
            {
                foreach (MenuItem tempMenuItem in tempMenuItems) { menuItem.Items.Add(tempMenuItem); }
                return menuItem;
            }
            else { return null; }
        }

19 View Source File : TriggersView.xaml.cs
License : BSD 3-Clause "New" or "Revised" License
Project Creator : anoyetta

private void ContextMenu_Loaded(
            object sender,
            RoutedEventArgs e)
        {
            const string TagMenuItemName = "TagMenu";
            const string PanelMenuItemName = "PanelMenu";

            var context = sender as ContextMenu;
            var data = context?.DataContext as ITreeItem;

            var tagMenuItem = default(MenuItem);
            var panelMenuItem = default(MenuItem);

            foreach (var item in context.Items)
            {
                if (item is MenuItem menuItem)
                {
                    if (menuItem.Name == TagMenuItemName)
                    {
                        tagMenuItem = menuItem;
                    }

                    if (menuItem.Name == PanelMenuItemName)
                    {
                        panelMenuItem = menuItem;
                    }
                }
            }

            if (tagMenuItem == null &&
                panelMenuItem == null)
            {
                return;
            }

            if (tagMenuItem != null)
            {
                tagMenuItem.Items.Clear();

                var tags =
                    from x in TagTable.Instance.Tags
                    orderby
                    x.SortPriority ascending,
                    x.Name
                    select
                    x;

                foreach (var tag in tags)
                {
                    var menuItem = new MenuItem()
                    {
                        Header = tag.Name
                    };

                    menuItem.Click += (x, y) =>
                    {
                        if (!TagTable.Instance.ItemTags.Any(z =>
                            z.ItemID == data.GetID() &&
                            z.TagID == tag.GetID()))
                        {
                            TagTable.Instance.ItemTags.Add(new ItemTags(
                                data.GetID(),
                                tag.GetID()));
                        }
                    };

                    tagMenuItem.Items.Add(menuItem);
                }
            }

            if (panelMenuItem != null)
            {
                panelMenuItem.Items.Clear();

                var panels =
                    from x in SpellPanelTable.Instance.Table
                    orderby
                    x.SortPriority ascending,
                    x.PanelName
                    select
                    x;

                foreach (var panel in panels)
                {
                    var menuItem = new MenuItem()
                    {
                        Header = panel.PanelName
                    };

                    menuItem.Click += (x, y) =>
                    {
                        if (data is Spell spell)
                        {
                            var oldPanel = spell.Panel;
                            spell.PanelID = panel.ID;

                            oldPanel.SetupChildrenSource();
                            panel.SetupChildrenSource();
                        }
                    };

                    panelMenuItem.Items.Add(menuItem);
                }
            }
        }

19 View Source File : AddDynamicThemeTask.xaml.cs
License : MIT License
Project Creator : Apollo199999999

public void AddAction(string time, string mode, string theme)
        {
            //create a Grid
            Grid ActionItem = new Grid();
            ActionItem.Height = 150;
            ActionItem.Width = 560;

            //create a label that says "Dynamic Theme Event"
            Label label1 = new Label();
            label1.Content = "Dynamic Theme Event:";
            label1.FontWeight = FontWeights.Bold;
            label1.HorizontalAlignment = HorizontalAlignment.Left;
            label1.VerticalAlignment = VerticalAlignment.Top;

            //create a label that says "Trigger this event at:"
            Label label2 = new Label();
            label2.Content = "Trigger this event at:";
            label2.HorizontalAlignment = HorizontalAlignment.Left;
            label2.VerticalAlignment = VerticalAlignment.Top;
            label2.Margin = new Thickness(0, 31, 0, 0);

            //create a TimePicker and set the initial time
            TimePicker TriggerTimePicker = new TimePicker();
            TriggerTimePicker.Margin = new Thickness(140, 25, 0, 0);
            TriggerTimePicker.HorizontalAlignment = HorizontalAlignment.Left;
            TriggerTimePicker.VerticalAlignment = VerticalAlignment.Top;
            TriggerTimePicker.SetTimereplacedtring(time);

            //create a label that says "When this event is triggered:"
            Label label3 = new Label();
            label3.Content = "When this event is triggered:";
            label3.HorizontalAlignment = HorizontalAlignment.Left;
            label3.VerticalAlignment = VerticalAlignment.Top;
            label3.Margin = new Thickness(0, 70, 0, 0);
            label3.FontWeight = FontWeights.Bold;

            //create a label that says "Change the"
            Label label4 = new Label();
            label4.Content = "Change the";
            label4.HorizontalAlignment = HorizontalAlignment.Left;
            label4.VerticalAlignment = VerticalAlignment.Top;
            label4.Margin = new Thickness(0, 111, 0, 0);

            //create a combobox for picking the system or app theme
            ComboBox SystemOrAppThemePicker = new ComboBox();
            SystemOrAppThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            SystemOrAppThemePicker.Margin = new Thickness(86, 105, 0, 0);
            SystemOrAppThemePicker.VerticalAlignment = VerticalAlignment.Top;
            SystemOrAppThemePicker.Width = 203;
            SystemOrAppThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem SystemThemeItem = new ComboBoxItem();
            ComboBoxItem AppsThemeItem = new ComboBoxItem();
            SystemThemeItem.Content = "Default Windows mode";
            AppsThemeItem.Content = "Default app mode";

            SystemOrAppThemePicker.Items.Add(SystemThemeItem);
            SystemOrAppThemePicker.Items.Add(AppsThemeItem);

            //set the default selected item
            if (mode == "windows")
            {
                SystemOrAppThemePicker.SelectedItem = SystemThemeItem;
            }
            else if (mode == "apps")
            {
                SystemOrAppThemePicker.SelectedItem = AppsThemeItem;
            }

            //create a label that says "to"
            Label label5 = new Label();
            label5.Content = "to";
            label5.HorizontalAlignment = HorizontalAlignment.Left;
            label5.VerticalAlignment = VerticalAlignment.Top;
            label5.Margin = new Thickness(302, 111, 0, 0);

            //create a combobox for picking light theme or dark theme
            ComboBox LightDarkThemePicker = new ComboBox();
            LightDarkThemePicker.HorizontalAlignment = HorizontalAlignment.Left;
            LightDarkThemePicker.Margin = new Thickness(338, 105, 0, 0);
            LightDarkThemePicker.VerticalAlignment = VerticalAlignment.Top;
            LightDarkThemePicker.Width = 136;
            LightDarkThemePicker.Height = 32;

            //add items to the combo box
            ComboBoxItem LightThemeItem = new ComboBoxItem();
            ComboBoxItem DarkThemeItem = new ComboBoxItem();
            LightThemeItem.Content = "Light Theme";
            DarkThemeItem.Content = "Dark Theme";

            LightDarkThemePicker.Items.Add(LightThemeItem);
            LightDarkThemePicker.Items.Add(DarkThemeItem);

            //set the default selected item
            if (theme == "light")
            {
                LightDarkThemePicker.SelectedItem = LightThemeItem;
            }
            else if (theme == "dark")
            {
                LightDarkThemePicker.SelectedItem = DarkThemeItem;
            }


            //add everything to the grid
            ActionItem.Children.Add(label1);
            ActionItem.Children.Add(label2);
            ActionItem.Children.Add(TriggerTimePicker);
            ActionItem.Children.Add(label3);
            ActionItem.Children.Add(label4);
            ActionItem.Children.Add(SystemOrAppThemePicker);
            ActionItem.Children.Add(label5);
            ActionItem.Children.Add(LightDarkThemePicker);

            //add the grid to the actionlistbox
            ActionsListBox.Items.Add(ActionItem);

            //make the action item the selected item and scroll to the selected item
            ActionsListBox.SelectedItem = ActionItem;
            ActionsListBox.ScrollIntoView(ActionsListBox.SelectedItem);
        }

19 View Source File : SettingsWindow.xaml.cs
License : MIT License
Project Creator : Apollo199999999

public void UpdateTaskListBox(ListBox listBox, int DynamicThemeOrDynamicDesktop)
        {
            //clear listbox items EXCEPT the first one
            var listBoxFirsreplacedem = listBox.Items[0];
            listBox.Items.Clear();
            listBox.Items.Add(listBoxFirsreplacedem);

            //string to store directory where all the tasks are located
            string TaskDirectories;

            //check where the tasks are stored
            if (DynamicThemeOrDynamicDesktop == 0)
            {
                TaskDirectories = DataDynamicThemeRootDir;
            }
            else
            {
                TaskDirectories = DataDynamicWallpaperRootDir;
            }

            //iterate through directories in TaskDirectory, getting the name of the tasks
            foreach (string TaskDirectory in Directory.GetDirectories(TaskDirectories))
            {
                //create a grid, populate it with controls, and add it to the listbox
                Grid TaskGrid = new Grid();
                //I have no idea why you need to minus 30, i do this so that the button fits ok
                TaskGrid.Width = listBox.Width - 30;
                TaskGrid.Height = 30;

                //Create an Image control and display the dynamicthemetaskicon or dynamicwallpapertaskicon
                System.Windows.Controls.Image icon = new System.Windows.Controls.Image();

                //display the correct icon
                if (DynamicThemeOrDynamicDesktop == 0)
                {
                    //display the dynamic theme icon
                    icon.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/DynamicThemeTaskIcon.png"));
                }
                else
                {
                    //display the dynamicwallpapericon
                    icon.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/DynamicWallpaperTaskIcon.png"));
                }

                icon.Height = 23;
                icon.Width = 23;
                icon.HorizontalAlignment = HorizontalAlignment.Left;

                //create a Label
                Label label1 = new Label();
                label1.Content = new DirectoryInfo(TaskDirectory).Name;
                label1.HorizontalAlignment = HorizontalAlignment.Left;
                label1.VerticalAlignment = VerticalAlignment.Center;
                label1.FontSize = 14;
                label1.FontWeight = FontWeights.Bold;
                label1.Margin = new Thickness(30, 0, 0, 0);
                label1.HorizontalContentAlignment = HorizontalAlignment.Center;

                //create a tooltip for the more button
                ToolTip toolTip = new ToolTip();
                toolTip.Content = "More";

                //create a more button
                Button MoreBtn = new Button();

                //set the tooltip service
                MoreBtn.ToolTip = toolTip;
                
                MoreBtn.Content = "\xE712";
                MoreBtn.HorizontalAlignment = HorizontalAlignment.Right;
                MoreBtn.VerticalAlignment = VerticalAlignment.Center;
                MoreBtn.FontFamily = new System.Windows.Media.FontFamily("Segoe MDL2 replacedets");
                MoreBtn.FontSize = 18;
                MoreBtn.FontWeight = FontWeights.Bold;
                MoreBtn.Background = System.Windows.Media.Brushes.Transparent;

                //store the filepath in the button tag
                MoreBtn.Tag = TaskDirectory;
                MoreBtn.Click += MoreBtn_Click;
               
                TaskGrid.Children.Add(icon);
                TaskGrid.Children.Add(label1);
                TaskGrid.Children.Add(MoreBtn);

                //add the item to the listbox and unselect all items
                listBox.Items.Add(TaskGrid);
                listBox.UnselectAll();
            }
        }

19 View Source File : SettingsWindow.xaml.cs
License : MIT License
Project Creator : Apollo199999999

private void MoreBtn_Click(object sender, RoutedEventArgs e)
        {
            //init the sender as button
            var MoreBtn = sender as Button;

            //create a context menu
            ContextMenu MenuFlyout = new ContextMenu();


            //create menu items
            MenuItem RemoveItem = new MenuItem();
            RemoveItem.Header = "Delete this task";

            //create the image that will act as the icon for the context menu icon
            System.Windows.Controls.Image RemoveImage = new System.Windows.Controls.Image();
            RemoveImage.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/TrashIcon.png"));
            
            //set the icon
            RemoveItem.Icon = RemoveImage;

            //Click event handler
            RemoveItem.Click += RemoveItem_Click;


            //second menu item for editing the task
            MenuItem Edireplacedem = new MenuItem();
            Edireplacedem.Header = "Edit this task";

            //create the image that will act as the icon for the context menu icon
            System.Windows.Controls.Image EditImage = new System.Windows.Controls.Image();
            EditImage.Source = new BitmapImage(new Uri("pack://siteoforigin:,,,/Resources/EditIcon.png"));

            //set the icon
            Edireplacedem.Icon = EditImage;

            //click event handler
            Edireplacedem.Click += Edireplacedem_Click;

            //add the items to the context menu
            MenuFlyout.Items.Add(RemoveItem);
            MenuFlyout.Items.Add(Edireplacedem);

            //show the context menu
            MoreBtn.ContextMenu = MenuFlyout;
            MenuFlyout.PlacementTarget = MoreBtn;
            MenuFlyout.IsOpen = true;

        }

19 View Source File : ControlHelper.cs
License : GNU General Public License v3.0
Project Creator : armandoalonso

public void PopulateComboBox(ComboBox cmbBox, params object[] items)
        {
            foreach (var item in items)
            {
                cmbBox.Items.Add(item);
            }
            cmbBox.Items.Refresh();
        }

19 View Source File : MainWindow.xaml.cs
License : MIT License
Project Creator : awaescher

private void lstRepositories_ContextMenuOpening(object sender, ContextMenuEventArgs e)
		{
			var selectedViews = lstRepositories.SelectedItems?.OfType<RepositoryView>();

			if (selectedViews == null || !selectedViews.Any())
			{
				e.Handled = true;
				return;
			}

			var items = ((FrameworkElement)e.Source).ContextMenu.Items;
			items.Clear();

			var innerRepositories = selectedViews.Select(view => view.Repository);
			foreach (var action in _repositoryActionProvider.GetContextMenuActions(innerRepositories))
			{
				if (action.BeginGroup && items.Count > 0)
					items.Add(new Separator());

				items.Add(CreateMenuItem(sender, action, selectedViews));
			}
		}

19 View Source File : AyLangComboBox.cs
License : MIT License
Project Creator : ay2015

public void Update()
        {
            Items.Clear();
            LangDir = System.IO.Path.Combine(ContentManager.Instance.ContentFolder, "Lang");
            //初始化下拉集合
            string[] dirs = Directory.GetDirectories(LangDir);
            foreach (var item in dirs)
            {
                ComboBoxItem cboItem = new ComboBoxItem();

                cboItem.Content = Path.GetFileNameWithoutExtension(item);
                this.Items.Add(cboItem);
            }
        }

19 View Source File : DropDownButton.cs
License : Apache License 2.0
Project Creator : beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this.clickButton = this.EnforceInstance<Button>("PART_Button");
            this.menu = this.EnforceInstance<ContextMenu>("PART_Menu");
            this.InitializeVisualElementsContainer();
            if (this.menu != null && this.Items != null && this.ItemsSource == null)
            {
                foreach (var newItem in this.Items)
                {
                    this.TryRemoveVisualFromOldTree(newItem);
                    this.menu.Items.Add(newItem);
                }
            }
        }

19 View Source File : SplitButton.cs
License : Apache License 2.0
Project Creator : beckzhu

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            this._clickButton = this.EnforceInstance<Button>("PART_Button");
            this._expander = this.EnforceInstance<Button>("PART_Expander");
            this._listBox = this.EnforceInstance<ListBox>("PART_ListBox");
            this._popup = this.EnforceInstance<Popup>("PART_Popup");
            this.InitializeVisualElementsContainer();
            if (this._listBox != null && this.Items != null && this.ItemsSource == null)
            {
                foreach (var newItem in this.Items)
                {
                    this.TryRemoveVisualFromOldTree(newItem);
                    this._listBox.Items.Add(newItem);
                }
            }
        }

19 View Source File : SplitButton.cs
License : Apache License 2.0
Project Creator : beckzhu

protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);
            if (this._listBox == null || this.ItemsSource != null || this._listBox.ItemsSource != null)
            {
                return;
            }
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    if (e.NewItems != null)
                    {
                        foreach (var newItem in e.NewItems)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this._listBox.Items.Add(newItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    if (e.OldItems != null)
                    {
                        foreach (var oldItem in e.OldItems)
                        {
                            this._listBox.Items.Remove(oldItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                case NotifyCollectionChangedAction.Replace:
                    if (e.OldItems != null)
                    {
                        foreach (var oldItem in e.OldItems)
                        {
                            this._listBox.Items.Remove(oldItem);
                        }
                    }
                    if (e.NewItems != null)
                    {
                        foreach (var newItem in e.NewItems)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this._listBox.Items.Add(newItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Reset:
                    if (this.Items != null)
                    {
                        this._listBox.Items.Clear();
                        foreach (var newItem in this.Items)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this._listBox.Items.Add(newItem);
                        }
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }

19 View Source File : TimePickerBase.cs
License : Apache License 2.0
Project Creator : beckzhu

protected virtual void ApplyCulture()
        {
            _deactivateRangeBaseEvent = true;
            if (_ampmSwitcher != null)
            {
                _ampmSwitcher.Items.Clear();
                if (!string.IsNullOrEmpty(SpecificCultureInfo.DateTimeFormat.AMDesignator))
                {
                    _ampmSwitcher.Items.Add(SpecificCultureInfo.DateTimeFormat.AMDesignator);
                }

                if (!string.IsNullOrEmpty(SpecificCultureInfo.DateTimeFormat.PMDesignator))
                {
                    _ampmSwitcher.Items.Add(SpecificCultureInfo.DateTimeFormat.PMDesignator);
                }
            }

            SetAmPmVisibility();

            CoerceValue(SourceHoursProperty);

            if (SelectedTime.HasValue)
            {
                SetHourPartValues(SelectedTime.Value);
            }

            SetDefaultTimeOfDayValues();
            _deactivateRangeBaseEvent = false;

            WriteValueToTextBox();
        }

19 View Source File : DropDownButton.cs
License : Apache License 2.0
Project Creator : beckzhu

protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);
            if (this.menu == null || this.ItemsSource != null || this.menu.ItemsSource != null)
            {
                return;
            }
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    if (e.NewItems != null)
                    {
                        foreach (var newItem in e.NewItems)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this.menu.Items.Add(newItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Remove:
                    if (e.OldItems != null)
                    {
                        foreach (var oldItem in e.OldItems)
                        {
                            this.menu.Items.Remove(oldItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Move:
                case NotifyCollectionChangedAction.Replace:
                    if (e.OldItems != null)
                    {
                        foreach (var oldItem in e.OldItems)
                        {
                            this.menu.Items.Remove(oldItem);
                        }
                    }
                    if (e.NewItems != null)
                    {
                        foreach (var newItem in e.NewItems)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this.menu.Items.Add(newItem);
                        }
                    }
                    break;
                case NotifyCollectionChangedAction.Reset:
                    if (this.Items != null)
                    {
                        this.menu.Items.Clear();
                        foreach (var newItem in this.Items)
                        {
                            this.TryRemoveVisualFromOldTree(newItem);
                            this.menu.Items.Add(newItem);
                        }
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }

19 View Source File : NotificationMessageContainer.cs
License : Apache License 2.0
Project Creator : beckzhu

private void ManagerOnOnMessageQueued(object sender, NotificationMessageManagerEventArgs args)
        {
            if (this.ItemsSource != null)
                throw new InvalidOperationException(
                    "Can't use both ItemsSource and Items collection at the same time.");

            this.Items.Add(args.Message);

            if (args.Message is INotificationAnimation animatableMessage)
            {
                var animation = animatableMessage.AnimationIn;
                if (animatableMessage.Animates && animatableMessage.AnimatableElement != null
                    && animation != null && animatableMessage.AnimationInDependencyProperty != null)
                {
                    animatableMessage.AnimatableElement.BeginAnimation(animatableMessage.AnimationInDependencyProperty, animation);
                }
            }
        }

See More Examples