private void Toast_Loaded(object sender, RoutedEventArgs e) { setting = Application.Current.LoadSetting(); try { parentWindow = Window.GetWindow(this); if (parentWindow is Window) { parentWindow.Closing += Window_Closing; Application.Current.AddToast(parentWindow); } } catch (Exception ex) { ex.ERROR("ToastLoaded"); } try { ButtonOk = new CustomButton() { Button = OK, Kind = ButtonOKIcon, Text = ButtonOKLabel }; ButtonCancel = new CustomButton() { Button = CANCEL, Kind = ButtonCancelIcon, Text = ButtonCancelLabel }; ButtonOpenFile = new CustomButton() { Button = OpenFile, Kind = ButtonOpenFileIcon, Text = ButtonOpenFileLabel }; ButtonOpenFolder = new CustomButton() { Button = OpenFolder, Kind = ButtonOpenFolderIcon, Text = ButtonOpenFolderLabel }; } catch (Exception ex) { ex.ERROR("ToastLoaded"); } try { if (Tag is Notification) { var toast = Tag as Notification; if (string.IsNullOrEmpty(toast.ImgURL)) { Preview.Hide(); } else { Preview.Show(); } } } catch (Exception ex) { ex.ERROR(); } try { StateMark.Hide(); if (Tag is CustomToast) { toast = Tag as CustomToast; SetState(toast.State, toast.StateDescription); } } catch (Exception ex) { ex.ERROR(); } try { SetButton(ItemType); } catch (Exception ex) { ex.ERROR(); } try { CheckImageSource(); } catch (Exception ex) { ex.ERROR(); } }
public StateContext(object context, StateMark stateMark) { this.contextObject = context; this.stateMark = stateMark; }
private void SetState(string state, string desc) { if (IsLoaded) { #region Show Toast State Mark if (string.IsNullOrEmpty(state)) { State.Text = string.Empty; State.Hide(); } else if (state.Equals("Successed", StringComparison.CurrentCultureIgnoreCase) || state.Equals("Successes", StringComparison.CurrentCultureIgnoreCase) || state.Equals("Succeed", StringComparison.CurrentCultureIgnoreCase)) { State.Text = "\uE10B"; State.Foreground = Theme.AccentBrush; State.Show(); } else if (state.Equals("Failed", StringComparison.CurrentCultureIgnoreCase)) { State.Text = "\uE10A"; State.Foreground = Theme.ErrorBrush; State.Show(); } else { State.Text = string.Empty; State.Hide(); } #endregion #region Show Toast State Description Mark if (string.IsNullOrEmpty(desc)) { StateDescription.Text = string.Empty; StateDescription.Hide(); } else if (desc.Equals("Public", StringComparison.CurrentCultureIgnoreCase)) { StateDescription.Text = "\uE1F7"; StateDescription.Foreground = State.Foreground; StateDescription.Show(); } else if (desc.Equals("Private", StringComparison.CurrentCultureIgnoreCase)) { StateDescription.Text = "\uE1F6"; StateDescription.Foreground = State.Foreground; StateDescription.Show(); } else { StateDescription.Text = string.Empty; StateDescription.Hide(); } #endregion if (string.IsNullOrEmpty(state) && string.IsNullOrEmpty(desc)) { StateMark.Hide(); } else { StateMark.Show(); } } }