Пример #1
0
 private void BookMarkScriptImg_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (this.IsBookmarked)
     {
         this.IsBookmarked = false;
         SingleMacroControl.DeleteScriptNameFromBookmarkedScriptListIfPresent(this.mRecording.Name);
         this.ParentWindow.mCommonHandler.OnMacroBookmarkChanged(this.mRecording.Name, false);
     }
     else if (RegistryManager.Instance.BookmarkedScriptList.Length < 5)
     {
         this.IsBookmarked = true;
         this.AddScriptNameToBookmarkedScriptListIfNotPresent(this.mRecording.Name);
         this.ParentWindow.mCommonHandler.OnMacroBookmarkChanged(this.mRecording.Name, true);
     }
     else
     {
         this.ParentWindow.mCommonHandler.AddToastPopup((Window)this.mMacroRecorderWindow, LocaleStrings.GetLocalizedString("STRING_BOOKMARK_MACRO_WARNING", ""), 2.5, true);
     }
     ClientStats.SendMiscellaneousStatsAsync("MacroOperations", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, "macro_window_bookmark", (string)null, this.mRecording.RecordingType.ToString(), (string)null, (string)null, (string)null, "Android");
 }
Пример #2
0
        private void DeleteMacroScript()
        {
            string path = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, this.mRecording.Name + ".json");

            if (File.Exists(path))
            {
                File.Delete(path);
            }
            if (this.mRecording.Shortcut != null && MainWindow.sMacroMapping.ContainsKey(this.mRecording.Shortcut))
            {
                MainWindow.sMacroMapping.Remove(this.mRecording.Shortcut);
            }
            SingleMacroControl.DeleteScriptNameFromBookmarkedScriptListIfPresent(this.mRecording.Name);
            MacroGraph.Instance.RemoveVertex((BiDirectionalVertex <MacroRecording>)MacroGraph.Instance.Vertices.Cast <MacroRecording>().Where <MacroRecording>((Func <MacroRecording, bool>)(macro => string.Equals(macro.Name, this.mRecording.Name, StringComparison.InvariantCultureIgnoreCase))).FirstOrDefault <MacroRecording>());
            if (this.ParentWindow.mAutoRunMacro != null && this.ParentWindow.mAutoRunMacro.Name.ToLower(CultureInfo.InvariantCulture).Trim() == this.mRecording.Name.ToLower(CultureInfo.InvariantCulture).Trim())
            {
                this.ParentWindow.mAutoRunMacro = (MacroRecording)null;
            }
            CommonHandlers.RefreshAllMacroRecorderWindow();
            CommonHandlers.OnMacroDeleted(this.mRecording.Name);
        }
