Exemplo n.º 1
0
        /// <summary>
        /// Confirms the specified title.
        /// </summary>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        /// <param name="onOK">The on OK.</param>
        /// <param name="onCancel">The on cancel.</param>
        public static void Confirm(string title, string message, System.Action onOK, System.Action onCancel = null)
        {
            var dialogParameters = new DialogParameters {
                Header = title,
                Content = message
            };
            dialogParameters.Closed += (sender, args) => {
                var result = args.DialogResult;
                if (result.HasValue && result.Value) {
                    onOK();
                    return;
                }

                if (onCancel != null)
                    onCancel();
            };
            Confirm(dialogParameters);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     设置提醒对话框
 /// </summary>
 /// <param name="header">对话框标题</param>
 /// <param name="okContent">Ok按钮显示内容</param>
 /// <param name="content">显示内容</param>
 /// <param name="fontSize">字号</param>
 /// <param name="width">对话框宽度</param>
 /// <returns>提醒对话框</returns>
 private static DialogParameters SetAlert(
     string header,
     string okContent,
     string content,
     int fontSize,
     int width)
 {
     var alert = new DialogParameters
         {
             Header = header,
             OkButtonContent = okContent,
             Content = new TextBlock
                 {
                     Text = content,
                     FontFamily = new FontFamily("Microsoft YaHei UI"),
                     FontSize = fontSize,
                     TextWrapping = TextWrapping.Wrap,
                     Width = width,
                 },
             Closed = null,
         };
     return alert;
 }
Exemplo n.º 3
0
        public void Edit()
        {
            var parameters = new DialogParameters();

            foreach (var weight in Weights)
            {
                weight.WeightText = weight.Weight.ToString();
            }
            var clonedWeights = new ObservableCollection <IWeightViewModel>(Weights);

            parameters.Add(nameof(Weights), clonedWeights);

            dialogService.ShowDialog(DialogNames.EditWeightsDialog, parameters, (r) =>
            {
                if (r.Result == ButtonResult.OK)
                {
                    var modifiedWeights = r.Parameters.GetValue <ObservableCollection <IWeightViewModel> >(nameof(Weights));

                    var weightsToUpdate = Weights.Where(w => modifiedWeights.Any(mf => mf.Id == w.Id));
                    var weightsToDelete = Weights.Where(mf => !modifiedWeights.Any(w => w.Id == mf.Id));

                    foreach (var wu in weightsToUpdate)
                    {
                        wu.IsDirty = true;
                        wu.Update();
                    }

                    foreach (var wd in weightsToDelete)
                    {
                        petsData.DeleteWeightById(wd.Id.Value);
                    }

                    LoadData();
                }
            });
        }
        private async Task Delete(int id)
        {
            string deleteContent = localizer["Delete Content"];
            var    parameters    = new DialogParameters();

            parameters.Add("ContentText", string.Format(deleteContent, id));
            var options = new DialogOptions()
            {
                CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true, DisableBackdropClick = true
            };
            var dialog = _dialogService.Show <Shared.Dialogs.DeleteConfirmation>("Delete", parameters, options);
            var result = await dialog.Result;

            if (!result.Cancelled)
            {
                var response = await _brandManager.DeleteAsync(id);

                if (response.Succeeded)
                {
                    await Reset();

                    await hubConnection.SendAsync("UpdateDashboardAsync");

                    _snackBar.Add(localizer[response.Messages[0]], Severity.Success);
                }
                else
                {
                    await Reset();

                    foreach (var message in response.Messages)
                    {
                        _snackBar.Add(localizer[message], Severity.Error);
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static void Confirm(string title, string message, System.Action onOK, System.Action onCancel = null)
        {
            var dialogParameters = new DialogParameters
            {
                Header  = title,
                Content = message
            };

            dialogParameters.Closed += (sender, args) =>
            {
                var result = args.DialogResult;
                if (result.HasValue && result.Value)
                {
                    onOK();
                    return;
                }

                if (onCancel != null)
                {
                    onCancel();
                }
            };
            Confirm(dialogParameters);
        }
Exemplo n.º 6
0
        private void DeleteEnquiryStatusCommandExecute()
        {
            var dp = new DialogParameters {
                Content = "Are you sure you want to delete " + ((EnquiryStatus)SelectedObject).Status + "?"
            };

            dp.Content            += "\n";
            dp.Header              = "Warning!";
            dp.OkButtonContent     = "Yes";
            dp.CancelButtonContent = "No";
            dp.Closed              = ConfirmDeleteClose;
            dp.Owner = Application.Current.MainWindow;

            RadWindow.Confirm(dp);
            if (_yesNo)
            {
                _adminDataUnit.EnquiryStatusesRepository.Delete((EnquiryStatus)SelectedObject);
                _adminDataUnit.SaveChanges();
                EnquiryStatuses.Remove((EnquiryStatus)SelectedObject);
                _yesNo = false;
            }

            SelectedObject = null;
        }
Exemplo n.º 7
0
        public void TestMethod0040()
        {
            var testEntity = TestUtilLib.GenarateRandomTodoTask();

            var dialogParameters = new DialogParameters {
                { nameof(DialogWindowEditViewModel.Parameter), new DialogWindowEditViewModel.Parameter
                  {
                      TodoTask = testEntity,
                  } }
            };

            var vm = new DialogWindowEditViewModel();

            vm.OnDialogOpened(dialogParameters);

            vm.CancelClick.Execute();

            // この画面でレコードが更新・登録・削除される訳ではない
            using (var context = new EfDbContext()) Assert.AreEqual(0, context.TodoTasks.Count());

            // カバレッジ 100% にするためのコード
            vm.RequestClose += new Action <IDialogResult>(delegate { });
            vm.CancelClick.Execute();
        }
        //private void OnCancel()
        //{
        //    Done?.Invoke();
        //}
        private async void OnSave()
        {
            string errors = "";

            if (GL.GLId == 0)
            {
                //   var editingGL = Mapper.Map<EditableGL, GL>(GL);
                if (GL.Title == null || GL.Title == "")
                {
                    errors += "عنوان خالی می باشد" + Environment.NewLine;
                }
                if (GL.GLCode == 0)
                {
                    errors += "کد حساب اشتباه می باشد" + Environment.NewLine;
                }
                if (_gLsService.HasTitle(GL.Title, GL.GLId))
                {
                    errors += ("عنوان نباید تکراری باشد") + Environment.NewLine;
                }
                ;
                if (_gLsService.Hasduplicate(GL.GLCode, GL.GLId))
                {
                    errors += ("کد  حساب نباید تکراری باشد") + Environment.NewLine;
                }
            }
            else
            {
                if (GL.Title == null || GL.Title == "")
                {
                    errors += "عنوان خالی می باشد" + Environment.NewLine;
                }
                if (GL.GLCode == 0)
                {
                    errors += "کد حساب اشتباه می باشد" + Environment.NewLine;
                }
                if (await _gLsService.HasTitleTree(GL.Title, GL.GLId))
                {
                    errors += ("عنوان نباید تکراری باشد") + Environment.NewLine;
                }
                ;
                if (await _gLsService.HasduplicateTree(GL.GLCode, GL.GLId))
                {
                    errors += ("کد  حساب نباید تکراری باشد") + Environment.NewLine;
                }
            }
            if (errors.Length > 0)
            {
                DialogParameters parameters = new DialogParameters();
                parameters.OkButtonContent = "بستن";
                parameters.Header          = "اخطار";
                parameters.Content         = errors;
                RadWindow.Alert(parameters);
            }
            else
            {
                try
                {
                    SaveClicked(GL);
                }
                catch (Exception ex)
                {
                    Failed(ex);
                }
                finally
                {
                    GL = null;
                }
            }
        }
		public static void Confirm(this IWindowManager windowManager, DialogParameters dialogParameters)
		{
			TelerikWindowManager.Confirm(dialogParameters);
		}
Exemplo n.º 10
0
        public override async Task <(bool Changed, SongData song)> Execute(SongData song)
        {
            log.Info($"Auto Tag: Processing file: {song.FullFileName}");
            var recordings = await GetRecordings(song.FullFileName);

            if (recordings.Count == 0)
            {
                log.Info("Auto Tag: Couldn't identify song");
                return(false, song);
            }

            var releases = new List <Release>();
            // We might get back a lot of Recordings, so condense the list to recordings, which have
            // the same duration
            var tmpRecordings = new List <MusicBrainzRecording>();

            foreach (var recording in recordings)
            {
                if (recording.Length != null)
                {
                    var timeDiff = Math.Abs(song.DurationTimespan.TotalMilliseconds / 1000 - (int)recording.Length / 1000);
                    if (timeDiff <= 5)
                    {
                        foreach (var release in recording.Releases)
                        {
                            releases.Add(release);
                            var mbRecording = new MusicBrainzRecording
                            {
                                Id         = recording.Id,
                                TrackId    = release.Media[0].Tracks[0].Id,
                                Title      = recording.Title,
                                Duration   = $"{TimeSpan.FromMilliseconds((int) recording.Length).Hours:D2}:{TimeSpan.FromMilliseconds((int) recording.Length).Minutes:D2}:{TimeSpan.FromMilliseconds((int) recording.Length).Seconds:D2}",
                                AlbumId    = release.Id,
                                ArtistId   = (recording.Credits != null && recording.Credits.Count > 0) ? recording.Credits[0].Artist.Id : "",
                                AlbumTitle = release.Title,
                                Country    = release.Country,
                                Date       = release.Date
                            };
                            mbRecording.Artist = JoinArtists(recording.Credits);
                            tmpRecordings.Add(mbRecording);
                        }
                    }
                }
            }

            var selectedRecording = new MusicBrainzRecording();
            var albumFound        = false;

            // We have already a Album from a previous search. Check,is this is found in the
            // releases from this song
            if (_album != null)
            {
                var release = releases.FirstOrDefault(r => r.Id == _album.Id);
                if (release != null && release.Id != String.Empty)
                {
                    selectedRecording = tmpRecordings.First(r => r.AlbumId == release.Id);
                    _album            = release;
                    albumFound        = true;
                }
            }

            if (!albumFound)
            {
                // And now we remove duplicate Recordings and Countries
                var condensedRecordings = tmpRecordings
                                          .GroupBy(r => new { r.AlbumTitle, r.Country })
                                          .Select(g => g.First())
                                          .ToList();

                var dialogResult = ButtonResult.None;
                var parameters   = new DialogParameters {
                    { "recordings", condensedRecordings }
                };
                DialogService.ShowDialogInAnotherWindow("IdentifySongView", "DialogWindowView", parameters, r =>
                {
                    dialogResult = r.Result;
                    if (dialogResult == ButtonResult.OK)
                    {
                        r.Parameters.TryGetValue("selectedrecording", out selectedRecording);
                    }
                });
            }

            if (selectedRecording.Id != string.Empty)
            {
                if (!albumFound)
                {
                    _album = await GetAlbum(selectedRecording.AlbumId);
                }

                song.Title       = selectedRecording.Title;
                song.Artist      = selectedRecording.Artist;
                song.AlbumArtist = _album.Credits != null?JoinArtists(_album.Credits) : "";

                song.Album = _album.Title;
                if (_album.Date != null && _album.Date.Length >= 4)
                {
                    song.Year = Convert.ToInt32(_album.Date.Substring(0, 4));
                }

                if (_album.Media != null && _album.Media.Count > 0)
                {
                    song.DiscNumber        = (uint)_album.Media[0].Position;
                    song.TrackCount        = (uint)_album.Media[0].TrackCount;
                    song.TrackNumber       = (uint)_album.Media[0].Tracks.First(t => t.Id == selectedRecording.TrackId).Position;
                    song.MusicBrainzDiscId = _album.Media[0].Discs != null ? _album.Media[0].Discs[0].Id : "";
                }

                // MusicBrainz Properties
                song.MusicBrainzArtistId       = selectedRecording.ArtistId;
                song.MusicBrainzReleaseId      = selectedRecording.AlbumId;
                song.MusicBrainzTrackId        = selectedRecording.TrackId;
                song.MusicBrainzReleaseCountry = selectedRecording.Country;
            }

            var coverArtUrl = _album.CoverArtArchive != null && _album.CoverArtArchive.Front
        ? string.Format(@"http://coverartarchive.org/release/{0}/front.jpg", _album.Id)
        : null;

            if (coverArtUrl != null)
            {
                _pic = new Picture();
                if (_pic.ImageFromUrl(coverArtUrl))
                {
                    song.Pictures.Clear();
                    song.Pictures.Add(_pic);
                }
            }

            return(true, song);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 设置确认对话框
 /// </summary>
 /// <param name="header">对话框标题</param>
 /// <param name="okContent">Ok按钮显示内容</param>
 /// <param name="cancelContent">Cancel按钮显示内容</param>
 /// <param name="content">显示内容</param>
 /// <param name="fontSize">字号</param>
 /// <param name="width">对话框宽度</param>
 /// <param name="closed">关闭对话框后执行的操作</param>
 /// <returns>确认对话框</returns>
 protected DialogParameters SetConfirm(
     string header,
     string okContent,
     string cancelContent,
     string content,
     int fontSize,
     int width,
     EventHandler<WindowClosedEventArgs> closed)
 {
     var confirm = new DialogParameters
     {
         Header = header,
         OkButtonContent = okContent,
         CancelButtonContent = cancelContent,
         Content = new TextBlock
         {
             Text = content,
             FontFamily = new FontFamily("Microsoft YaHei UI"),
             FontSize = fontSize,
             TextWrapping = TextWrapping.Wrap,
             Width = width,
         },
         Closed = closed,
     };
     return confirm;
 }
Exemplo n.º 12
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if ((checkBoxColour.IsChecked ?? false) && radComboBoxColour.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for Colour.";
                RadWindow.Alert(param);
                return;
            }
            else if ((checkBoxElectricals.IsChecked ?? false) && radComboBoxElectricals.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for Electricals.";
                RadWindow.Alert(param);
                return;
            }
            if ((checkBoxLandscaping.IsChecked ?? false) && radComboBoxLandscaping.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for Landscaping.";
                RadWindow.Alert(param);
                return;
            }
            else if ((checkBoxAppliances.IsChecked ?? false) && radComboBoxAppliances.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for Appliances.";
                RadWindow.Alert(param);
                return;
            }
            if ((checkBoxCarpets.IsChecked ?? false) && radComboBoxCarpets.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for Carpets.";
                RadWindow.Alert(param);
                return;
            }
            else if ((checkBoxTimberFloor.IsChecked ?? false) && radComboBoxTimberFloor.SelectedValue.ToString() == "0")
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Select Studio M revision(s)";
                param.Content = "Please select a person for TimberFloor.";
                RadWindow.Alert(param);
                return;
            }
            else
            {
                string revisionTypeIds   = string.Empty;
                string assignedToUserIds = string.Empty;

                if (checkBoxColour.IsChecked ?? false)
                {
                    revisionTypeIds   += ",7";
                    assignedToUserIds += "," + radComboBoxColour.SelectedValue.ToString();
                }
                if (checkBoxElectricals.IsChecked ?? false)
                {
                    revisionTypeIds   += ",8";
                    assignedToUserIds += "," + radComboBoxElectricals.SelectedValue.ToString();
                }
                if (checkBoxLandscaping.IsChecked ?? false)
                {
                    revisionTypeIds   += ",29";
                    assignedToUserIds += "," + radComboBoxLandscaping.SelectedValue.ToString();
                }
                if (checkBoxAppliances.IsChecked ?? false)
                {
                    revisionTypeIds   += ",28";
                    assignedToUserIds += "," + radComboBoxAppliances.SelectedValue.ToString();
                }
                if (checkBoxCarpets.IsChecked ?? false)
                {
                    revisionTypeIds   += ",12";
                    assignedToUserIds += "," + radComboBoxCarpets.SelectedValue.ToString();
                }
                if (checkBoxTimberFloor.IsChecked ?? false)
                {
                    revisionTypeIds   += ",22";
                    assignedToUserIds += "," + radComboBoxTimberFloor.SelectedValue.ToString();
                }

                if (!string.IsNullOrWhiteSpace(revisionTypeIds))
                {
                    BusyIndicator1.IsBusy      = true;
                    BusyIndicator1.BusyContent = "Creating Ready for Studio M Split Revisions...";
                    if ((App.Current as App).SelectedEstimateRevisionTypeID == 5)
                    {
                        // CSC - in progress select complete Ready for Studio M needs current one also to move Completed
                        revisionTypeIds   = "6" + revisionTypeIds;
                        assignedToUserIds = (App.Current as App).CurrentUserId.ToString() + assignedToUserIds;
                    }
                    else
                    {
                        // remove the initial comma ,
                        revisionTypeIds = revisionTypeIds.Substring(1);
                    }
                    _mrsClient.CreateSplitStudioMRevisionsCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(mrsClient_CreateSplitStudioMRevisionsCompleted);
                    _mrsClient.CreateSplitStudioMRevisionsAsync(_estimateRevisionId, revisionTypeIds, assignedToUserIds, (App.Current as App).CurrentUserId);
                }
                else
                {
                    DialogParameters param = new DialogParameters();
                    param.Header  = "Select Studio M revision(s)";
                    param.Content = "Please assign one or more Studio M revision(s).";
                    RadWindow.Alert(param);
                    return;
                }
            }
        }
        private Popup createModalPopup(FrameworkElement element, FrameworkElement target, DialogParameters dialogParameters)
        {
            var popup = new Popup();

            popup.Name = "ModalPopup";


            popup.VerticalAlignment   = VerticalAlignment.Stretch;
            popup.HorizontalAlignment = HorizontalAlignment.Stretch;
            popup.Width  = target.ActualWidth;
            popup.Height = target.ActualHeight;
            //  popup.IsOpen = false;
            var grid = new Grid();

            grid.Background = dialogParameters.DialogScreenLayerBackground;

            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
            grid.VerticalAlignment   = VerticalAlignment.Stretch;
            Binding minWBinding = new Binding();

            minWBinding.Path   = new PropertyPath("ActualWidth");
            minWBinding.Mode   = BindingMode.TwoWay;
            minWBinding.Source = target;
            grid.SetBinding(FrameworkElement.WidthProperty, minWBinding);


            Binding minHBinding = new Binding();

            minHBinding.Path   = new PropertyPath("ActualHeight");
            minHBinding.Mode   = BindingMode.TwoWay;
            minHBinding.Source = target;
            grid.SetBinding(FrameworkElement.HeightProperty, minHBinding);
            var border = new Border();

            border.MinWidth            = 400;
            border.MinHeight           = 400;
            border.Margin              = new Thickness(0, 48, 0, 0);
            border.HorizontalAlignment = HorizontalAlignment.Center;
            border.VerticalAlignment   = VerticalAlignment.Center;

            var contentControl = new ContentControl();

            contentControl.Name = "RootContainer";
            contentControl.HorizontalAlignment        = HorizontalAlignment.Stretch;
            contentControl.VerticalAlignment          = VerticalAlignment.Stretch;
            contentControl.VerticalContentAlignment   = VerticalAlignment.Stretch;
            contentControl.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            contentControl.Transitions = new Windows.UI.Xaml.Media.Animation.TransitionCollection()
            {
                new EntranceThemeTransition()
                {
                    FromVerticalOffset = 220
                }
            };
            contentControl.Content = element;
            border.Child           = contentControl;
            grid.Children.Add(border);

            popup.Child = grid;
            return(popup);
        }
Exemplo n.º 14
0
 public static void Alert(DialogParameters dialogParameters)
 {
     RadWindow.Alert(dialogParameters);
 }
Exemplo n.º 15
0
 private void DebugSaveCommandExecute()
 {
     MessageDialog.ShowDialog(DialogParameters.Success(this.saveService.ReadRaw()));
 }
Exemplo n.º 16
0
        void rw_Closed(object sender, WindowClosedEventArgs e)
        {
            RecordTable table = this.related.Table;
            var changes = table.CreateChangeSet();

            if (changes.HasChanges)
            {
                DialogParameters pars = new DialogParameters();
                pars.Header = String.Empty;
                pars.Content = "Submit Changes ?";
                pars.Closed = this.Dialog_Closed;

                RadWindow.Confirm(pars);
            }
        }
Exemplo n.º 17
0
 public static void Confirm(DialogParameters dialogParameters)
 {
     RadWindow.Confirm(dialogParameters);
 }
        void licenseClient_licenseChange(LicenseStatusEventArg obj)
        {
            System.Diagnostics.Debug.WriteLine(obj.oldStatus + " And " +obj.NewStatus.ToString());
             
            switch (obj.NewStatus)
            {
                case LicenseStatus.joinLicense:
                    {
                        WriteLog("licenseChange 이벤트 발생 " + LicenseStatus.joinLicense.ToString());

                        Dispatcher.BeginInvoke(delegate(){
                           LicenseState.Fill = new SolidColorBrush(Colors.Blue);});
                    }
                    break;
                case LicenseStatus.fullLicense:
                    {
                        WriteLog("licenseChange 이벤트 발생 current is " + LicenseStatus.fullLicense.ToString());

                        Dispatcher.BeginInvoke(delegate()
                        {
                            var parameters = new DialogParameters()
                            {
                                Content = LicenseStatus.fullLicense.ToString() ,
                                Theme = new Windows8Theme()
                            };

                            RadWindow.Alert(parameters);

                            LicenseState.Fill = new SolidColorBrush(Colors.Yellow);
                        });
                    }

                    break;
                case LicenseStatus.stopConnection:
                    {
                        WriteLog("licenseChange 이벤트 발생 " + LicenseStatus.stopConnection.ToString());
                        
                        Dispatcher.BeginInvoke(delegate(){
                            LicenseState.Fill = new SolidColorBrush(Colors.Red);});
                    }
                    break;
                case LicenseStatus.reConnectLicense:
                    {
                        WriteLog("licenseChange 이벤트 발생 " + LicenseStatus.reConnectLicense.ToString());

                        Dispatcher.BeginInvoke(delegate(){
                            LicenseState.Fill = new SolidColorBrush(Colors.Green);});
                    }
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 19
0
 public static void Prompt(DialogParameters dialogParameters)
 {
     RadWindow.Prompt(dialogParameters);
 }
 /// <summary>
 /// Opens a Prompt modal window
 /// </summary>
 public static void Prompt(this IWindowManager windowManager, DialogParameters dialogParameters)
 {
     TelerikWindowManager.Prompt(dialogParameters);
 }
        /// <summary>通知メッセーボックスを表示します。</summary>
        /// <param name="dlgService">IDialogService。</param>
        /// <param name="message">表示するメッセージを表す文字列。</param>
        public static void ShowInformationMessage(this IDialogService dlgService, string message)
        {
            var param = new DialogParameters($"Message={message}");

            dlgService.ShowDialog("NotifiedMessageBox", param, null);
        }
        private async void SaveCustomer()
        {
            if (string.IsNullOrEmpty(Firstname))
            {
                await _customDialogService.ShowMessageDialogAsync("Isim Alanı Boş Bırakılamaz.");

                return;
            }
            if (string.IsNullOrEmpty(Lastname))
            {
                await _customDialogService.ShowMessageDialogAsync("Soyad Alanı Boş Bırakılamaz.");

                return;
            }
            if (string.IsNullOrEmpty(ProfessionCode))
            {
                await _customDialogService.ShowMessageDialogAsync("Uzmanlık Alanı Boş Bırakılamaz.");

                return;
            }
            if (string.IsNullOrEmpty(LocationName))
            {
                await _customDialogService.ShowMessageDialogAsync("Kurum Alanı Boş Bırakılamaz.");

                return;
            }

            var confResult = await _customDialogService.ShowConfirmationDialogAsync(Firstname + " " + Lastname + " Kişisini Eklemek Istediğinize Emin Misiniz ?");

            if (confResult == Models.ConfirmationDialogResult.Accepted)
            {
                CustomerData customerData = new CustomerData();
                customerData.CardName           = Firstname + " " + Lastname;
                customerData.LocationName       = LocationName;
                customerData.CardProfessionCode = ProfessionCode;

                if (Application.Current.Properties.ContainsKey("CustomerData"))
                {
                    var list = Application.Current.Properties["CustomerData"] as List <CustomerData>;

                    list.Add(customerData);
                    Application.Current.Properties["CustomerData"] = list;
                }
                else
                {
                    List <CustomerData> localCustomerList = new List <CustomerData>();
                    localCustomerList.Add(customerData);

                    Application.Current.Properties.Add("CustomerData", localCustomerList);
                }

                IDialogParameters parameters = new DialogParameters();
                parameters.Add("Result", true);
                parameters.Add("Model", customerData);

                RequestClose(parameters);
            }
            else
            {
                return;
            }
        }
Exemplo n.º 23
0
 public void ButtonConfirm()
 {
     var parameters = new DialogParameters();
     var box = new TextBlock();
     box.Width = 250;
     box.Text = "Are you sure you like this person well enough that they should get moved over to the selected list? It is very prestigious of course...";
     box.TextWrapping = System.Windows.TextWrapping.Wrap;
     parameters.Content = box;
     parameters.OkButtonContent = "Yes";
     parameters.CancelButtonContent = "No";
     parameters.Closed += OnConfirmClosed;
     RadWindow.Confirm(parameters);
 }
Exemplo n.º 24
0
        public void ShowPasswordGenerationDialog()
        {
            var p = new DialogParameters();

            _dialogService.Show("PasswordGenerationDialog", p, res => { });
        }
        public MainWindowViewModel(IDialogService dialogService)
        {
            this.dialogService = dialogService;
            this.ShowNotificationDialog.Subscribe(_ =>
            {
                // Standard
                //var param = new DialogParameters
                //{
                //    { DialogParameterNames.Message, "Notification" },
                //    { DialogParameterNames.Title, "Notification" },
                //    { DialogParameterNames.WindowStyle, (System.Windows.Style)App.Current.FindResource("dialogStyle") },
                //};
                //this.dialogService.ShowDialog(DialogNames.Notification, param, res => this.ResultMessage.Value = "Notification");

                // Extensions
                this.dialogService.ShowNotification("Notification", "Notification", res => this.ResultMessage.Value = "Notification");
            });
            this.ShowConfirmationDialog.Subscribe(_ =>
            {
                this.dialogService.ShowConfirmation("Confirmation?", "Confirmation", res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        this.ResultMessage.Value = "Confirmed OK";
                    }
                    else if (res.Result == ButtonResult.Cancel)
                    {
                        this.ResultMessage.Value = "Confirmed Cancel";
                    }
                    else
                    {
                        this.ResultMessage.Value = $"Confirmed {res.Result}";
                    }
                });
            });
            this.ShowSingleFolderSelectDialog.Subscribe(_ =>
            {
                this.dialogService.ShowFolderSelectDialog("SingleFolderSelect", false, res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var selectedPath         = res.Parameters.GetValue <IEnumerable <string> >(DialogResultParameterNames.SelectedPaths).First();
                        this.ResultMessage.Value = $"Selected Folder: {selectedPath}";
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel Single Folder Select";
                    }
                });
            });
            this.ShowMultiFolderSelectDialog.Subscribe(_ =>
            {
                this.dialogService.ShowFolderSelectDialog("MultiFolderSelect", true, res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var selectedPaths        = res.Parameters.GetValue <IEnumerable <string> >(DialogResultParameterNames.SelectedPaths);
                        this.ResultMessage.Value = $"Selected Folders:{Environment.NewLine}    {string.Join($"{Environment.NewLine}    ", selectedPaths)}";
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel Multi Folder Select";
                    }
                });
            });
            this.ShowSingleFileSelectDialog.Subscribe(_ =>
            {
                this.dialogService.ShowFileSelectDialog("SingleFileSelect", false, res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var selectedPaths = res.Parameters.GetValue <IEnumerable <string> >(DialogResultParameterNames.SelectedPaths);
                        if (selectedPaths != null && selectedPaths.Any())
                        {
                            this.ResultMessage.Value = $"Selected File: {selectedPaths.First()}";
                        }
                        else
                        {
                            this.ResultMessage.Value = "File Not Selected";
                        }
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel Single File Select";
                    }
                });
            });
            this.ShowMultiFileSelectDialog.Subscribe(_ =>
            {
                var filters = new[]
                {
                    new FileFilter("All Files (*.*)"),
                    new FileFilter("Text File (*.txt; *.csv)", new[] { ".txt", ".csv" }),
                    new FileFilter("Excel File (*.xlsx; *.xlsm; *.xls)", ".xlsx", ".xlsm", ".xls"),
                };
                this.dialogService.ShowFileSelectDialog("MultiFileSelect", true, res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var selectedPaths = res.Parameters.GetValue <IEnumerable <string> >(DialogResultParameterNames.SelectedPaths);
                        if (selectedPaths != null && selectedPaths.Any())
                        {
                            this.ResultMessage.Value = $"Selected Files:{Environment.NewLine}    {string.Join($"{Environment.NewLine}    ", selectedPaths)}";
                        }
                        else
                        {
                            this.ResultMessage.Value = "File Not Selected";
                        }
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel Multi File Select";
                    }
                },
                                                        // Add File Filters
                                                        filters: filters);
            });
            this.ShowFileSaveDialog.Subscribe(_ =>
            {
                this.dialogService.ShowFileSaveDialog("FileSave", res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var saveFilePath         = res.Parameters.GetValue <string>(DialogResultParameterNames.SaveFilePath);
                        this.ResultMessage.Value = $"Save File Path: {saveFilePath}";
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel File Save";
                    }
                });
            });
            this.ShowCustomizedFileSaveDialog.Subscribe(_ =>
            {
                var textResource = new ExplorerBaseTextResource()
                {
                    FileName         = "Name",
                    FileDateModified = "Date modified",
                    FileType         = "Type",
                    FileSize         = "Size",
                };
                var filters = new[]
                {
                    new FileFilter("All Files (*.*)"),
                    new FileFilter("Text File (*.txt)", ".txt"),
                    new FileFilter("CSV File (*.csv)", ".csv"),
                };
                var icons = new ExplorerIcons()
                {
                    BackWardIcon = new BitmapImage(new Uri("/Resources/Backwards_16x.png", UriKind.Relative)),
                    ForwardIcon  = new BitmapImage(new Uri("/Resources/Forwards_16x.png", UriKind.Relative)),
                };
                Func <string, string> overwriteConfirmationMessageFunc = (x => $"{x} already exists.{Environment.NewLine}Do you want to replace it?");
                var param = new DialogParameters
                {
                    { DialogParameterNames.Title, "FileSave" },
                    { DialogParameterNames.DefaultSaveFileName, "Sample.txt" },
                    { DialogParameterNames.FileNamePrefixText, "File name:" },
                    { DialogParameterNames.FileTypePrefixText, "Save as type:" },
                    { DialogParameterNames.SaveButtonText, "Save" },
                    { DialogParameterNames.CancelButtonText, "Cancel" },
                    { DialogParameterNames.TextResource, textResource },
                    { DialogParameterNames.Filters, filters },
                    { DialogParameterNames.ExplorerIcons, icons },
                    { DialogParameterNames.OverwriteConfirmationTitle, "OverWrite Confirmation" },
                    { DialogParameterNames.OverwriteConfirmationMessageFunc, overwriteConfirmationMessageFunc },
                    { DialogParameterNames.OverwriteConfirmationOKButtonText, "Yes" },
                    { DialogParameterNames.OverwriteConfirmationCancelButtonText, "No" },
                    //{ DialogParameterNames.RootFolders, new [] { @"C:\" } },
                };
                this.dialogService.ShowDialog(DialogNames.FileSaveDialog, param, res =>
                {
                    if (res.Result == ButtonResult.OK)
                    {
                        var saveFilePath         = res.Parameters.GetValue <string>(DialogResultParameterNames.SaveFilePath);
                        this.ResultMessage.Value = $"Save File Path: {saveFilePath}";
                    }
                    else
                    {
                        this.ResultMessage.Value = "Cancel File Save";
                    }
                });
            });
        }
