コード例 #1
0
        private void Window_Load(object sender, EventArgs e)
        {
            foreach (TabItem tab in UIUtils.FindLogicalChildren <TabItem>(ui.tabMode))
            {
                ICNCView view = getView(tab);
                view.Setup(UIViewModel, UIViewModel.Profile);
                tab.IsEnabled = view.ViewType == ViewType.GRBL || view.ViewType == ViewType.AppConfig;
            }

            if (!UIViewModel.Profile.Config.GCodeViewer.IsEnabled)
            {
                ShowView(false, ViewType.GCodeViewer);
            }

            xx.ItemsSource = UIViewModel.SidebarItems;
            UIViewModel.SidebarItems.Add(new SidebarItem("Jog", jogControl));
            UIViewModel.SidebarItems.Add(new SidebarItem("Macros", macroControl));
            UIViewModel.SidebarItems.Add(new SidebarItem("Goto", gotoControl));

            UIViewModel.CurrentView = getView((TabItem)tabMode.Items[tabMode.SelectedIndex = 0]);
            System.Threading.Thread.Sleep(50);
            Comms.com.PurgeQueue();
            UIViewModel.CurrentView.Activate(true, ViewType.Startup);

            if (!string.IsNullOrEmpty(UIViewModel.Profile.FileName))
            {
                FileLoad?.Invoke(UIViewModel.Profile.FileName);
            }
        }
コード例 #2
0
        public static void CloseFile()
        {
            ICNCView view, grbl = getView(getTab(ViewType.GRBL));

            grbl.CloseFile();

            foreach (TabItem tabitem in UIUtils.FindLogicalChildren <TabItem>(ui.tabMode))
            {
                if ((view = getView(tabitem)) != null && view != grbl)
                {
                    view.CloseFile();
                }
            }
        }
コード例 #3
0
 private void TabMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (UIViewModel.CurrentView != null && e.AddedItems.Count > 0)
     {
         ViewType prevMode = UIViewModel.CurrentView.ViewType;
         ICNCView nextView = getView((TabItem)tabMode.Items[tabMode.SelectedIndex]);
         if (nextView != UIViewModel.CurrentView)
         {
             UIViewModel.CurrentView.Activate(false, nextView.ViewType);
             UIViewModel.CurrentView = nextView;
             UIViewModel.CurrentView.Activate(true, prevMode);
         }
     }
 }
コード例 #4
0
        private static ICNCView getView(TabItem tab)
        {
            ICNCView view = null;

            foreach (UserControl uc in UIUtils.FindLogicalChildren <UserControl>(tab))
            {
                if (uc is ICNCView)
                {
                    view = (ICNCView)uc;
                    break;
                }
            }

            return(view);
        }
コード例 #5
0
        private void Window_Load(object sender, EventArgs e)
        {
            foreach (TabItem tab in UIUtils.FindLogicalChildren <TabItem>(ui.tabMode))
            {
                ICNCView view = getView(tab);
                if (view != null)
                {
                    view.Setup(UIViewModel, AppConfig.Settings);
                    tab.IsEnabled = view.ViewType == ViewType.GRBL || view.ViewType == ViewType.AppConfig;
                }
            }

            if (!AppConfig.Settings.GCodeViewer.IsEnabled)
            {
                ShowView(false, ViewType.GCodeViewer);
            }

            xx.ItemsSource = UIViewModel.SidebarItems;
            UIViewModel.SidebarItems.Add(new SidebarItem("_Jog", jogControl));
            UIViewModel.SidebarItems.Add(new SidebarItem("_Macros", macroControl));
            UIViewModel.SidebarItems.Add(new SidebarItem("_Goto", gotoControl));
            UIViewModel.SidebarItems.Add(new SidebarItem("M_Pos", mposFlyout));
//            UIViewModel.SidebarItems.Add(new SidebarItem("_THC Monitor", thcControl));

            UIViewModel.CurrentView = getView((TabItem)tabMode.Items[tabMode.SelectedIndex = 0]);
            System.Threading.Thread.Sleep(50);
            Comms.com.PurgeQueue();
            UIViewModel.CurrentView.Activate(true, ViewType.Startup);

            if (!string.IsNullOrEmpty(AppConfig.Settings.FileName))
            {
                // Delay loading until app is ready
                Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new System.Action(() =>
                {
                    GCode.File.Load(AppConfig.Settings.FileName);
                }));
            }

            IGCodeConverter c = new Excellon2GCode();

            GCode.File.AddConverter(c.GetType(), c.FileType);
            c = new HpglToGCode();
            GCode.File.AddConverter(c.GetType(), c.FileType);

            GCode.File.AddTransformer(typeof(CNC.Controls.ArcsToLines), "Arcs to lines", UIViewModel.TransformMenuItems);
            GCode.File.AddTransformer(typeof(CNC.Controls.DragKnife.DragKnifeViewModel), "Add drag knife moves", UIViewModel.TransformMenuItems);
        }
