private static void SetDefaultPropertiesForMergedMacroConfig(MergedMacroConfiguration config)
 {
     config.LoopCount       = 1;
     config.LoopInterval    = 0;
     config.Acceleration    = 1.0;
     config.DelayNextScript = 0;
 }
 private void Move(MergedMacroConfiguration source, int sourceIndex, int targetIndex)
 {
     if (sourceIndex < targetIndex)
     {
         if (!(this.mListBox.DataContext is ObservableCollection <MergedMacroConfiguration> dataContext))
         {
             return;
         }
         dataContext.Insert(targetIndex + 1, source);
         dataContext.RemoveAt(sourceIndex);
     }
     else
     {
         if (!(this.mListBox.DataContext is ObservableCollection <MergedMacroConfiguration> dataContext))
         {
             return;
         }
         int index = sourceIndex + 1;
         if (dataContext.Count + 1 <= index)
         {
             return;
         }
         dataContext.Insert(targetIndex, source);
         dataContext.RemoveAt(index);
     }
 }
        private void ListBoxItem_DragOver(object sender, DragEventArgs e)
        {
            if (!(sender is ListBoxItem))
            {
                return;
            }
            MergedMacroConfiguration data        = e.Data.GetData(typeof(MergedMacroConfiguration)) as MergedMacroConfiguration;
            ListBoxItem neglectItem              = (ListBoxItem)sender;
            MergedMacroConfiguration dataContext = ((FrameworkElement)sender).DataContext as MergedMacroConfiguration;
            int num1 = this.mListBox.Items.IndexOf((object)data);
            int num2 = this.mListBox.Items.IndexOf((object)dataContext);

            if (num2 < num1)
            {
                (neglectItem.Template.FindName("mMainGrid", (FrameworkElement)neglectItem) as Grid).Margin = new Thickness(0.0, 10.0, 0.0, 0.0);
            }
            else if (num2 > num1)
            {
                (neglectItem.Template.FindName("mMainGrid", (FrameworkElement)neglectItem) as Grid).Margin = new Thickness(0.0, -1.0, 0.0, 10.0);
            }
            else
            {
                (neglectItem.Template.FindName("mMainGrid", (FrameworkElement)neglectItem) as Grid).Margin = new Thickness(0.0, -1.0, 0.0, 0.0);
            }
            this.UnsetMarginDuringDrag(neglectItem);
        }
        private void UnGroup_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is CustomPictureBox customPictureBox))
            {
                return;
            }
            MergedMacroConfiguration dataContext = customPictureBox.DataContext as MergedMacroConfiguration;
            int sourceIndex = this.mListBox.Items.IndexOf((object)dataContext);

            this.UnMerge(dataContext, sourceIndex);
        }
        private void AddMacro_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            MergedMacroConfiguration macroConfiguration = new MergedMacroConfiguration();

            macroConfiguration.MacrosToRun.Add(this.mMacroName.Text);
            macroConfiguration.Tag = this.mMergeMacroWindow.mAddedMacroTag++;
            if (this.mMergeMacroWindow.MergedMacroRecording.MergedMacroConfigurations == null)
            {
                this.mMergeMacroWindow.MergedMacroRecording.MergedMacroConfigurations = new ObservableCollection <MergedMacroConfiguration>();
            }
            this.mMergeMacroWindow.MergedMacroRecording.MergedMacroConfigurations.Add(macroConfiguration);
        }
        private void ListBoxItem_Drop(object sender, DragEventArgs e)
        {
            this.UnsetMarginDuringDrag((ListBoxItem)null);
            if (!(sender is ListBoxItem))
            {
                return;
            }
            MergedMacroConfiguration data        = e.Data.GetData(typeof(MergedMacroConfiguration)) as MergedMacroConfiguration;
            MergedMacroConfiguration dataContext = ((FrameworkElement)sender).DataContext as MergedMacroConfiguration;
            int sourceIndex = this.mListBox.Items.IndexOf((object)data);
            int targetIndex = this.mListBox.Items.IndexOf((object)dataContext);

            this.Move(data, sourceIndex, targetIndex);
        }
 private void Remove_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (!(sender is CustomPictureBox customPictureBox))
         {
             return;
         }
         MergedMacroConfiguration dataContext = customPictureBox.DataContext as MergedMacroConfiguration;
         int index = this.mListBox.Items.IndexOf((object)dataContext);
         Logger.Info("Macro tag= " + dataContext?.Tag.ToString() + "and index= " + index.ToString());
         (this.mListBox.DataContext as ObservableCollection <MergedMacroConfiguration>).RemoveAt(index);
         this.MergeMacroWindow.MergedMacroRecording.MergedMacroConfigurations.Remove(dataContext);
     }
     catch (Exception ex)
     {
         Logger.Error("Exception in removing the merged macro configuration : " + ex.ToString());
     }
 }
 private void UnMerge(MergedMacroConfiguration source, int sourceIndex)
 {
     if (!(this.mListBox.DataContext is ObservableCollection <MergedMacroConfiguration> dataContext))
     {
         return;
     }
     MacroAddedDragControl.SetDefaultPropertiesForMergedMacroConfig(source);
     for (int index = 0; index < source.MacrosToRun.Count; ++index)
     {
         string str = source.MacrosToRun[index];
         MergedMacroConfiguration macroConfiguration = new MergedMacroConfiguration()
         {
             Tag = this.MergeMacroWindow.mAddedMacroTag++
         };
         macroConfiguration.MacrosToRun.Add(str);
         dataContext.Insert(sourceIndex + index + 1, macroConfiguration);
     }
     dataContext.RemoveAt(sourceIndex);
 }
        private void Settings_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (!(sender is CustomPictureBox customPictureBox))
            {
                return;
            }
            ListBoxItem visualParent             = WpfUtils.FindVisualParent <ListBoxItem>((DependencyObject)customPictureBox);
            MergedMacroConfiguration dataContext = visualParent.DataContext as MergedMacroConfiguration;

            dataContext.IsSettingsVisible = !dataContext.IsSettingsVisible;
            (visualParent.Template.FindName("mMacroSettingsImage", (FrameworkElement)visualParent) as CustomPictureBox).ImageName = dataContext.IsSettingsVisible ? "outline_settings_collapse" : "outline_settings_expand";
            ClientStats.SendMiscellaneousStatsAsync("MacroOperations", RegistryManager.Instance.UserGuid, RegistryManager.Instance.ClientVersion, dataContext.IsSettingsVisible ? "merge_dropdown_expand" : "merge_dropdown_collapse", (string)null, (string)null, (string)null, (string)null, (string)null, "Android");
            foreach (object obj in (IEnumerable)this.mListBox.Items)
            {
                ListBoxItem listBoxItem = this.mListBox.ItemContainerGenerator.ContainerFromItem(obj) as ListBoxItem;
                if (listBoxItem != visualParent)
                {
                    (listBoxItem.DataContext as MergedMacroConfiguration).IsSettingsVisible = false;
                    (listBoxItem.Template.FindName("mMacroSettingsImage", (FrameworkElement)listBoxItem) as CustomPictureBox).ImageName = "outline_settings_expand";
                }
            }
        }