Пример #1
0
        private void SafeHide(object sender, EventArgs e)
        {
            try
            {
                //    this.BeginAnimation(UserControl.OpacityProperty, new DoubleAnimation(0.0f, new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior.HoldEnd));

                GC_UIHelper.CloseMessageWindow();

                if (state == ResultState.Pass ||
                    state == ResultState.Perfect)
                {
                    if (this.callback != null)
                    {
                        this.callback(true);
                    }
                }
                else
                {
                    if (this.callback != null)
                    {
                        this.callback(false);
                    }
                }
            }
            catch
            {
            }
        }
Пример #2
0
        private bool SelectItem(UIElement element)
        {
            int currentIndex = -1;
            int index        = -1;

            foreach (UIElement child in this.Children)
            {
                index++;
                if (GC_UIHelper.FindChild <UIElement>(child, element) != null)
                {
                    currentIndex = index;
                    break;
                }
            }
            int deltaIndex = currentIndex - this.SelectedIndex;

            if (deltaIndex == 0 && currentIndex != -1)
            {
                this.RaiseSelectionChangedEvent();
                return(false);
            }

            this.preSelectedItem = this.SelectedItem;
            this.SelectedIndex   = currentIndex;

            return(true);
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            //this.Left = (float)SystemInformation.WorkingArea.Left;
            //this.Top = (float)SystemInformation.WorkingArea.Top;
            //this.Width = (float)SystemInformation.WorkingArea.Width;
            //this.Height = (float)SystemInformation.WorkingArea.Height;

            //    this.containerGrid.Width = this.Width;
            //    this.containerGrid.Height = this.Height;
            //    this.containerGrid.Height = this.containerGrid.Width / (this.Width / this.Height);

            this.Dispatcher.BeginInvoke(new ThreadStart(() =>
            {
                foreach (string title in GC_UIHelper.GetCurrentUser())
                {
                    this.titleTextBlock.Text = title;
                }
            }),
                                        DispatcherPriority.Background,
                                        null);

            LoginWindow loginCtrl = new LoginWindow();

            loginCtrl.ShowDirectLogin = true;
            loginCtrl.ShowDialog();

            this.containerPanel.Content = new LoadGadgetWindow();
        }
Пример #4
0
 private void cancelBtn_Click(object sender, RoutedEventArgs e)
 {
     GC_UIHelper.CloseMessageWindow();
     if (this.callback != null)
     {
         this.callback(false);
     }
 }
Пример #5
0
        internal void ShowPuzzle()
        {
            this.loadGadgetDataWnd.DataItemLoadedEvent    -= new DataItemLoadedDelegate(win_DataItemLoadedEvent);
            this.loadGadgetDataWnd.DataLoadCompletedEvent -= new DataLoadCompletedDelegate(win_DataLoadCompletedEvent);

            GC_UIHelper.CloseMessageWindow();

            this.rootGrid.Children.Clear();
            this.rootGrid.Children.Add(ControlMgr.Instance.PuzzlePage);
        }
Пример #6
0
        private void SafeHide(object sender, EventArgs e)
        {
            this.BeginAnimation(UserControl.OpacityProperty, new DoubleAnimation(0.0f, new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior.HoldEnd));

            GC_UIHelper.CloseMessageWindow();

            if (this.ResultInfoCompleted != null)
            {
                this.ResultInfoCompleted(this, EventArgs.Empty);
            }
        }
