Beispiel #1
0
        private void UpdateStatus(WirelessNetworkStatus status)
        {
            LoadingIcon.Visibility        = Visibility.Collapsed;
            SignalStrengthIcon.Visibility = Visibility.Visible;
            NetworkStatusIcon.Visibility  = Visibility.Visible;

            switch (status)
            {
            case WirelessNetworkStatus.Connected:
                NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Green);
                break;

            case WirelessNetworkStatus.Connecting:
                LoadingIcon.Visibility        = Visibility.Visible;
                SignalStrengthIcon.Visibility = Visibility.Collapsed;
                NetworkStatusIcon.Visibility  = Visibility.Collapsed;
                UpdateText(text.Get(TextKey.SystemControl_WirelessConnecting));
                break;

            default:
                NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Close, Brushes.Orange);
                SignalStrengthIcon.Child = GetIcon(0);
                UpdateText(text.Get(TextKey.SystemControl_WirelessDisconnected));
                break;
            }
        }
Beispiel #2
0
        public FileViewModel(string filePath)
        {
            FilePath = filePath;
            Title    = FileName;

            IconSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Dashboard, Brushes.Black, 15);//bi;
        }
        public SingleAnimation()
        {
            InitializeComponent();

            Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.Spinner, Brushes.BlueViolet);
            //Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.RotateRight, Brushes.BlueViolet);
        }
Beispiel #4
0
        /// <summary>
        /// Constructor of the <see cref="TaskPanel"/> class
        /// </summary>
        /// <param name="taskInfo">The task informations to be filled in the panel</param>
        public TaskPanel(TaskInfo taskInfo)
        {
            InitializeComponent();
            Info             = taskInfo;
            TextTitle.Text   = Info.Title;
            TextContent.Text = Info.Content;
            IsBlocking       = false;
            CanHover         = true;

            // Status of a Task
            Image img = new Image
            {
                Width  = 10,
                Height = 10
            };

            if (Info.Completed)
            {
                img.Source            = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.White);
                DoneButton.Visibility = Visibility.Hidden;
            }
            else
            {
                img.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Times, Brushes.White);
            }
            Grid.SetColumn(TopInnerGrid, 0);
            img.VerticalAlignment   = VerticalAlignment.Top;
            img.HorizontalAlignment = HorizontalAlignment.Left;
            img.Margin = new Thickness(5, 5, 0, 0);
            TaskGrid.Children.Add(img);
        }
Beispiel #5
0
 private void InitMenuItems()
 {
     MenuItems.Clear();
     MenuItems.Add(new MenuItem
     {
         Name    = "DataSets",
         Icon    = ImageAwesome.CreateImageSource(FontAwesomeIcon.Database, Brushes.WhiteSmoke),
         Content = new ManageDataSet()
     });
     //MenuItems.Add(new MenuItem
     //{
     //    Name = "Data",
     //    Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.FilesOutline, Brushes.WhiteSmoke),
     //    Content = new ManageData()
     //});
     MenuItems.Add(new MenuItem
     {
         Name    = "Services",
         Icon    = ImageAwesome.CreateImageSource(FontAwesomeIcon.Tasks, Brushes.WhiteSmoke),
         Content = new ManageService()
     });
     MenuItems.Add(new MenuItem
     {
         Name    = "Processes",
         Icon    = ImageAwesome.CreateImageSource(FontAwesomeIcon.Spinner, Brushes.WhiteSmoke),
         Content = new ManageProcess()
     });
     MenuItems.Add(new MenuItem
     {
         Name    = "ResourcesMonitor",
         Icon    = ImageAwesome.CreateImageSource(FontAwesomeIcon.AreaChart, Brushes.WhiteSmoke),
         Content = new ResourcesMonitor()
     });
 }
Beispiel #6
0
        public MainWindow()
        {
            InitializeComponent();
            Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.Flag, Brushes.Black);

            Closed += (sender, args) => Application.Current.Shutdown();
        }
Beispiel #7
0
        protected override void OnContextMenuOpening(ContextMenuEventArgs e)
        {
            var parentContentPane = FindDependencyParent.FindParent <DesignerView>(this);
            var dataContext       = parentContentPane?.DataContext;

            if (dataContext != null)
            {
                if (dataContext.GetType().Name == "ServiceTestViewModel" || dataContext.GetType().Name == "MergeWorkflowViewModel")
                {
                    e.Handled = true;
                }
                else
                {
                    base.OnContextMenuOpening(e);

                    if (ViewModel != null && ViewModel.HasLargeView && !ViewModel.ShowSmall && ViewModel.ShowSmall)
                    {
                        var imageSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Expand, Brushes.Black);
                        var icon        = new Image
                        {
                            Source = imageSource,
                            Height = 14,
                            Width  = 14
                        };
                        _showCollapseLargeView.Header = "Show Large View";
                        _showCollapseLargeView.Icon   = icon;
                    }
                }
            }
        }
        public MainWindow(MainWindowVM viewModel, IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;

            InitializeComponent();

            WindowChrome windowChrome = new WindowChrome()
            {
                CaptionHeight         = 55,
                CornerRadius          = new CornerRadius(0),
                GlassFrameThickness   = new Thickness(0),
                NonClientFrameEdges   = NonClientFrameEdges.None,
                ResizeBorderThickness = new Thickness(6),
                UseAeroCaptionButtons = false
            };

            WindowChrome.SetWindowChrome(this, windowChrome);

            // Hold reference to FontAwesome library
            ImageAwesome.CreateImageSource(FontAwesomeIcon.Times, Brushes.Black);

            this.Loaded += (s, e) =>
            {
                HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).AddHook(new HwndSourceHook(WindowProc));

                this.DataContext = viewModel;

                if (viewModel != null)
                {
                    viewModel.Loaded();
                }
            };
        }
