コード例 #1
0
        private void listBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox       listBox = (ListBox)sender;
            MyListBoxItem item    = listBox.Items[e.Index] as MyListBoxItem; // Get the current item and cast it to MyListBoxItem

            if (item != null)
            {
                e.DrawBackground();
                if (listBox.GetSelected(e.Index))
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.LightGray), e.Bounds);
                }
                else
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.White), e.Bounds);
                }

                e.Graphics.DrawString(              // Draw the appropriate text in the ListBox
                    item.Message,                   // The message linked to the item
                    listBox.Font,                   // Take the font from the listbox
                    new SolidBrush(item.ItemColor), // Set the color
                    0,                              // X pixel coordinate
                    e.Index * listBox.ItemHeight    // Y pixel coordinate.  Multiply the index by the ItemHeight defined in the listbox.
                    );
            }
            else
            {
                // The item isn't a MyListBoxItem, do something about it
            }
        }
コード例 #2
0
        public static void generatePrograme(MainWindow window)
        {
            if (window.ProgrameSceneList.Items.Count < 1)
            {
                MessageBox.Show("_请添加场景!");
                return;
            }
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.DefaultExt = ".pro";
            dlg.Filter     = "节目包(*.pro)|*.pro";
            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result      = dlg.ShowDialog();
            List <string>   scenesArray = new List <string>();

            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                for (int i = 0; i < window.ProgrameSceneList.Items.Count; i++)
                {
                    string path = (window.ProgrameSceneList.Items[i] as ListBoxItem).DataContext as string;
                    scenesArray.Add(path);
                }
                string filename = dlg.FileName;
                savePrograme(scenesArray, filename);
                MyListBoxItem lbi = new MyListBoxItem();
                lbi.Content = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4);
                window.ProgrameList.Items.Add(lbi);
            }
        }
コード例 #3
0
        private static void saveSceneTo(MainWindow window)
        {
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            dlg.InitialDirectory = appPath + "\\scene";
            dlg.DefaultExt       = ".Sce";
            dlg.Filter           = "场景文件(*.Sce)|*.Sce";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                HandleSources.saveScene(window.myContainer, filename);
                MyListBoxItem lbi = new MyListBoxItem();
                lbi.DataContext = dlg.FileName;

                lbi.resolution = window.myContainer.Width + "," + window.myContainer.Height;
                lbi.Content    = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4) + "{" + lbi.resolution + "}";
                window.scenes.Items.Add(lbi);
                //window.scenesArray.Add(dlg.FileName);
                window.scenes.SelectedIndex = window.scenes.Items.Count - 1;
            }
        }
コード例 #4
0
        public static void readScene(MainWindow window)
        {
            string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.InitialDirectory = appPath + "\\scene";
            dlg.DefaultExt       = ".Sce";
            dlg.Filter           = "场景文件(*.Sce)|*.Sce";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;
                //HandleSources.saveScene(window.myContainer, filename);
                int           count = window.scenes.Items.Count;
                MyListBoxItem lbi   = new MyListBoxItem();
                XmlDocument   doc   = HandleSources.readXMLDoc(dlg.FileName);
                if (doc == null)
                {
                    return;
                }
                XmlNode resolution = doc.GetElementsByTagName("resolution")[0];
                lbi.resolution  = resolution.InnerText;
                lbi.Content     = dlg.SafeFileName.Substring(0, dlg.SafeFileName.Length - 4) + "{" + lbi.resolution + "}";
                lbi.DataContext = dlg.FileName;

                window.scenes.Items.Add(lbi);
                //window.scenesArray.Add(dlg.FileName);
                window.scenes.SelectedIndex = window.scenes.Items.Count - 1;
            }
        }
コード例 #5
0
        public async void GetMiracast()
        {
            Projection p = new Projection();

            while (this.ScreenMiracast)
            {
                MiracastLibrary s = await p.GetDeviceList();

                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                {
                    foreach (AreaParty.info.miracast.Screen sc in s.value)
                    {
                        MyListBoxItem temp = new MyListBoxItem {
                            Name = sc.name, ImagePath = "/styles/skin/item/item_tv.png"
                        };
                        if (!Miracast.Contains(temp))
                        {
                            Miracast.Add(new MyListBoxItem {
                                Name = sc.name, ImagePath = "/styles/skin/item/item_tv.png"
                            });
                        }
                    }
                });
                Thread.Sleep(1000);
            }
        }
