示例#1
0
 public static void CheckTranslationRequests(Dispatcher dispatcher)
 {
     try {
         string cultureName = App.CurrentCulture.Name;
         if (!cultureName.StartsWith("en", StringComparison.OrdinalIgnoreCase))
         {
             SettingsStringCache checkedVersion = DialogAbout.TranslationRequestVersion();
             if (!Version.TryParse(checkedVersion.Value, out Version version) || version < DialogAbout.CurrentVersion())
             {
                 string text = null;
                 using (WebClient client = new WebClient()) {
                     client.UseDefaultCredentials = true;
                     text = client.DownloadString(new Uri("https://www.LogicCircuit.org/TranslationRequests.txt"));
                 }
                 if (!string.IsNullOrWhiteSpace(text) && text.Contains(cultureName))
                 {
                     dispatcher.BeginInvoke(
                         new Action(() => App.Mainframe.InformationMessage(
                                        "If you can help translating this program to any language you are fluent in please contact me at:\n" +
                                        "<Hyperlink NavigateUri=\"https://www.logiccircuit.org/contact.html\">https://www.logiccircuit.org/contact.html</Hyperlink>"
                                        )),
                         DispatcherPriority.ApplicationIdle
                         );
                 }
                 checkedVersion.Value = DialogAbout.CurrentVersion().ToString();
             }
         }
     } catch (Exception exception) {
         Tracer.Report("DialogAbout.CheckTranslationRequests", exception);
         // ignore all exception here
     }
 }
 private void Import()
 {
     if (this.Editor != null && this.Editor.InEditMode)
     {
         string dir    = Mainframe.DefaultProjectFolder();
         string recent = Settings.User.RecentFile();
         if (Mainframe.IsFilePathValid(recent))
         {
             dir = Path.GetDirectoryName(recent);
         }
         SettingsStringCache location = new SettingsStringCache(Settings.User, "ImportFile.Folder", dir);
         OpenFileDialog      dialog   = new OpenFileDialog {
             Filter           = Mainframe.FileFilter,
             DefaultExt       = Mainframe.FileExtention,
             InitialDirectory = Mainframe.IsDirectoryPathValid(location.Value) ? location.Value : Mainframe.DefaultProjectFolder()
         };
         bool?result = dialog.ShowDialog(this);
         if (result.HasValue && result.Value)
         {
             string file = dialog.FileName;
             location.Value = Path.GetDirectoryName(file);
             this.Editor.Import(file);
         }
     }
 }
		protected DialogMemoryEditor(Memory memory) {
			string typeName = this.GetType().Name;
			this.openFileFolder = new SettingsStringCache(Settings.User, typeName + ".OpenFile.Folder", Mainframe.DefaultProjectFolder());
			this.DataHeight = new SettingsGridLengthCache(Settings.User, typeName + ".Data.Height", memory.Writable ? "0.25*" : "0.75*");
			this.NoteHeight = new SettingsGridLengthCache(Settings.User, typeName + ".Note.Height", memory.Writable ? "0.75*" : "0.25*");

			this.Memory = memory;
			this.data = memory.MemoryValue();

			this.DataContext = this;
			this.InitializeComponent();

			this.addressBitWidth.ItemsSource = MemoryDescriptor.AddressBitWidthRange;
			this.dataBitWidth.ItemsSource = PinDescriptor.BitWidthRange;
			IEnumerable<EnumDescriptor<bool>> writeOnList = MemoryDescriptor.WriteOnList;
			this.writeOn.ItemsSource = writeOnList;
			EnumDescriptor<MemoryOnStart>[] onStartList = new EnumDescriptor<MemoryOnStart>[] {
				new EnumDescriptor<MemoryOnStart>(MemoryOnStart.Random, Properties.Resources.MemoryOnStartRandom),
				new EnumDescriptor<MemoryOnStart>(MemoryOnStart.Zeros, Properties.Resources.MemoryOnStartZeros),
				new EnumDescriptor<MemoryOnStart>(MemoryOnStart.Ones, Properties.Resources.MemoryOnStartOnes),
				new EnumDescriptor<MemoryOnStart>(MemoryOnStart.Data, Properties.Resources.MemoryOnStartData)
			};
			this.onStart.ItemsSource = onStartList;

			this.addressBitWidth.SelectedItem = this.currentAddressBitWidth = this.Memory.AddressBitWidth;
			this.dataBitWidth.SelectedItem = this.currentDataBitWidth = this.Memory.DataBitWidth;
			this.writeOn.SelectedItem = writeOnList.First(d => d.Value == this.Memory.WriteOn1);
			this.onStart.SelectedItem = onStartList.First(d => d.Value == (this.Memory.Writable ? this.Memory.OnStart : MemoryOnStart.Data));
			this.note.Text = this.Memory.Note;

			this.FunctionMemory = new MemoryEditor(this.data, this.Memory.AddressBitWidth, this.DataBitWidth);

			this.initialized = true;
		}
 public DialogFind(Editor editor)
 {
     this.searchFilter = new SettingsStringCache(Settings.Session, "DialogFind.filter", string.Empty);
     this.editor       = editor;
     this.DataContext  = this;
     this.InitializeComponent();
     this.PreviewKeyUp += DialogFindPreviewKeyUp;
 }
示例#5
0
        private static void ValidateSettingsCulture()
        {
            SettingsStringCache cultureName = new SettingsStringCache(Settings.User, App.SettingsCultureName, App.DefaultCultureName());
            string name = App.ValidateCultureName(cultureName.Value);

            if (name != cultureName.Value)
            {
                Tracer.FullInfo("App.ValidateSettingsCulture", "Replacing current settings culture {0} with {1}", cultureName.Value, name);
                App.currentCultureName.Value = name;
            }
        }
示例#6
0
        public static void ResetTranslationRequestVersion()
        {
            SettingsStringCache checkedVersion = DialogAbout.TranslationRequestVersion();

            checkedVersion.Value = null;
        }