/// <summary>
        /// 手动指定班次估算值
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="newValue"></param>
        /// <param name="e"></param>
        public void ChangeAssignmentTypeCells(object layer, object newValue, WPF.ApplicationFramework.Controls.CellEditRoutedEventArgs e)
        {
            if(layer == null) return;

            var timeRange = new Core.Reflector(layer).Property<TimeRange>("TimeRange");
            var dataRowRange = new Core.Reflector(layer).Property<int[]>("DataRowRange");

            // HeaderContainer<AssignmentType, DailyCounter<AssignmentType>, DateTime>
            CellTraversal<int, HeaderContainer<AssignmentType, DailyCounter<AssignmentType>, DateTime>>(timeRange, dataRowRange, newValue,
                assignmentType => { }, WhenShiftEstimatesChanged, AssignmentTypes,

                (value, item) => item.SaftyGetProperty<double, DailyCounter<AssignmentType>>(c => c.Max) == value,
                (value, header, item) =>
                {
                    DateTime? effectDate = null;
                    item.SaftyInvoke<DailyCounter<AssignmentType>>(c =>
                    {
                        if (value == c.Max) return;

                        AlterShiftEstimation(c, value); // don't change order
                        //c.Max = value; // don't change order -> move to AlterShiftEstimation method
                        c.IsDirty = true;
                        effectDate = c.Date;
                    });
                    return effectDate;
                }, () =>
                {
                    CellChanged = true;
                }, e);
        }
Exemple #2
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Save window state/dimensions
            var handle = ((HwndSource)PresentationSource.FromVisual(this)).Handle;

            Global.Local.WindowSettings = WPF.GetWindowPlacement(handle);
        }
Exemple #3
0
        /// <summary>
        /// Set focus on the first valid focusable element in the control
        /// </summary>
        public void SetFocus(object dataContext = null)
        {
            UIElement focus = null;

            if (IsEnabled && Focusable)
            {
                focus = this;
            }
            else
            {
                if (dataContext != null)
                {
                    focus = WPF.FindFirstChild <FrameworkElement>(this,
                                                                  (wx) => wx.IsVisible && wx.IsEnabled && wx.Focusable && wx.DataContext == dataContext
                                                                  );
                }

                if (focus == null)
                {
                    focus = WPF.FindFirstChild <UIElement>(this,
                                                           (wx) => wx.IsVisible && wx.IsEnabled && wx.Focusable
                                                           );
                }
            }

            LimeMsg.Debug("LimeControl SetFocus: {0}", focus);
            if (focus != null)
            {
                Keyboard.Focus(focus);
            }
        }
Exemple #4
0
        private void Popup_Opened(object sender, EventArgs e)
        {
            LimeMsg.Debug("Popup_Opened");

            // Subscribe to every parent scrollviewers to detect scrolling there (and close the DropDown)
            if (_ScrollChangedEventHandler == null)
            {
                _ScrollChangedEventHandler = new ScrollChangedEventHandler(ScrollViewer_ScrollChanged);
                foreach (var scrollViewer in GetParentScrollViewers())
                {
                    scrollViewer.ScrollChanged += _ScrollChangedEventHandler;
                }
            }

            // Autosize
            if (wxPopup.Placement == PlacementMode.Bottom || wxPopup.Placement == PlacementMode.Top)
            {
                wxPopupBorder.MinWidth   = wxMain.ActualWidth;
                wxPopup.HorizontalOffset = wxMain.Margin.Left;
            }

            var item = WPF.FindFirstChild <TextBox>(wxPicker);

            if (item != null)
            {
                Keyboard.Focus(item);
            }
        }
        public FunctionNamePrompt(string name, string currentCategory, IEnumerable <string> categories, string description)
        {
            InitializeComponent();

            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            // set the current name
            this.nameBox.Focus();
            this.nameBox.Text = name;

            // set the description
            this.DescriptionInput.Text = description;

            // sort the categories
            var sortedCats = categories.ToList();

            sortedCats.Sort();

            foreach (var item in sortedCats)
            {
                this.categoryBox.Items.Add(item);
            }

            // set the current category
            this.categoryBox.Text = currentCategory;
        }