コード例 #6
0
        public void StageSelectView_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index == -1)
            {
                return;
            }
            MyListBoxItem item = StageSelectView.Items[e.Index] as MyListBoxItem;

            string msg;


            if (item.Message.Length > 0)
            {
                item.ItemColor = Color.Black;
                msg            = item.Message;
            }
            else
            {
                item.ItemColor = Color.Green;
                msg            = "클릭해서 추가해주세요";
            }

            e.Graphics.DrawString(
                msg,
                StageSelectView.Font,
                new SolidBrush(item.ItemColor),
                0,
                e.Index * StageSelectView.ItemHeight
                );
        }
コード例 #7
0
 public void RemoveAgentKey(object obj)
 {
     if (obj != null) // 선택 됐으면
     {
         MyListBoxItem listBoxitem = obj as MyListBoxItem;
         mainModel.RemoveAgentKey(listBoxitem);
         agentKeylist = mainModel.agentKeylist;
     }
 }
コード例 #8
0
 public void RemoveRequest(object obj)
 {
     if (obj != null) //선택 됐으면
     {
         MyListBoxItem listBoxitem = obj as MyListBoxItem;
         mainModel.RemoveRequest(listBoxitem);
         requestList = mainModel.requestList;
     }
 }
コード例 #9
0
        public MyListBoxItem AddListBoxItem(String _textListItem)
        {
            MyListBoxItem listBoxItem = new MyListBoxItem();

            listBoxItem.Foreground = Brushes.Black;
            listBoxItem.Content    = _textListItem.ToString();
            listBoxItem.Height     = heightBox;
            listBoxItem.FontSize   = 10;
            return(listBoxItem);
        }
コード例 #10
0
 public static void updateProgramPageSceneItem(MainWindow window)
 {
     window.SceneItems.Items.Clear();
     for (int i = 0; i < window.scenes.Items.Count; i++)
     {
         MyListBoxItem lbi = new MyListBoxItem();
         lbi.DataContext = (window.scenes.Items[i] as MyListBoxItem).DataContext;
         lbi.Content     = (window.scenes.Items[i] as MyListBoxItem).Content;
         lbi.resolution  = (window.scenes.Items[i] as MyListBoxItem).resolution;
         window.SceneItems.Items.Add(lbi);
     }
 }
コード例 #11
0
        /// <summary>
        /// 重绘listBox2,使得item能根据指定颜色显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox2_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index < 0)
            {
                return;
            }
            MyListBoxItem it = listBox2.Items[e.Index] as MyListBoxItem;

            e.DrawBackground();
            e.Graphics.DrawString(it.Message, e.Font, new SolidBrush(it.ItemColor), e.Bounds, null);
            e.DrawFocusRectangle();
        }
コード例 #12
0
        public void OpenShowRequestWindow(object obj)
        {
            if (obj != null)
            {
                Console.Write(obj);
                MyListBoxItem listBoxitem  = obj as MyListBoxItem;
                string        title        = listBoxitem.content;
                string        fileTostring = mainModel.LoadRequest(title);

                editRequestwindow       = new EditRequestWindow(fileTostring, this);
                editRequestwindow.Owner = Application.Current.MainWindow;
                txt_requestTitle        = title;
                OnPropertyChanged("txt_requestTitle");
                editRequestwindow.ShowDialog();
            }
        }
コード例 #13
0
        public void StageSelectView_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox       listBox = (ListBox)sender;
            MyListBoxItem curItem = (MyListBoxItem)listBox.SelectedItem;

            if (curItem == null)
            {
                return;
            }

            string buttonText = curItem.Message.Length > 0 ? "수정" : "추가";

            StageTextBox.Enabled   = true;
            btnStageModify.Enabled = true;
            btnStageModify.Text    = buttonText;
            StageTextBox.Text      = curItem.Message;
            CurStageText.Text      = (listBox.SelectedIndex + 1) + "차";
        }
コード例 #14
0
 private void listBox1_SetColor(object sender, DrawItemEventArgs e)
 {
     try
     {
         MyListBoxItem item = listBox1.Items[e.Index] as MyListBoxItem;
         if (item != null)
         {
             e.Graphics.DrawString(item.Message, listBox1.Font, new SolidBrush(item.ItemColor), 0, e.Index * listBox1.ItemHeight);
         }
         else
         {
             Form1.ActiveForm.Text = ("kok gini");
         }
     }
     catch
     {
     }
 }
コード例 #15
0
ファイル: Selection.cs プロジェクト: ShinEDL/Spyer
 //查看按钮
 private void button1_Click(object sender, EventArgs e)
 {
     if (mylistBox1.SelectedIndex >= 0)
     {
         MyListBoxItem item = (MyListBoxItem)mylistBox1.SelectedItem;
         Cat           cat  = new Cat(this);
         cat.username   = this.username;
         cat.user       = item.userName;
         cat.ip         = item.ip;
         cat.department = item.department;
         cat.cid        = item.id;
         cat.Show();
         this.timer1.Enabled = false;
         this.Hide();
     }
     else
     {
         MessageBox.Show("请选择被监控对象!");
     }
 }
