Exemplo n.º 1
0
        public static WindowItem VMToWindowItem(WindowItemVM windowItemVM)
        {
            WindowItem windowItem = new WindowItem(
                windowItemVM.Left,
                windowItemVM.Top,
                windowItemVM.Width,
                windowItemVM.Height,
                windowItemVM.WindowInfoVM.Title,
                windowItemVM.WindowInfoVM.WindowBorderSolidColorBrush.Color.ToInt(),
                windowItemVM.WindowInfoVM.TitleBackgroundSolidColorBrush.Color.ToInt(),
                windowItemVM.WindowInfoVM.TitleBackgroundOpacity,
                windowItemVM.WindowInfoVM.TitleTextSolidColorBrush.Color.ToInt(),
                windowItemVM.WindowInfoVM.WindowBackgroundSolidColorBrush.Color.ToInt(),
                windowItemVM.WindowInfoVM.WindowBackgroundOpacity,
                windowItemVM.WindowInfoVM.WindowTextSolidColorBrush.Color.ToInt());

            // Convert ItemVMs to Items
            windowItem.Items = VMsToItems(windowItemVM.RootItemVMs);
            // Convert  WindowItemVMClones to WindowClones
            foreach (WindowItemVM windowItemVMClone in windowItemVM.WindowItemVMClones)
            {
                WindowClone windowClone = new WindowClone(windowItemVMClone.Left, windowItemVMClone.Top, windowItemVMClone.Width, windowItemVMClone.Height);
                windowItem.WindowClones.Add(windowClone);
            }
            return(windowItem);
        }
Exemplo n.º 2
0
        private void CenterWindowToItsOwnScreen()
        {
            WindowItemVM windowItemVM = (WindowItemVM)DataContext;

            if (lastWindowWidth == 0 && lastWindowHeight == 0 && lastWindowLeft == 0 && lastWindowTop == 0)
            {
                // Store the last position
                lastWindowWidth  = windowItemVM.Width;
                lastWindowHeight = windowItemVM.Height;
                lastWindowLeft   = windowItemVM.Left;
                lastWindowTop    = windowItemVM.Top;

                // Center
                System.Windows.Forms.Screen screen = Helper.GetScreenFromWindow(this);
                windowItemVM.Width  = 400;
                windowItemVM.Height = 500;
                windowItemVM.Left   = (screen.Bounds.Left + ((screen.Bounds.Width - windowItemVM.Width) / 2));
                windowItemVM.Top    = (screen.Bounds.Top + ((screen.Bounds.Height - windowItemVM.Height) / 2));
            }
            else
            {
                // Restore to the last position
                windowItemVM.Width  = lastWindowWidth;
                windowItemVM.Height = lastWindowHeight;
                windowItemVM.Left   = lastWindowLeft;
                windowItemVM.Top    = lastWindowTop;

                // Reset last position variables
                lastWindowWidth  = 0;
                lastWindowHeight = 0;
                lastWindowLeft   = 0;
                lastWindowTop    = 0;
            }
            SaveData.SaveShortcuts(false);
        }
Exemplo n.º 3
0
        public static ObservableCollection <WindowItemVM> WindowItemsToVMs(List <WindowItem> windowItems)
        {
            ObservableCollection <WindowItemVM> windowItemVMs = new ObservableCollection <WindowItemVM>();

            foreach (WindowItem windowItem in windowItems)
            {
                WindowItemVM windowItemVM = WindowItemToVM(windowItem);
                windowItemVMs.Add(windowItemVM);
            }
            return(windowItemVMs);
        }
Exemplo n.º 4
0
 public static Window GetWindowFromWindowItemVM(WindowItemVM windowItemVM)
 {
     foreach (Window window in ((App)Application.Current).Windows)
     {
         if (window.DataContext is WindowItemVM)
         {
             if ((WindowItemVM)window.DataContext == windowItemVM)
             {
                 return(window);
             }
         }
     }
     return(null);
 }