Exemple #6
0
        public void SetViewController(WPF.TimeEntryEditViewController timeEntryEditViewController)
        {
            this.controller = timeEntryEditViewController;

            timeEntryEditViewController.MouseDown += (sender, args) => this.mouseDown(args);
            timeEntryEditViewController.MouseMove += (sender, args) => this.mouseMove(args);
        }
 private void DigitalMeterView_HandleDestroyed(object sender, EventArgs e)
 {
     if (WPF != null)
     {
         WPF.Dispose();
     }
 }
Exemple #8
0
        private void OnSampleFileSelected(object sender, RoutedEventArgs e)
        {
            var dp           = e.OriginalSource as DependencyObject;
            var treeViewItem = WPF.FindUpVisualTree <TreeViewItem>(dp) as TreeViewItem;

            if (sampleFileTreeView.SelectedItem != null)
            {
                treeViewItem.IsExpanded = !treeViewItem.IsExpanded;
            }

            var filePath = (sampleFileTreeView.SelectedItem as SampleFileEntry).FilePath;

            if (string.IsNullOrEmpty(filePath))
            {
                return;
            }

            if (!Path.GetExtension(filePath).Equals(".dyn"))
            {
                return;
            }

            var dvm = this.dynamoViewModel;

            if (dvm.OpenCommand.CanExecute(filePath))
            {
                dvm.OpenCommand.Execute(filePath);
            }
        }
Exemple #9
0
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            var view = WPF.FindUpVisualTree <DynamoView>(this);

            dynSettings.ReturnFocusToSearch();

            view.mainGrid.Focus();

            var node = this.ViewModel.NodeModel;

            if (node.WorkSpace.Nodes.Contains(node))
            {
                Guid nodeGuid = this.ViewModel.NodeModel.GUID;
                dynSettings.Controller.DynamoViewModel.ExecuteCommand(
                    new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers));
            }
            if (e.ClickCount == 2)
            {
                if (ViewModel.GotoWorkspaceCommand.CanExecute(null))
                {
                    e.Handled = true;
                    ViewModel.GotoWorkspaceCommand.Execute(null);
                }
            }
        }
Exemple #10
0
 private void WPFInWinForm_HandleDestroyed(object sender, EventArgs e)
 {
     if (WPF != null)
     {
         WPF.Dispose();
     }
 }
        public SearchView()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SearchView_Loaded);

            SearchTextBox.IsVisibleChanged += delegate
            {
                DynamoCommands.SearchCommand.Execute(null);
                Keyboard.Focus(this.SearchTextBox);
                var view = WPF.FindUpVisualTree <DynamoView>(this);
                SearchTextBox.InputBindings.AddRange(view.InputBindings);
            };

            SearchTextBox.GotKeyboardFocus += delegate
            {
                if (SearchTextBox.Text == "Search...")
                {
                    SearchTextBox.Text = "";
                }

                SearchTextBox.Foreground = Brushes.White;
            };

            SearchTextBox.LostKeyboardFocus += delegate
            {
                SearchTextBox.Foreground = Brushes.Gray;
            };
        }
Exemple #12
0
        public PackageManagerDownloadView()
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            InitializeComponent();
        }
Exemple #13
0
 public NodeHelpPrompt(NodeModel node)
 {
     this.DataContext = node;
     this.Owner       = WPF.FindUpVisualTree <DynamoView>(this);
     //this.Owner = dynSettings.Bench;
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     InitializeComponent();
 }
Exemple #14
0
 public dynEditWindow()
 {
     InitializeComponent();
     //this.Owner = dynSettings.Bench;
     this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
     this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     this.editText.Focus();
 }
Exemple #15
0
        private void ListBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            LimeMsg.Debug("ListBox_PreviewKeyDown: {0}", e.Key);

            var wxobj = e.OriginalSource as ListBoxItem;

            if (wxobj == null)
            {
                return;
            }
            if (Keyboard.Modifiers != 0)
            {
                return;
            }

            bool close = false;

            switch (e.Key)
            {
            case Key.Enter:
                var wxcheck = WPF.FindFirstChild <CheckBox>(wxobj);
                if (wxcheck != null)
                {
                    wxcheck.IsChecked = !wxcheck.IsChecked;
                    e.Handled         = true;
                }
                else
                {
                    close = true;
                }
                break;

            case Key.Escape:
                var prop = wxMain.DataContext as LimeProperty;
                Cache = prop.Value;
                close = true;
                break;

            case Key.Up:
                close = wxMenu.SelectedIndex == 0;
                break;

            case Key.Right:
            case Key.Left:
                close = true;
                break;
            }


            if (close)
            {
                wxPopup.IsOpen   = false;
                wxMain.IsChecked = false;
                Keyboard.Focus(wxMain);
                e.Handled = true;
            }
        }
        public PackageManagerSearchView(PackageManagerSearchViewModel pm)
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.DataContext = pm;
            InitializeComponent();
        }
        public InstalledPackagesView()
        {
            //this.Owner = dynSettings.Bench;
            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            this.DataContext = dynSettings.PackageLoader;
            InitializeComponent();
        }