コード例 #16
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                foreach (var iter in this.AllRenderers)
                {
                    // Visible means its in RenderMode
                    var annObjectId = iter.Key;

                    // ignore these types
                    switch (annObjectId)
                    {
                    case AnnObject.SelectObjectId:
                    case AnnObject.ImageObjectId:
                        break;

                    default:
                        var automationObject = this.AutomationManager.FindObjectById(annObjectId);
                        if (automationObject != null)
                        {
                            var listBoxItem = new MyListBoxItem {
                                ObjectId = annObjectId, Name = automationObject.Name
                            };
                            if (this.CurrentRenderers.ContainsKey(annObjectId))
                            {
                                _visibleObjectsListBox.Items.Add(listBoxItem);
                            }
                            else
                            {
                                _invisibleObjectsListBox.Items.Add(listBoxItem);
                            }
                        }
                        break;
                    }
                }

                UpdateUIState();
            }

            base.OnLoad(e);
        }
コード例 #17
0
        private void UpdateBoxAvailability()
        {
            // Is config file is required by this type of server?
            MyListBoxItem item = (MyListBoxItem)comboBox_Server.SelectedItem;
            bool          configFileRequired = item.ItemData;

            checkBox_configfile.Enabled = !configFileRequired;

            if (configFileRequired)
            {
                m_ConfigFileEnable          = configFileRequired;
                checkBox_configfile.Checked = configFileRequired;
            }
            else
            {
                m_ConfigFileEnable = checkBox_configfile.Checked;
            }

            comboBox_configfile.Enabled = (m_ConfigFileEnable && m_configFileAvailable);
            textBox_configfile.Enabled  = (m_ConfigFileEnable);
            button_browse.Enabled       = (m_ConfigFileEnable);
            button_ok.Enabled           = !m_ConfigFileEnable || m_configFileAvailable;
        }
コード例 #18
0
        public void GetScreenTV()
        {
            while (this.ScreenTVServer)
            {
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate()

                {
                    foreach (TVInfo item in MyInfo.tvLibrary.value)
                    {
                        MyListBoxItem temp = new MyListBoxItem {
                            Name = item.name, ImagePath = "/styles/skin/item/item_tv.png"
                        };
                        if (!ScreenTV.Contains(temp))
                        {
                            ScreenTV.Add(temp);
                        }

                        //Console.WriteLine(item.name);
                    }
                });
                Thread.Sleep(1000);
            }
        }
コード例 #19
0
 public static void addScenesToPrograme(MainWindow window)
 {
     if (window.SceneItems.SelectedIndex != -1)
     {
         MyListBoxItem lbi = new MyListBoxItem();
         lbi.Content     = (window.SceneItems.SelectedItem as MyListBoxItem).Content;
         lbi.DataContext = (window.SceneItems.SelectedItem as MyListBoxItem).DataContext;
         lbi.resolution  = (window.SceneItems.SelectedItem as MyListBoxItem).resolution;
         if (window.ProgrameSceneList.Items.Count < 1)
         {
             window.ProgrameSceneList.Items.Add(lbi);
         }
         else
         {
             string resolution = (window.ProgrameSceneList.Items[0] as MyListBoxItem).resolution;
             if (lbi.resolution != resolution)
             {
                 MessageBox.Show("分辨率不同!");
                 return;
             }
             window.ProgrameSceneList.Items.Add(lbi);
         }
     }
 }
