예제 #1
0
        private void FuncSelect_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count <= 0)
            {
                return;
            }
            ButtonType currentConfPanel = (ButtonType)e.AddedItems[0];

            ConfPanel.Children.Clear();
            switch (currentConfPanel)
            {
            case ButtonType.AHKCommand:
            {
                Conf_Autokey panel = new Conf_Autokey();
                ConfPanel.Children.Add(panel);
            }
            break;

            case ButtonType.Goto:
            {
                Conf_Goto panel = new Conf_Goto();
                ConfPanel.Children.Add(panel);
            }
            break;

            case ButtonType.Blank:
            {
                Business.GetInstance().ButtonMatrixPanel.SelectedButtonData.Init();
            }
            break;

            default:
                break;
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            PageTree.ItemsSource = CoreData.GetInstance().PageTree;

            if (Business.GetInstance().Deck != null)
            {
                Business.GetInstance().Deck.SetBrightness(100);
                Business.GetInstance().Deck.ClearKeys();
            }

            // Load default config
            string s = System.Windows.Forms.Application.ExecutablePath.Substring(0, System.Windows.Forms.Application.ExecutablePath.LastIndexOf('\\')) + "\\Config.stm";

            if (File.Exists(s))
            {
                try
                {
                    Business.GetInstance().Load(s);
                }
                catch
                { }
            }

            InitialTray(); //最小化至托盘

            // Expend Tree Items
            ExpandAllItems(PageTree);
            TreeViewDefaultFocus(PageTree);

            //throw new ArgumentNullException("这是故意抛出的异常");
        }
예제 #3
0
 private void clearPage_Click(object sender, RoutedEventArgs e)
 {
     if (System.Windows.Forms.MessageBox.Show("Confirm to clear all the data?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         Business.GetInstance().Clear();
     }
 }
예제 #4
0
 private void btnCleanImage_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext != null && DataContext is ButtonData)
     {
         (DataContext as ButtonData).ClearImage();
         Business.GetInstance().RefreshStreamDeckButton(this.Index);
     }
 }
예제 #5
0
 private void btnCopy_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext != null && DataContext is ButtonData)
     {
         // Not Need Deep Copy
         Business.GetInstance().ButtonCopyBuffer = DataContext as ButtonData;
     }
 }
 private void Window_Closed(object sender, EventArgs e)
 {
     if (Business.GetInstance().Deck == null)
     {
         return;
     }
     Business.GetInstance().Deck.ClearKeys();
     Business.GetInstance().Deck.ShowLogo();
 }
예제 #7
0
 private void btnPaste_Click(object sender, RoutedEventArgs e)
 {
     if (Business.GetInstance().ButtonCopyBuffer != null)
     {
         // Need Deep Copy
         PageData currPage = Business.GetInstance().ButtonMatrixPanel.DataContext as PageData;
         currPage.BtnList[Index] = (ButtonData)Util.DeepCopy <ButtonData>(Business.GetInstance().ButtonCopyBuffer);
         Business.GetInstance().ButtonMatrixPanel.InitPanel();
     }
 }
예제 #8
0
 private void imgBtnMenu_Opened(object sender, RoutedEventArgs e)
 {
     if (Business.GetInstance().ButtonCopyBuffer == null)
     {
         btnPaste.IsEnabled = false;
     }
     else
     {
         btnPaste.IsEnabled = true;
     }
 }
예제 #9
0
        private void loadPage_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.Filter           = "StreamDeck Config Files|*.stm";
            dlg.Title            = "Select a StreamDeck Config File";
            dlg.InitialDirectory = System.Windows.Forms.Application.StartupPath;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Business.GetInstance().Load(dlg.FileName);
            }
        }
예제 #10
0
        private void ImageBlock_Drop(object sender, DragEventArgs e)
        {
            // 图片文件
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                // Note that you can have more than one file.
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

                // Assuming you have one file that you care about, pass it off to whatever
                // handling code you have defined.
                BitmapImage img = new BitmapImage();
                //若要原始文件的站点,可以调用 Application 类的 GetRemoteStream 方法,同时传递标识原始文件的所需站点的 pack URI。 GetRemoteStream 将返回一个 StreamResourceInfo 对象,该对象将原始文件的该站点作为 Stream 公开,并描述其内容类型。
                img.BeginInit();
                try
                {
                    string filepath = files[0].ToString();
                    Stream sr       = new FileStream(filepath, FileMode.Open, FileAccess.Read);
                    img.StreamSource = sr;
                }
                catch
                {
                }

                img.EndInit();
                (this.DataContext as ButtonData).Image = img;

                //ImageBlock.Source = img;
            }

            // ImgBtn Move or Exchange
            if (e.Data.GetDataPresent(typeof(ImgBtn)) && (sender is Grid))
            {
                ImgBtn dropSrc = e.Data.GetData(typeof(ImgBtn)) as ImgBtn;

                if (dropSrc != null)
                {
                    int SrcIndex = dropSrc.Index;
                    int TarIndex = this.Index;

                    PageData currPage = Business.GetInstance().ButtonMatrixPanel.DataContext as PageData;

                    ButtonData temp = currPage.BtnList[SrcIndex];
                    currPage.BtnList[SrcIndex] = currPage.BtnList[TarIndex];
                    currPage.BtnList[TarIndex] = temp;
                    Business.GetInstance().ButtonMatrixPanel.InitPanel();
                }
            }
            // 快捷方式
        }
 public MainWindow()
 {
     InitializeComponent();
     Business.GetInstance().ButtonMatrixPanel = btnMartix;
     Business.GetInstance().MainWindowPanel   = this;
 }
예제 #12
0
 private void UserControl_LayoutUpdated(object sender, EventArgs e)
 {
     Business.GetInstance().RefreshStreamDeckButton(Index);
 }
예제 #13
0
        private void savePage_Click(object sender, RoutedEventArgs e)
        {
            string s = System.Windows.Forms.Application.ExecutablePath.Substring(0, System.Windows.Forms.Application.ExecutablePath.LastIndexOf('\\')) + "\\Config.stm";

            Business.GetInstance().Save(s);
        }