Exemple #18
0
        //void PackageManagerClient_RequestSetLoginState(object sender, LoginStateEventArgs e)
        //{
        //    PackageManagerLoginState.Text = e.Text;
        //    PackageManagerLoginButton.IsEnabled = e.Enabled;
        //}

        void _vm_RequestSaveImage(object sender, ImageSaveEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Path))
            {
                //var bench = dynSettings.Bench;

                //if (bench == null)
                //{
                //    DynamoLogger.Instance.Log("Cannot export bench as image without UI.  No image wil be exported.");
                //    return;
                //}

                var control = WPF.FindChild <DragCanvas>(this, null);

                double width  = 1;
                double height = 1;

                // connectors are most often within the bounding box of the nodes and notes

                foreach (dynNodeModel n in dynSettings.Controller.DynamoModel.CurrentSpace.Nodes)
                {
                    width  = Math.Max(n.X + n.Width, width);
                    height = Math.Max(n.Y + n.Height, height);
                }

                foreach (dynNoteModel n in dynSettings.Controller.DynamoModel.CurrentSpace.Notes)
                {
                    width  = Math.Max(n.X + n.Width, width);
                    height = Math.Max(n.Y + n.Height, height);
                }

                var rtb = new RenderTargetBitmap(Math.Max(1, (int)width),
                                                 Math.Max(1, (int)height),
                                                 96,
                                                 96,
                                                 System.Windows.Media.PixelFormats.Default);

                rtb.Render(control);

                //endcode as PNG
                var pngEncoder = new PngBitmapEncoder();
                pngEncoder.Frames.Add(BitmapFrame.Create(rtb));

                try
                {
                    using (var stm = File.Create(e.Path))
                    {
                        pngEncoder.Save(stm);
                    }
                }
                catch
                {
                    DynamoLogger.Instance.Log("Failed to save the Workspace an image.");
                }
            }
        }
        public PublishPackageView(PublishPackageViewModel packageViewModel)
        {
            this.DataContext = packageViewModel;
            packageViewModel.PublishSuccess += PackageViewModelOnPublishSuccess;

            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            InitializeComponent();
        }
Exemple #20
0
        void dynPort_Loaded(object sender, RoutedEventArgs e)
        {
            //Debug.WriteLine("Port loaded.");
            canvas = WPF.FindUpVisualTree <Dynamo.Controls.DragCanvas>(this);

            if (ViewModel != null)
            {
                ViewModel.UpdateCenter(CalculateCenter());
            }
        }
Exemple #21
0
        private void Form_Load(object sender, EventArgs e)
        {
            questions                  = ReadQuestionsFromDatabase();
            wpf                        = new WPF(server, questions);
            wpf.IPadressText.Text      = "Ip-Address: " + LocalIpAddress();
            wpf.inGameLabel.Visibility = Visibility.Hidden;
            SetQuestionListData();

            new Thread(() => server.RunServer(questions)).Start();
            elementHost1.Child = wpf;
        }
Exemple #22
0
        private void btnYearInsert_Click(object sender, RoutedEventArgs e)
        {
            var year = int.Parse(txtBoxYear.Text);
            var time = new DateTime(year, 1, 1);

            var wpf = new WPF();

            wpf.InsertSeason(new Season {
                Year = time
            });
        }
Exemple #23
0
        // --------------------------------------------------------------------------------------------------
        #region GUI Callbacks

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Restore window state/dimensions
            Handle = ((HwndSource)PresentationSource.FromVisual(this)).Handle;
            var wcfg = Global.Local.WindowSettings;

            if (wcfg.Length > 0)
            {
                WPF.SetWindowPlacement(Handle, wcfg, this);
            }
        }