Exemplo n.º 5
0
        public static WindowItemVM CloneWindow(WindowItemVM parent)
        {
            Window window = Helper.GetWindowFromWindowItemVM(parent);
            Screen screen = Helper.GetScreenFromWindow(window);

            // Position the new window at the center of the screen
            int          left        = screen.Bounds.Left + (screen.Bounds.Width - parent.Width) / 2;
            int          top         = screen.Bounds.Top + (screen.Bounds.Height - parent.Height) / 2;
            WindowItemVM windowClone = new WindowItemVM(true, left, top, parent.Width, parent.Height, parent.WindowInfoVM);

            windowClone.RootItemVMs = parent.RootItemVMs;
            parent.WindowItemVMClones.Add(windowClone);
            return(windowClone);
        }
Exemplo n.º 6
0
 private void dockWindowRight_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         WindowItemVM windowItemVM          = (WindowItemVM)DataContext;
         System.Windows.Forms.Screen screen = Helper.GetScreenFromWindow(this);
         windowItemVM.Left   = screen.WorkingArea.Left + screen.WorkingArea.Width - windowItemVM.Width;
         windowItemVM.Top    = screen.WorkingArea.Top;
         windowItemVM.Height = screen.WorkingArea.Height;
         SaveData.SaveShortcuts(false);
     }
     catch (Exception ex)
     {
         Error.ShowDialog(ex);
     }
 }
Exemplo n.º 7
0
 private void rectangleColors_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         System.Windows.Shapes.Rectangle rectangleColor = (System.Windows.Shapes.Rectangle)sender;
         if (DataContext != null)
         {
             WindowItemVM windowItemVM = (WindowItemVM)DataContext;
             windowItemVM.WindowInfoVM.WindowBackgroundOpacity = rectangleColor.Fill.Opacity;
         }
     }
     catch (Exception ex)
     {
         Error.ShowDialog(ex);
     }
 }
Exemplo n.º 8
0
        public static List <WindowItemVM> CloneWindowToAllScreens(WindowItemVM parent)
        {
            List <WindowItemVM> windowClones = new List <WindowItemVM>();

            // Loop through all available windows
            foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
            {
                // Position the new window at the center of the screen
                int          left        = screen.Bounds.Left + (screen.Bounds.Width - parent.Width) / 2;
                int          top         = screen.Bounds.Top + (screen.Bounds.Height - parent.Height) / 2;
                WindowItemVM windowClone = new WindowItemVM(true, left, top, parent.Width, parent.Height, parent.WindowInfoVM);
                windowClone.RootItemVMs = parent.RootItemVMs;
                parent.WindowItemVMClones.Add(windowClone);
                windowClones.Add(windowClone);
            }
            return(windowClones);
        }