Пример #7
0
        private void okBtn_Click(object sender, RoutedEventArgs e)
        {
            this.holdTimer.Stop();

            GC_UIHelper.CloseMessageWindow();

            if (this.callback != null)
            {
                this.callback(true);
            }
        }
        internal void Save()
        {
            byte[] bkImgData     = new byte[0];
            byte[] numberImgData = new byte[0];
            if (!string.IsNullOrEmpty(this.bkImageFile))
            {
                BitmapImage bi = new BitmapImage(new Uri(this.bkImageFile));
                bkImgData = GC_UIHelper.GetBitmapData(this.bkImageFile, (int)bi.Width, (int)bi.Height);
                //    bkImgData = GC_UIHelper.GetBitmapData(this.bkImageFile, (int)this.Width, (int)this.Height);
            }

            if (!string.IsNullOrEmpty(this.imageFile))
            {
                numberImgData = GC_UIHelper.GetBitmapData(this.imageFile, (int)this.drawingImage.Width, (int)this.drawingImage.Height);
            }

            //    RenderTargetBitmap bmp = new RenderTargetBitmap((int)this.Width, (int)this.Height, 96, 96, PixelFormats.Pbgra32);
            //    bmp.Render(this);

            this.drawNumberData.DrawNumberItem.ThumbnailData = GC_UIHelper.GetBitmapData(this.bkImageFile, 128, 128);

            //BitmapEncoder encoder = new PngBitmapEncoder();

            //encoder.Frames.Add(BitmapFrame.Create(bmp));
            //using (MemoryStream ms = new MemoryStream())
            //{
            //    encoder.Save(ms);

            //    System.Drawing.Bitmap visualBmp = new System.Drawing.Bitmap(ms);

            //    Vector vec = GC_UIHelper.MatchImageToWnd(new Size(this.Width, this.Height), new Size(128, 128));
            //    System.Drawing.Image thumbnail = visualBmp.GetThumbnailImage((int)vec.X, (int)vec.Y, null, IntPtr.Zero);

            //    MemoryStream thumbnailMS = new MemoryStream();
            //    thumbnail.Save(thumbnailMS, System.Drawing.Imaging.ImageFormat.Png);
            //    this.drawNumberData.DrawNumberItem.ThumbnailData = thumbnailMS.ToArray();
            //}

            this.drawNumberData.DrawNumberItem.NumberImagePoint = new Point(Canvas.GetLeft(this.drawingImage), Canvas.GetTop(this.drawingImage));
            this.drawNumberData.DrawNumberItem.CanvasWidth      = (int)this.Width;
            this.drawNumberData.DrawNumberItem.CanvasHeight     = (int)this.Height;
            this.drawNumberData.DrawNumberItem.ForegroundWidth  = this.drawingImage.ActualWidth;
            this.drawNumberData.DrawNumberItem.ForegroundHeight = this.drawingImage.ActualHeight;

            this.drawNumberData.BackgroundImageData = bkImgData;
            this.drawNumberData.DrawNumberImageData = numberImgData;
        }
Пример #9
0
        public void ShowMessage(string message, MessageBoxButton msgBtn, MessageWindowCallback callback)
        {
            if (msgBtn == MessageBoxButton.OK)
            {
                this.btnPanel.Children.Remove(this.cancelBtn);
            }

            this.callback = callback;
            //     this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            this.infoTextBlock.Text = message;
            //     this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;

            GC_UIHelper.ShowMessageWindow(this);

            //    return this.ShowDialog().Value;
        }
Пример #10
0
        private void bkImageBtn_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDlg = new OpenFileDialog();

            openFileDlg.Filter = SoonLearning.ConnectNumber.Properties.Resources.ImageFilter;
            if (openFileDlg.ShowDialog(App.Current.MainWindow).Value)
            {
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(openFileDlg.FileName);

                Vector vec = GC_UIHelper.MatchImageToWnd(new Size(bmp.Width, bmp.Height), new Size(this.canvasWidth, this.canvasHeight));
                this.drawNumberEditingCanvas.Width  = vec.X;
                this.drawNumberEditingCanvas.Height = vec.Y;

                bmp.Dispose();

                this.drawNumberEditingCanvas.BkImageFile = openFileDlg.FileName;
            }
        }
Пример #11
0
        private void resultTimerCallback(object state)
        {
            this.resultTimer.Dispose();
            this.resultTimer = null;

            this.Dispatcher.BeginInvoke(new ThreadStart(() =>
            {
                ResultInfoUserControl resultControl = new ResultInfoUserControl();
                resultControl.State = ResultState.Pass;
                resultControl.ResultInfoCompleted += (object sender, EventArgs e) =>
                {
                    this.Next();
                };
                GC_UIHelper.ShowMessageWindow(resultControl);
            }),
                                        DispatcherPriority.Background,
                                        null);
        }