Exemple #24
0
        public EditWindow()
        {
            InitializeComponent();

            this.Owner = WPF.FindUpVisualTree <DynamoView>(this);
            this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            this.editText.Focus();

            // do not accept value if user closes
            this.Closing += (sender, args) => this.DialogResult = false;
        }
Exemple #25
0
        private void NickNameBlock_OnMouseEnter(object sender, MouseEventArgs e)
        {
            TextBlock textBlock           = sender as TextBlock;
            string    tooltipContent      = ViewModel.NickName + '\n' + ViewModel.Description;
            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);
            Point     topLeft             = textBlock.TranslatePoint(new Point(0, 0), containingWorkspace);
            double    actualWidth         = textBlock.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            double    actualHeight        = textBlock.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
            Point     botRight            = new Point(topLeft.X + actualWidth, topLeft.Y + actualHeight);

            ViewModel.ShowTooltipCommand.Execute(new InfoBubbleDataPacket(InfoBubbleViewModel.Style.NodeTooltip, topLeft,
                                                                          botRight, tooltipContent, InfoBubbleViewModel.Direction.Bottom));
        }
Exemple #26
0
 private void wxMain_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (Keyboard.FocusedElement != wxMain)
     {
         var wxobj = WPF.FindFirstParent <ScrollViewer>(sender as UIElement);
         if (wxobj != null)
         {
             e.Handled = true;
             var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
             e2.RoutedEvent = MouseWheelEvent;
             wxobj.RaiseEvent(e2);
         }
     }
 }
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            dynSettings.ReturnFocusToSearch();
            //dynSettings.Bench.mainGrid.Focus();
            var view = WPF.FindUpVisualTree <DynamoView>(this);

            view.mainGrid.Focus();

            ViewModel.SelectCommand.Execute(null);
        }
Exemple #28
0
        void DynamoViewModelRequestSaveImage(object sender, ImageSaveEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Path))
            {
                var control = WPF.FindChild <DragCanvas>(this, null);

                double width  = 1;
                double height = 1;

                // connectors are most often within the bounding box of the nodes and notes

                foreach (NodeModel n in dynamoViewModel.Model.CurrentWorkspace.Nodes)
                {
                    width  = Math.Max(n.X + n.Width, width);
                    height = Math.Max(n.Y + n.Height, height);
                }

                foreach (NoteModel n in dynamoViewModel.Model.CurrentWorkspace.Notes)
                {
                    width  = Math.Max(n.X + n.Width, width);
                    height = Math.Max(n.Y + n.Height, height);
                }

                var rtb = new RenderTargetBitmap(Math.Max(1, (int)width),
                                                 Math.Max(1, (int)height),
                                                 96,
                                                 96,
                                                 System.Windows.Media.PixelFormats.Default);

                rtb.Render(control);

                //endcode as PNG
                var pngEncoder = new PngBitmapEncoder();
                pngEncoder.Frames.Add(BitmapFrame.Create(rtb));

                try
                {
                    using (var stm = File.Create(e.Path))
                    {
                        pngEncoder.Save(stm);
                    }
                }
                catch
                {
                    dynamoViewModel.Model.Logger.Log("Failed to save the Workspace an image.");
                }
            }
        }
Exemple #29
0
        public SearchView()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SearchView_Loaded);

            SearchTextBox.IsVisibleChanged += delegate
            {
                if (SearchTextBox.IsVisible)
                {
                    DynamoCommands.SearchCommand.Execute(null);
                    Keyboard.Focus(this.SearchTextBox);
                    var view = WPF.FindUpVisualTree <DynamoView>(this);
                    SearchTextBox.InputBindings.AddRange(view.InputBindings);
                }
            };
        }
