private void SetTemplate() { StringResources stx = new StringResources( "/libtaotu/Message" ); PrimaryButtonText = stx.Str( "OK" ); int[] KnownCodePages = new int[] { 37, 437, 500, 708, 720, 737, 775, 850, 852, 855, 857, 858, 860, 861, 862, 863, 864 , 865, 866, 869, 870, 874, 875, 932, 936, 949, 950, 1026, 1047, 1140, 1141, 1142, 1143 , 1144, 1145, 1146, 1147, 1148, 1149, 1200, 1201, 1250, 1251, 1252, 1253, 1254, 1255 , 1256, 1257, 1258, 1361, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008 , 10010, 10017, 10021, 10029, 10079, 10081, 10082, 12000, 12001, 20000, 20001, 20002 , 20003, 20004, 20005, 20105, 20106, 20107, 20108, 20127, 20261, 20269, 20273, 20277 , 20278, 20280, 20284, 20285, 20290, 20297, 20420, 20423, 20424, 20833, 20838, 20866 , 20871, 20880, 20905, 20924, 20932, 20936, 20949, 21025, 21866, 28591, 28592, 28593 , 28594, 28595, 28596, 28597, 28598, 28599, 28603, 28605, 29001, 38598, 50220, 50221 , 50222, 50225, 50227, 51932, 51936, 51949, 52936, 54936, 57002, 57003, 57004, 57005 , 57006, 57007, 57008, 57009, 57010, 57011, 65000, 65001 }; Encoding.RegisterProvider( CodePagesEncodingProvider.Instance ); foreach ( int CodePage in KnownCodePages ) { try { Encoding Enc = Encoding.GetEncoding( CodePage ); SupportedCodePages.Add( Enc.EncodingName, Enc.CodePage ); } catch ( Exception ) { } } Encodings.ItemsSource = SupportedCodePages; }
public ChangePassword() { this.InitializeComponent(); StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); }
private void SetTemplate() { StringResources stx = new StringResources( "LoadingMessage" ); CoverSize.Text = stx.Str( "Calculating" ); CalculateCoverSize(); TextContentSize.Text = stx.Str( "Calculating" ); CalculateTextSize(); }
private Rename() { this.InitializeComponent(); StringResources stx = new StringResources( "Message", "ContextMenu" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); TitleBlock.Text = stx.Text( "Rename", "ContextMenu" ); }
private void SetTemplate() { StringResources stx = new StringResources( "/libtaotu/Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); InputTitle.Text = Param.Caption; LayoutRoot.DataContext = Param; }
private void SetTemplate( ColorItem BindColor ) { StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); // PresetColors PresetColors.ItemsSource = global::wenku8.System.ThemeManager.PresetColors(); UpdateColor( BindColor ); }
public Announcements() { this.InitializeComponent(); StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "AllRead" ); SecondaryButtonText = stx.Str( "OK" ); FullVersion.Text = global::wenku8.Config.AppSettings.Version; version.Text = global::wenku8.System.Bootstrap.Version; SetTemplate(); }
public AssignAuth( StringAuthManager Mgr, string Title ) { this.InitializeComponent(); this.Title = Title; Canceled = true; AuthMgr = Mgr; StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); SetTemplate(); }
private void SetTemplate() { StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); stx = new StringResources( "AppBar" ); Title = stx.Text( "Bookmark" ); stx = new StringResources( "AppResources" ); BookmarkName.PlaceholderText = stx.Text( "DefaultToParagraph" ); ColorGrid.ItemsSource = PresetColors; }
private void SetTemplate() { StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); MessageBus.OnDelivery += MessageBus_OnDelivery; }
private EBDictSearch() { this.InitializeComponent(); StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); }
public ReviewsInput( BookItem B ) :this() { IsReview = false; StringResources stx = new StringResources( "AppBar" ); Title.Text = stx.Str( "AddComment" ); }
public PlaceRequest( SHTarget Target, HubScriptItem HSI, string Placeholder ) { this.InitializeComponent(); StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( "OK" ); SecondaryButtonText = stx.Str( "Cancel" ); this.Target = Target; Canceled = true; BindItem = HSI; RemarksPlaceholder = Placeholder; SetTemplate(); }
public NameValueInput( NameValue<string> Item , string Title , string NameLabel, string ValueLabel , string BtnLeft = "OK", string BtnRight = "Cancel" ) { this.InitializeComponent(); Canceled = true; Target = Item; StringResources stx = new StringResources( "Message" ); PrimaryButtonText = stx.Str( BtnLeft ); SecondaryButtonText = stx.Str( BtnRight ); TitleText.Text = Title; NameLbl.Text = NameLabel; ValueLbl.Text = ValueLabel; }
private void DetectInputLogin() { string Name = Account.Text.Trim(); string Passwd = Password.Password; string PasswdV = PasswordV.Password; string Email = EmailInput.Text.Trim(); if ( string.IsNullOrEmpty( Name ) || string.IsNullOrEmpty( Passwd ) || string.IsNullOrEmpty( PasswdV ) || string.IsNullOrEmpty( Email ) ) { if ( string.IsNullOrEmpty( Name ) ) { Account.Focus( FocusState.Keyboard ); } else if ( string.IsNullOrEmpty( Passwd ) ) { Password.Focus( FocusState.Keyboard ); } else if( string.IsNullOrEmpty( PasswdV ) ) { PasswordV.Focus( FocusState.Keyboard ); } else if( string.IsNullOrEmpty( Email ) ) { EmailInput.Focus( FocusState.Keyboard ); } } else if( Passwd != PasswdV ) { StringResources stx = new StringResources( "Error" ); ServerMessage.Text = stx.Str( "PasswordMismatch" ); Password.Focus( FocusState.Keyboard ); } else { ServerMessage.Text = ""; IsPrimaryButtonEnabled = IsSecondaryButtonEnabled = Account.IsEnabled = Password.IsEnabled = PasswordV.IsEnabled = EmailInput.IsEnabled = false ; this.Focus( FocusState.Pointer ); IndicateLoad(); RuntimeCache RCache = new RuntimeCache() { EN_UI_Thead = true }; RCache.POST( Shared.ShRequest.Server , Shared.ShRequest.Register( Name, Passwd, Email ) , RequestComplete, RequestFailed, false ); } }
private void DetectInputLogin() { string CurrPasswd = CurrentPassword.Password; string NewPasswd = Password.Password; string PasswdV = PasswordV.Password; if ( string.IsNullOrEmpty( CurrPasswd ) || string.IsNullOrEmpty( NewPasswd ) || string.IsNullOrEmpty( PasswdV ) ) { if ( string.IsNullOrEmpty( CurrPasswd ) ) { CurrentPassword.Focus( FocusState.Keyboard ); } else if ( string.IsNullOrEmpty( NewPasswd ) ) { Password.Focus( FocusState.Keyboard ); } else if( string.IsNullOrEmpty( PasswdV ) ) { PasswordV.Focus( FocusState.Keyboard ); } } else if( NewPasswd != PasswdV ) { StringResources stx = new StringResources( "Error" ); ServerMessage.Text = stx.Str( "PasswordMismatch" ); Password.Focus( FocusState.Keyboard ); } else { ServerMessage.Text = ""; IsPrimaryButtonEnabled = IsSecondaryButtonEnabled = CurrentPassword.IsEnabled = Password.IsEnabled = PasswordV.IsEnabled = false ; this.Focus( FocusState.Pointer ); IndicateLoad(); RuntimeCache RCache = new RuntimeCache() { EN_UI_Thead = true }; RCache.POST( Shared.ShRequest.Server , Shared.ShRequest.ChangePassword( CurrPasswd, NewPasswd ) , RequestComplete, RequestFailed, false ); } }
private async void PopupSettings( object P ) { if( P.GetType() == typeof( bool ) ) { StringResources sts = new StringResources( "Settings" ); if ( !Properties.ENABLE_ONEDRIVE ) { StringResources stx = new StringResources( "InitQuestions" ); StringResources stm = new StringResources( "Message" ); MessageDialog Msg = new MessageDialog( stx.Text( "EnableOneDrive" ), "OneDrive" ); Msg.Commands.Add( new UICommand( stm.Str( "Yes" ), ( x ) => Properties.ENABLE_ONEDRIVE = true ) ); Msg.Commands.Add( new UICommand( stm.Str( "No" ), ( x ) => Properties.ENABLE_ONEDRIVE = false ) ); await Popups.ShowDialog( Msg ); if ( Properties.ENABLE_ONEDRIVE ) { if ( global::wenku8.Storage.OneDriveSync.Instance == null ) { global::wenku8.Storage.OneDriveSync.Instance = new global::wenku8.Storage.OneDriveSync(); } await global::wenku8.Storage.OneDriveSync.Instance.Authenticate(); } OneDriveButton.Desc = sts.Text( "Enabled" ); } else { Properties.ENABLE_ONEDRIVE = false; await global::wenku8.Storage.OneDriveSync.Instance.UnAuthenticate(); OneDriveButton.Desc = sts.Text( "Disabled" ); } return; } PopupFrame.Navigate( ( Type ) P ); PopupPage.State = ControlState.Reovia; }
public async Task<bool> ConfirmRestart( string CaptionRes ) { StringResources stx = new StringResources( "Settings" ); StringResources stm = new StringResources( "Message" ); // Ask for confirmatiosn MessageDialog Confirm = new MessageDialog( stm.Str( "NeedRestart" ), stx.Text( CaptionRes ) ); bool Restart = false; Confirm.Commands.Add( new UICommand( stm.Str( "Yes" ) , ( e ) => { Restart = true; } ) ); Confirm.Commands.Add( new UICommand( stm.Str( "No" ) ) ); await Popups.ShowDialog( Confirm ); if( Restart ) { Frame.BackStack.Clear(); NavigationHandler.InsertHandlerOnNavigatedBack( Exit ); RestartMask.State = ControlState.Reovia; PopupPage.State = ControlState.Foreatii; } return Restart; }
private async void GotoSettings( object sender, RoutedEventArgs e ) { StringResources stx = new StringResources( "Message", "Settings", "AppBar" ); bool Go = false; MessageDialog Msg = new MessageDialog( stx.Text( "Preface", "Settings" ), stx.Text( "Settings", "AppBar" ) ); Msg.Commands.Add( new UICommand( stx.Str( "Yes" ), x => Go = true ) ); Msg.Commands.Add( new UICommand( stx.Str( "No", "Message" ) ) ); await Popups.ShowDialog( Msg ); if ( Go ) { Dispose(); Frame.Navigate( typeof( Pages.Settings.MainSettings ) ); } }
private async void Delete( object sender, RoutedEventArgs e ) { StringResources stx = new StringResources( "Message" ); MessageDialog MsgBox = new MessageDialog( stx.Str( "ConfirmScriptRemove" ) ); bool DoDelete = false; MsgBox.Commands.Add( new UICommand( stx.Str( "Yes" ), x => { DoDelete = true; } ) ); MsgBox.Commands.Add( new UICommand( stx.Str( "No" ) ) ); await Popups.ShowDialog( MsgBox ); if ( DoDelete ) { // Since we cannot close the Frame from here // We call for help MessageBus.SendUI( GetType(), AppKeys.SH_SCRIPT_REMOVE, new Tuple<string, HubScriptItem>( AccessToken, BindItem ) ); } }
private async void OpenProcedures( object sender, RoutedEventArgs e ) { bool Yes = false; StringResources stx = new StringResources( "/libtaotu/Message" ); MessageDialog Msg = new MessageDialog( stx.Str( "ConfirmDiscard" ) ); Msg.Commands.Add( new UICommand( stx.Str( "Yes" ), x => Yes = true ) ); Msg.Commands.Add( new UICommand( stx.Str( "No" ) ) ); await Popups.ShowDialog( Msg ); if ( !Yes ) return; RootManager = PM = new ProcManager(); ProcChains.Clear(); SelectedItem = null; UpdateVisualData(); try { // Remove the file new AppStorage().DeleteFile( TargetFile ); IStorageFile ISF = await AppStorage.OpenFileAsync( ".xml" ); if ( ISF == null ) return; ProcManager.PanelMessage( ID, Res.RSTR( "Reading", ISF.Name ), LogType.INFO ); ReadXReg( new XRegistry( await ISF.ReadString(), TargetFile ) ); ProcManager.PanelMessage( ID, () => Res.RSTR( "ParseOK" ), LogType.INFO ); UpdateVisualData(); } catch( Exception ex ) { ProcManager.PanelMessage( ID, ex.Message, LogType.ERROR ); ProcManager.PanelMessage( ID, () => Res.RSTR( "InvalidXML" ), LogType.ERROR ); } }
private async void ChangeBackground( object sender, RoutedEventArgs e ) { MenuFlyoutItem item = sender as MenuFlyoutItem; string[] Argv = item.Tag.ToString().Split( ',' ); if ( Argv[ 0 ] == "Preset" ) { bool No = true; StringResources stx = new StringResources( "Message", "ContextMenu" ); MessageDialog MsgBox = new MessageDialog( stx.Str( "BInfoView_PresetBg_Mesg" ), stx.Text( "PresetBackground", "ContextMenu" ) ); MsgBox.Commands.Add( new UICommand( stx.Str( "Yes" ), x => { No = false; } ) ); MsgBox.Commands.Add( new UICommand( stx.Str( "No" ) ) ); await Popups.ShowDialog( MsgBox ); if ( No ) return; } LayoutSettings.GetBgContext( Argv[ 1 ] ).SetBackground( Argv[ 0 ] ); }
private async void DownloadVolume( object sender, RoutedEventArgs e ) { StringResources stx = new StringResources( "ContextMenu", "Message" ); MessageDialog Msg = new MessageDialog( RightClickedVolume.VolumeTitle, stx.Text( "AutoUpdate" ) ); bool Confirmed = false; Msg.Commands.Add( new UICommand( stx.Str( "Yes", "Message" ), ( x ) => Confirmed = true ) ); Msg.Commands.Add( new UICommand( stx.Str( "No", "Message" ) ) ); await Popups.ShowDialog( Msg ); if ( !Confirmed ) return; AutoCache.DownloadVolume( ThisBook, RightClickedVolume ); }
private async void ProcessVols() { StringResources stx = new StringResources( "LoadingMessage" ); string LoadText = stx.Str( "ProgressIndicator_Message" ); IEnumerable<string> BookIds = Shared.Storage.ListDirs( FileLinks.ROOT_LOCAL_VOL ); string[] favs = new BookStorage().GetIdList(); List<LocalBook> Items = new List<LocalBook>(); foreach ( string Id in BookIds ) { Loading = LoadText + ": " + Id; LocalBook LB = await LocalBook.CreateAsync( Id ); if ( LB.ProcessSuccess ) { Items.Add( LB ); LB.IsFav = favs.Contains( Id ); } } Action<string, SpiderBook> ProcessSpider = ( Id, LB ) => { Loading = LoadText + ": " + Id; if ( LB.aid != Id ) { try { Logger.Log( ID, "Fixing misplaced spider book" ); Shared.Storage.MoveDir( FileLinks.ROOT_SPIDER_VOL + Id, LB.MetaLocation ); } catch ( Exception ex ) { Logger.Log( ID , string.Format( "Unable to move script: {0} => {1}, {2} " , Id, LB.aid, ex.Message ) , LogType.WARNING ); } } if ( LB.ProcessSuccess || LB.CanProcess ) { Items.Add( LB ); LB.IsFav = favs.Contains( Id ); } else { try { Logger.Log( ID, "Removing invalid script: " + Id, LogType.INFO ); Shared.Storage.RemoveDir( LB.MetaRoot ); } catch ( Exception ex ) { Logger.Log( ID, "Cannot remove invalid script: " + ex.Message, LogType.WARNING ); } } }; BookIds = Shared.Storage.ListDirs( FileLinks.ROOT_SPIDER_VOL ); foreach ( string Id in BookIds ) { if ( Id[ 0 ] == ZONE_PFX ) { IEnumerable<string> ZoneItems = Shared.Storage.ListDirs( FileLinks.ROOT_SPIDER_VOL + Id + "/" ); foreach ( string SId in ZoneItems ) { /** * This code is a mess. I'll explain a bit more in here * First, the location of the Book.MetaLocation for ZoneItems * can only be retrived from BookInstruction * However ZoneId and Id are assinged by Spider on the fly, * restoring this information is a bit tricky */ // Create BookIntstruction just to retrieve the correct id pattern BookInstruction BInst = new BookInstruction( Id, SId ); /** * After 2 hours of investigations... * Welp, just outsmarted by myself, The CreateAsyncSpide works because: * Inside the TestProcessed method, the BookInstruction are created * using BoockInstruction( Id, Setings ) overload * the provided id is "this.aid" here BUT the full id is restored again * in InitProcMan() method * Fortunately, ssid will be set correctly inside the ReadInfo method */ ProcessSpider( BInst.Id, await SpiderBook.CreateAsyncSpider( BInst.Id ) ); } } else { ProcessSpider( Id, await SpiderBook.CreateAsyncSpider( Id ) ); } } if ( 0 < Items.Count ) SearchSet = Items; Loading = null; }
private void GotoBookInfoView( string id ) { Logger.Log( ID, string.Format( "Navigate to BookInfoView, id: {0}", id ), LogType.INFO ); StringResources stx = new StringResources( "LoadingMessage" ); LoadingMask.Text = stx.Str( "ProgressIndicator_Message" ); Action A = async () => { TaskCompletionSource<BookItem> TCS = new TaskCompletionSource<BookItem>(); new BookLoader( ( x ) => TCS.SetResult( x ) ).Load( X.Instance<BookItem>( XProto.BookItemEx, id ) , true ); BookItem b = await TCS.Task; if( b == null ) { LoadingMask.Text = "Failed to download data"; return; } LoadingMask.Text = b.Title; await Frame.Dispatcher.RunIdleAsync( x => Frame.Navigate( typeof( Pages.BookInfoView ), id ) ); }; LoadingMask.HandleForward( Frame, A ); }
private async Task SearchBooks( List<BookInstruction> ItemList, ProcPassThru PPass, ProcConvoy KnownBook, string Content ) { ProcFind.RegItem RegParam = new ProcFind.RegItem( ItemPattern, ItemParam, true ); if ( !RegParam.Validate() ) return; MatchCollection matches = RegParam.RegExObj.Matches( Content ); foreach ( Match match in matches ) { if ( HasSubProcs && RegParam.Valid ) { string FParam = string.Format( RegParam.Format , match.Groups .Cast<Group>() .Select( g => g.Value ) .ToArray() ); ProcConvoy ItemConvoy = await ItemProcs.CreateSpider().Crawl( new ProcConvoy( PPass, FParam ) ); string Id = await GetId( ItemConvoy ); if ( string.IsNullOrEmpty( Id ) ) { ProcManager.PanelMessage( this, () => { StringResources stx = new StringResources( "Error" ); return stx.Str( "NoIdForBook" ); }, LogType.WARNING ); continue; } ItemConvoy = ProcManager.TracePackage( ItemConvoy, ( P, C ) => C.Payload is BookInstruction ); if ( !( ItemConvoy == null || ItemConvoy == KnownBook ) ) { BookInstruction BInst = ( BookInstruction ) ItemConvoy.Payload; ItemList.Add( BInst ); if ( HasBookSpider ) BInst.PlaceDefs( Id, BookSpider ); } else { ProcManager.PanelMessage( this, () => { StringResources stx = new StringResources( "Error" ); return stx.Str( "NotABook" ); }, LogType.WARNING ); } } } }
private void SetTemplate() { StringResources stx = new StringResources( "/libtaotu/ProcItems" ); Dictionary<ProcType, string> ProcChoices = new Dictionary<ProcType, string>(); Type PType = typeof( ProcType ); foreach ( ProcType P in Enum.GetValues( PType ) ) { string ProcName = stx.Str( Enum.GetName( PType, P ) ); if ( string.IsNullOrEmpty( ProcName ) ) continue; ProcChoices.Add( P, ProcName ); } RootManager = new ProcManager(); ProcComboBox.ItemsSource = ProcChoices; RunLog.ItemsSource = Logs; ProcManager.PanelMessage( ID, () => Res.RSTR( "Welcome" ), LogType.INFO ); Logs.CollectionChanged += ( s, e ) => ScrollToBottom(); PM = RootManager; ReadProcedures( TargetFile ); UpdateVisualData(); }
private void SetTemplate() { LayoutRoot.DataContext = BindItem; if( BindItem.Encrypted ) { ReqTarget = SHTarget.KEY; Crypt = ( CryptAES ) new AESManager().GetAuthById( BindItem.Id ); } BottomControls = new ObservableCollection<PaneNavButton>(); AccessToken = ( string ) new TokenManager().GetAuthById( BindItem.Id )?.Value; XGrant.SetParameter( BindItem.Id, BookStorage.TimeKey ); if ( !string.IsNullOrEmpty( AccessToken ) ) { TransitionDisplay.SetState( AccessControls, TransitionState.Active ); } AvailControls = new Dictionary<string, PaneNavButton>() { { "Download", new PaneNavButton( new IconLogin() { AutoScale = true, Direction = Direction.Rotate270 }, Download ) } , { "Comment", new PaneNavButton( new IconComment() { AutoScale = true }, ToggleComments ) } , { "HideComment", new PaneNavButton( new IconNavigateArrow() { AutoScale = true, Direction = Direction.MirrorHorizontal }, ToggleComments ) } , { "NewComment", new PaneNavButton( new IconPlusSign() { AutoScale = true }, () => { StringResources stx = new StringResources( "AppBar" ); CCTarget = SHTarget.SCRIPT; CCId = BindItem.Id; NewComment( stx.Str( "AddComment" ) ); } ) } , { "OpenRequest", new PaneNavButton( new IconKeyRequest() { AutoScale = true }, ToggleRequests ) } , { "KeyRequest", new PaneNavButton( new IconRawDocument() { AutoScale = true }, () => { ShowRequest( SHTarget.KEY ); } ) } , { "TokenRequest", new PaneNavButton( new IconMasterKey() { AutoScale = true }, () => { ShowRequest( SHTarget.TOKEN ); } ) } , { "CloseRequest", new PaneNavButton( new IconNavigateArrow() { AutoScale = true, Direction = Direction.MirrorHorizontal }, ToggleRequests ) } , { "Submit", new PaneNavButton( new IconTick() { AutoScale = true }, SubmitComment ) } , { "Discard", new PaneNavButton( new IconCross() { AutoScale = true }, DiscardComment ) } }; DisplayControls( HomeControls ); ControlsList.ItemsSource = BottomControls; CommentStory = new Storyboard(); CommentStory.Completed += CommentStory_Completed; RequestStory = new Storyboard(); RequestStory.Completed += RequestStory_Completed; Member = X.Singleton<IMember>( XProto.SHMember ); Unloaded += ScriptDetails_Unloaded; }
private void SetTemplate() { StringResources stx = new StringResources( "/libtaotu/Message" ); PrimaryButtonText = stx.Str( "OK" ); }
private void OpenMask() { StringResources stx = new StringResources( "LoadingMessage" ); RenderMask.Text = stx.Str( "ProgressIndicator_Message" ); RenderMask.State = ControlState.Reovia; }