Beispiel #9
0
        public FileViewModel()
        {
            IsDirty = true;
            Title   = FileName;

            IconSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Dashboard, Brushes.Black, 15);//bi;
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var str  = value as string;
            var size = 128;

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }

            string tbtext = "";

            if (str != "Windows")
            {
                var words = str.Split(' ');
                if (words.Length > 2)
                {
                    tbtext = string.Format("{0}{1}{2}", words[0][0], words[1][0], words[2][0]);
                }
                else if (words.Length > 1)
                {
                    tbtext = string.Format("{0}{1}", words[0][0], words[1][0]);
                }
                else
                {
                    tbtext = words[0].Length > 2 ? words[0].Substring(0, 3) : words[0].Substring(0, words[0].Length);
                }
            }

            if (_cache.ContainsKey(tbtext))
            {
                return(_cache[tbtext]);
            }
            else
            {
                if (str == "Windows")
                {
                    return(ImageAwesome.CreateImageSource(FaIcons.fa_windows, new SolidColorBrush(Colors.White)));
                }
                else
                {
                    Border b = new Border();
                    b.Width  = size;
                    b.Height = size;
                    TextBlock t = new TextBlock();
                    t.FontWeight = FontWeights.Bold;
                    Viewbox strecher = new Viewbox();
                    strecher.Child = t;
                    b.Child        = strecher;
                    t.Text         = tbtext.ToUpper();
                    var index = Math.Abs(tbtext.ToUpper().GetHashCode()) % _colors.Length;
                    b.Background = new SolidColorBrush(_colors[index]);
                    t.Foreground = new SolidColorBrush(Colors.White);
                    var img = b.Render();
                    _cache.Add(tbtext, img);
                    return(img);
                }
            }
        }
        public MainWindow(MainWindowVM viewModel,
                          IEventAggregator eventAggregator,
                          IDialogService dialogService,
                          IRuntimeDataService runtimeDataService)
        {
            this._eventAggregator    = eventAggregator;
            this._dialogService      = dialogService;
            this._runtimeDataService = runtimeDataService;

            this.InitializeComponent();

            WindowChrome windowChrome = new WindowChrome()
            {
                CaptionHeight         = 55,
                CornerRadius          = new CornerRadius(0),
                GlassFrameThickness   = new Thickness(0),
                NonClientFrameEdges   = NonClientFrameEdges.None,
                ResizeBorderThickness = new Thickness(6),
                UseAeroCaptionButtons = false
            };

            WindowChrome.SetWindowChrome(this, windowChrome);

            // Hold reference to FontAwesome library
            ImageAwesome.CreateImageSource(FontAwesomeIcon.Times, Brushes.Black);

            this.SizeChanged += (s, e) => {
                if (this.WindowState == WindowState.Normal)
                {
                    this.WidthNormal  = this.Width;
                    this.HeightNormal = this.Height;
                }
            };

            this.LocationChanged += (s, e) => {
                if (this.WindowState == WindowState.Normal)
                {
                    this.TopNormal  = this.Top;
                    this.LeftNormal = this.Left;
                }
            };

            this.Loaded += (s, e) => {
                HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).AddHook(new HwndSourceHook(this.WindowProc));

                this.DataContext = viewModel;

                if (viewModel != null)
                {
                    viewModel.Loaded();
                }

                this.LoadWindowState();
            };

            this.Closed += (s, e) => {
                this.SaveWindowState();
            };
        }