Пример #3
0
 private void SaveScriptSettings()
 {
     try
     {
         if (string.Equals(this.mRecording.Shortcut, this.mMacroShortcutTextBox.Tag.ToString(), StringComparison.InvariantCulture) && string.Equals(this.mRecording.Name.Trim(), this.mScriptName.Text.Trim(), StringComparison.InvariantCultureIgnoreCase))
         {
             return;
         }
         JsonSerializerSettings serializerSettings = Utils.GetSerializerSettings();
         serializerSettings.Formatting = Formatting.Indented;
         string str1 = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, this.mRecording.Name + ".json");
         if (this.mRecording.Shortcut != this.mMacroShortcutTextBox.Tag.ToString())
         {
             if (!string.IsNullOrEmpty(this.mRecording.Shortcut) && MainWindow.sMacroMapping.ContainsKey(this.mRecording.Shortcut))
             {
                 MainWindow.sMacroMapping.Remove(this.mRecording.Shortcut);
             }
             if (this.mMacroShortcutTextBox.Tag != null && !string.IsNullOrEmpty(this.mMacroShortcutTextBox.Tag.ToString()))
             {
                 MainWindow.sMacroMapping[this.mMacroShortcutTextBox.Tag.ToString()] = this.mScriptName.Text;
             }
             if (this.mRecording.Shortcut != null && this.mMacroShortcutTextBox.Tag != null && !string.Equals(this.mRecording.Shortcut, this.mMacroShortcutTextBox.Tag.ToString(), StringComparison.InvariantCulture))
             {
                 ClientStats.SendMiscellaneousStatsAsync("MacroOperations", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, "macro_window_shortcutkey", (string)null, this.mRecording.RecordingType.ToString(), (string)null, (string)null, (string)null, "Android");
             }
             if (this.mMacroShortcutTextBox.Tag != null)
             {
                 this.mRecording.Shortcut = this.mMacroShortcutTextBox.Tag.ToString();
             }
             if (this.mRecording.PlayOnStart)
             {
                 this.ParentWindow.mAutoRunMacro = this.mRecording;
             }
             string contents = JsonConvert.SerializeObject((object)this.mRecording, serializerSettings);
             File.WriteAllText(str1, contents);
         }
         if (!string.Equals(this.mRecording.Name.Trim(), this.mScriptName.Text.Trim(), StringComparison.InvariantCultureIgnoreCase))
         {
             string         oldMacroName   = this.mRecording.Name;
             MacroRecording macroRecording = MacroGraph.Instance.Vertices.Cast <MacroRecording>().Where <MacroRecording>((Func <MacroRecording, bool>)(macro => string.Equals(macro.Name, this.mRecording.Name, StringComparison.InvariantCultureIgnoreCase))).FirstOrDefault <MacroRecording>();
             macroRecording.Name  = this.mScriptName.Text.ToLower(CultureInfo.InvariantCulture).Trim();
             this.mRecording.Name = this.mScriptName.Text.Trim();
             if (this.mRecording.PlayOnStart)
             {
                 this.ParentWindow.mAutoRunMacro = this.mRecording;
             }
             string contents = JsonConvert.SerializeObject((object)this.mRecording, serializerSettings);
             File.WriteAllText(str1, contents);
             string destFileName = Path.Combine(RegistryStrings.MacroRecordingsFolderPath, this.mScriptName.Text.Trim() + ".json");
             File.Move(str1, destFileName);
             foreach (MacroRecording record in macroRecording.Parents.Cast <MacroRecording>())
             {
                 foreach (MergedMacroConfiguration macroConfiguration in (Collection <MergedMacroConfiguration>)record.MergedMacroConfigurations)
                 {
                     List <string> stringList = new List <string>();
                     foreach (string str2 in macroConfiguration.MacrosToRun.Select <string, string>((Func <string, string>)(macroToRun => !string.Equals(oldMacroName, macroToRun, StringComparison.CurrentCultureIgnoreCase) ? macroToRun : macroToRun.Replace(macroToRun, this.mRecording.Name))))
                     {
                         stringList.Add(str2);
                     }
                     macroConfiguration.MacrosToRun.Clear();
                     foreach (string str2 in stringList)
                     {
                         macroConfiguration.MacrosToRun.Add(str2);
                     }
                 }
                 CommonHandlers.SaveMacroJson(record, CommonHandlers.GetCompleteMacroRecordingPath(record.Name));
                 CommonHandlers.OnMacroSettingChanged(record);
             }
             if (this.IsBookmarked)
             {
                 SingleMacroControl.DeleteScriptNameFromBookmarkedScriptListIfPresent(oldMacroName);
                 this.AddScriptNameToBookmarkedScriptListIfNotPresent(this.mRecording.Name);
             }
         }
         CommonHandlers.OnMacroSettingChanged(this.mRecording);
         CommonHandlers.RefreshAllMacroRecorderWindow();
         CommonHandlers.ReloadMacroShortcutsForAllInstances();
     }
     catch (Exception ex)
     {
         Logger.Error("Error in saving macro settings: " + ex.ToString());
     }
 }
 internal void Init(MacroRecording mergedMacro = null, SingleMacroControl singleMacroControl = null)
 {
     try
     {
         this.mMacroNameStackPanel.Visibility = mergedMacro == null ? Visibility.Visible : Visibility.Collapsed;
         this.mOriginalMacroRecording         = mergedMacro;
         int num = 0;
         foreach (MacroRecording macroRecording in MacroGraph.Instance.Vertices.Cast <MacroRecording>().OrderBy <MacroRecording, DateTime>((Func <MacroRecording, DateTime>)(o => DateTime.ParseExact(o.TimeCreated, "yyyyMMddTHHmmss", (IFormatProvider)CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal))).ToList <MacroRecording>())
         {
             MacroRecording record = macroRecording;
             this.ParentWindow.mIsScriptsPresent = true;
             if (!record.Equals(mergedMacro) && (mergedMacro == null || !MacroGraph.Instance.DoesParentExist(MacroGraph.Instance.Vertices.Where <BiDirectionalVertex <MacroRecording> >((Func <BiDirectionalVertex <MacroRecording>, bool>)(macro => macro.Equals((object)mergedMacro))).FirstOrDefault <BiDirectionalVertex <MacroRecording> >(), MacroGraph.Instance.Vertices.Where <BiDirectionalVertex <MacroRecording> >((Func <BiDirectionalVertex <MacroRecording>, bool>)(macro => macro.Equals((object)record))).FirstOrDefault <BiDirectionalVertex <MacroRecording> >())))
             {
                 MacroToAdd macroToAdd = new MacroToAdd(this, record.Name);
                 if (num % 2 == 0)
                 {
                     BlueStacksUIBinding.BindColor((DependencyObject)macroToAdd, Control.BackgroundProperty, "DarkBandingColor");
                 }
                 else
                 {
                     BlueStacksUIBinding.BindColor((DependencyObject)macroToAdd, Control.BackgroundProperty, "LightBandingColor");
                 }
                 this.mCurrentMacroScripts.Children.Add((UIElement)macroToAdd);
                 ++num;
             }
         }
         if (singleMacroControl != null)
         {
             this.mSingleMacroControl = singleMacroControl;
         }
         if (mergedMacro == null)
         {
             string str = DateTime.Now.ToString("yyyyMMddTHHmmss", (IFormatProvider)CultureInfo.InvariantCulture);
             this.MergedMacroRecording = new MacroRecording()
             {
                 Name        = CommonHandlers.GetMacroName("Macro"),
                 TimeCreated = str,
                 MergedMacroConfigurations = new ObservableCollection <MergedMacroConfiguration>()
             };
             this.mUnifyButton.Visibility = Visibility.Collapsed;
             BlueStacksUIBinding.Bind((Button)this.mMergeButton, "STRING_MERGE");
             BlueStacksUIBinding.Bind(this.mMergeMacroWindowHeading, "STRING_MERGE_MACROS", "");
         }
         else
         {
             this.MergedMacroRecording = mergedMacro.DeepCopy <MacroRecording>();
             BlueStacksUIBinding.Bind((Button)this.mMergeButton, "STRING_UPDATE_SETTING");
             BlueStacksUIBinding.Bind(this.mMergeMacroWindowHeading, "STRING_EDIT_MERGED_MACRO", "");
             this.mUnifyButton.Visibility = Visibility.Visible;
         }
         this.MacroName.Text = this.MergedMacroRecording.Name;
         this.mMacroDragControl.Init();
         this.MergedMacroRecording.MergedMacroConfigurations.CollectionChanged -= new NotifyCollectionChangedEventHandler(this.Items_CollectionChanged);
         this.MergedMacroRecording.MergedMacroConfigurations.CollectionChanged += new NotifyCollectionChangedEventHandler(this.Items_CollectionChanged);
         this.Items_CollectionChanged((object)null, (NotifyCollectionChangedEventArgs)null);
         this.DataModificationTracker.Lock((object)this.mOriginalMacroRecording, new List <string>()
         {
             "IsGroupButtonVisible",
             "IsUnGroupButtonVisible",
             "IsSettingsVisible",
             "IsFirstListBoxItem",
             "IsLastListBoxItem",
             "Parents",
             "Childs",
             "IsVisited"
         }, true);
         this.CheckIfCanSave();
     }
     catch (Exception ex)
     {
         Logger.Error("Error in export window init err: " + ex.ToString());
     }
 }