Beispiel #1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (Editor.IsModified)
            {
                var ret = MessageBox.Show(Properties.Resources.RequestSave, Properties.Resources.RequestSaveTitle, MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (ret == MessageBoxResult.Yes)
                {
                    OnSave(null, null);
                }
            }
            ScaleRatio = Editor.ScacleRatio;
            IniFile.WriteValue("Editor", "IsHighLight", ButtonHighligh.IsChecked + "");
            IniFile.WriteValue("Editor", "HighLightSpeed", (100 - SliderSpeeder.Value) + "");
            int    usedTime = 0;
            string v        = IniFile.ReadValue("Editor", "UseCycle");

            if (!string.IsNullOrEmpty(v))
            {
                int.TryParse(v, out usedTime);
            }
            usedTime++;
            IniFile.WriteValue("Editor", "UseCycle", usedTime + "");
            string review = IniFile.ReadValue("Editor", "Reviewed");

            if (string.IsNullOrEmpty(review) && usedTime % 10 == 4)
            {
            }
            try
            {
                engine?.Stop();
            }
            catch { }
            //Environment.Exit(0);
            base.OnClosing(e);
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            string language = IniFile.ReadValue("Language", "Language");

            if (!string.IsNullOrEmpty(language))
            {
                SetLanguage(language);
            }
            this.DispatcherUnhandledException          += App_DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            base.OnStartup(e);
        }
Beispiel #3
0
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     foreach (var l in libs)
     {
         if (l.IsStoreLibrary)
         {
             var s = IniFile.ReadValue("Addon", l.Assembly);
             if (!string.IsNullOrEmpty(s))
             {
                 l.IsPurchased = true;
             }
         }
     }
 }
Beispiel #4
0
        public MainWindow()
        {
            InitializeComponent();
            //AllocConsole();
            libs.Add(new LibraryItem()
            {
                Library = new MathLibary(), IsStoreLibrary = false, Image = LoadSource("/images/Math.png")
            });
            libs.Add(new LibraryItem()
            {
                Library = new CanvasCollection(), IsStoreLibrary = false, Image = LoadSource("/images/PAINT.png")
            });
            libs.Add(new LibraryItem()
            {
                Library = new SpeechLibrary(), IsStoreLibrary = false, Image = LoadSource("/images/Microphone.png")
            });
            libs.Add(new LibraryItem()
            {
                Library = new CollectionLibary(), IsStoreLibrary = false, Image = LoadSource("/images/list.png")
            });
            libs.Add(new LibraryItem()
            {
                Library = new DataStructureLibrary(), IsStoreLibrary = false, Image = LoadSource("/images/collection.png")
            });
            libs.Add(new LibraryItem()
            {
                Library = new ThreadCollection(), IsStoreLibrary = false, Image = LoadSource("/images/th.png")
            });

            Editor.IsEnabled        = false;
            Editor.IsLibraryEnabled = true;
            Editor.Register((Color)ColorConverter.ConvertFromString("#95f0c7"), typeof(StringExpression), typeof(IndexOfStringExpression),
                            typeof(LastIndexOfStringExpression), typeof(SubStringExpression), typeof(StringLengthExpression), typeof(ParseLongExpression),
                            typeof(ParseIntExpression), typeof(ParseFloatExpression), typeof(ParseDoubleExpression));
            Editor.Register((Color)ColorConverter.ConvertFromString("#4C97FF"), typeof(PrintLnStatement), typeof(PrintStatement),
                            typeof(ReadLineExpression), typeof(ReadExpression), typeof(ClearStatement));
            Editor.Register <IfStatement, TrueExpression, FalseExpression>((Color)ColorConverter.ConvertFromString("#078aab"));
            Editor.Register((Color)ColorConverter.ConvertFromString("#06cccc"), typeof(NewArrayExpression), typeof(ArrayValueExpression),
                            typeof(NewArray2Expression), typeof(Array2ValueExpression),
                            typeof(ArrayLengthExpression));
            foreach (var l in libs)
            {
                Color c = (Color)ColorConverter.ConvertFromString(l.Library.DefaultColor);
                foreach (var g in l.Library)
                {
                    foreach (var s in g)
                    {
                        Editor.Register(c, s.Step.GetType());
                    }
                }
            }
            Editor.SetToolBar(CreateToolbar());
            Editor.ScacleRatio          = ScaleRatio;
            Editor.TypeColorChanged    += EditTypeColorChanged;
            Editor.ChangeImportLibrary += Editor_ChangeImportLibrary;
            if ("true".Equals(IniFile.ReadValue("Editor", "IsHighLight"), StringComparison.OrdinalIgnoreCase))
            {
                ButtonHighligh.IsChecked = true;
            }
            string speed = IniFile.ReadValue("Editor", "HighLightSpeed");

            if (!string.IsNullOrEmpty(speed))
            {
                try
                {
                    SliderSpeeder.Value = 100 - double.Parse(speed);
                }
                catch { }
            }
            toast     = new Toast();
            Unloaded += MainWindow_Unloaded;
            Loaded   += MainWindow_Loaded;
            LoadColors();
            string firstTime = IniFile.ReadValue("Editor", "FirstUsage");

            if (string.IsNullOrEmpty(firstTime))
            {
                IniFile.WriteValue("Editor", "FirstUsage", "false");
                new Thread(() =>
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        MessageBoxResult ret = MessageBox.Show(this, Properties.Resources.RequestVideo, Properties.Resources.Welcome, MessageBoxButton.YesNo, MessageBoxImage.Information);
                        if (ret == MessageBoxResult.Yes)
                        {
                            OnHelp(null, null);
                        }
                    });
                }).Start();
            }
            else if (!string.IsNullOrEmpty(File) && System.IO.File.Exists(File))
            {
                new Thread(() =>
                {
                    Thread.Sleep(500);
                    Dispatcher.Invoke(() =>
                    {
                        Editor.Script    = null;
                        Editor.IsEnabled = false;
                        try
                        {
                            Script script = Serialization.Load(File) as Script;
                            SetupScriptToolbar(script);
                            Editor.Script = script;
                            this.Title    = Properties.Resources.VisualCodeEditor + " - " + File;
                            ShowMessage(toast.ShowSuccess, string.Format(Properties.Resources.SuccessLodFile, File));
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Console.WriteLine(ex.StackTrace);
                            ShowMessage(toast.ShowWarning, string.Format(Properties.Resources.ExceptionLoadFile, File));
                            return;
                        }
                        Editor.IsEnabled       = true;
                        ButtonStart.IsEnabled  = true;
                        ButtonOpen.IsEnabled   = true;
                        ButtonSave.IsEnabled   = true;
                        ButtonSaveAs.IsEnabled = true;
                        ButtonPrint.IsEnabled  = true;
                        //d.PurchaseAddOn("9NG2QVSXT34H");
                    });
                }).Start();
            }
        }