Beispiel #12
0
        /**
         * Crea el ícono de FontAwesome para insertar al lado de la noticia
         */
        private Image createNewspaperIcon()
        {
            ImageSource iconSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.NewspaperOutline, Utils.brushFromHTML("#c33d2b"));
            Image       icon       = new Image();

            icon.Source = iconSource;
            icon.Height = 10;
            icon.Margin = new Thickness(0, 10, 0, 0);
            return(icon);
        }
        public FileStatsViewModel()
            : base("Tool View - Bottom")
        {
            Workspace.This.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
            ContentId = ToolContentId;


            //part of issue no. 60(icon) -edited by reeden
            IconSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Warning, Brushes.Black, 15);//bi;
        }
        public static Image getAwesomeIcon(FontAwesomeIcon fIcon, System.Windows.Media.Brush color)
        {
            Image icon = new Image();

            icon.Source = ImageAwesome.CreateImageSource(fIcon, color);
            icon.Height = 16;
            icon.Width  = 16;

            return(icon);
        }
 static SourceControlIcons()
 {
     Normal      = ImageAwesome.CreateImageSource(FontAwesomeIcon.Lock, Brushes.SteelBlue);
     Changed     = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Red);
     Ignored     = ImageAwesome.CreateImageSource(FontAwesomeIcon.MinusCircle, Brushes.LightSlateGray);
     Added       = ImageAwesome.CreateImageSource(FontAwesomeIcon.Plus, Brushes.LightGreen);
     Conflict    = ImageAwesome.CreateImageSource(FontAwesomeIcon.Warning, Brushes.DarkGoldenrod);
     Unversioned = ImageAwesome.CreateImageSource(FontAwesomeIcon.MinusCircle, Brushes.LightSlateGray);
     Deleted     = ImageAwesome.CreateImageSource(FontAwesomeIcon.MinusCircle, Brushes.IndianRed);
 }
Beispiel #16
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is EFontAwesomeIcon))
            {
                return(null);
            }

            Brush foregroundBrush = parameter as Brush ?? Brushes.Black;

            return(ImageAwesome.CreateImageSource((EFontAwesomeIcon)value, foregroundBrush));
        }
    public RecentFilesViewModel()
      : base("Tool VIew - Left ")
    {
      ////Workspace.This.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged);
      ContentId = ToolContentId;

      this.mMruList = new MRUListVM();
      
     //part of issue no. 60(icon) -edited by reeden
      IconSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Home, Brushes.Black, 15);//bi;
        }
Beispiel #18
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is FontAwesomeIcon))
            {
                return(null);
            }

            if (!(parameter is Brush brush))
            {
                brush = Brushes.Black;
            }

            return(ImageAwesome.CreateImageSource((FontAwesomeIcon)value, brush));
        }
Beispiel #19
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            FontAwesomeIcon fontAwesomeIcon;

            if (string.IsNullOrEmpty(_name))
            {
                fontAwesomeIcon = FontAwesomeIcon.None;
            }
            else
            if (!ClassNameLookup.TryGetValue(_name, out fontAwesomeIcon))
            {
                fontAwesomeIcon = FontAwesomeIcon.Square;
            }

            return(ImageAwesome.CreateImageSource(fontAwesomeIcon, _foregroundBrush));
        }
Beispiel #20
0
        private void RedrawImage()
        {
            FontAwesomeIcon icon = FontAwesomeIcon.None;

            Enum.TryParse(Icon, out icon);
            Color color        = string.IsNullOrEmpty(Color) ? Colors.Black : (Color)ColorConverter.ConvertFromString(Color);
            var   imageSource  = ImageAwesome.CreateImageSource(icon, new SolidColorBrush(color));
            var   drawingImage = new Image {
                Source = imageSource
            };

            drawingImage.Arrange(new Rect(0, 0, 48, 48));
            var img = new RenderTargetBitmap(48, 48, 96, 96, PixelFormats.Pbgra32);

            img.Render(drawingImage);
            _Image = img;
            RenderToPng();
        }
        public CustomToolBarSelector()
        {
            #region Label
            lblText.MinWidth = 85;

            this.AddChild(lblText);
            #endregion
            #region ComboBox
            cmbBx.MinWidth = 75;
            cmbBx.MaxWidth = 150;

            this.AddChild(cmbBx);
            #endregion

            #region Buttons
            #region images
            var imgAdd = new Image();
            imgAdd.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Plus, Brushes.Green);
            imgAdd.Height = 18;

            var imgEdit = new Image();
            imgEdit.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Edit, Brushes.Brown);
            imgEdit.Height = 18;


            var imgDelete = new Image();
            imgDelete.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Trash, Brushes.Red);
            imgDelete.Height = 18;
            #endregion

            btnAdd.Click    += new RoutedEventHandler(btnAdd_Click);
            btnEdit.Click   += new RoutedEventHandler(btnEdit_Click);
            btnDelete.Click += new RoutedEventHandler(btnDelete_Click);

            btnAdd.Content    = imgAdd;
            btnEdit.Content   = imgEdit;
            btnDelete.Content = imgDelete;

            this.AddChild(btnAdd);
            this.AddChild(btnEdit);
            this.AddChild(btnDelete);
            #endregion
        }
        static Image CreateImage(string sourceUri)
        {
            Image image = new Image
            {
                Height = 14,
                Width  = 14
            };

            if (Application.Current != null)
            {
                Brush brush = Application.Current.TryFindResource("WareWolfButtonBrush") as SolidColorBrush;

                switch (sourceUri)
                {
                case "Question":
                    image.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Question, brush);
                    break;

                case "ServiceQuickVariableInput":
                    image.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.ListAlt, brush);
                    break;

                case "ServicePropertyEdit":
                    image.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Pencil, brush);
                    break;

                case "ServiceHelp":
                    image.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Gears, brush);
                    break;

                default:
                    image.Source = new BitmapImage(new Uri(sourceUri));
                    break;
                }
            }
            return(image);
        }