Exemplo n.º 26
0
        public Task<bool?> NotifySpellCheckingComplete()
        {
            var tcs = new TaskCompletionSource<bool?>();
            var dialogParameters = new DialogParameters
                                       {
                                           Header = LocalizationManager.GetString("SpellChecker_SpellingCheckIsCompleteMessageHeader"),
                                           Content = LocalizationManager.GetString("SpellChecker_SpellingCheckIsCompleteMessage")
                                       };

            dialogParameters.Closed = (sender, e) =>
                {
                    dialogParameters.Closed = null;
                    tcs.TrySetResult(e.DialogResult);
                };

            RadWindow.Alert(dialogParameters);

            return tcs.Task;
        }
Exemplo n.º 27
0
        public static void ShowMessage(string message, string detail, bool success)
        {
            DialogParameters parameters = new DialogParameters();

            parameters.Theme = ThemeManager.FromName("Office_Black");

            TextBlock block = new TextBlock();

            block.MinWidth     = 100;
            block.MaxWidth     = 350;
            block.Text         = message;
            block.TextWrapping = TextWrapping.Wrap;
            Image image = new Image();


            StackPanel panel = new StackPanel();

            panel.Orientation          = Orientation.Horizontal;
            panel.HorizontalAlignment  = HorizontalAlignment.Left;
            parameters.OkButtonContent = "确定";
            if (success)
            {
                block.Margin = new Thickness(10, 0, 0, 0);

                //   image.Source = new BitmapImage(new Uri("/Images/applications-internet.png", UriKind.Relative));
                panel.Children.Add(image);
                panel.Children.Add(block);

                parameters.Content = panel;
                //  parameters.Content = message;
                parameters.Header = "提示消息";
            }
            else
            {
                parameters.Header = "错误提示";


                block.Margin = new Thickness(10, 0, 0, 0);
                //      block.VerticalAlignment = VerticalAlignment.Center;
                //     image.Source = new BitmapImage(new Uri("/Images/dialog-warning.png", UriKind.Relative));
                image.VerticalAlignment = VerticalAlignment.Top;
                panel.Children.Add(image);
                panel.Children.Add(block);

                StackPanel panel1 = new StackPanel();
                panel1.Orientation = Orientation.Vertical;

                panel1.Children.Add(panel);
                if (!string.IsNullOrEmpty(detail))
                {
                    RadExpander expander = new RadExpander();
                    expander.Header   = "  展开其详细跟踪信息,可以复制进行质询。";
                    expander.MinWidth = 200;
                    expander.MaxWidth = 400;
                    expander.Margin   = new Thickness(0, 10, 0, 0);
                    TextBox block1 = new TextBox();
                    block1.MaxWidth              = 396;
                    block1.MinWidth              = 100;
                    block1.Text                  = detail;
                    block1.MaxHeight             = 200;
                    block1.TextWrapping          = TextWrapping.Wrap;
                    expander.Content             = block1;
                    expander.IsExpanded          = true;
                    expander.HorizontalAlignment = HorizontalAlignment.Left;
                    panel1.Children.Add(expander);
                }
                parameters.Content = panel1;
                //   parameters.Content = message;
            }
            RadWindow.Alert(parameters);
        }
		public static void Prompt(this IWindowManager windowManager, DialogParameters dialogParameters)
		{
			TelerikWindowManager.Prompt(dialogParameters);
		}