Пример #12
0
        internal void LoadPuzzleItems(EventHandler <EventArgs> endLoading)
        {
            ControlMgr.Instance.DataMgr.Clear();

            this.endLoadPuzzleItems = endLoading;

            if (this.loadGadgetDataWnd == null)
            {
                loadGadgetDataWnd = new LoadAppDataWindow(new Uri(ControlMgr.Instance.Entry.Thumbnail));
            }
            this.loadGadgetDataWnd.DataPath                = PuzzleSetting.Instance.DataFolder;
            this.loadGadgetDataWnd.FileExt                 = new string[] { "*.pd" };
            this.loadGadgetDataWnd.DataItemLoadedEvent    += new DataItemLoadedDelegate(win_DataItemLoadedEvent);
            this.loadGadgetDataWnd.DataLoadCompletedEvent += new DataLoadCompletedDelegate(win_DataLoadCompletedEvent);

            GC_UIHelper.ShowMessageWindow(this.loadGadgetDataWnd);

            this.loadGadgetDataWnd.StartToLoad();
        }
Пример #13
0
        private void appListBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox listBox = sender as ListBox;

            if (listBox == null)
            {
                return;
            }

            Point         clickPoint = e.GetPosition(listBox);
            HitTestResult result     = VisualTreeHelper.HitTest(listBox, clickPoint);

            ListBoxItem listBoxItem = GC_UIHelper.FindParent <ListBoxItem>(result.VisualHit);

            if (listBoxItem == null)
            {
                return;
            }

            if (listBoxItem.Content is AddAppItem)
            {
                this.managementBtn_Click(sender, new RoutedEventArgs());
            }
            else if (listBoxItem.Content is AppItem)
            {
                AppItem    item    = listBoxItem.Content as AppItem;
                MainWindow mainWnd = App.Current.MainWindow as MainWindow;
                mainWnd.LoadGadget(item);

                listBox.SelectedIndex = -1;

                Thread.Sleep(System.Windows.Forms.SystemInformation.DoubleClickTime);
            }
            else if (listBoxItem.Content is TypeItem)
            {
                //TypeItem typeItem = listBoxItem.Content as TypeItem;
                //this.appListStackPanel.Visibility = System.Windows.Visibility.Visible;
                //this.appListBox.Visibility = System.Windows.Visibility.Hidden;
                //if (!string.IsNullOrEmpty(typeItem.Thumbnail))
                //    this.typeThumbnailImage.Source = new BitmapImage(new Uri(typeItem.Thumbnail));
                //this.appListBox_All.ItemsSource = DataMgr.Instance[typeItem.Type];
            }
        }