Exemplo n.º 9
0
        public static ObservableCollection <WindowItemVM> GetWindowItemVMClones(WindowItemVM windowItemVMToClose)
        {
            // Get the application context
            ShortcutsVM shortcutsVM = ((App)Application.Current).DataContext;

            foreach (WindowItemVM windowItemVM in shortcutsVM.WindowItemVMs)
            {
                if (windowItemVM.WindowItemVMClones != null)
                {
                    foreach (WindowItemVM windowItemVMClone in windowItemVM.WindowItemVMClones)
                    {
                        if (windowItemVMClone == windowItemVMToClose)
                        {
                            return(windowItemVM.WindowItemVMClones);
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 10
0
 private void CustomTheme()
 {
     try
     {
         WindowItemVM WindowItemVM = (WindowItemVM)DataContext;
         if (WindowItemVM != null)
         {
             WindowInfoVM windowInfoVM = WindowItemVM.WindowInfoVM;
             if (windowInfoVM != null)
             {
                 CustomThemeWindow customThemeWindow = new CustomThemeWindow(windowInfoVM);
                 customThemeWindow.ShowDialog();
             }
         }
     }
     catch (Exception ex)
     {
         Error.ShowDialog(ex);
     }
 }
Exemplo n.º 11
0
 private void menuItemMyTheme_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         WindowItemVM WindowItemVM = (WindowItemVM)DataContext;
         if (WindowItemVM != null)
         {
             WindowInfoVM windowInfoVM = WindowItemVM.WindowInfoVM;
             if (windowInfoVM != null)
             {
                 Themes.MyTheme(windowInfoVM);
                 SaveData.SaveShortcuts(false);
             }
         }
     }
     catch (Exception ex)
     {
         Error.ShowDialog(ex);
     }
 }
Exemplo n.º 12
0
        public static WindowItemVM WindowItemToVM(WindowItem windowItem)
        {
            WindowItemVM windowItemVM = new WindowItemVM
                                        (
                isClone: false,
                left: windowItem.Left,
                top: windowItem.Top,
                width: windowItem.Width,
                height: windowItem.Height,
                windowInfoVM: new WindowInfoVM
                (
                    title: windowItem.Title,
                    windowBorderSolidColorBrush: windowItem.WindowBorderColor.ToColor().ToSolidColorBrush(),
                    titleBackgroundSolidColorBrush: windowItem.TitleBackgroundColor.ToColor().ToSolidColorBrush(),
                    titleBackgroundOpacity: windowItem.TitleBackgroundOpacity,
                    titleTextSolidColorBrush: windowItem.TitleTextColor.ToColor().ToSolidColorBrush(),
                    windowBackgroundSolidColorBrush: windowItem.WindowBackgroundColor.ToColor().ToSolidColorBrush(),
                    windowBackgroundOpacity: windowItem.WindowBackgroundOpacity,
                    windowTextSolidColorBrush: windowItem.WindowTextColor.ToColor().ToSolidColorBrush()
                )
                                        );

            // Convert Items to ItemVMs
            windowItemVM.RootItemVMs = ItemsToVMs(windowItem.Items);
            // Convert WindowClones to WindowItemVMClones
            foreach (WindowClone windowClone in windowItem.WindowClones)
            {
                WindowItemVM windowItemVMClone = new WindowItemVM(
                    true,
                    windowClone.Left,
                    windowClone.Top,
                    windowClone.Width,
                    windowClone.Height,
                    windowItemVM.WindowInfoVM);
                windowItemVMClone.RootItemVMs = windowItemVM.RootItemVMs;
                windowItemVM.WindowItemVMClones.Add(windowItemVMClone);
            }
            return(windowItemVM);
        }
Exemplo n.º 13
0
        public static WindowItemVM NewWindow(Screen screen)
        {
            // The default new window model
            WindowItem windowItem = NewData.NewWindow();
            // Position the new window at the center of the screen
            int          left         = screen.Bounds.Left + (screen.Bounds.Width - windowItem.Width) / 2;
            int          top          = screen.Bounds.Top + (screen.Bounds.Height - windowItem.Height) / 2;
            WindowInfoVM windowInfoVM = new WindowInfoVM
                                        (
                title: windowItem.Title,
                windowBorderSolidColorBrush: windowItem.WindowBorderColor.ToColor().ToSolidColorBrush(),
                titleBackgroundSolidColorBrush: windowItem.TitleBackgroundColor.ToColor().ToSolidColorBrush(),
                titleBackgroundOpacity:  windowItem.TitleBackgroundOpacity,
                titleTextSolidColorBrush: windowItem.TitleTextColor.ToColor().ToSolidColorBrush(),
                windowBackgroundSolidColorBrush: windowItem.WindowBackgroundColor.ToColor().ToSolidColorBrush(),
                windowBackgroundOpacity: windowItem.WindowBackgroundOpacity,
                windowTextSolidColorBrush: windowItem.WindowTextColor.ToColor().ToSolidColorBrush()
                                        );
            WindowItemVM windowItemVM = new WindowItemVM(false, left, top, windowItem.Width, windowItem.Height, windowInfoVM);

            return(windowItemVM);
        }