Exemplo n.º 29
0
 protected virtual void Save(DialogParameters param)
 {
     DialogHost.Close(IdentifierName, new DialogResult(ButtonResult.OK, param));
 }
Exemplo n.º 30
0
    private async Task CreateClick()
    {
        _errors = Array.Empty <string>();
        var errors = new List <string>();

        if (!_creating)
        {
            _creating = true;
            if (_selectedBean is null)
            {
                errors.Add("Please select a bean from the drop-down list");
            }
            if (_quantity == 0)
            {
                errors.Add("Please enter a quantity greater than zero");
            }
            if (_buy)
            {
                if (_price * _quantity > _user !.Balance)
                {
                    errors.Add($"You do not have {(_price * _quantity).ToCurrency(2)} in your account");
                }
            }
            else
            {
                if (_quantity > _selectedBean !.MyHoldings)
                {
                    errors.Add($"You do not have enough {_selectedBean!.Name} beans");
                }
            }
            if (_price <= 0M)
            {
                errors.Add($"You must enter a price greater than {0M.ToCurrency(2)}");
            }
            if (_days <= 0)
            {
                errors.Add($"Please enter a number of days greater than zero");
            }
            if (!errors.Any())
            {
                var date   = DateTime.UtcNow.AddDays(_days);
                var result = await _offerService !.CreateAsync(_user !.Id, _selectedBean !.Id, _quantity, _price, date, _buy);
                if (result.Successful)
                {
                    var parameters = new DialogParameters
                    {
                        { "Title", "Offer Created" },
                        { "Message", "Offer has been created" }
                    };
                    await _dialogService !.Show <GenericDialog>("Offer Created", parameters).Result;
                    _navigationManager !.NavigateTo("/Trade");
                    return;
                }
                else
                {
                    errors.AddRange(result.Errors());
                }
            }
            _creating = false;
        }
        _errors = errors.ToArray();
    }