Beispiel #23
0
        /// <summary>
        /// Loads the add-in menu and toolbar buttons
        /// </summary>
        /// <param name="window"></param>
        public void InitializeAddinsUi(MainWindow window, List <MarkdownMonsterAddin> addins = null)
        {
            if (addins == null)
            {
                addins = this.AddIns;
            }

            foreach (var addin in addins)
            {
                addin.Model = window.Model;

                foreach (var menuItem in addin.MenuItems)
                {
                    try
                    {
                        var mitem = new MenuItem()
                        {
                            Header = menuItem.Caption,
                        };

                        Action <object, ICommand> xAction = (s, c) =>
                        {
                            try
                            {
                                menuItem.Execute?.Invoke(mitem);
                            }
                            catch (Exception ex)
                            {
                                mmApp.Log($"Addin {addin.Name ?? addin.Id} Execute failed", ex);
                                string msg = $"The '{addin.Name ?? addin.Id}' addin failed:\r\n\r\n{ex.GetBaseException().Message}\r\n\r\n" +
                                             "You can check to see if there is an update for the Addin available in the Addin Manager. We also recommend you update to the latest version of Markdown Monster.";
                                MessageBox.Show(msg, "Addin Execution Failed",
                                                MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        };
                        Func <object, ICommand, bool> cxAction = null;
                        if (menuItem.CanExecute != null)
                        {
                            cxAction = (s, e) =>
                            {
                                try
                                {
                                    return(menuItem.CanExecute.Invoke(s));
                                }
                                catch (Exception ex)
                                {
                                    mmApp.Log($"Addin {addin.Name} CanExecute failed", ex);
                                    return(true);
                                }
                            }
                        }
                        ;
                        menuItem.Command = new CommandBase(xAction, cxAction);
                        mitem.Command    = menuItem.Command;

                        // if an icon is provided also add to toolbar
                        if (menuItem.FontawesomeIcon != FontAwesomeIcon.None || menuItem.IconImageSource != null)
                        {
                            var hasConfigMenu = menuItem.ExecuteConfiguration != null;

                            var titem = new Button();

                            var source = menuItem.IconImageSource ??
                                         ImageAwesome.CreateImageSource(menuItem.FontawesomeIcon, addin.Model.Window.Foreground);

                            titem.Content = new Image()
                            {
                                Source  = source,
                                ToolTip = menuItem.Caption +
                                          (!string.IsNullOrEmpty(menuItem.KeyboardShortcut) ?
                                           $" ({menuItem.KeyboardShortcut})" :
                                           string.Empty),
                                Height = menuItem.IconImageSource == null ? 18 : 19,
                                Width  = menuItem.IconImageSource == null ? 18 : 19,
                                Margin = new Thickness(5, 0, hasConfigMenu ? 0 : 5, 0)
                            };



                            if (menuItem.Execute != null)
                            {
                                titem.Command = menuItem.Command;
                                AddKeyboardShortcut(menuItem, addin);
                            }

                            addin.Model.Window.ToolbarAddIns.Visibility = Visibility.Visible;
                            int toolIndex = addin.Model.Window.ToolbarAddIns.Items.Add(titem);

                            // Add configuration dropdown if configured
                            if (hasConfigMenu)
                            {
                                var tcitem = new Button
                                {
                                    FontSize = 10F,
                                    Content  = new Image()
                                    {
                                        Source =
                                            ImageAwesome.CreateImageSource(FontAwesomeIcon.CaretDown,
                                                                           addin.Model.Window.Foreground),
                                        Height = 16,
                                        Width  = 8,
                                        Margin = new Thickness(0, 0, 0, 0),
                                    },
                                    ToolTip = menuItem.Caption + " Configuration",
                                };

                                var ctxm = new ContextMenu();
                                tcitem.ContextMenu = ctxm;

                                // create context menu and add drop down behavior
                                var behaviors = Interaction.GetBehaviors(tcitem);
                                behaviors.Add(new DropDownButtonBehavior());

                                tcitem.Click += (sender, args) =>
                                {
                                    ctxm.Items.Clear();
                                    var configMenuItem = new MenuItem()
                                    {
                                        Header = menuItem.Caption
                                    };
                                    configMenuItem.Command = menuItem.Command;
                                    if (menuItem.CanExecute != null)
                                    {
                                        configMenuItem.IsEnabled = menuItem.CanExecute.Invoke(sender);
                                    }
                                    ctxm.Items.Add(configMenuItem);

                                    configMenuItem = new MenuItem()
                                    {
                                        Header = menuItem.Caption + " Configuration",
                                    };
                                    if (menuItem.ExecuteConfiguration != null)
                                    {
                                        configMenuItem.Click += (s, e) => menuItem.ExecuteConfiguration?.Invoke(s);
                                    }

                                    ctxm.Items.Add(configMenuItem);
                                };

                                addin.Model.Window.ToolbarAddIns.Items.Add(tcitem);
                            }
                            ;

                            addin.Model.PropertyChanged += (s, arg) =>
                            {
                                if (arg.PropertyName == "ActiveDocument" || arg.PropertyName == "ActiveEditor")
                                {
                                    menuItem.Command?.InvalidateCanExecute();

                                    // this shouldn't be necessary but it looks if the Command bindings work correctly
                                    //var item = addin.Model.Window.ToolbarAddIns.Items[toolIndex] as Button;
                                    //if (item != null)
                                    //{
                                    //    ((CommandBase)item.Command).InvalidateCanExecute();
                                    //    if (menuItem.CanExecute != null)
                                    //        item.IsEnabled = menuItem.CanExecute.Invoke(null);
                                    //}
                                }
                            };
                        }
                    }
                    catch (Exception ex)
                    {
                        var msg = $"Unable to load add-in: {Path.GetFileNameWithoutExtension(addin.Name)}";
                        mmApp.Log(msg, ex);
                        AddinLoadErrors.AppendLine(msg + "\r\n");
                    }
                }
            }

            if (AddinLoadErrors.Length > 0)
            {
                MessageBox.Show(AddinLoadErrors.ToString() +
                                "\r\n\r\n" +
                                "Try updating each failing addin and Markdown Monster to the latest versions or uninstall each failing addins.",
                                "The following addins failed to load",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            _addinLoadErrors = null;
        }
        public Single()
        {
            InitializeComponent();

            Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.Flag, Brushes.BlueViolet);
        }
        /// <summary>
        /// Loads the add-in menu and toolbar buttons
        /// </summary>
        /// <param name="window"></param>
        public void InitializeAddinsUi(MainWindow window, List <MarkdownMonsterAddin> addins = null)
        {
            if (addins == null)
            {
                addins = AddIns;
            }

            foreach (var addin in addins)
            {
                addin.Model = window.Model;

                foreach (var addinMenuItem in addin.MenuItems)
                {
                    try
                    {
                        var mitem = new MenuItem
                        {
                            Header = addinMenuItem.Caption,
                            Name   = StringUtils.ToCamelCase(addinMenuItem.Caption)
                        };

                        if (string.IsNullOrEmpty(addin.Name))
                        {
                            addin.Name = addinMenuItem.Caption;
                        }

                        Action <object, ICommand> xAction = (s, c) =>
                        {
                            try
                            {
                                addinMenuItem.Execute?.Invoke(mitem);
                            }
                            catch (Exception ex)
                            {
                                mmApp.Log($"Addin {addin.Name ?? addin.Id} Execute failed", ex);
                                string msg = $"The '{addin.Name ?? addin.Id}' addin failed:\r\n\r\n{ex.GetBaseException().Message}\r\n\r\n" +
                                             "You can check to see if there is an update for the Addin available in the Addin Manager. We also recommend you update to the latest version of Markdown Monster.";
                                MessageBox.Show(msg, "Addin Execution Failed",
                                                MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        };
                        Func <object, ICommand, bool> cxAction = null;
                        if (addinMenuItem.CanExecute != null)
                        {
                            cxAction = (s, e) =>
                            {
                                try
                                {
                                    return(addinMenuItem.CanExecute.Invoke(s));
                                }
                                catch (Exception ex)
                                {
                                    mmApp.Log($"Addin {addin.Name} CanExecute failed", ex);
                                    return(true);
                                }
                            }
                        }
                        ;
                        addinMenuItem.Command = new CommandBase(xAction, cxAction);
                        mitem.Command         = addinMenuItem.Command;

                        addin.Model.Window.MenuAddins.Items.Add(mitem);

                        // if an icon is provided also add to toolbar
                        if (addinMenuItem.FontawesomeIcon != FontAwesomeIcon.None || addinMenuItem.IconImageSource != null)
                        {
                            var hasConfigMenu = addinMenuItem.ExecuteConfiguration != null;

                            Brush colorBrush;
                            if (string.IsNullOrEmpty(addinMenuItem.FontawesomeIconColor))
                            {
                                colorBrush = mmApp.Model.Window.Foreground;
                            }
                            else
                            {
                                colorBrush = new BrushConverter().ConvertFrom(addinMenuItem.FontawesomeIconColor) as Brush;
                            }

                            var titem = new Button();

                            var source = addinMenuItem.IconImageSource ??
                                         ImageAwesome.CreateImageSource(addinMenuItem.FontawesomeIcon, colorBrush);

                            titem.Content = new Image()
                            {
                                Source  = source,
                                ToolTip = addinMenuItem.Caption +
                                          (!string.IsNullOrEmpty(addinMenuItem.KeyboardShortcut) ?
                                           $" ({addinMenuItem.KeyboardShortcut})" :
                                           string.Empty),
                                Height = addinMenuItem.IconImageSource == null ? 18 : 19,
                                Width  = addinMenuItem.IconImageSource == null ? 18 : 19,
                                Margin = new Thickness(5, 0, hasConfigMenu ? 0 : 5, 0)
                            };
                            addinMenuItem.MenuItemButton = titem;


                            if (addinMenuItem.Execute != null)
                            {
                                titem.Command = addinMenuItem.Command;
                                AddKeyboardShortcut(addinMenuItem, addin);
                            }

                            addin.Model.Window.ToolbarAddIns.Visibility = Visibility.Visible;
                            int toolIndex = addin.Model.Window.ToolbarAddIns.Items.Add(titem);

                            // Add configuration dropdown if configured
                            if (hasConfigMenu)
                            {
                                var tcitem = new Button
                                {
                                    FontSize = 10F,
                                    Content  = new Image()
                                    {
                                        Source =
                                            ImageAwesome.CreateImageSource(FontAwesomeIcon.CaretDown,
                                                                           addin.Model.Window.Foreground),
                                        Height = 16,
                                        Width  = 8,
                                        Margin = new Thickness(0, 0, 0, 0),
                                    },
                                    ToolTip = addinMenuItem.Caption + " Configuration",
                                };

                                var ctxm = new ContextMenu();
                                tcitem.ContextMenu = ctxm;

                                // create context menu and add drop down behavior
                                var behaviors = Interaction.GetBehaviors(tcitem);
                                behaviors.Add(new DropDownButtonBehavior());

                                tcitem.Click += (sender, args) =>
                                {
                                    ctxm.Items.Clear();
                                    var configMenuItem = new MenuItem()
                                    {
                                        Header = addinMenuItem.Caption
                                    };
                                    configMenuItem.Command = addinMenuItem.Command;
                                    if (addinMenuItem.CanExecute != null)
                                    {
                                        configMenuItem.IsEnabled = addinMenuItem.CanExecute.Invoke(sender);
                                    }
                                    ctxm.Items.Add(configMenuItem);

                                    configMenuItem = new MenuItem()
                                    {
                                        Header = $"{addinMenuItem.Caption} Configuration",
                                    };
                                    if (addinMenuItem.ExecuteConfiguration != null)
                                    {
                                        configMenuItem.Click += (s, e) => addinMenuItem.ExecuteConfiguration?.Invoke(s);
                                    }

                                    addinMenuItem.ConfigurationMenuItem = configMenuItem;

                                    ctxm.Items.Add(configMenuItem);

                                    // Uninstall Addin
                                    if (!addin.Id.Equals("screencapture",
                                                         StringComparison.InvariantCultureIgnoreCase) &&
                                        !addin.Id.Equals("weblog", StringComparison.InvariantCultureIgnoreCase) &&
                                        !addin.Id.Equals("snippets", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        configMenuItem = new MenuItem()
                                        {
                                            Header = $"Uninstall {addinMenuItem.Caption}",
                                        };
                                        if (addinMenuItem.ExecuteConfiguration != null)
                                        {
                                            configMenuItem.Click += (s, e) =>
                                            {
                                                if (AddinManager.Current.UninstallAddin(addin.Id))
                                                {
                                                    mmApp.Model.Window.ShowStatusSuccess(
                                                        $"{addin.Name} addin has been removed.");
                                                    addinMenuItem.MenuItemButton.Visibility = Visibility.Collapsed;
                                                    tcitem.Visibility = Visibility.Collapsed;
                                                }
                                                else
                                                {
                                                    mmApp.Model.Window.ShowStatusError(
                                                        $"Unable to uninstall {addin.Name} addin.");
                                                }
                                            }
                                        }
                                        ;

                                        addinMenuItem.ConfigurationMenuItem = configMenuItem;
                                        ctxm.Items.Add(configMenuItem);
                                    }
                                };

                                addin.Model.Window.ToolbarAddIns.Items.Add(tcitem);
                            }
                            ;
                        }
                    }
                    catch (Exception ex)
                    {
                        var msg = $"Unable to load add-in: {Path.GetFileNameWithoutExtension(addin.Name)}";
                        mmApp.Log(msg, ex);
                        AddinLoadErrors.AppendLine(msg + "\r\n");
                    }
                }
            }

            if (AddinLoadErrors.Length > 0)
            {
                MessageBox.Show(AddinLoadErrors.ToString() +
                                "\r\n\r\n" +
                                "Try updating each failing addin and Markdown Monster to the latest versions or uninstall each failing addins.",
                                "The following addins failed to load",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            _addinLoadErrors = null;
        }
Beispiel #26
0
        public MainWindow(
            MainWindowVM viewModel,
            IDialogService dialogService,
            IRuntimeDataService runtimeDataService)
        {
            _dialogService      = dialogService;
            _runtimeDataService = runtimeDataService;

            InitializeComponent();

            WindowChrome windowChrome = new WindowChrome()
            {
                CaptionHeight         = 55,
                CornerRadius          = new CornerRadius(0),
                GlassFrameThickness   = new Thickness(0),
                NonClientFrameEdges   = NonClientFrameEdges.None,
                ResizeBorderThickness = new Thickness(6),
                UseAeroCaptionButtons = false
            };

            WindowChrome.SetWindowChrome(this, windowChrome);

            _namedPipeManager            = new NamedPipeManager("TwitchLeecher");
            _namedPipeManager.OnMessage += OnPipeMessage;
            _namedPipeManager.StartServer();

            // Hold reference to FontAwesome library
            ImageAwesome.CreateImageSource(FontAwesomeIcon.Times, Brushes.Black);

            SizeChanged += (s, e) =>
            {
                if (WindowState == WindowState.Normal)
                {
                    WidthNormal  = Width;
                    HeightNormal = Height;
                }
            };

            LocationChanged += (s, e) =>
            {
                if (WindowState == WindowState.Normal)
                {
                    TopNormal  = Top;
                    LeftNormal = Left;
                }
            };

            Loaded += (s, e) =>
            {
                HwndSource.FromHwnd(new WindowInteropHelper(this).Handle).AddHook(new HwndSourceHook(WindowProc));

                DataContext = viewModel;

                if (viewModel != null)
                {
                    viewModel.Loaded();
                }

                LoadWindowState();
            };

            Activated += (s, e) =>
            {
                if (viewModel != null && !_shown)
                {
                    _shown = true;
                    viewModel.Shown();
                }
            };

            Closed += (s, e) =>
            {
                SaveWindowState();

                _namedPipeManager.StopServer();
            };
        }
Beispiel #27
0
 public MainWindow()
 {
     InitializeComponent();
     Icon = ImageAwesome.CreateImageSource(FontAwesomeIcon.Bolt, Brushes.White);
 }
 private void InitializeFontAwesome()
 {
     // To be able to use FontAwesome in XAML icon resources, we need to make sure that the FontAwesome.WPF assembly is loaded into
     // the AppDomain before attempting to load an icon resource - thus the creation of an unused image below...
     ImageAwesome.CreateImageSource(FontAwesomeIcon.FontAwesome, Brushes.Black);
 }
#pragma warning disable S1541 // Methods and properties should not be too complex
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
#pragma warning restore S1541 // Methods and properties should not be too complex
        {
            if (value != null)
            {
                switch (value.ToString())
                {
                case "WorkflowService":
                    return(_dict[CustomMenuIcons.WorkflowService] as DrawingImage);

                case "PluginSource":
                case "ComPluginSource":
                    return(_dict[CustomMenuIcons.PluginSource] as DrawingImage);

                case "WcfSource":
                    return(_dict["WcfEndPointSource"] as DrawingImage);

                case "EmailSource":
                    return(_dict[CustomMenuIcons.EmailSource] as DrawingImage);

                case "RabbitMQSource":
                    return(_dict[CustomMenuIcons.RabbitMqSource] as DrawingImage);

                case "ExchangeSource":
                    return(_dict[CustomMenuIcons.ExchangeSource] as DrawingImage);

                case "SqlDatabase":
                    return(_dict[CustomMenuIcons.SqlServerSource] as DrawingImage);

                case "Oracle":
                    return(_dict[CustomMenuIcons.OracleSource] as DrawingImage);

                case "MySqlDatabase":
                    return(_dict[CustomMenuIcons.MySqlSource] as DrawingImage);

                case "PostgreSQL":
                    return(_dict["PostgreSource"] as DrawingImage);

                case "ElasticsearchSource":
                    return(_dict["ElasticsearchSource"] as DrawingImage);

                case "ODBC":
                    return(_dict["OdbcSource"] as DrawingImage);

                case "RedisSource":
                    return(_dict[CustomMenuIcons.RedisSource] as DrawingImage);

                case "WebSource":
                    return(_dict[CustomMenuIcons.WebSource] as DrawingImage);

                case "SharepointServerSource":
                    return(Application.Current.Resources["SharepointSource"]);

                case "ServerSource":
                case "Server":
                case "Dev2Server":
                    return(_dict[CustomMenuIcons.ServerSource] as DrawingImage);

                case "StartPage":
                    var imageSource = ImageAwesome.CreateImageSource(FontAwesomeIcon.Home, _brush);
                    return(imageSource);

                case "OAuth":
                case "OauthSource":
                case "DropBoxSource":
                    return(Application.Current.Resources["DropboxSource"]);

                //TODO: Remove once Triggers is the only entry point.
                case "Scheduler":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.History, _brush));

                case "Triggers":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.Play, _brush));

                case "ServiceTestsViewer":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.Flask, _brush));

                case "MergeConflicts":
                    return(_dict[CustomMenuIcons.MergeConflicts] as DrawingImage);

                case "Search":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.Search, _brush));

                case "Settings":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.Cogs, _brush));

                case "DependencyViewer":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.Sitemap, _brush));

                case "DeployViewer":
                    return(ImageAwesome.CreateImageSource(FontAwesomeIcon.PaperPlane, _brush));

                default:
                    return(_dict[CustomMenuIcons.Folder] as DrawingImage);
                }
            }
            return(null);
        }
        /// <summary>
        /// Creates/Updates the Recent Items Context list
        /// from recent file and recent folder configuration
        /// </summary>
        public void UpdateRecentDocumentsContextMenu(RecentFileDropdownModes mode)
        {
            var contextMenu = new ContextMenu {
                FontSize = 12.5, Padding = new Thickness(0, 8, 8, 8),
            };

            if (mode == RecentFileDropdownModes.MenuDropDown)
            {
                Window.ButtonRecentFiles.Items.Clear();
            }
            else if (mode == RecentFileDropdownModes.ToolbarDropdown)
            {
                Window.ToolbarButtonRecentFiles.ContextMenu = contextMenu;
            }

            var      icon          = new AssociatedIcons();
            MenuItem mi            = null;
            var      lowlightColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#aaa"));


            var headerContent = new StackPanel
            {
                Orientation = Orientation.Vertical
            };

            // image/textblock panel
            var headerPanel = new StackPanel {
                Orientation = Orientation.Horizontal
            };

            headerPanel.Children.Add(new Image
            {
                Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Star, Brushes.Goldenrod, 17),
                Height = 16
            });
            headerPanel.Children.Add(new TextBlock
            {
                Text       = "Favorites...",
                FontWeight = FontWeights.SemiBold,
                Margin     = new Thickness(5, 2, 0, 0)
            });
            headerContent.Children.Add(headerPanel);

            mi = new MenuItem()
            {
                Header = headerContent, Padding = new Thickness(0, 2, 0, 3)
            };
            mi.Click += (o, args) => Window.OpenFavorites();
            contextMenu.Items.Add(mi);

            contextMenu.Items.Add(new Separator());



            mmApp.Configuration.CleanupRecentFilesAndFolders();

            foreach (string file in mmApp.Configuration.RecentDocuments)
            {
                var fileOnly = Path.GetFileName(file).Replace("_", "__");
                var path     = Path.GetDirectoryName(file).Replace("_", "__");

                var content = new StackPanel
                {
                    Orientation = Orientation.Vertical
                };

                // image/textblock panel
                var panel = new StackPanel {
                    Orientation = Orientation.Horizontal
                };
                panel.Children.Add(new Image
                {
                    Source = icon.GetIconFromFile(file),
                    Height = 14
                });
                panel.Children.Add(new TextBlock
                {
                    Text       = fileOnly,
                    FontWeight = FontWeights.Medium,
                    Margin     = new Thickness(5, 0, 0, 0)
                });
                content.Children.Add(panel);

                // folder
                content.Children.Add(new TextBlock
                {
                    Text      = path,
                    FontStyle = FontStyles.Italic,
                    FontSize  = 10.35,
                    Margin    = new Thickness(19, 0, 0, 2),
                    Opacity   = 0.80
                });


                mi = new MenuItem
                {
                    Header           = content,
                    Command          = Window.Model.Commands.OpenRecentDocumentCommand,
                    CommandParameter = file,
                    Padding          = new Thickness(0, 1, 0, 3)
                };

                if (mode == RecentFileDropdownModes.ToolbarDropdown)
                {
                    contextMenu.Items.Add(mi);
                }
                else
                {
                    Window.ButtonRecentFiles.Items.Add(mi);
                }
            }


            if (mmApp.Configuration.FolderBrowser.RecentFolders.Count > 0)
            {
                mi = new MenuItem
                {
                    IsEnabled = false,
                    Header    = "————————— Recent Folders —————————"
                };

                if (mode == RecentFileDropdownModes.ToolbarDropdown)
                {
                    contextMenu.Items.Add(mi);
                }
                else
                {
                    Window.ButtonRecentFiles.Items.Add(mi);
                }

                foreach (var folder in mmApp.Configuration.FolderBrowser.RecentFolders.Take(7))
                {
                    var pathOnly = Path.GetFileName(folder).Replace("_", "__");
                    var path     = folder.Replace("_", "__");

                    var content = new StackPanel()
                    {
                        Orientation = Orientation.Vertical
                    };

                    // image/textblock panel
                    var panel = new StackPanel {
                        Orientation = Orientation.Horizontal
                    };
                    panel.Children.Add(new Image
                    {
                        Source = icon.GetIconFromFile("folder.folder"),
                        Height = 14
                    });
                    panel.Children.Add(new TextBlock
                    {
                        Text       = pathOnly,
                        FontWeight = FontWeights.Medium,
                        Margin     = new Thickness(5, 0, 0, 0)
                    });
                    content.Children.Add(panel);

                    content.Children.Add(new TextBlock
                    {
                        Text      = path,
                        FontStyle = FontStyles.Italic,
                        FontSize  = 10.35,
                        Margin    = new Thickness(19, 1, 0, 0),
                        Opacity   = 0.8
                    });

                    mi = new MenuItem()
                    {
                        Header           = content,
                        Command          = Window.Model.Commands.OpenRecentDocumentCommand,
                        CommandParameter = folder,
                        Padding          = new Thickness(0, 2, 0, 3)
                    };

                    if (mode == RecentFileDropdownModes.ToolbarDropdown)
                    {
                        contextMenu.Items.Add(mi);
                    }
                    else
                    {
                        Window.ButtonRecentFiles.Items.Add(mi);
                    }
                }
            }
        }