Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            List <ButtonData> ButtonDataList = ThisFormData.ListData;
            ContentControl    btn            = sender as ContentControl;

            if (FormEditingMode)
            {
            }
            else
            {
                int        i       = int.Parse(Regex.Match(btn.Name, "\\d+$").Value);
                ButtonData btnData = ButtonDataList[i];
                try
                {
                    cInput.KeySend(btnData.KeyDataList);
                    if (btnData.PathDataList != null)
                    {
                        foreach (string path in btnData.PathDataList)
                        {
                            Process.Start(CI.ExpandEnvironmentStrings(path));
                        }
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            ComboBox combo;

            combo = FindName("combo") as ComboBox;
            switch ((MODE)Enum.ToObject(typeof(MODE), combo.SelectedIndex))
            {
            //case MODE.EDITING:
            //    FormEditingMode = true;
            //    tmpComboIndex = comboBox.SelectedIndex;
            //    break;
            case MODE.MIN:
                combo.SelectedIndex = tmpComboIndex;
                WindowState         = WindowState.Minimized;
                CI.ChangeWindowActivate(this, formEditingMode, false);
                break;

            case MODE.CLOSE:
                Close();
                return;

            case MODE.JSON:
                ProcessStartInfo p = new ProcessStartInfo(CI.ExpandEnvironmentStrings(ThisFormData.AppJson), JsonFileName);
                p.LoadUserProfile = true;
                try
                {
                    Process.Start(p);
                } catch
                {
                    p.FileName = default_app_json;
                    Process.Start(p);
                }
                combo.SelectedIndex = tmpComboIndex;
                break;

            case MODE.RELOAD:
                ReadFormJSON();
                SyncButtonData();
                SyncFormViewData();
                combo.SelectedIndex = tmpComboIndex;
                break;

            default:
                FormEditingMode = false;
                tmpComboIndex   = comboBox.SelectedIndex;
                break;
            }
            SyncPanelMenu();
        }
Ejemplo n.º 3
0
 protected override void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     CI.ChangeWindowActivate(this, false, false);
 }
Ejemplo n.º 4
0
 public MainWindow()
 {
     InitializeComponent();
     btnPanel             = FindName("panel") as WrapPanel;
     cInput               = new CI(1, Dispatcher);
     ButtonList           = new List <ContentControl>();
     ThisFormData         = new FormData(this);
     FormEditingMode      = false;
     MouseLeftButtonDown += (o, e) => {
         try { DragMove(); } catch { }
     };
     //割り当て全解除
     MouseRightButtonDown += (o, e) => {
         foreach (var kvPair in keysdic)
         {
             cInput.KeySend(kvPair.Key, false, true);
         }
     };
     //割合変形
     btnPanel.SizeChanged += (o, e) =>
     {
         SyncResize();
     };
     //FromPanelSetButtonData();
     //WriteFormJSON();
     ReadFormJSON();
     SyncFormViewData();
     SyncButtonData();
     MoniterTimer          = new DispatcherTimer(DispatcherPriority.Normal, Dispatcher);
     MoniterTimer.Interval = TimeSpan.FromMilliseconds(MoniterTimerInterval);
     MoniterTimer.Tick    += (o, e) =>
     {
         if (ButtonList == null)
         {
             return;
         }
         for (int i = 0; i < keyslist.Count; i++)
         {
             keysdic[keyslist[i]] = CI.GetAsyncKeyState((Keys)keyslist[i]) != 0;
         }
         for (int i = 0; i < ThisFormData.ListData.Count; i++)
         {
             ContentControl btn   = ButtonList[i];
             BrushObject    brush = ContentBrushes[btn];
             if (btn.IsMouseOver)
             {
                 if (brush.HoverBackground != null)
                 {
                     btn.Background = brush.HoverBackground;
                 }
                 if (brush.HoverForeground != null)
                 {
                     btn.Foreground = brush.HoverForeground;
                 }
                 if (brush.HoverBorder != null)
                 {
                     btn.BorderBrush = brush.HoverBorder;
                 }
                 continue;
             }
             var  data     = ThisFormData.ListData[i];
             bool keycheck = false;
             if (ThisFormData.Monitor)
             {
                 foreach (var keydata in data.KeyDataList)
                 {
                     keycheck = keysdic[keydata.Code];
                     if (!keycheck)
                     {
                         break;
                     }
                 }
             }
             Brush cb_back, cb_front, cb_border;
             if (keycheck)
             {
                 if (brush.ToggleBackground == null)
                 {
                     cb_back = brush.HoverBackground;
                 }
                 else
                 {
                     cb_back = brush.ToggleBackground;
                 }
                 if (brush.ToggleBackground == null)
                 {
                     cb_front = brush.HoverForeground;
                 }
                 else
                 {
                     cb_front = brush.ToggleForeground;
                 }
                 if (brush.ToggleBorder == null)
                 {
                     cb_border = brush.HoverBorder;
                 }
                 else
                 {
                     cb_border = brush.ToggleBorder;
                 }
             }
             else
             {
                 cb_back   = brush.Background;
                 cb_front  = brush.Foreground;
                 cb_border = brush.Border;
             }
             if (cb_back != null)
             {
                 ButtonList[i].Background = cb_back;
             }
             if (cb_front != null)
             {
                 ButtonList[i].Foreground = cb_front;
             }
             if (cb_border != null)
             {
                 ButtonList[i].BorderBrush = cb_border;
             }
         }
     };
     MoniterTimer.Start();
 }