예제 #1
0
 public MirakurunViewerView()
 {
     //services = new MirakurunService("http://127.0.0.1:40772/");
     try
     {
         services = new MirakurunService(SettingObj.Read());
     }
     catch (System.Net.WebException ex)
     {
         System.Windows.MessageBox.Show(ex.Message +
                                        "\nPlease make sure server is up online." +
                                        "\nServer_ADDR:[" + SettingObj.Read().Mirakurun_ServiceAddr + "]",
                                        "ERROR",
                                        System.Windows.MessageBoxButton.OK,
                                        System.Windows.MessageBoxImage.Error);
         Environment.Exit(1);
     }
     catch
     {
         Environment.Exit(1);
     }
     _ChannelList = new Dictionary <ChannelType, ObservableCollection <Apis.Service> >();
     _ChannelList.Add(ChannelType.GR, new ObservableCollection <Apis.Service>(services.GetServices(cType: ChannelType.GR)));
     _ChannelList.Add(ChannelType.BS, new ObservableCollection <Apis.Service>(services.GetServices(cType: ChannelType.BS)));
     _ChannelList.Add(ChannelType.CS, new ObservableCollection <Apis.Service>(services.GetServices(cType: ChannelType.CS)));
     _ChannelList.Add(ChannelType.SKY, new ObservableCollection <Apis.Service>(services.GetServices(cType: ChannelType.SKY)));
     this.pTicks           = new Timer();
     this.pTicks.Interval  = 1000;
     this.pTicks.Elapsed  += this.pTick_Tick;
     this.pTicks.AutoReset = true;
     this.pTicks.Start();
 }
예제 #2
0
    private void PopulateAndSetMaintenanceMode()
    {
        try
        {
            // populate the dropdown values
            dropdown_maintenance_mode.Items.Insert(0, new ListItem("Disabled", "0"));
            dropdown_maintenance_mode.Items.Insert(1, new ListItem("Enabled", "1"));

            string MaintenanceValue = "0";
            // set the dropdown values
            foreach (Settings SettingObj in ListOfSettings.GetSettingsList())
            {
                if (SettingObj.GetSettingsKey() == "MAINTENANCE")
                {
                    MaintenanceValue = SettingObj.GetSettingsValue();
                    break;
                }
            }
            dropdown_maintenance_mode.SelectedValue = MaintenanceValue;
            TextStatus.Visible = false;
            dropdown_maintenance_mode.Visible = true;
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            dropdown_maintenance_mode.Visible = false;
            TextStatus.Visible   = true;
            TextStatus.BackColor = System.Drawing.Color.FromArgb(Int32.Parse("FF6E6E", NumberStyles.HexNumber));
            TextStatus.ForeColor = System.Drawing.Color.White;
        }
    }
예제 #3
0
        public DBItemChangeViewModel(string id, string name, string path, long time, bool uploaded, bool visable, Database db)
        {
            this.ID         = id;
            this.Name       = name;
            this.Path       = path;
            this.Time       = time;
            this.IsUploaded = uploaded;
            this.Visable    = visable;
            this.root       = SettingObj.Read().StorageFolder;
            this.NewFiles   = new ObservableCollection <FileItemView>();
            var t = new FileInfo(System.IO.Path.Combine(root, this.Path)).DirectoryName;

            if (Directory.Exists(t))
            {
                this.fPath = t;
            }
            else
            {
                fPath = string.Empty;
            }
            string tmp = path;

            try
            {
                tmp = System.IO.Path.Combine(root, tmp);
            }
            finally
            {
                this.NewFiles.Add(tmp);
            }
            InitFolder();

            this.mDB = db;
        }
예제 #4
0
 public RecordListViewViewModel()
 {
     Setting    = SettingObj.Read();
     _mainTable = new DataSet();
     if (Setting.DataBase != "mysql")
     {
         throw new InvalidOperationException("Database type is unsupported!");
     }
     System.Threading.ThreadPool.QueueUserWorkItem(x => {
         database = new Database(Setting.DataBase_Addr, Setting.DataBase_User, Setting.DataBase_Pw, Setting.DataBase_Port ?? 3306);
         IsReady  = true;
     });
 }
예제 #5
0
    private string ReturnDBValue(string Key)
    {
        string Value = "";

        foreach (Settings SettingObj in ListOfSettings.GetSettingsList())
        {
            if (SettingObj.GetSettingsKey() == Key)
            {
                return(SettingObj.GetSettingsValue());
            }
        }
        return(Value);
    }
예제 #6
0
    // Start is called before the first frame update
    // Check For config file, create one if not.
    void Start()
    {
        //Variables
        string CurrentDirectory = Directory.GetCurrentDirectory();
        string targetFile       = "Settings.cfg";
        String path             = CurrentDirectory + "\\" + targetFile;

        Debug.Log("Current Directory: " + path);
        Debug.Log("Attempting to look for " + path + "\\" + targetFile);
        //Not exists
        if (File.Exists(path) == false)
        {
            Debug.Log("Settings.cfg does not exist, attempting to create one.");
            try
            {
                //Unity doesn't seem to like doing this, unable to test for now.
                using (FileStream fs = File.Create(path))
                {
                    //Write to .cfg file line per line
                    string[] defaultSetting =
                    {
                        "Volume=100",
                        "SFX=100",
                        "Music=100"
                    };
                    System.IO.File.WriteAllLines(path, defaultSetting);
                }
            }
            catch (Exception ex)
            {
                Debug.Log(ex.ToString());
            }
        }
        else
        {
            //Purely for debugging sake
            Debug.Log("Settings.cfg found!");
        }
        // TODO: Now we need to load from .cfg file
        SettingObj Setting1 = new SettingObj(path);
    }
예제 #7
0
 public SettingViewModel()
 {
     data = SettingObj.Read();
 }