Пример #14
0
        private void loginBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.idTextBox.Text))
                {
                    MessageBox.Show("请输入用户编号!如果您还没有快学账号,请登录快学网站注册。", "快学", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (string.IsNullOrEmpty(this.passwordTextBox.Password))
                {
                    MessageBox.Show("请输入密码!", "快学", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                DataMgr.Instance.LoginInfo.Password = this.passwordTextBox.Password;
                string ret = DataMgr.Instance.AppService.GetLoginName(DataMgr.Instance.LoginInfo.LoginId,
                                                                      DataMgr.Instance.LoginInfo.Password,
                                                                      LoginInfo.GetMD5Hash("4%!@s*&d"));

                string[] rets = ret.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                if (rets != null && rets.Length > 1)
                {
                    if (rets[0] == "0")
                    {
                        StringBuilder strBuilder = new StringBuilder();
                        strBuilder.AppendLine("登录失败。");
                        strBuilder.AppendLine(rets[1]);
                        MessageBox.Show(strBuilder.ToString(), "快学", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("登录失败,请稍后重试!", "快学", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            GC_UIHelper.CloseMessageWindow();
        }
Пример #15
0
        private void readCountResultListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox       lb            = sender as ListBox;
            ReadCountItem readCountItem = lb.SelectedItem as ReadCountItem;

            if (readCountItem == null)
            {
                return;
            }

            ListBoxItem item = lb.ItemContainerGenerator.ContainerFromItem(readCountItem) as ListBoxItem;

            FocusItem(item, "numberTextBox");
            NumberOnlyTextBox textBox = GC_UIHelper.FindChild <NumberOnlyTextBox>(item, "numberTextBox");

            if (textBox != null)
            {
                textBox.SelectAll();
            }
        }
Пример #16
0
        private void ShowInfo()
        {
            switch (this.state)
            {
            case ResultState.Perfect:
            {
                this.resultImage.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/SoonLearning.AppCenter;component/Resources/Images/BigSmile.png"));
                this.infoLabel.Text     = Strings.Good;
                AudioHelper.PlayPassSound();
            }
            break;

            case ResultState.NotPass:
            {
                this.resultImage.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/SoonLearning.AppCenter;component/Resources/Images/Cry.png"));
                this.infoLabel.Text     = Strings.Back;
            }
            break;
            }

            this.holdTimer.Interval = 1000;
            this.BeginAnimation(UserControl.OpacityProperty, new DoubleAnimation(1.0f, new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior.HoldEnd));
            this.holdTimer.Start();

            GC_UIHelper.ShowMessageWindow(this);
        }
        private void okButton_Click(object sender, RoutedEventArgs e)
        {
            bool ret = LicenseMgr.Instance.IsLicenseForCurrentMachine(this.licenseTextBox.Text, App.appCenterId);

            if (!ret)
            {
                MessageBox.Show("速学应用平台预览版证书格式错误,请访问http://www.soonlearning.com获取证书!", "证书错误", MessageBoxButton.OK, MessageBoxImage.Stop);
                this.licenseTextBox.SelectAll();
                this.licenseTextBox.Focus();
                return;
            }

            LicenseMgr.Instance.SaveLicenseToFile(this.licenseTextBox.Text, App.appCenterId);

            GC_UIHelper.CloseMessageWindow();

            if (this.LicenseVerifiedEvent != null)
            {
                this.LicenseVerifiedEvent(this, EventArgs.Empty);
            }
        }
Пример #18
0
        private void Update()
        {
            if (!this.update)
            {
                return;
            }

            DrawNumberItem item = ControlMgr.Instance.DataMgr.SelectedItem;

            if (item == null)
            {
                return;
            }

            DrawNumberControl.Instance.SelectedStage = ControlMgr.Instance.DataMgr.CurrentIndex;

            this.drawNumberData = DrawNumberData.Load(item.DataFile);

            Size imgSize = new Size();

            imgSize.Width  = this.drawNumberData.DrawNumberItem.CanvasWidth;
            imgSize.Height = this.drawNumberData.DrawNumberItem.CanvasHeight;
            if (imgSize.Width < 1.0f)
            {
                imgSize.Width = this.drawNumberData.DrawNumberItem.CanvasWidth;
            }
            if (imgSize.Height < 1.0f)
            {
                imgSize.Height = this.drawNumberData.DrawNumberItem.CanvasHeight;
            }
            Vector vec = GC_UIHelper.MatchImageToWnd(imgSize, new Size(panelGrid.ActualWidth, panelGrid.ActualHeight));

            this.drawNumberCanvas.Width  = vec.X; // this.drawNumberData.DrawNumberItem.CanvasWidth;
            this.drawNumberCanvas.Height = vec.Y; // this.drawNumberData.DrawNumberItem.CanvasHeight;

            this.drawNumberCanvas.Data = this.drawNumberData;
            this.update = false;
        }
        private void thumbnailList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListBox listBox = sender as ListBox;

            if (listBox == null)
            {
                return;
            }

            Point         clickPoint = e.GetPosition(listBox);
            HitTestResult result     = VisualTreeHelper.HitTest(listBox, clickPoint);

            ListBoxItem listBoxItem = GC_UIHelper.FindParent <ListBoxItem>(result.VisualHit);

            if (listBoxItem == null)
            {
                return;
            }

            if (this.ThumbnailItemSelectedEvent != null)
            {
                this.ThumbnailItemSelectedEvent(listBox.Items.IndexOf(listBoxItem));
            }
        }
 private void closeButton_Click(object sender, RoutedEventArgs e)
 {
     GC_UIHelper.CloseMessageWindow();
     App.Current.Shutdown();
 }
Пример #21
0
 private void cancelButton_Click(object sender, RoutedEventArgs e)
 {
     GC_UIHelper.CloseMessageWindow();
 }
Пример #22
0
 public void ShowMessage(MessageWindowCallback callback)
 {
     this.callback = callback;
     this.ShowInfo();
     GC_UIHelper.ShowMessageWindow(this);
 }
Пример #23
0
 private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
 {
     GC_UIHelper.CloseMessageWindow();
 }