Exemple #30
0
        private void SetupAndShowTooltip(UIElement sender, InfoBubbleViewModel.Direction direction)
        {
            string content      = "";
            double actualWidth  = 0;
            double actualHeight = 0;

            switch (direction)
            {
            case InfoBubbleViewModel.Direction.Bottom:
                TextBlock tb = sender as TextBlock;
                content = ViewModel.Description;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = tb.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = tb.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;

            case InfoBubbleViewModel.Direction.Left:
            case InfoBubbleViewModel.Direction.Right:
                ContentPresenter nodePort = sender as ContentPresenter;
                content = (nodePort.Content as PortViewModel).ToolTipContent;
                if (string.IsNullOrWhiteSpace(content))
                {
                    return;
                }

                actualWidth  = nodePort.ActualWidth * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                actualHeight = nodePort.ActualHeight * dynSettings.Controller.DynamoViewModel.CurrentSpaceViewModel.Zoom;
                break;
            }

            UIElement containingWorkspace = WPF.FindUpVisualTree <TabControl>(this);

            InfoBubbleDataPacket data = new InfoBubbleDataPacket();

            data.Text                = content;
            data.Style               = InfoBubbleViewModel.Style.NodeTooltip;
            data.TopLeft             = sender.TranslatePoint(new Point(0, 0), containingWorkspace);
            data.BotRight            = new Point(data.TopLeft.X + actualWidth, data.TopLeft.Y + actualHeight);
            data.ConnectingDirection = direction;

            StartDelayedTooltipFadeIn(data);
        }
Exemple #31
0
 /// <summary>
 /// Load up our xaml window
 /// </summary>
 /// <param name="uiPath"></param>
 /// <returns></returns>
 internal UserControl LoadWindowContent(string uiPath)
 {
     try
     {
         lock (ContentLock)
         {
             _windowContent = WPF.LoadWindowContent(Resources.MainView);
             //LoadResourceForWindow(Path.Combine(uiPath, "Dictionary.xaml"), _windowContent);
             return(_windowContent);
         }
     }
     catch (Exception ex)
     {
         Logger.Error("Exception loading window content! {0}", ex);
     }
     return(null);
 }
Exemple #32
0
        private void topControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (ViewModel == null)
            {
                return;
            }

            dynSettings.ReturnFocusToSearch();
            //dynSettings.Bench.mainGrid.Focus();
            var view = WPF.FindUpVisualTree <DynamoView>(this);

            view.mainGrid.Focus();

            Guid nodeGuid = this.ViewModel.NodeModel.GUID;

            dynSettings.Controller.DynamoViewModel.ExecuteCommand(
                new DynCmd.SelectModelCommand(nodeGuid, Keyboard.Modifiers));
        }
 void LoadImage(WPF.UCs.ImgBox pImage, string mylocalImage, string imgPath)
 {
     try
     {
         if (File.Exists(mylocalImage) && !m_blnForced2GetImagesFromFTP)
         {
             pImage.fullName = mylocalImage;
             pImage.LoadIMg();
             pImage.Tag = mylocalImage;
             return;
         }
         if (!string.IsNullOrEmpty(imgPath))
         {
             if (!PropertyLib._FTPProperties.IamLocal || m_blnForced2GetImagesFromFTP)
             {
                 FtpClient.CurrentDirectory = string.Format("{0}{1}", _FtpClientCurrentDirectory,
                     objChitiet.IdChitietchidinh.ToString());
                 if (FtpClient.FtpFileExists(FtpClient.CurrentDirectory + imgPath))
                 {
                     string sPath1 = string.Format(@"{0}\{1}\{2}", _baseDirectory,
                     objChitiet.IdChitietchidinh.ToString(), imgPath);
                     Utility.CreateFolder(sPath1);
                     FtpClient.Download(imgPath, sPath1, true);
                     pImage.fullName = sPath1;
                     pImage.LoadIMg();
                     pImage.Tag = sPath1;
                 }
                 else
                 {
                     pImage.fullName = path + @"\Path\noimage.jpg";
                     pImage.LoadIMg();
                     pImage.Tag = "";
                 }
             }
             else//Ảnh trên chính máy tính này
             {
                 pImage.fullName = imgPath;
                 pImage.LoadIMg();
                 pImage.Tag = imgPath;
             }
         }
     }
     catch
     {
     }
     finally
     {
         if (pImage._img.Source == null)
         {
             pImage.fullName = path + @"\Path\noimage.jpg";
             pImage.LoadIMg();
             pImage.Tag = "";
         }
     }
 }
 private void RemoveHighlightOnButton(WPF.ImageButton button)
 {
     button.Background = null;
     button.BorderBrush = null;
 }
 public void SetEditPopup(WPF.TimeEntryEditViewController editView)
 {
     editView.SetTimer(this.timerEditViewController);
 }
 private void HighlightButton(WPF.ImageButton button, Media.SolidColorBrush highlightBrush, Media.SolidColorBrush borderBrush)
 {
     button.Background = highlightBrush;
     button.BorderBrush = borderBrush;
 }