コード例 #20
0
ファイル: Selection.cs プロジェクト: ShinEDL/Spyer
 //
 //List<MyListBoxItem>排序规则
 //使用委托的方式实现
 //
 private int sortMy(MyListBoxItem a, MyListBoxItem b)
 {
     //待定
     return(a.department.CompareTo(b.department));//根据部门排序
 }
        private void DrawComponentTree(Object o, TreeNode tnControl)
        {
            MyListBoxItem item = (MyListBoxItem)o;
            TreeNode      tnSubtreeRoot;
            Button        btn = new Button();

            btn.Content = item.name;

            if (tnControl == null)
            {
                wrongServices.Clear();
                tcMain.Clear();
                tnSubtreeRoot = tcMain.AddRoot(btn);
            }
            else
            {
                tnSubtreeRoot = tcMain.AddNode(btn, tnControl);
            }

            if (item != null)
            {
                var childList = new List <MyListBoxItem>();

                if (string.IsNullOrEmpty(item.description))
                {
                    try
                    {
                        var serviceList = PackageHelper.Instance.getServicesList(provisioningDescription, item.name);
                        if (serviceList != null && serviceList.Count != 0)
                        {
                            childList.AddRange(serviceList);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
                else if (item.description == ServiceName.servisNotInList)
                {
                    wrongServices.Add(item.name);
                }
                else
                {
                    try
                    {
                        var childItems = ServiceHelper.Instance.GetChildElements(provisioningDescription, item);
                        if (childItems != null && childItems.Count > 0)
                        {
                            childList.AddRange(childItems);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }

                foreach (var node in childList)
                {
                    DrawComponentTree(node, tnSubtreeRoot);
                }
            }
        }
コード例 #22
0
        public List <MyListBoxItem> GetChildElements(ProvisioningDescription provisioningDescription, MyListBoxItem item)
        {
            if (item.description == Constants.ServiceName.simpleService)
            {
                return(null);
            }

            List <MyListBoxItem> arrayOfChild = new List <MyListBoxItem>();

            var complexService = provisioningDescription.servicesDescription.complexServiceList.Where(s => s.name == item.name).FirstOrDefault();

            var partServicesArray = complexService.partList.partService;

            if (partServicesArray != null)
            {
                var partServices = partServicesArray.ToList();

                foreach (var p in partServices)
                {
                    var service = GetServiceByName(provisioningDescription, p.name);
                    if (service != null)
                    {
                        arrayOfChild.Add(service);
                    }
                    else
                    {
                        arrayOfChild.Add(new MyListBoxItem(p.name, Constants.ServiceName.servisNotInList));
                    }
                }
            }

            return(arrayOfChild);
        }
コード例 #23
0
        private void UpdateNames()
        {
            //Delete ccf name file list
            ccffiles.Clear();

            string currentDir    = m_currentConfigDir;
            string keyName       = ConfigKeyName;
            string curServerName = comboBox_Server.SelectedItem.ToString();

            m_ResourceIndex = comboBox_Device.SelectedIndex;
            m_ServerName    = curServerName;
            curServerName   = curServerName.Substring(0, curServerName.Length - 2);

            DirectoryInfo dir = new DirectoryInfo(currentDir);

            if (dir.Exists)
            {
                FileInfo[] ccffileInfo = dir.GetFiles("*.ccf");
                comboBox_configfile.Items.Clear();

                foreach (FileInfo f in ccffileInfo)
                {
                    string        filePath       = m_currentConfigDir + "\\" + f.Name;
                    StringBuilder tempServerName = new StringBuilder(512);
                    StringBuilder sbCameraName   = new StringBuilder(512);
                    StringBuilder sbCompanyName  = new StringBuilder(512);
                    StringBuilder sbModelName    = new StringBuilder(512);
                    StringBuilder sbVicName      = new StringBuilder(512);
                    string        companyName    = "";
                    string        modelName      = "";
                    string        cameraDesc     = "";

                    GetPrivateProfileString("Board", "Server name", "Unknow", tempServerName, 512, filePath);

                    // Check if the current configuration file has been created for the current server
                    if (string.Compare(curServerName, tempServerName.ToString(), StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        continue;
                    }
                    // Add ccf File name
                    ccffiles.Add(f.Name);

                    GetPrivateProfileString("General", keyName, "Unknown", sbCameraName, 512, filePath);
                    GetPrivateProfileString("General", CompanyKeyName, "", sbCompanyName, 512, filePath);
                    GetPrivateProfileString("General", ModelKeyName, "", sbModelName, 512, filePath);
                    GetPrivateProfileString("General", VicName, "", sbVicName, 512, filePath);

                    if (sbCompanyName.ToString().Length != 0 && sbModelName.ToString().Length != 0)
                    {
                        companyName = sbCompanyName.ToString() + ", ";
                    }
                    if (sbModelName.ToString().Length != 0 && sbCameraName.ToString().Length != 0)
                    {
                        modelName = sbModelName.ToString() + ", ";
                    }

                    cameraDesc = companyName + modelName + sbCameraName.ToString() + " - " + sbVicName.ToString();


                    MyListBoxItem item = new MyListBoxItem(cameraDesc, true);
                    comboBox_configfile.Items.Add(item);
                }
            }

            if (comboBox_configfile.Items.Count != 0)
            {
                m_configFileAvailable = true;
                int newFileIndex = 0;

                // Try to find the current camera file selected
                for (int i = 0; i < ccffiles.Count; i++)
                {
                    String currentccf = (String)ccffiles[i];
                    if (string.Compare(m_currentConfigFileName, currentccf, StringComparison.Ordinal) == 0)
                    {
                        newFileIndex = i;
                    }
                }
                comboBox_configfile.SelectedIndex = newFileIndex;
            }
            else
            {
                m_configFileAvailable = false;
            }
            UpdateBoxAvailability();
        }