コード例 #6
0
        private void TabMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!(DataContext as GrblViewModel).IsReady)
            {
                return;
            }

            if (Equals(e.OriginalSource, sender) && UIViewModel.CurrentView != null && e.AddedItems.Count == 1)
            {
                ICNCView prevView = UIViewModel.CurrentView, nextView = getView((TabItem)e.AddedItems[0]);
                if (nextView != null && nextView != UIViewModel.CurrentView)
                {
                    UIViewModel.CurrentView = nextView;
                    prevView.Activate(false, nextView.ViewType);
                    nextView.Activate(true, prevView.ViewType);
                }
            }
        }
コード例 #7
0
        private void Window_Load(object sender, EventArgs e)
        {
            if (AppConfig.Settings.Base.KeepWindowSize)
            {
                if (AppConfig.Settings.Base.WindowWidth == -1)
                {
                    WindowState = WindowState.Maximized;
                }
                else
                {
                    Width  = Math.Max(Math.Min(AppConfig.Settings.Base.WindowWidth, SystemParameters.PrimaryScreenWidth), MinWidth);
                    Height = Math.Max(Math.Min(AppConfig.Settings.Base.WindowHeight, SystemParameters.PrimaryScreenHeight), MinHeight);
                    if (Left + Width > SystemParameters.PrimaryScreenWidth)
                    {
                        Left = 0d;
                    }
                    if (Top + Height > SystemParameters.PrimaryScreenHeight)
                    {
                        Top = 0d;
                    }
                }
            }
            saveWinSize = AppConfig.Settings.Base.KeepWindowSize;
            var appconf = getView(getTab(ViewType.AppConfig));

            appconf.Setup(UIViewModel, AppConfig.Settings);

            foreach (TabItem tab in UIUtils.FindLogicalChildren <TabItem>(ui.tabMode))
            {
                ICNCView view = getView(tab);
                if (view != null && view != appconf)
                {
                    view.Setup(UIViewModel, AppConfig.Settings);
                    tab.IsEnabled = view.ViewType == ViewType.GRBL || view.ViewType == ViewType.AppConfig;
                }
            }
#if ADD_CAMERA
            enableCamera(this);
#else
            menuCamera.Visibility = Visibility.Hidden;
#endif
            if (!AppConfig.Settings.GCodeViewer.IsEnabled)
            {
                ShowView(false, ViewType.GCodeViewer);
            }

            xx.ItemsSource = UIViewModel.SidebarItems;
            if (AppConfig.Settings.Jog.Mode != JogConfig.JogMode.Keypad)
            {
                UIViewModel.SidebarItems.Add(new SidebarItem(jogControl));
            }
            UIViewModel.SidebarItems.Add(new SidebarItem(macroControl));
            UIViewModel.SidebarItems.Add(new SidebarItem(gotoControl));
            UIViewModel.SidebarItems.Add(new SidebarItem(outlineFlyout));
            UIViewModel.SidebarItems.Add(new SidebarItem(mposFlyout));
//          UIViewModel.SidebarItems.Add(new SidebarItem(thcControl));

            UIViewModel.CurrentView = getView((TabItem)tabMode.Items[tabMode.SelectedIndex = 0]);
            System.Threading.Thread.Sleep(50);
            Comms.com.PurgeQueue();
            UIViewModel.CurrentView.Activate(true, ViewType.Startup);

            if (!string.IsNullOrEmpty(AppConfig.Settings.FileName))
            {
                // Delay loading until app is ready
                Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new System.Action(() =>
                {
                    GCode.File.Load(AppConfig.Settings.FileName);
                }));
            }

            IGCodeConverter c = new Excellon2GCode();
            GCode.File.AddConverter(c.GetType(), c.FileType);
            c = new HpglToGCode();
            GCode.File.AddConverter(c.GetType(), c.FileType);

            GCode.File.AddTransformer(typeof(GCodeRotateViewModel), (string)FindResource("MenuRotate"), UIViewModel.TransformMenuItems);
            GCode.File.AddTransformer(typeof(ArcsToLines), (string)FindResource("MenuArcsToLines"), UIViewModel.TransformMenuItems);
            GCode.File.AddTransformer(typeof(GCodeCompress), (string)FindResource("MenuCompress"), UIViewModel.TransformMenuItems);
            GCode.File.AddTransformer(typeof(CNC.Controls.DragKnife.DragKnifeViewModel), (string)FindResource("MenuDragKnife"), UIViewModel.TransformMenuItems);
        }