Exemplo n.º 31
0
        private void ContextMenuClick(object sender, RoutedEventArgs e)
        {
            //GL gl = ClickedTreeViewItem.DataContext as GL;
            //TL tl = ClickedTreeViewItem.DataContext as TL;
            var SystemAccountingSettingModel = _systemAccountingSettingsService.GetSystemAccountingSettingModel();

            int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);

            // var SystemAccountingSettingModelGLLength = int.Parse(SystemAccountingSettingModel.GLLength);
            long   lastGLCode   = _gLsService.GetLastGLCode() + 1;
            var    lastGLLenght = (lastGLCode.ToString()).Length;
            string tag          = (e.OriginalSource as RadMenuItem).Tag as string;

            if (ClickedTreeViewItem == null)
            {
                if (lastGLLenght == SystemAccountingSettingModelGLLength)
                {
                    AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                    var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                    //   treeGL.GL = gl;
                    treeGL.SaveClicked += (g) =>
                    {
                        //addTLTreeItemWindow0.DataItem.GL = gl;
                        g.ImageUrl = "../../Resources/cian.png";
                        _vm.AddGL(g);
                        g.GLId = _vm.GetGLId(g.GLCode);
                        _vm.Items.Add(g);
                        //_vm.Save();
                        addGLTreeItemWindow0.Close();
                        // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                        //     gl.IsExpanded = true; // Ensure that the new child is visible
                        //using (var uow = new SainaDbContext())
                        //{
                        //    uow.GLs.Add(g);
                        //    uow.SaveChanges();
                        //    addGLTreeItemWindow0.Close();
                        //}
                    };
                    addGLTreeItemWindow0.Width    = 1000;
                    addGLTreeItemWindow0.Height   = 500;
                    addGLTreeItemWindow0.CanClose = true;
                    addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                    addGLTreeItemWindow0.Show();
                }
                else
                {
                    DialogParameters parameters = new DialogParameters();
                    parameters.OkButtonContent = "بستن";
                    parameters.Header          = "اخطار";
                    parameters.Content         = " شماره گذاری این حساب  به پایان رسیده است";
                    RadWindow.Alert(parameters);
                }
            }
            else if (ClickedTreeViewItem.DataContext is GL gl)
            {
                if (tag == "newGL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        if (lastGLLenght == SystemAccountingSettingModelGLLength)
                        {
                            AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                            var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                            //   treeGL.GL = gl;
                            treeGL.SaveClicked += (g) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                g.ImageUrl = "../../Resources/cian.png";
                                _vm.AddGL(g);
                                g.GLId = _vm.GetGLId(g.GLCode);
                                _vm.Items.Add(g);
                                //_vm.Save();
                                addGLTreeItemWindow0.Close();
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                gl.IsExpanded = true; // Ensure that the new child is visible
                                                      //using (var uow = new SainaDbContext())
                                                      //{
                                                      //    uow.GLs.Add(g);
                                                      //    uow.SaveChanges();
                                                      //    addGLTreeItemWindow0.Close();
                                                      //}
                            };
                            addGLTreeItemWindow0.Width    = 1000;
                            addGLTreeItemWindow0.Height   = 500;
                            addGLTreeItemWindow0.CanClose = true;
                            addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                            addGLTreeItemWindow0.Show();
                        }

                        else
                        {
                            DialogParameters parameters = new DialogParameters();
                            parameters.OkButtonContent = "بستن";
                            parameters.Header          = "اخطار";
                            parameters.Content         = " شماره گذاری این حساب  به پایان رسیده است";
                            RadWindow.Alert(parameters);
                        }
                    }
                    // break;
                }
                else if (tag == "newTL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;

                        treeTL.TL           = new TL();
                        treeTL.TL.GLId      = gl.GLId;
                        treeTL.TL.GL        = gl;
                        treeTL.SaveClicked += (t) =>
                        {
                            //addTLTreeItemWindow0.DataItem.GL = gl;
                            //t.GLId = gl.GLId;
                            t.ImageUrl = "../../Resources/cian.png";
                            _vm.AddTL(t);
                            t.GLId = _vm.GetTLId(t.TLCode);
                            gl.TLs.Add(t);
                            //_vm.Save();
                            addTLTreeItemWindow0.Close();
                            gl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.TLs.Add(t);
                                                  //    //uow.Entry(gl).State = EntityState.Modified;
                                                  //    var vv = uow.SaveChanges();
                                                  //    addTLTreeItemWindow0.Close();
                                                  //}
                        };
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddGLTreeItemWindow addGLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddGLTreeItemWindow>();
                        var treeGL = addGLTreeItemWindow0.DataContext as AddGLTreeItemWindowViewModel;
                        treeGL.GL = gl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasGL = uow.GLs.FirstOrDefault(x => x.GLId == gl.GLId)?.TLs?.Any() == true;
                            if (hasGL == true)
                            {
                                addGLTreeItemWindow0.gLCodeTextbox.IsEnabled = false;
                            }
                            treeGL.SaveClicked += (g) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                g.GLId     = gl.GLId;
                                g.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                gl.IsExpanded = true; // Ensure that the new child is visible
                                                      // _vm.Save();

                                uow.GLs.Attach(g);
                                uow.Entry <GL>(g).State = EntityState.Modified;
                                //  uow.GLs(g);
                                var x = uow.SaveChanges();
                                addGLTreeItemWindow0.Close();
                            };
                        }
                        addGLTreeItemWindow0.Width    = 1000;
                        addGLTreeItemWindow0.Height   = 500;
                        addGLTreeItemWindow0.CanClose = true;
                        addGLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addGLTreeItemWindow0.Show();
                    }
                    // break;
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasGL = uow.GLs.FirstOrDefault(x => x.GLId == gl.GLId)?.TLs?.Any() == true;

                            if (hasGL == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                var test = uow.GLs.ToList().Select(x => x.GLId);
                                _vm.Items.Remove(gl);
                                uow.Database.ExecuteSqlCommand($"Delete Info.GLs where  GLId={gl.GLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
            else if (ClickedTreeViewItem.DataContext is TL tl)
            {
                if (tag == "newTL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        gl = tl.GL;
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;
                        treeTL.TL      = new TL();
                        treeTL.TL.GLId = gl.GLId;
                        treeTL.TL.GL   = gl;
                        //treeTL.SelectedGL = gl;
                        //treeTL.TL = new TL { GL = gl, GLId = gl.GLId };
                        treeTL.SaveClicked += (t) =>
                        {
                            //   t.GLId = gl.GLId;
                            t.ImageUrl = "../../Resources/cian.png";
                            _vm.AddTL(t);
                            t.GLId = _vm.GetTLId(t.TLCode);
                            gl.TLs.Add(t);
                            addTLTreeItemWindow0.Close();

                            gl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.TLs.Add(t);
                                                  //   // uow.Entry(gl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addTLTreeItemWindow0.Close();
                            //}
                        };
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "newSL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL      = new SL();
                        treeSL.SL.TLId = tl.TLId;
                        treeSL.SL.TL   = tl;
                        //treeSL.SelectedTL = tl;
                        //treeSL.SL = new SL { TL = tl, TLId = tl.TLId };
                        treeSL.SaveClicked += (s) =>
                        {
                            //addTLTreeItemWindow0.DataItem.GL = gl;
                            // s.TLId = tl.TLId;
                            s.ImageUrl = "../../Resources/cian.png";
                            _vm.AddSL(s);
                            s.TLId = _vm.GetSLId(s.SLCode);

                            tl.SLs.Add(s);
                            // _vm.Save();
                            addSLTreeItemWindow0.Close();
                            tl.IsExpanded = true; // Ensure that the new child is visible
                                                  //using (var uow = new SainaDbContext())
                                                  //{
                                                  //    uow.SLs.Add(s);
                                                  //    uow.Entry(tl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addSLTreeItemWindow0.Close();
                            //}
                        };
                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddTLTreeItemWindow addTLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddTLTreeItemWindow>();
                        var treeTL = addTLTreeItemWindow0.DataContext as AddTLTreeItemWindowViewModel;
                        treeTL.TL = tl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasTL = uow.TLs.FirstOrDefault(x => x.TLId == tl.TLId)?.SLs?.Any() == true;
                            if (hasTL == true)
                            {
                                addTLTreeItemWindow0.tLCodeTextbox.IsEnabled = false;
                            }
                            treeTL.SaveClicked += (t) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                t.TLId     = tl.TLId;
                                t.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                tl.IsExpanded = true; // Ensure that the new child is visible

                                uow.TLs.Attach(t);
                                uow.Entry <TL>(t).State = EntityState.Modified;
                                //  uow.GLs(g);
                                //  uow.GLs(g);
                                uow.SaveChanges();
                                addTLTreeItemWindow0.Close();
                            };
                        }
                        addTLTreeItemWindow0.Width    = 1000;
                        addTLTreeItemWindow0.Height   = 500;
                        addTLTreeItemWindow0.CanClose = true;
                        addTLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addTLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasTL = uow.TLs.FirstOrDefault(x => x.TLId == tl.TLId)?.SLs?.Any() == true;

                            if (hasTL == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                //   var test = uow.TLs.ToList().Select(x => x.TLId);
                                foreach (var item in _vm.Items)
                                {
                                    item.TLs.Remove(tl);
                                }
                                uow.Database.ExecuteSqlCommand($"Delete Info.TLs where  TLId={tl.TLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
            else if (ClickedTreeViewItem.DataContext is SL)
            {
                SL sl = ClickedTreeViewItem.DataContext as SL;

                if (tag == "newSL")
                {
                    if (_accessUtility.HasAccess(70))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();

                        tl = sl.TL;
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL           = new SL();
                        treeSL.SL.TLId      = tl.TLId;
                        treeSL.SL.TL        = tl;
                        treeSL.SaveClicked += (s) =>
                        {
                            s.TLId     = tl.TLId;
                            s.ImageUrl = "../../Resources/cian.png";
                            tl.SLs.Add(s);
                            _vm.AddSL(s);
                            // _vm.Save();
                            addSLTreeItemWindow0.Close();

                            tl.IsExpanded = true;     // Ensure that the new child is visible
                                                      //using (var uow = new SainaDbContext())
                                                      //{
                                                      //    uow.SLs.Add(s);
                            ////    uow.Entry(tl).State = EntityState.Modified;

                            //    uow.SaveChanges();
                            //    addSLTreeItemWindow0.Close();
                            //}
                        };


                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "edit")
                {
                    if (_accessUtility.HasAccess(71))
                    {
                        AddSLTreeItemWindow addSLTreeItemWindow0 = SmObjectFactory.Container.GetInstance <AddSLTreeItemWindow>();
                        var treeSL = addSLTreeItemWindow0.DataContext as AddSLTreeItemWindowViewModel;
                        treeSL.SL = sl;
                        using (var uow = new SainaDbContext())
                        {
                            var hasItem = uow.AccDocumentItems.Any(x => x.SLId == sl.SLId);
                            if (hasItem == true)
                            {
                                addSLTreeItemWindow0.sLCodeTextbox.IsEnabled = false;
                                addSLTreeItemWindow0.DL1.IsEnabled           = false;
                                addSLTreeItemWindow0.DL2.IsEnabled           = false;
                            }
                            treeSL.SaveClicked += (s) =>
                            {
                                //addTLTreeItemWindow0.DataItem.GL = gl;
                                s.SLId     = sl.SLId;
                                s.ImageUrl = "../../Resources/cian.png";
                                // gl.TLs.Add(addTLTreeItemWindow0.DataItem);
                                sl.IsExpanded = true; // Ensure that the new child is visible

                                uow.SLs.Attach(s);
                                uow.Entry <SL>(s).State = EntityState.Modified;
                                //  uow.GLs(g);
                                uow.SaveChanges();
                                addSLTreeItemWindow0.Close();
                            };
                        }
                        addSLTreeItemWindow0.Width    = 1000;
                        addSLTreeItemWindow0.Height   = 500;
                        addSLTreeItemWindow0.CanClose = true;
                        addSLTreeItemWindow0.Owner    = Window.GetWindow(this);
                        addSLTreeItemWindow0.Show();
                    }
                }
                else if (tag == "delete")
                {
                    if (_accessUtility.HasAccess(72))
                    {
                        using (var uow = new SainaDbContext())
                        {
                            var hasItem = uow.AccDocumentItems.Any(x => x.SLId == sl.SLId);


                            if (hasItem == false)
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent     = "بله، مطمئنم";
                                parameters.CancelButtonContent = "خیر";
                                parameters.Header  = "اخطار";
                                parameters.Content = "آیا برای حذف  مطمئن هستید؟";
                                parameters.Closed  = OnClosed;
                                RadWindow.Confirm(parameters);
                                _dialogResult = _dialogResult == true;
                                // _dialogResult == true;
                            }
                            else
                            {
                                DialogParameters parameters = new DialogParameters();
                                parameters.OkButtonContent = "بستن";
                                parameters.Header          = "اخطار";
                                parameters.Content         = ".امکان حذف وجود ندارد";
                                // parameters.Closed = OnClosed;
                                RadWindow.Alert(parameters);
                                _dialogResult = false;
                            }
                            if (_dialogResult == true)
                            {
                                //  uow.GLs.Attach(gl);
                                //   var test = uow.TLs.ToList().Select(x => x.TLId);
                                foreach (var item in _vm.Items)
                                {
                                    foreach (var x in item.TLs)
                                    {
                                        if (x.SLs.Remove(sl))
                                        {
                                            break;
                                        }
                                    }
                                }
                                uow.Database.ExecuteSqlCommand($"Delete Info.SLs where  SLId={sl.SLId} ");
                                // uow.RejectChanges();
                                // uow.GLs.Attach(new GL { GLId = gl.GLId });
                                //uow.Entry<GL>(gl).State = EntityState.Deleted;
                                //// uow.GLs.Remove(new GL { GLId=gl.GLId});
                                uow.SaveChanges();
                                var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                                var alert = new RadDesktopAlert
                                {
                                    FlowDirection = FlowDirection.RightToLeft,
                                    Header        = "اطلاعات",
                                    Content       = ".حذف با موفقیت انجام شد",
                                    ShowDuration  = 5000,
                                };
                                manager.ShowAlert(alert);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 32
0
 /// <summary>
 /// Add a resource
 /// </summary>
 private void AddResource()
 {
     var dialogparameters = new DialogParameters()
     {
         Content = "Resource name:"
     };
     RadWindow.Prompt(dialogparameters, (sender, e) =>
                                             {
                                                 var result = e.PromptResult;
                                             });
 }
Exemplo n.º 33
0
 private Texture2D getTextureForParameter(DialogParameters param)
 {
     Texture2D texture = null;
     // si no la encuentra la carga
     if (!textures.TryGetValue(param.CustomAssetName, out texture))
     {
         texture = Program.GAME.Content.Load<Texture2D>(param.CustomAssetName);
         textures.Add(param.CustomAssetName, texture);
     }
     // regresa textura
     return texture;
 }
        public async Task ShowAsync(FrameworkElement view, string title = "", object parameter = null, DialogParameters dialogParameters = null, bool AlwaysActiveViewOnOpen = true, bool AlwaysDeactiveViewOnClose = true)
        {
            var customDialog = new CustomDialog();

            if (dialogParameters == null)
            {
                dialogParameters = new DialogParameters();
            }

            FillParameters(customDialog, dialogParameters);


            if (view == null)
            {
                throw new Exception("View not found");
            }

            customDialog.Child = view;



            customDialog.Title = title;
            var modal = view.DataContext as IModalDialog;

            if (modal != null)
            {
                customDialog.Title = string.IsNullOrEmpty(title) ? modal.Title : title;
                if (modal.AcceptCommand != null)
                {
                    customDialog.AcceptCommandText = modal.AcceptLabel;
                    customDialog.AcceptCommand     = modal.AcceptCommand;
                }



                if (modal.CancelCloseCommand != null)
                {
                    customDialog.CancelCommandText = modal.CancelLabel;

                    customDialog.CancelCommand = modal.CancelCloseCommand;
                }
            }


            modal = null;
            var activatable = view.DataContext as INavigationAware;

            if (activatable != null)
            {
                activatable.OnNavigatedTo(new NavigatedToEventArgs()
                {
                    NavigationMode = Windows.UI.Xaml.Navigation.NavigationMode.New,
                    Parameter      = parameter
                },
                                          null
                                          );
            }


            var deactivator = view.DataContext as INavigationAware;

            if (deactivator != null)
            {
                if (Window.Current != null)
                {
                    var control = Window.Current.Content as UserControl;
                    if (control == null)
                    {
                        return;
                    }
                    var grid = control.Content as Grid;

                    if (grid == null)
                    {
                        Debug.WriteLine("Control must have a Grid as main container");
                        return;
                    }
                    var popups = grid.Children.OfType <Popup>();
                    if (popups != null && popups.Any())
                    {
                        var modalPopup = popups.FirstOrDefault(x => x.Name == "ModalPopup");
                    }
                    else
                    {
                        var modalPopup = createModalPopup(customDialog, grid, dialogParameters);


                        grid.Children.Add(modalPopup);

                        modalPopup.IsOpen = true;
                        var closedEvent = Observable.FromEventPattern(modalPopup, "Closed");

                        IDisposable subscriber = null;
                        subscriber = closedEvent.Subscribe(x =>
                        {
                            var container = customDialog.FindName("Container") as ContentControl;
                            if (container != null)
                            {
                                container.Content = null;
                            }

                            deactivator.OnNavigatingFrom(new NavigatingFromEventArgs()
                            {
                                NavigationMode = Windows.UI.Xaml.Navigation.NavigationMode.Back,
                            }, null, false);

                            DialogClosed?.Invoke(this, new DialogClosedEventArgs(Result, DialogCloseParameter));


                            deactivator = null;



                            container    = null;
                            customDialog = null;
                            if (view != null)
                            {
                                ((FrameworkElement)view).DataContext = null;
                                view = null;
                            }
                            GC.Collect();



                            subscriber.Dispose();
                            closedEvent = null;
                        });
                    }
                }
            }
        }
Exemplo n.º 35
0
        private Rectangle setupDialogBox(ref DialogParameters param)
        {
            Rectangle rect = new Rectangle();
            // para saber cuanto tomara el texto
            Vector2 size = font.MeasureString("");

            // primero a resolver el horizontal align
            if (param.HorizontalAlign == GameConstants.HorizontalAlign.Left)
            {
                rect.X = safeArea.X;
            }
            else if (param.HorizontalAlign == GameConstants.HorizontalAlign.Right)
            {
                rect.X = safeArea.Width - (int)size.X;
            }
            else if (param.HorizontalAlign == GameConstants.HorizontalAlign.HorizontalCenter)
            {
                rect.X = (safeArea.Width / 2) - (int)(size.X / 2);
            }
            else
            {
                // else es free!
                if (param.FreeX != 0)
                {
                    // no valida safe area ni nada
                    rect.X = (int)param.FreeX;
                }
                else
                {
                    // si es cero entonces se toma posicion defecto
                    rect.X = safeArea.X;
                }
            }

            //vertical values now
            if (param.VerticalAlign == GameConstants.VerticalAlign.Top)
            {
                rect.Y = safeArea.Y;
                // verifica si hay que ajustar Y al posible avatar if any
                if (param.CustomAssetName != null)
                {
                    // sacar textura
                    Texture2D textura = getTextureForParameter(param);
                    if (param.AvatarPixelsToShow != 0)
                    {
                        rect.Y += (int)param.AvatarPixelsToShow;
                    }
                    else
                    {
                        // se mostrara la mitad then
                        rect.Y += textura.Height / 2;
                        param.AvatarPixelsToShow = textura.Height / 2;
                    }
                }
            }
            else if (param.VerticalAlign == GameConstants.VerticalAlign.Bottom)
            {
                rect.Y = safeArea.Height - (int)size.Y;
            }
            else if (param.VerticalAlign == GameConstants.VerticalAlign.VerticalCenter)
            {
                rect.Y = (safeArea.Height / 2) - (int)(size.Y / 2);
                // verifica si hay que ajustar Y al posible avatar if any
                if(param.CustomAssetName != null){
                    // sacar textura
                    Texture2D textura = getTextureForParameter(param);
                    if (param.AvatarPixelsToShow != 0)
                    {
                        rect.Y += (int)param.AvatarPixelsToShow;
                    }
                    else
                    {
                        // se mostrara la mitad then
                        rect.Y += textura.Height / 2;
                        // seta de una vez lo que mostrara
                        param.AvatarPixelsToShow = textura.Height / 2;
                    }
                }
            }
            else
            {
                // else es free!
                if (param.FreeY != 0)
                {
                    // no valida safe area ni nada
                    rect.Y = (int)param.FreeY;
                }
                else
                {
                    // si es cero entonces se toma posicion defecto
                    rect.Y = safeArea.Height - (int)size.Y;
                }
            }

            // ahora a ver si el cuadro de texto es grande o se adapta al texto
            if (param.IsAdaptToText)
            {
                // margen por 2 para que se aplique de los dos lados
                rect.Width = (int)size.X + (param.HorizontalMargin * 2);
                rect.Height = (int)size.Y + (param.VerticalMargin * 2);
            }
            else
            {
                rect.Width = safeArea.Width;
                rect.Height = (int)size.Y + (param.VerticalMargin * 2);
            }
            return rect;
        }
Exemplo n.º 36
0
 private void RaiseRequestClose(ButtonResult dialogResult, DialogParameters dialogParameters)
 => RequestClose?.Invoke(new DialogResult(dialogResult, dialogParameters));
Exemplo n.º 37
0
        //private InventoryControl _InventoryControl;
        //public InventoryControl InventoryControl
        //{
        //    get { return _InventoryControl; }
        //    set { SetProperty(ref _InventoryControl, value); }
        //}


        #endregion
        #region Methods
        public async void Loaded()
        {
            _uow                 = new SainaDbContext();
            Products             = new QueryableCollectionView(_uow.Products.ToList());
            _allMeasurementUnits = await _uow.MeasurementUnits.AsNoTracking().ToListAsync().ConfigureAwait(false);

            MeasurementUnits = new ObservableCollection <MeasurementUnit>(_allMeasurementUnits);
            _allStocks       = _uow.Stocks.AsNoTracking().ToList();
            Stocks           = new ObservableCollection <Stock>(_allStocks);
            var ShoppingSystemSettingModel = AutoMapper.Mapper.Map <ShoppingSystemSettingModel, EditableShoppingSystemSettingViewModel>(_shoppingSystemSettingsService.GetShoppingSystemSettingModel());

            int.TryParse(ShoppingSystemSettingModel.ProductCodeLenght, out int productCodeLenght);

            ProductCommunication  = ShoppingSystemSettingModel.ProductCommunication;
            ProductCodeLenght     = productCodeLenght;
            ProductTypeLenght     = int.Parse(ShoppingSystemSettingModel.ProductTypeLenght ?? "0");
            ProductBrandLenght    = int.Parse(ShoppingSystemSettingModel.ProductBrandLenght ?? "0");
            ProductModelLenght    = int.Parse(ShoppingSystemSettingModel.ProductModelLenght ?? "0");
            OtherProductLenght    = int.Parse(ShoppingSystemSettingModel.OtherProductLenght ?? "0");
            IranCodeProductLenght = int.Parse(ShoppingSystemSettingModel.IranCodeProduct ?? "0");
            NumberLevel           = int.Parse(ShoppingSystemSettingModel.NumberLevel ?? "0");
            BarcodeLenght         = int.Parse(ShoppingSystemSettingModel.Barcode ?? "0");
            string s = "0," + (ProductCodeLenght).ToString();

            Regex = $"^[0-9]{{{s}}}$";
            if (ProductCodeLenght == 0 ||
                ProductTypeLenght == 0 ||
                ProductBrandLenght == 0 ||
                ProductModelLenght == 0 ||
                OtherProductLenght == 0 ||
                IranCodeProductLenght == 0 ||
                NumberLevel == 0 ||
                BarcodeLenght == 0
                )
            {
                DialogParameters parameters = new DialogParameters();
                parameters.OkButtonContent = "بستن";
                parameters.Header          = "!اخطار";
                parameters.Content         = " تنظیمات بازرگانی خرید انجام نشده است";
                RadWindow.Alert(parameters);
                Error(" تنظیمات بازرگانی خرید انجام نشده است");
                EnableTab = false;
            }
            else
            {
                EnableTab = true;
            }

            if (ProductCommunication == "Yes")
            {
                EnableCodeText   = true;
                EnableCodeButton = true;
            }
            else
            {
                EnableCodeText   = false;
                EnableCodeButton = false;
            }

            //ProductBrands = _uow.ProductBrands.ToList();
        }
Exemplo n.º 38
0
        private void RegisterCommands()
        {
            BlinkGoBackButtonCommand = new DelegateCommand(() =>
            {
                GoPreviousImage();
            });
            BlinkGoNextButtonCommand = new DelegateCommand(() =>
            {
                GoNextImage();
            });
            BuildBookContextMenuCommand = new DelegateCommand <ContextMenuEventArgs>(args =>
            {
                BuildContextMenus_Books();
                (args.Source as FrameworkElement).ContextMenu.IsOpen = true;
            });
            BuildContentsContextMenuCommand = new DelegateCommand <ContextMenuEventArgs>(args =>
            {
                BuildContextMenus_Contents();
                (args.Source as FrameworkElement).ContextMenu.IsOpen = true;
            });
            ChangeStarCommand = new DelegateCommand <ObservableCollection <BookViewModel> >(args =>
            {
                IDialogResult result         = new DialogResult();
                IDialogParameters parameters = new DialogParameters();
                parameters.Add("Book", args.First());
                dialogService.ShowDialog(nameof(ChangeStar), parameters, ret => result = ret);
                UpdateStarLevel();
            });
            CloseTabCommand = new DelegateCommand(() =>
            {
                MainWindowViewModel.Value.CloseTab(this);
            });
            CloseSearchPaneCommand = new DelegateCommand(() =>
            {
                CloseSearchPane();
            });
            DropCommand.Subscribe(args =>
            {
                foreach (var dropPlugin in DropPlugins)
                {
                    dropPlugin.Value.Execute(args.Data);
                }
            })
            .AddTo(disposables);
            ExportBooksCommand = new DelegateCommand(() =>
            {
                var books = BookListViewSelectedItems;
                OpenExportDialog(books.ToArray());
            });
            FilterBooksCommand = new DelegateCommand(() =>
            {
                MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems);
            });
            LeftKeyDownCommand = new DelegateCommand(() =>
            {
                if (OpenedPage != null)
                {
                    GoPreviousImage();
                }
                else if (OpenedBook != null)
                {
                    //Do nothing
                }
                else
                {
                    //Do nothing
                }
            });
            MouseWheelCommand = new DelegateCommand <MouseWheelEventArgs>(args =>
            {
                var delta = args.Delta;

                if (OpenedPage != null)
                {
                    if (delta > 0) //奥方向に回転
                    {
                        GoPreviousImage();
                    }
                    else if (delta < 0) //手前方向に回転
                    {
                        GoNextImage();
                    }
                }
                else if (OpenedBook != null)
                {
                    //Do nothing
                }
                else
                {
                    //Do nothing
                }
            });
            OpenBookCommand = new DelegateCommand(() =>
            {
                OpenBook(BookListViewSelectedItems.First());
            });
            OpenBookInNewTabCommand = new DelegateCommand(() =>
            {
                MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems.First());
                MainWindowViewModel.Value.ActiveDocumentViewModel.OpenBook(BookListViewSelectedItems.First());
            });
            OpenBookPropertyDialogCommand = new DelegateCommand(() =>
            {
                var books = BookListViewSelectedItems;
                OpenBookPropertyDialog(books.First());
            });
            OpenImageByDefaultProgramCommand = new DelegateCommand <object>((p) =>
            {
                OpenImageByDefaultProgram(p as IEnumerable <PageViewModel>);
            });
            OpenSearchPaneCommand = new DelegateCommand(() =>
            {
                OpenSearchPane();
            });
            RightKeyDownCommand = new DelegateCommand(() =>
            {
                if (OpenedPage != null)
                {
                    GoNextImage();
                }
                else if (OpenedBook != null)
                {
                    //Do nothing
                }
                else
                {
                    //Do nothing
                }
            });
            RemakeThumbnailOfBookCommand = new DelegateCommand(async() =>
            {
                var books = BookListViewSelectedItems;
                await RemakeThumbnail(books);
            });
            RemakeThumbnailOfPageCommand = new DelegateCommand(async() =>
            {
                var pages = ContentsListViewSelectedItems;
                await RemakeThumbnail(pages);
            });
            RemoveBookCommand = new DelegateCommand(async() =>
            {
                var books = BookListViewSelectedItems;
                await RemoveBook(books.ToArray());
            });
            RemovePageCommand = new DelegateCommand <object>(async(p) =>
            {
                await RemovePage(p as IEnumerable <PageViewModel>);
            });
            SearchInNewTabCommand = new DelegateCommand(() =>
            {
                MainWindowViewModel.Value.NewSearchTab(BookCabinet.OnStage);
            });
            SendBookToExistTabCommand = new DelegateCommand <IDocumentViewModelBase>(p =>
            {
                foreach (var item in BookListViewSelectedItems)
                {
                    p.BookCabinet.AddToMemory(item);
                }
            });
            SendBookToNewTabCommand = new DelegateCommand(() =>
            {
                MainWindowViewModel.Value.NewContentTab(BookListViewSelectedItems);
            });
            ScrapPagesCommand = new DelegateCommand <object>(async(p) =>
            {
                await ScrapPages(p as IEnumerable <PageViewModel>);
            });
            XButton1MouseButtonDownCommand = new DelegateCommand(() =>
            {
                if (OpenedPage != null)
                {
                    CloseImage();
                }
                else if (OpenedBook != null)
                {
                    CloseBook();
                }
                else
                {
                    if (BookCabinet.IsSearching)
                    {
                        ClearSearchResult();
                        CloseSearchPane();
                        RestoreScrollOffset(BeforeSearchPosition);
                    }
                }
            });
            XButton2MouseButtonDownCommand = new DelegateCommand(() =>
            {
                if (OpenedPage != null)
                {
                    //Do nothing
                }
                else if (OpenedBook != null)
                {
                    //Do nothing
                }
                else
                {
                    //Do nothing
                }
            });
        }
        /// <summary>
        /// Show file save dialog.
        /// </summary>
        /// <param name="dialogService"></param>
        /// <param name="title">Dialog title.</param>
        /// <param name="callBack">Callback action.</param>
        /// <param name="isModal">If true; dialog is shown as a modal.</param>
        /// <param name="fileNamePrefixText">File name prefix text.</param>
        /// <param name="fileTypePrefixText">File type prefix text.</param>
        /// <param name="saveButtonText">Save button text.</param>
        /// <param name="cancelButtonText">Cancel button text.</param>
        /// <param name="textResource">Text resource for explorer.</param>
        /// <param name="filters">File filters.</param>
        /// <param name="rootFolders">Root folders path.</param>
        /// <param name="overwriteConfirmationTitle">Dialog title when overwriting files.</param>
        /// <param name="overwriteConfirmationMessageFunc">Message function when overwriting files.</param>
        /// <param name="overwriteConfirmationOKButtonText">Dialog OK button text when overwriting files.</param>
        /// <param name="overwriteConfirmationCancelButtonText">Dialog Cancel button text when overwriting files.</param>
        public static void ShowFileSaveDialog(this IDialogService dialogService,
                                              string title,
                                              Action <IDialogResult> callBack,
                                              bool isModal = true,
                                              string fileNamePrefixText             = null,
                                              string fileTypePrefixText             = null,
                                              string saveButtonText                 = null,
                                              string cancelButtonText               = null,
                                              ExplorerBaseTextResource textResource = null,
                                              IEnumerable <FileFilter> filters      = null,
                                              IEnumerable <string> rootFolders      = null,
                                              string overwriteConfirmationTitle     = null,
                                              Func <string, string> overwriteConfirmationMessageFunc = null,
                                              string overwriteConfirmationOKButtonText     = null,
                                              string overwriteConfirmationCancelButtonText = null)
        {
            var param = new DialogParameters
            {
                { DialogParameterNames.Title, title }
            };

            if (!string.IsNullOrEmpty(fileNamePrefixText))
            {
                param.Add(DialogParameterNames.FileNamePrefixText, fileNamePrefixText);
            }
            if (!string.IsNullOrEmpty(fileTypePrefixText))
            {
                param.Add(DialogParameterNames.FileTypePrefixText, fileTypePrefixText);
            }
            if (!string.IsNullOrEmpty(saveButtonText))
            {
                param.Add(DialogParameterNames.SaveButtonText, saveButtonText);
            }
            if (!string.IsNullOrEmpty(cancelButtonText))
            {
                param.Add(DialogParameterNames.CancelButtonText, cancelButtonText);
            }
            if (textResource != null)
            {
                param.Add(DialogParameterNames.TextResource, textResource);
            }
            if (filters != null)
            {
                param.Add(DialogParameterNames.Filters, filters);
            }
            if (rootFolders != null)
            {
                param.Add(DialogParameterNames.RootFolders, rootFolders);
            }
            if (!string.IsNullOrEmpty(overwriteConfirmationTitle))
            {
                param.Add(DialogParameterNames.OverwriteConfirmationTitle, overwriteConfirmationTitle);
            }
            if (overwriteConfirmationMessageFunc != null)
            {
                param.Add(DialogParameterNames.OverwriteConfirmationMessageFunc, overwriteConfirmationMessageFunc);
            }
            if (!string.IsNullOrEmpty(overwriteConfirmationOKButtonText))
            {
                param.Add(DialogParameterNames.OverwriteConfirmationOKButtonText, overwriteConfirmationOKButtonText);
            }
            if (!string.IsNullOrEmpty(overwriteConfirmationCancelButtonText))
            {
                param.Add(DialogParameterNames.OverwriteConfirmationCancelButtonText, overwriteConfirmationCancelButtonText);
            }
            if (isModal)
            {
                dialogService.ShowDialog(DialogNames.FileSaveDialog, param, callBack);
            }
            else
            {
                dialogService.Show(DialogNames.FileSaveDialog, param, callBack);
            }
        }
 /// <summary>
 /// Opens a Confirm modal window
 /// </summary>
 public static void Confirm(this IWindowManager windowManager, DialogParameters dialogParameters)
 {
     TelerikWindowManager.Confirm(dialogParameters);
 }
		public static void Alert(DialogParameters dialogParameters)
		{
			RadWindow.Alert(dialogParameters);
		}
Exemplo n.º 42
0
 /// <summary>
 /// 设置提醒对话框
 /// </summary>
 /// <param name="header">对话框标题</param>
 /// <param name="okContent">Ok按钮显示内容</param>
 /// <param name="content">显示内容</param>
 /// <param name="fontSize">字号</param>
 /// <param name="width">对话框宽度</param>
 /// <param name="callBack">关闭对话框后执行的操作</param>
 /// <returns>提醒对话框</returns>
 protected DialogParameters SetAlter(
     string header,
     string okContent,
     string content,
     int fontSize,
     int width,
     Action callBack)
 {
     var alter = new DialogParameters
         {
             Header = header,
             OkButtonContent = okContent,
             Content = new TextBlock
                 {
                     Text = content,
                     FontFamily = new FontFamily("Microsoft YaHei UI"),
                     FontSize = fontSize,
                     TextWrapping = TextWrapping.Wrap,
                     Width = width,
                 },
             Closed = (o, e) => callBack(),
         };
     return alter;
 }
		public static void Confirm(DialogParameters dialogParameters)
		{
			RadWindow.Confirm(dialogParameters);
		}
Exemplo n.º 44
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            double totalsignedvalue;
            string genericmessage = "Customer signed total is mandatory.";

            if (cmbRevision.SelectedIndex == 0 && cmbRevision.Items.Count > 1)
            {
                DialogParameters param = new DialogParameters();
                param.Header  = "Next Revision Type is required";
                param.Content = "Please specify Next Revision Type";
                RadWindow.Alert(param);
                return;
            }

            if (!(cmbReason.SelectedIndex > 0 || cmbReason.Items.Count == 1))
            {
                DialogParameters param = new DialogParameters();
                param.Header  = txtReason.Text + "is required";
                param.Content = "Please specify " + txtReason.Text;
                RadWindow.Alert(param);
                return;
            }

            if (txtSignedTotal.Visibility == Visibility.Visible)
            {
                if (txtSignedTotal.Text.Trim() == "")
                {
                    DialogParameters param = new DialogParameters();
                    param.Header  = "Alert";
                    param.Content = genericmessage;
                    RadWindow.Alert(param);
                    return;
                }
                else
                {
                    try
                    {
                        totalsignedvalue = double.Parse(txtSignedTotal.Text);
                        if (totalsignedvalue == _totalvalue)
                        {
                            BusyIndicator1.IsBusy      = true;
                            BusyIndicator1.BusyContent = "Saving Estimate...";

                            if (_statusId != 3) // Complete, cancel, on hold, activate
                            {
                                _mrsClient.ValidateSetEstimateStatusCompleted += new EventHandler <ValidateSetEstimateStatusCompletedEventArgs>(_mrsClient_ValidateSetEstimateStatusCompleted);
                                _mrsClient.ValidateSetEstimateStatusAsync(_estimateRevisionId, Convert.ToInt32(cmbRevision.SelectedValue));
                            }
                            else // Reject
                            {
                                _mrsClient.RejectVariationCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(_mrsClient_RejectVariationCompleted);
                                _mrsClient.RejectVariationAsync(_estimateRevisionId, (App.Current as App).CurrentUserId);
                            }
                        }
                        else
                        {
                            DialogParameters param = new DialogParameters();
                            param.Header = "Alert";
                            if (_customerdocumenttype.ToUpper().Contains("VARIATION"))
                            {
                                param.Content = "Customer signed total " + totalsignedvalue.ToString("C", CultureInfo.CurrentCulture) + " does not match variation value " + _totalvalue.ToString("C", CultureInfo.CurrentCulture) + "." + Environment.NewLine + "Please rectify.";
                            }
                            else
                            {
                                param.Content = "Customer signed total " + totalsignedvalue.ToString("C", CultureInfo.CurrentCulture) + " does not match contract value " + _totalvalue.ToString("C", CultureInfo.CurrentCulture) + "." + Environment.NewLine + "Please rectify.";
                            }

                            //RadWindow.Alert(param);
                            RadWindow.Alert(new TextBlock()
                            {
                                Text = param.Content.ToString(), TextWrapping = TextWrapping.Wrap, Width = 250
                            });
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        DialogParameters param = new DialogParameters();
                        param.Header  = "Alert";
                        param.Content = genericmessage;
                        RadWindow.Alert(param);
                        return;
                    }
                }
            }
            else
            {
                // when TBA selected for pc, contract, variation then accepted date must be set, raise error otherwise.
                // this is an incorrect logic, this is already taken care on the stored procedure validate SP
                //if (Convert.ToInt32(cmbRevision.SelectedValue) == 0)
                //{
                //    DialogParameters param = new DialogParameters();
                //    param.Header = "Accepted date is required";
                //    param.Content = "Please specify Accepted Date before completing this revision.";
                //    RadWindow.Alert(param);
                //    return;
                //}

                BusyIndicator1.IsBusy      = true;
                BusyIndicator1.BusyContent = "Saving Estimate...";

                if (_statusId != 3) // Complete, cancel, on hold, activate
                {
                    _mrsClient.ValidateSetEstimateStatusCompleted += new EventHandler <ValidateSetEstimateStatusCompletedEventArgs>(_mrsClient_ValidateSetEstimateStatusCompleted);
                    _mrsClient.ValidateSetEstimateStatusAsync(_estimateRevisionId, Convert.ToInt32(cmbRevision.SelectedValue));
                }
                else // Reject
                {
                    _mrsClient.RejectVariationCompleted += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(_mrsClient_RejectVariationCompleted);
                    _mrsClient.RejectVariationAsync(_estimateRevisionId, (App.Current as App).CurrentUserId);
                }
            }
        }
		public static void Prompt(string title, string message, string defaultPromptResultValue, Action<string> onOK)
		{
			var dialogParameters = new DialogParameters
			{
				Header = title,
				Content = message,
				DefaultPromptResultValue = defaultPromptResultValue,
			};
			dialogParameters.Closed += (o, args) =>
			{
				if (args.DialogResult.HasValue && args.DialogResult.Value)
					onOK(args.PromptResult);
			};

			Prompt(dialogParameters);
		}
Exemplo n.º 46
0
 public static void ShowDialogInAnotherWindow(this IDialogService dialogService, string dialogName, string windowName, DialogParameters parameters, Action <IDialogResult> callBack)
 {
     dialogService.ShowDialog(dialogName, parameters, callBack, windowName);
 }
		public static void Prompt(DialogParameters dialogParameters)
		{
			RadWindow.Prompt(dialogParameters);
		}